<?php 

class modArtifactBagView {
  
  public function __construct(modArtifactBag $artifactBag) {
    if (isset($artifactBag)) {

      $this->loginName = $artifactBag->login_name;
//      $this->pw_id = $artifactBag->get('pw_id');
      $this->pw_id = $artifactBag->pw_id;

      $menu = new MainMenu('artifactbag', $artifactBag->lo_id);
      $this->beforeMenu = $menu->before();
      $this->afterMenu  = $menu->after();

      $controlsControls = new EntryInit('artifactbag');
      $entryInit = $controlsControls->get("entryInit");
      foreach ($entryInit as $control) {
//print_r ($control);
//print_r ("<br>");        
        eval ($control);
      }
    }  
  }
  
  public function output() {

  $layout = "

  $this->beforeMenu 

<div id='divartifactbag' style='border:1px solid black;border-bottom:none;'>
  <div class='container'>	
    <div class='row'>
      <div class='col-md-12'>
    $this->cxtArtifactBagLayout

        <table class='table table-condensed'>
          <tbody>
            <tr>
              <td style='width:25%'>
    $this->inpBagRefnoLayout
              </td>
              <td style='width:25%'>
    $this->inpBagTitleLayout
              </td>
              <td style='width:25%'>
              </td>
              <td style='width:25%' >
    $this->frmCollectBagLayout
              </td>
            </tr>
            <tr>
              <td colspan='4'>
                <div id='valmsgfrmCollectBag' style='color:red'></div>
              </td>
            </tr>
            <tr>
              <td colspan='3'>
              </td>
              <td colspan='1'>
    $this->togArtifactBatchesLayout
              </td>
            </tr>
          </table>

        <!-- ARTIFACT FORM -->
          <div class='panel1 slidetogArtifactBatches'>
            <table class='table table-condensed'>
              <tr>
                <td colspan='8' style='width:80%'>
                  <label>Artifact</label>
                </td>
                <td colspan='2' style='width:20%'>
                  <label>Count</label>
                </td>
              </tr>
              <tr>
                <td colspan='2' style='width:20%'>
    $this->selArtAffiliationLayout
                </td>
                <td colspan='2' style='width:20%'>
    $this->selArtMaterialLayout
                </td>
                <td colspan='2' style='width:20%'>
    $this->selArtifactFormLayout
                </td>
                <td colspan='2' style='width:20%'>
    $this->selArtCompletenessLayout
                </td>
                <td colspan='1' style='width:10%'>
    $this->inpCollectCountLayout
                </td>
                <td colspan='1' style='width:10%'>
    $this->inpDocuCountLayout        
                </td>
              </tr>
              <tr>          
                <td colspan='2' style='width:20%'>
    $this->chkArtDiagnosticLayout
                </td>
                <td colspan='2'  style='width:20%'>
    $this->selSampleRationaleLayout
                </td>
                <td colspan='5' style='width:50%'>
    $this->inpAddObservationsLayout
                </td>
                <td  colspan='1''style='width:10%'>
    $this->frmArtifactBatchLayout
                </td>
              </tr>
              <tr>
                <td colspan='4'>
                  <div id='valmsgfrmArtifactBatch' style='color:red'></div>
                </td>
              </tr>
            </tbody>  
          </table>
    $this->sumArtifactBatchesLayout  
        </div>

        <!-- BAG SUMMARY -->
    $this->sumCollectBagsLayout  

      </div>
    </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('tagartifactbag').click();
document.getElementById('loginartifactbag').innerHTML='Login: $this->loginName'

if ($this->pw_id == 0) {
  document.getElementById('divartifactbag').style.display='none';
  document.getElementById('hdrmsgartifactbag').innerHTML='Pre-select a Project Work Event';    
}


$this->frmCollectBagScript
$this->frmArtifactBatchScript

$this->cxtArtifactBagScript

$this->inpBagRefnoScript
$this->inpBagTitleScript
$this->togArtifactBatchesScript

$this->selArtAffiliationScript
$this->selArtMaterialScript
$this->selArtifactFormScript
$this->selArtCompletenessScript
$this->chkArtDiagnosticScript
$this->inpCollectCountScript
$this->inpDocuCountScript        
$this->selSampleRationaleScript
$this->inpAddObservationsScript

$this->sumArtifactBatchesScript  
$this->sumCollectBagsScript  

</script>
    ";
	
    return $layout;
 
  }
}

?>