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

class ViewPrintLaporanInvTanah extends HtmlResponse {

   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot').'module/laporan_inventarisasi_tanah/template');
      $this->SetTemplateFile('print_laporan_inv_tanah.html');
   }
   
   function TemplateBase() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application', 'docroot') . 'main/template/');
      $this->SetTemplateFile('document-print.html');
      $this->SetTemplateFile('layout-common-print.html');
   }
   
   function ProcessRequest() {
      $Obj = new LaporanInventarisasiTanah();
		//-- 
		$company_name 			= GTFWConfiguration::GetValue('organization', 'company_name');
		$alamat 			= GTFWConfiguration::GetValue('organization', 'city');
		$namacetak	 	= $_SESSION['username'];
		$tglcetak		= IndonesianDate(date('Y-m-d'), 'YYYY-MM-DD');
		
		$return['company_name'] = $company_name;
		$return['alamat'] = $alamat;
		$return['nama'] = $namacetak;
		$return['tanggal'] = $tglcetak;
		$data = $_GET->AsArray();//Dispatcher::Instance()->Decrypt($_GET);
      $return['data']= $Obj->GetInventarisasiTanah($data, 0, 10000);
      $return['tahun']=$_GET['tahun'];
		
   	return $return;  
   }
   
   function ParseTemplate($data = NULL) {
      $this->mrTemplate->addVar('content','COMPANY_NAME', $data['company_name']);
		$this->mrTemplate->addVar('content','ALAMAT', $data['alamat']);
      $this->mrTemplate->addVar('content','NAMA', $data['nama']);
		$this->mrTemplate->addVar('content','TAHUN', $data['tahun']);
      $this->mrTemplate->addVar('content','TANGGAL', $data['tanggal']);
      
      if (!is_array($data['data']) OR count($data['data']) == 0)
         return $this->mrTemplate->AddVar('data', 'DATA_EMPTY', 'YES');
      else $this->mrTemplate->AddVar('data', 'DATA_EMPTY', 'NO');
      
      $i = $data['startRec'] + 1;
      foreach ($data['data'] as $value)
      {
         $data = $value;
         $data['number'] = $i;
         $data['class_name'] = ($i % 2 == 0) ? '' : 'table-common-even';
         $data['luas'] = number_format($data['luas'],'2',',','.');
         $this->mrTemplate->AddVars('data_item', $data, '');
         $this->mrTemplate->parseTemplate('data_item', 'a');
         $i++;
      }
   }
}
?>
