<?php
session_start();

require_once($_SERVER['DOCUMENT_ROOT'] . "/sys/access.php");

//access.php (above) establishes $access as a new instance of AccessControl defined in LAL.
if(!$access->CheckLogin()){
  $access->RedirectToURL("/login/login.php");
  exit;
}
//Not sure how this works.
  define("PUBLIC_ACCESS", 1);
?>

<!DOCTYPE html>
<html lang="en">
  <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Language"  content="en-us">
    <title>Report Tracker</title>

    <link rel="stylesheet" href="/ext/bootstrap/bootstrap.min.css">
    <link rel="stylesheet" href="/ext/bootstrap/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/site/css/stickythead.css">
    <link rel="stylesheet" href="/site/css/bootstrap.css">
    <link rel="stylesheet" href="/site/css/multiselect.css">
    <link rel="stylesheet" href="/site/css/slider.css">
    <link rel="stylesheet" href="/site/css/style.css">

    <script src="/ext/jquery/jquery-3.1.1.min.js"></script>
    <script src="/ext/bootstrap/bootstrap.min.js"></script>
    <script src="/ext/jquery/jquery.stickytableheaders.min.js"></script>
    <script src="/site/js/main.js"></script>

    <!-- Are some of these styles holdovers from their source panel or is it true that buttone have not
       been renamed from other contexts?-->
    <style>
     button#putweather {
	 width:80px;
	 margin-top:20px;
     }
     button#putformhandler.btn {
	 width:80px;
	 margin-top:27px;
     }

     body {
	 font-size:16px;
	 font-weight:500;
	 color:#000;
     }  
     
     td > * {
	 width: 100%;
     }

     div > * {
	 width: 100%;
     }
     

     .btn {
	 width:80px;    
     } 
     
     label {
	 margin-bottom:0px;
     }

     .table>td { 
	 vertical-align:bottom;    
     }

     select, input {
	 height:28px;
	 width:100%;
     }

     input[type=checkbox] {
	 height:20px;
	 width:20px;
	 vertical-align:middle;
     }
    </style>
  </head>
  <body>

    <?php

    //Die check constant for indirectly accessed php
    //Not sure how this works. The same constant was defined in the head php.
    define("PUBLIC_ACCESS", 1);

    date_default_timezone_set("Canada/Eastern");

    //Location of class definitions
    $docRoot = $_SERVER['DOCUMENT_ROOT'];
    $toolkit = "$docRoot/toolkit";

    //Class object definitions for the UI controls used in the panel
    //Keeping it simple - trying for just one kind of control on the page to start.
//    require_once ("toolkit/liveaddunique.php");
    require_once ("toolkit/selectoption.php");
/*    require_once ("toolkit/livesearch.php");
    require_once ("toolkit/inputtext.php");
    require_once ("toolkit/selectdate.php");
    require_once ("toolkit/clickcheckbox.php");
    require_once ("toolkit/addonselliv.php");
    require_once ("toolkit/multiselect2.php");
    require_once ("toolkit/addonselinpdt.php");
    require_once ("toolkit/summarytable.php"); */
 
    
    //Class definitions for the Controls instantiator and Menu generator
    require_once ("$docRoot/sys/init.php");
    require_once ("$docRoot/sys/panel.php");

    //Model and view class object definitions for the module.
    require_once ("$docRoot/reportracker/model.php");
    require_once ("$docRoot/reportracker/view.php");

    //These are clearly session values to be passed into the panel method in model.php
    $lo_id = (isset($_SESSION['login'])) ? $_SESSION['login'] : 0;
    $en_id = 1;
    $ig_id = (isset($_SESSION['instrumentgroup'])) ? $_SESSION['instrumentgroup'] : 0;
    $ic_id = (isset($_SESSION['instrumentclass'])) ? $_SESSION['instrumentclass'] : 0;
    $it_id = (isset($_SESSION['instrumenttype'])) ? $_SESSION['instrumenttype'] : 0;
    $in_id = (isset($_SESSION['instrument'])) ? $_SESSION['instrument'] : 0;
    $ip_id = (isset($_SESSION['instrperform'])) ? $_SESSION['instrperform'] : 0;

    print_r ("lo:$lo_id en:$en_id ig:$ig_id ic:$ic_id it:$it_id in:$in_id ip:$ip_id");

    //Instantiate the model and view.
    $reportTracker = new modReportTracker($lo_id, $en_id, $ig_id, $ic_id, $it_id, $in_id, $ip_id);
    $reportTrackerView = new modReportTrackerView($reportTracker);

    //Insert html layout and javascript
    echo $reportTrackerView->output();
    
    ?>
  </body>
</html>
