<?php

/*
 @ClassName : Print Laporan DIR
 @Copyright : PT Gamatechno Indosnesia
 @Analyzed By : Nanang Ruswianto <nanang@gamatechno.com>
 @Designed By : Rosyid <rosyid@gamatechno.com>
 @Author By : Dyan Galih <galih@gamatechno.com>
 @Version : 1.0
 @StartDate : Nov 11, 2008
 @LastUpdate : Nov 11, 2008
 @Description :
*/

require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/mutasi_barang/business/AppMutasi.class.php';
//set Label for module
require_once GTFWConfiguration::GetValue( 'application', 'docroot') .
'module/label/response/Label.proc.class.php';
class PrintMutasiBarang extends HtmlResponse {

   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot').'module/mutasi_barang/template');
      $this->SetTemplateFile('print_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 TemplateLabeling(){
      $ObjLabel = new GetModuleLabel();
      $arrLabel = $ObjLabel->GetLabel();
      //patTemplate name yang memiliki label2 dinamic
      $arrContent=array("content");
      
      for($i=0;$i<count($arrContent);$i++){
         for($j=0;$j<count($arrLabel);$j++){
            $this->mrTemplate->AddVar($arrContent[$i],$arrLabel[$j]['labelCode'],$arrLabel[$j]['labelName']);
         }
      }
   }
   
   function ProcessRequest() {
      $Obj = new AppMutasiBarang();
		$golBarang = Dispatcher::Instance()->Decrypt($_GET['jenis_kib']);
   	$lokasi = Dispatcher::Instance()->Decrypt($_GET['lokasi']);
   	$unit = Dispatcher::Instance()->Decrypt($_GET['unit_kerja']);
   	$tglAwal = Dispatcher::Instance()->Decrypt($_GET['tanggal_awal_year']).'-'.Dispatcher::Instance()->Decrypt($_GET['tanggal_awal_mon']).'-'.Dispatcher::Instance()->Decrypt($_GET['tanggal_awal_day']);
   	$tglAkhir = Dispatcher::Instance()->Decrypt($_GET['tanggal_akhir_year']).'-'.Dispatcher::Instance()->Decrypt($_GET['tanggal_akhir_mon']).'-'.Dispatcher::Instance()->Decrypt($_GET['tanggal_akhir_day']);
   	$kodeBrg = Dispatcher::Instance()->Decrypt($_GET['aset']);

      $return['data'] = $Obj->GetListMutasi($golBarang,$tglAwal,$tglAkhir,$kodeBrg,$kodeBrg,$unit,$lokasi);
		
   	return $return;  
   }
   
   function ParseTemplate($data = NULL) {
   	
      $this->TemplateLabeling();
      
      if(empty($data['data'])){
      	$this->mrTemplate->AddVar('data','DATA_EMPTY','YES');      	
      	return;
		}else
			$this->mrTemplate->AddVar('data','DATA_EMPTY','NO');
			
			$gridList = $data['data'];
			
		$no = 1;
		//print_r($gridList);
		for($i=0;$i<count($gridList);$i++){
			$gridList[$i]['NO'] = $no;
			$this->mrTemplate->AddVars('data_item',$gridList[$i],'MUTASI_');
			$this->mrTemplate->parseTemplate('data_item','a');
			$no++;
		}
   }
}
?>
