<?php 

class ConfirmModal  {
  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->target   = $entry->target;
    }
  }

  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>$this->bodyText
        <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>
        </label>
      </div>
    </div>
  </div>    
</div> 
    ";

 	return $layout;
  }	

  public function outputScript() {

	$script = "
	
function show$this->scope (){
  $('#modal$this->scope').modal('show');
}

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

$(document).on('click', '#ok$this->scope', function (e) {
  confirm$this->iterator (true);
});

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


    "; 
    return $script;
  }
}

?>