<?php 

class modFormHandlerView {
    
  public function __construct(modFormHandler $formHandler) {
    if (isset($formHandler)) {

      $this->loginName = $formHandler->get('login_name');
      $this->lo_id = $formHandler->get('lo_id');

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

      $panelFields = new FieldInit('formhandler'); 
      $fields = $panelFields->get("fieldInit");
      foreach ($fields as $field) {
//print_r ($field);
//print_r ("<br>");        
        eval ($field);
      }
    }  
  }
  
  public function output() {

    $layout = "

<div class='container'>	
    $this->beforeMenu
  <div id='divformhander' style='border:1px solid black;border-bottom:none;'>
    <div class='row'>
      <div class='col-md-12'>
    $this->cxtFormHandlerLayout
        <table class='table table-condensed'>
          <tr>
            <td style='width:50%;'>
    $this->inpInstrNameLayout
            </td>
            <td style='width:50%;'>
    $this->selInstrTypeLayout
            </td>
          </tr>
          <tr>
            <td colspan='2'>
    $this->frmInstrumentLayout
            </td>
          </tr>     
          <tr>
            <td colspan='2'>
            <div id='valmsgfrmInstrument' style='color:red'></div>
            </td>
          </tr>
          <tr>
            <td>
            </td>
            <td colspan='1'>
    $this->togInstrPerformsLayout
            </td>
          </tr>
        </table>
      </div> 
    </div>

    <div class='row'>
      <div class='col-md-12'>
        <div class='panel12 slidetogInstrPerforms'>		  
          <table class='table table-condensed'>
            <tr>
              <td>
    $this->selPerfPeriodLayout
              </td>
              <td>
    $this->inpPeriodChangeLayout
              </td>
            </tr>  
          <tr>
            <td colspan='2'>
    $this->frmInstrPerformLayout
            </td>
          </tr>     
            <tr>
              <td>
                <div id='valmsgfrmInstrPerform' style='color:red'></div>
              </td>
              <td>
              </td>
            </tr>     
            <tr>
              <td colspan='2'>
    $this->sumInstrPerformsLayout
              </td>
            </tr>
            <tr>
              <td colspan='2'>
    $this->delInstrPerformLayout
              </td>
            </tr>
          </table>
        </div>
      </div>  
    </div>
    $this->frmInstrPerformLayout

    <div class='row'>
      <div class='col-md-12'>
    $this->sumInstrumentsLayout
      
    $this->delInstrumentLayout
	</div>
  </div>
    $this->afterMenu
</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>Function</th><th>Key</th><th>Sender</th><th>Value</th>
            <th>Attr</th><th>Receiver</th><th>Reason</th>
        </table>
      </div>
    </div>
  </div>
</div>

<script>

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

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

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

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

$this->frmInstrumentScript  
$this->frmInstrPerformScript
$this->cxtFormHandlerScript
$this->inpInstrNameScript
$this->selInstrTypeScript
$this->selPerfPeriodScript
$this->inpPeriodChangeScript
$this->togInstrPerformsScript
$this->sumInstrumentsScript
$this->sumInstrPerformsScript
</script>
  ";

  return $layout;
  }	

}

?>