<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/lap_mutasi_barang/business/LapMutasiBarang.class.php';
require_once GTFWConfiguration::GetValue('application', 'docroot') . 'main/function/date.php';

class ViewCetakLapMutasiBarang extends HtmlResponse {

   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot').'module/lap_mutasi_barang/template');
      $this->SetTemplateFile('view_cetak_lap_mutasi_barang.html');
   }
   
   function TemplateBase() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application', 'docroot') . 'main/template/');
      $this->SetTemplateFile('document-print.html');
      $this->SetTemplateFile('layout-common-print.html');
   }
   
   function ProcessRequest() {
      $barangObj = new LapMutasiBarang();
	  
      $tglAwal = $_GET['tglAwal']->Raw();
		$tglAkhir = $_GET['tglAkhir']->Raw();
		$unitAsal = $_GET['unitAsal']->Raw();
		$unitTuj = $_GET['unitTuj']->Raw();
		$kodeBA = $_GET['kodeba']->Raw();
			
      //print_r($unit_id);
      $dataMutasi= $barangObj->GetDataMutasi($tglAwal,$tglAkhir,$unitAsal,$unitTuj, $kodeBA);
			$return['dataMutasi'] = $dataMutasi;
					
      //$return['url']['popup_detail_pembayaran'] = Dispatcher::Instance()->GetUrl(Dispatcher::Instance()->mModule, 'detailPembayaran', 'popup', 'html');
      $return['search']['ruang_id'] = $ruang_id;
		$return['search']['ruang_nama'] = $ruang_nama;
		$return['search']['unit_id'] = $unit_id;
      return $return;
	}
	
	function ParseTemplate ($data = NULL)
   {
   
		$search = $data['search'];
		$this->mrTemplate->AddVar('content', 'SEARCH_RUANG_NAMA', $search['ruang_nama']);
		$this->mrTemplate->AddVar('content', 'SEARCH_RUANG_ID', $search['ruang_id']);
		$this->mrTemplate->AddVar('content', 'UNIT', $search['unit_id']);

	  if (empty($data['dataMutasi']))
      {
         $this->mrTemplate->addVar('data_grid', 'IS_DATA_EMPTY', 'YES');
         return;
      }
      else $this->mrTemplate->addVar('data_grid', 'IS_DATA_EMPTY', 'NO');
	  
	  
			$dataMutasi = $data['dataMutasi'];
			
			for ($i=0; $i<sizeof($dataMutasi); $i++) {
				$no = $i+1;
				$dataMutasi[$i]['number'] = $no;
				if ($no % 2 != 0) $dataMutasi[$i]['class_name'] = 'table-common-even';
				else $dataMutasi[$i]['class_name'] = '';					
					
				$this->mrTemplate->AddVars('data_mutasi', $dataMutasi[$i], 'DATA_');
				$this->mrTemplate->parseTemplate('data_mutasi', 'a');	 
			}
	//============================================================================================
	}
   
}
?>
