<?php 

class modControlInstanceView {
  private $scope;
    
  public function __construct(modControlInstance $controlInstance) {
    if (isset($controlInstance)) {

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

      $menu = new MainMenu('controlinstance', $controlInstance->lo_id);
      $this->beforeMenu = $menu->before();
      $this->afterMenu  = $menu->after();
      
      $controlControls = new EntryInit('controlinstance');
      $entryInit = $controlControls->get("entryInit");
      foreach ($entryInit as $control) {
//print_r ($control);
//print_r ("<br>");        
        eval ($control);
      }
    }
  }  

  public function output() {

    $layout = "
    $this->beforeMenu

<div id='divcontrolinstance' style='border:1px solid black;border-bottom:none;'>
  <div class='container'>	
    <div class='row'>
      <div class='col-md-12'>
    $this->cxtControlInstanceLayout
        <table class='table table-condensed'>
          <tr>
            <td>
    $this->inpInstanceLayout
            </td>
            <td>
    $this->selControlLayout
            </td>
            <td>
    $this->frmControlInstanceLayout
            </td>
          </tr>
          <tr>
            <td colspan='3'>
            <div id='valmsgfrmControlInstance' style='color:red'></div>
            </td>
          </tr>
          <tr>
            <td colspan='3'>
    $this->togControlEntriesLayout
            </td>
          </tr>
        </table>
      </div> 
    </div>

    <div class='row'>
      <div class='col-md-12'>
        <div class='panel12 slidetogControlEntries'>		  
          <table class='table table-condensed'>
            <tr>
              <td>
    $this->inpPropertyLayout
              </td>
              <td>
    $this->inpValueLayout
              </td>
            </tr>  
            <tr>
              <td>
                <div id='valmsgfrmControlEntry' style='color:red'></div>
              </td>
              <td>
    $this->frmControlEntryLayout
              </td>
            </tr>     
            <tr>
              <td colspan='2'>
    $this->sumControlEntriesLayout
              </td>
            </tr>
            <tr>
              <td colspan='2'>
    $this->delControlEntryLayout
              </td>
            </tr>
          </table>
        </div>
      </div>  
    </div>
    <div class='row'>
      <div class='col-md-12'>
    $this->sumControlInstancesLayout
      
    $this->delControlInstanceLayout
	</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('tagcontrolinstance').click();
document.getElementById('logincontrolinstance').innerHTML='Login: $this->loginName'

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

  
$this->frmControlInstanceScript
$this->frmControlEntryScript
$this->cxtControlInstanceScript
$this->inpInstanceScript
$this->selControlScript
$this->fkyPanelFolderScript
$this->inpPropertyScript
$this->inpValueScript
$this->togControlEntriesScript
$this->sumControlInstancesScript
$this->sumControlEntriesScript

</script>
  ";
 
  return $layout;
  }	

}

?>