<?php
session_start();

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

if(!$access->CheckLogin()){
  $access->RedirectToURL("/login/login.php");
  exit;
}

// Die check constant for indirectly accessed php  
define("PUBLIC_ACCESS", 1);
?>

<!DOCTYPE html>
<html lang="en">

<head>
  <meta http-equiv="Content-Language" content="en-us">
  <title>Operation</title>
  <meta charset="utf-8">

  <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/livesearch.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>

<style>

body {
  font-size:16px;
  font-weight:500;
  color:#000;
}  


.btn {
    width:160px;    
}

textarea > * {
  width: 100%;
}

div > * {
  width: 100%;
}

label {
  margin-bottom:0px;
}

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

td > * {
  width:100%;
}

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

input[type=checkbox] {
  height:20px;
  width:20px;
  vertical-align:middle;
}

.punch {
  display: inline-block;
  padding: 6px 0px;
  font-size: 16px;
  width:100px;
  cursor: pointer;
  text-align: center;
  vertical-align:50%;
  text-decoration: none;
  outline: none;
  color: #000;
  border: none;
  border-radius: 5px;
  box-shadow: 0 4px #999;
}

.punch-start {
  background-color: #4CAF50;
}

.punch-stop {
  background-color: red;
}

.punch-start:hover {background-color:#3e8e41}

.punch-stop:hover {background-color:crimson}

.punch-start:active {
  background-color:#3e8e41;
  box-shadow: 0 2px #666;
  transform: translateY(2px);
}

.punch-stop:active {
  background-color:crimson;
  box-shadow: 0 2px #666;
  transform: translateY(2px);
}

</style>

</head>

<body>

<?php 

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
require_once ("$toolkit/formdatahandler.php");
require_once ("$toolkit/inputtext.php");
require_once ("$toolkit/multlist2list.php");
require_once ("$toolkit/multlist2listsel.php");
require_once ("$toolkit/notetext.php");
require_once ("$toolkit/putbutton.php");
require_once ("$toolkit/liveaddunique.php");
require_once ("$toolkit/selecthourmin.php");
require_once ("$toolkit/selectoption.php");
require_once ("$toolkit/summarytable.php");
require_once ("$toolkit/toggleslider.php");

// Class definitions for the Controls instantiator and Menu generator 
require_once ("$docRoot/sys/init.php");
require_once ("$docRoot/sys/menu.php");

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

$pr_id = isset($_SESSION['project']) ? $_SESSION['project'] : 0;
$pa_id = isset($_SESSION['parcel']) ? $_SESSION['parcel'] : 0;
$pw_id = isset($_SESSION['projectworkday']) ? $_SESSION['projectworkday'] : 0;
$pwo_id = isset($_SESSION['projectworkdayoperation']) ?
           $_SESSION['projectworkdayoperation'] : 0;

//print_r ("pa:$pa_id pw:$pw_id pwo:$pwo_id");

//Instantiate the model and view
$workdayOperation = new modWorkdayOperation($pr_id, $pa_id, $pw_id, $pwo_id);
$workdayOperationView = new modWorkdayOperationView($workdayOperation);

// Output html layout and javascript
echo $workdayOperationView->output();

?>

</body>
</html>

