<?php 

class modControlFieldView {
  private $scope;
    
  public function __construct(modControlField $controlField) {
    if (isset($controlField)) {

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

      $menu = new MainMenu('controlfield', $controlField->lo_id);
      $this->beforeMenu = $menu->before();
      $this->afterMenu  = $menu->after();
      
      $panelFields = new FieldInit('controlfield'); 
      $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='divcontrolfield' style='border:1px solid black;border-bottom:none;'>
    <div class='row'>
      <div class='col-md-12'>
    $this->cxtControlFieldLayout
        <table class='table table-condensed'>
          <tr>
            <td style='width:40%;'>
    $this->inpFieldLayout
            </td>
            <td style='width:25%;'>
    $this->selControlLayout
            </td>
            <td style='width:25%;'>
    $this->selFormLayout
            </td>
            <td style='width:10%;'>
    $this->frmControlFieldLayout
            </td>
          </tr>
          <tr>
            <td colspan='4'>
            <div id='valmsgfrmControlField' style='color:red'></div>
            </td>
          </tr>
          <tr>
            <td colspan='3'>
    $this->togContextSelectorLayout
            </td>
            <td colspan='1'>
    $this->togControlAttrsLayout
            </td>
          </tr>
        </table>
      </div> 
    </div>

    <div class='row'>
      <div class='col-md-12'>
        <div class='panel12 slidetogControlAttrs'>		  
          <table class='table table-condensed'>
            <tr>
              <td>
    $this->inpAttributeLayout
              </td>
              <td>
    $this->inpValueLayout
              </td>
            </tr>  
            <tr>
              <td>
                <div id='valmsgfrmControlAttr' style='color:red'></div>
              </td>
              <td>
    $this->frmControlAttrLayout
              </td>
            </tr>     
            <tr>
              <td colspan='2'>
    $this->sumControlAttrsLayout
              </td>
            </tr>
            <tr>
              <td colspan='2'>
    $this->delControlAttrLayout
              </td>
            </tr>
          </table>
        </div>
      </div>  
    </div>
    <div class='row'>
      <div class='col-md-12'>
        <div class='panel12 slidetogContextSelector'>		  
          <table class='table table-condensed'>
            <tr>
              <td>
    $this->bitSelectorPosLayout
              </td>
            </tr>  
            <tr>
              <td>
                <div id='valmsgfrmContextSelector' style='color:red'></div>
              </td>
            </tr>  
            <tr>
              <td>
    $this->frmContextSelectorLayout
              </td>
            </tr>     
          </table>
        </div>
      </div>  
    </div>
    <div class='row'>
      <div class='col-md-12'>
    $this->sumControlFieldsLayout
      
    $this->delControlFieldLayout
	</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('tagcontrolfield').click();
document.getElementById('logincontrolfield').innerHTML='Login: $this->loginName'

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

  
$this->frmControlFieldScript
$this->frmControlAttrScript
$this->cxtControlFieldScript
$this->inpFieldScript
$this->selControlScript
$this->selFormScript
$this->fkyPanelFolderScript
$this->inpAttributeScript
$this->inpValueScript
$this->bitSelectorPosScript
$this->togContentSelectorScript
$this->togControlAttrsScript
$this->sumControlFieldsScript
$this->sumControlAttrsScript

</script>
  ";
 
  return $layout;
  }	

}

?>