<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot').
   'module/pengembalian_aset/business/PengembalianAset.class.php';

require_once GTFWConfiguration::GetValue('application', 'docroot') . 'main/function/date.php';

class ViewCetakPengembalianAset extends HtmlResponse {

   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot').
         'module/pengembalian_aset/template');
      $this->SetTemplateFile('view_cetak_pengembalian_aset.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 PengembalianAset();

      $data = $Obj->GetDataPengembalianAsetDetilById($_GET['id']);
      $return['data'] = $data;

      return $return;
	}

	function ParseTemplate ($data = NULL)
   {
		$dataForm = $data['data'][0];
		$dataForm['tgl_kembali'] = IndonesianDate($dataForm['tgl_kembali'], 'yyyy-mm-dd');
  
		$this->mrTemplate->AddVars('content', $dataForm, '');
      
      // Render data grid
		if (empty($data['data']))
		{
			$this->mrTemplate->AddVar('data', 'DATA_EMPTY', 'YES');
			return;
		}
			else $this->mrTemplate->AddVar('data', 'DATA_EMPTY', 'NO');
      
		$i = 1;
      foreach ($data['data'] as $value)
      {
			$value['nomor'] = $i;
			
			$value['terlambat']=number_format($value['terlambat'], 2, ',', '.');
			$value['rusak']=number_format($value['rusak'], 2, ',', '.');
			$value['ganti']=number_format($value['ganti'], 2, ',', '.');
			
			$this->mrTemplate->AddVars('data_item', $value, '');
			$this->mrTemplate->parseTemplate('data_item', 'a');
				
			$i++;
      }
		
      // ---------
		$namacetak	= $_SESSION['username'];
		$tglcetak	= date('d F Y');
		$kota 	= GTFWConfiguration::GetValue('organization', 'city');

		$this->mrTemplate->AddVar('content', 'KOTA', $kota);
		$this->mrTemplate->AddVar('content', 'TGLCETAK', $tglcetak);
		$this->mrTemplate->AddVar('content', 'NAMACETAK', $namacetak);
		$this->mrTemplate->AddVar('data', 'TOTAL_BIAYA', number_format($totalBiaya, 2, ', ', '.'));
   }
}
?>