<?php 

class modWorkdayOperationView {
  
  public function __construct(modWorkdayOperation $workdayOperation) {
    if (isset($workdayOperation)) {

//print_r ("lo:");
//print_r ($workdayOperation->lo_id);
      $this->loginName = $workdayOperation->login_name;
//      $this->pw_id = $workdayOperation->get('pw_id');
      $this->pw_id = $workdayOperation->pw_id;
        
      $menu = new MainMenu('workdayoperation', $workdayOperation->lo_id);
      $this->beforeMenu = $menu->before();
      $this->afterMenu  = $menu->after();


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

    $layout = "

    $this->beforeMenu

<div id='divworkdayoperation' style='border:1px solid black;border-bottom:0px'>
  <div class='container'>	

    <div class='row'>
      <div class='col-md-12'>
    $this->cxtOperationDefinitionLayout
        <table class='table table-condensed'>
          <tbody>
            <tr>
              <td colspan='4' style='width:40%'>
    $this->livOperationNameLayout
              </td>
              <td colspan='3' style='width:30%'>
    $this->selOperationTypeLayout
              </td>
              <td colspan='1' style='width:10%'>
              </td>
              <td colspan='2' style='width:20%;vertical-align:bottom;'>
    $this->frmOperationDefinitionLayout
              </td>
            </tr>
            <tr>
              <td colspan='8' style='width:80%;'>
              </td>
              <td colspan='2' style='width:20%;'>
    $this->togDailyOperationsLayout
              </td>
            </tr>
            <tr>
              <td colspan='10'>
                <div id='valmsgfrmOperationDefinition' style='color:red'></div>
              </td>
            </tr>
          </tbody>
        </table>      
      </div>
    </div>

    <div class='panel12 slidetogDailyOperations'>	
      <div class='row'>
        <div class='col-md-12'>
          <table class='table table-condensed'>
            <tbody>
              <tr>
                <td colspan='3' style='width:30%'>
    $this->timOpStartTimeLayout
                </td>
                <td colspan='4' style='width:40%'>
    $this->timBreakDurLayout
                </td>
                <td colspan='2' style='width:20%'>
    $this->timOpStopTimeLayout
                </td>
                <td colspan='1' style='width:10%'>
    $this->timOpDurationLayout
                </td>
              </tr>
              <tr>
                <td colspan='4' style='width:40%;'>
    $this->mulOperationCrewLayout
                </td>
                <td colspan='1' style='width:10%;'>
                </td>
                <td colspan='5' style='width:50%'>
    $this->mulOpObserversLayout
                </td>
              </tr>
              <tr>
                <td colspan='8' style='width:80%;'>
                </td>
                <td colspan='2' style='width:20%;'>
    $this->frmDailyOperationLayout
                </td>
              </tr>
              <tr>
                <td colspan='10'>
                  <div id='valmsgfrmDailyOperation' style='color:red'></div>
                </td>
              </tr>
            </tbody>
          </table>      
          <div class='row' id='divsumWorkdayOperations'>
            <div class='col-md-12'>
    $this->sumDailyOperationsLayout
            </div>
          </div>
        </div>
      </div>
    </div>    

    <div class='row' id='divsumDailyOperations'>
      <div class='col-md-12'>
    $this->sumOperationDefinitionsLayout
      </div>
    </div>
    <div class='row'>
      <div class='col-md-12'>
    $this->delOperationDefintionLayout
      </div>
    </div>
  </div> 
</div>  

<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('tagworkdayoperation').click();
document.getElementById('loginworkdayoperation').innerHTML='Login: $this->loginName'

if ($this->pw_id == 0) {
  document.getElementById('divworkdayoperation').style.display='none';
  document.getElementById('hdrmsgworkdayoperation').innerHTML=
    'Pre-select a Project Work Event';    
}

$this->frmOperationDefinitionScript
$this->frmDailyOperationScript
$this->cxtOperationDefinitionScript
$this->livOperationNameScript
$this->selOperationTypeScript
$this->togDailyOperationsScript
$this->fkyOperationScript
$this->fkyProjectWorkeventScript
$this->fkyProjectWorkeventDOScript
$this->timOpStartTimeScript
$this->timBreakDurScript
$this->timOpStopTimeScript
$this->timOpDurationScript
$this->mulOperationCrewScript
$this->mulOpObserversScript
$this->inpOperationNoteScript
$this->sumDailyOperationsScript
$this->sumOperationDefinitionsScript
$this->delOperationDefintionScript

</script>
    ";
	
    return $layout;
 
  }
}

?>