<?php 

defined('PUBLIC_ACCESS') or die('Restricted Access');

class modOfficeTimesheetView {
   
  // Initialize controls using data from the model. 
  public function __construct(modOfficeTimesheet $officeTimesheet) {
    if (isset($officeTimesheet)) {

      $this->loginName = $officeTimesheet->login_name;
      $this->lo_id = $officeTimesheet->lo_id;

      $menu = new MainMenu('officetimesheet', $officeTimesheet->lo_id);
      $this->beforeMenu = $menu->before();
      $this->afterMenu  = $menu->after();

      $controlsControls = new EntryInit('officetimesheet');
      $entryInit = $controlsControls->get("entryInit");
      foreach ($entryInit as $control) {
//print_r ($control);
//print_r ("<br>");        
        eval ($control);
      }
    }
  }
  
  public function output() {

    $layout = "

   $this->beforeMenu

<div id='divofficetimesheet' style='border:1px solid black;border-bottom:none;'>

  <div class='container'>
    <div class='row'>
      <div class='col-sm-12'>
        <table class='table table-condensed'>
          <tr>
            <td colspan='1' style='width:10%;'>
    $this->selOfficeWorkdayLayout
            </td>
            <td colspan='1' style='width:10%;'>
    $this->frmOfficeWorkdayLayout
            </td>
            <td colspan='1' style='width:10%;'>
            </td>
            <td colspan='2' style='width:20%;vertical-align:middle;'>
    $this->chkAwayFromWorkLayout
            </td>
            <td colspan='5' style='width:50%;'>
            </td>
          </tr>
          <tr>
            <td colspan='10'>
            <div id='valmsgfrmOfficeWorkday' style='color:red'></div>
            </td>
          </tr>
          <tr>
            <td colspan='6' style='width:60%;'>
    $this->livProjectSearchLayout
            </td>
            <td colspan='3' style='width:30%;'>
    $this->selProjectParcelLayout
            </td>
            <td  colspan='1' style='width:10%;'>
    $this->frmOfficeProjectLayout
            </td>
          </tr>
          <tr>
            <td colspan='10'>
            <div id='valmsgfrmOfficeProject' style='color:red'></div>
            </td>
          </tr>
          <tr>
            <td colspan='2' style='width:20%;'>
    $this->selProjectRoleLayout
            </td>
            <td colspan='2' style='width:20%;vertical-align:middle;text-align:center;'>
    $this->chkBillableTimeLayout
            </td>
            <td colspan='5' style='width:50%;'>
    $this->inpBillRationaleLayout
            </td>
            <td  colspan='1' style='width:10%;'>
            </td>
          </tr>
          <tr>
            <td colspan='2' style='width:20%;'>
    $this->timOfficeStartLayout
            </td>
            <td colspan='4' style='width:40%;text-align:center;'>
    $this->timOfficeBreakLayout
            </td>
            <td colspan='2' style='width:20%;'>
    $this->timOfficeStopLayout
            </td>
            <td colspan='2' style='width:20%;padding-top:7px;text-align:center;'>
    $this->timOfficeDurationLayout
            </td>
          </tr>
          <tr>
            <td colspan='10'>
            <div id='timmsgfrmOfficeTimesheet' style='color:red'></div>
            </td>
          </tr>
          <tr>
            <td colspan='9' style='width:90%;'>
    $this->inpOfficeNoteLayout
            </td>
            <td colspan='1' style='width:10%;'>
    $this->frmOfficeTimesheetLayout
            </td>
          </tr>
          <tr>
            <td colspan='10'>
            <div id='valmsgfrmOfficeTimesheet' style='color:red'></div>
            </td>
          </tr>
        </table>
      </div>
    </div>  
    <div class='row'>
      <div class='col-sm-12'>
      $this->sumOfficeProjectsLayout
      $this->delfrmOfficeProjectLayout
      </div>
    </div>  
  </div>
</div>  

$this->cnfOfficeUpdateLayout

<div id='debug' style='border:1px solid black;border-bottom:0px;'>  
  <div class='container'>	
    <div class='row' style='margin-top:10px;margin-bottom:10px;'>
      <div class='col-md-12'>
        <button class='btn btn-inverse' onclick='clearMessages();'>
          Clear
        </button>
        <table id='logmessages' class='table table-condensed'>
          <tr>
            <th>Funtion</th><th>Key</th><th>To</th><th>Value</th><th>Text</th>
            <th>Source</th><th>Index</th><th>Reason</th>
        </table>
      </div>
    </div>
  </div>
</div>

$this->afterMenu

<script>

function logMessage (message) {
  $('#logmessages').append ('<tr>' + message + '</tr>');
}

function clearMessages () {
  document.getElementById('logmessages').innerHTML = '';
}

document.getElementById('tagofficetimesheet').click();
document.getElementById('loginofficetimesheet').innerHTML='Login: $this->loginName'

if ($this->lo_id == 0) {
  document.getElementById('divofficetimesheet').style.display='none';
  document.getElementById('hdrmsgofficetimesheet').innerHTML=
    'Login';    
}

$this->frmOfficeWorkdayScript
$this->frmOfficeTimesheetScript
$this->frmOfficeProjectScript

$this->selOfficeWorkdayScript

$this->chkAwayFromWorkScript
$this->fkyWorkdayScript
$this->livProjectSearchScript
$this->selProjectParcelScript
$this->selProjectRoleScript
$this->timOfficeStartScript
$this->timOfficeStopScript
$this->timOfficeBreakScript
$this->timOfficeDurationScript
$this->chkBillableTimeScript
$this->inpBillRationaleScript
$this->inpOfficeNoteScript
$this->fkyWorkdayScript
$this->sumOfficeProjectsScript
$this->delfrmOfficeProjectScript
  
</script>
  ";
 
  return $layout;
  }	

}

?>