<?php 

class modProjectDefinitionView {

  public function __construct(modProjectDefinition $projectDefinition) {
    if (isset($projectDefinition)) {

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

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

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

    $layout = "
    
$this->beforeMenu 

<div id='divprojectdefinition' style='border:1px solid black;border-bottom:none;'>
  <div class='container'>
    <div class='row' style='margin-top:10px;'>
      <div class='col-md-12'>
        <table class='table table-condensed'>
          <tr>
            <td  colspan='1' style='width:10%'>
    $this->frmSetProjectNameLayout
            </td>
            <td colspan='4' style='width:40%'>
    $this->sasClientProjectLayout
            </td>
            <td colspan='4' style='width:40%'>
    $this->sasOrganizationContactLayout
            </td>
            <td colspan='1' style='width:10%'>
    $this->frmSetOrgContactLayout
            </td>
          </tr>
          <tr>
            <td  colspan='1' style='width:10%'>
            </td>
            <td colspan='4' style='width:40%'>
    $this->livProjShortNameLayout
            </td>
            <td colspan='4' style='width:40%'>
    $this->selContactTypeLayout
            </td>
            <td colspan='1' style='width:10%'>
            </td>
          </tr>
          <tr>
            <td  colspan='1' style='width:10%'>
            </td>
            <td colspan='4' style='width:40%'>
    $this->inpProjectRefNoLayout
            </td>
            <td colspan='4' style='width:40%'>
            </td>
            <td colspan='1' style='width:10%'>
            </td>
          </tr>
             <tr>
              <td colspan='10' style='height:37px;'>
    $this->frmProjectDefinitionLayout
              </td>
            </tr>
         <tr>
            <td colspan='5'>
              <div id='valmsgfrmSetProjectName' style='color:red'></div>
            </td>
            <td colspan='5'>
              <div id='valmsgfrmSetOrgContact' style='color:red'></div>
            </td>
          </tr>
          <tr>
            <td colspan='3' style='width:30%'>
    $this->selProjDepartmentLayout
            </td>
            <td colspan='2' style='width:20%'>
    $this->selProjectLicenceLayout
            </td>
            <td colspan='2' style='width:20%'>
    $this->selProjectStageLayout
            </td>
            <td colspan='3' rowspan='6' style='width:30%'>
    $this->addProjectFrameworksLayout
            </td>
          </tr>    
          <tr>
            <td colspan='2' style='width:20%'>
    $this->inpProponentNoLayout
            </td>
            <td colspan='2' style='width:20%'>
    $this->selApprovalContactLayout
            </td>
            <td colspan='3' style='width:30%'>
    $this->inpApprovalBodyLayout
            </td>
          </tr>    
          <tr>
            <td colspan='7' style='width:70%'>
    $this->inpProjectDescrLayout
            </td>
          </tr>    
          <tr>
            <td colspan='5' style='width:50%'>
    $this->addRelatedProjectsLayout
            </td>
            <td colspan='5' style='width:50%'>
    $this->inpProjectNoteLayout
            </td>
          </tr>
          <tr>
            <td colspan='10 style='width:100%'>
    $this->frmProjectDefinitionLayout
            </td>
          </tr>
          <tr>
            <td colspan='10'>
              <div id='valmsgfrmProjectDefinition' style='color:red'></div>
            </td>
          </tr>
        </table>
    $this->sumProjectDefinitionsLayout

      </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->cnfProjectNameUpdateLayout

$this->afterMenu

<script>

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

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

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

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

$this->frmProjectDefinitionScript
$this->frmSetProjectNameScript
$this->frmSetOrgContactScript
$this->sasClientProjectScript
$this->sasOrganizationContactScript
$this->livProjShortNameScript
$this->selContactTypeScript
$this->selProjDepartmentScript
$this->inpProjectRefNoScript
$this->selProjectLicenceScript
$this->selProjectStageScript
$this->inpProponentNoScript
$this->selApprovalContactScript
$this->inpApprovalBodyScript
$this->inpProjectDescrScript
$this->addProjectFrameworksScript
$this->addRelatedProjectsScript
$this->inpProjectNoteScript
$this->fkyProjectScript
$this->mapProjectNameScript
$this->mapOrganizationContactScript
$this->sumProjectDefinitionsScript

$this->cnfProjectNameUpdateScript 

</script>
  ";

  return $layout;
  }	

}

?>