<?php 

//require_once ("$toolkit/selecthourminv0.php");

class SetTimeModal  {
  private $scope;
  private $headText;
  private $bodyText;

  public function __construct($entry) {

    if (isset($entry)) {
      $this->scope    = $entry->scope;
      $this->iterator = $entry->iterator;
      $this->headText = $entry->headText;
      $this->bodyText = $entry->bodyText;
      $this->iterator = $entry->iterator;
      
    $props = (object)array(
             "scope"     => "set$this->scope",
             "hourRange" => "00,23",
             "iterator"  => "set$this->scope",
             "format"    => "time",              
             "minList"   => "00,15,30,45"
             );

      $setTime = new SelectHourMin($props);
      $this->setTimeLayout = $setTime->outputLayout();
      $this->setTimeScript = $setTime->outputScript();

    }
  }

  public function outputLayout() {

    $layout = "
<div class='modal fade' id='modal$this->scope' tabindex='-1' role='dialog'>
  <div class='modal-dialog modal-sm cnf-modal' role='document'>
    <div class='modal-content'>
      <div class='modal-header'>
        <button type='button' class='close' data-dismiss='modal'>&times;</button>
        <h4 class='modal-title'>$this->headText</h4>
      </div>
      <div class='modal-body'>
        <div id='cnfmsg$this->scope'></div>
        <label id='lab$this->scope'>$this->bodyText</label>
        $this->setTimeLayout<br>
        <button type='button' id='ok$this->scope'  data-dismiss='modal' class='btn btn-inverse' style='width:70px'>OK</button>
        <button type='button' data-dismiss='modal' class='btn btn-inverse' style='width:70px'>Cancel</button>
      </div>
    </div>
  </div>    
</div> 
    ";

 	return $layout;
  }	

  public function outputScript() {

	$script = "

$this->setTimeScript

function show$this->scope (label){
  document.getElementById('lab$this->scope').innerHTML = label + ' Time';
  $('#modal$this->scope').modal('show');
}

function hide$this->scope (){
  $('#modal$this->scope').modal('hide');
}

$(document).on('click', '#ok$this->scope', function (e) {
  var time = document.getElementById ('hidset$this->scope').value;
//alert (time);  
  confirm$this->iterator (time);
});

$('#modal$this->scope').on('hidden.bs.modal', function () {
  confirm$this->iterator ('00:00');
})


    "; 
    return $script;
  }
}

?>