<?php 

class clickCheckbox  {
  private $scope;
  private $iterator;
  private $label;
  private $formDefs;
  private $formAlts;
  
  
  public function __construct($entry) {

    if (isset($entry)) {
      $this->scope    = $entry->scope;
      $this->iterator = $entry->iterator;
      $this->label    = $entry->label;
    }
  
 }

  public function outputLayout() {

    $layout = "
<span>
<label style='vertical-align:middle;padding-top:4px'>$this->label</label>
<input type='checkbox' id='box$this->scope' style='vertical-align:middle;'>
</span>
    ";
  
 	return $layout;
  }	

  public function outputScript() {

    $script = "

$(document).on('click', '#box$this->scope', function (e) {
//alert ($(this).prop('checked'));
  if ($(this).prop('checked'))
    send$this->scope (1, 'Yes');
  else
    send$this->scope (0, 'No');
});

function set$this->scope (value, text, source) {
  var checked = ((value == 1) ? true : false);
  $('#box$this->scope').prop('checked', checked);

  if ('$this->scope' == 'chkAwayFromWork')
  document.getElementById('box$this->scope').disabled = 
      ((value == 1) ? true : false);
}

multiFunction['set$this->scope'] = {
  set$this->scope:set$this->scope
}; 

function com$this->scope (message) {
  var key = Object.keys(message);
logMessage ('<td>com msg</td><td>' + key +  '</td><td>$this->scope</td><td>' + message[key][0] + '</td><td>' + message[key][1] + '</td><td>' + message[key][2] + '</td><td>' + message[key][3] + '</td><td>' + message[key][4] + '</td>');  
  if (key == 'selectId') {
    document.getElementById('box$this->scope').disabled = 
      ((message[key][0] == 0) ? true : false);
  }  
}  

multiFunction['com$this->scope'] = {
  com$this->scope:com$this->scope
};  


function send$this->scope (value, text) {
//alert ('send');
  var msgContent = [];
  msgContent.$this->scope = [value, text, 'sequent_frm', '$this->scope', 'new field value'];
  newValue$this->iterator (msgContent);
}
    "; 
    
    return $script;
  }
}

?>