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

class ViewDetilVerifikasi extends HtmlResponse {

	function TemplateBase()
   {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application', 'docroot') . 'main/template/');
      $this->SetTemplateFile('document-common-popup.html');
      $this->SetTemplateFile('layout-common-popup.html');
   }
   
   function TemplateModule()
   {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot').
         'module/pb_usulan_verifikasi/template');
      $this->SetTemplateFile('popup_detil_verifikasi.html');
   }
	
	function ProcessRequest() {		
		$objUsulan = new VerifikasiUsulan();
		$id = $_GET['id']->integer()->Raw();
      $dataUsulan = $objUsulan->getDataUsulanById($id);
		$data = $dataUsulan[0];
		$dataDetil = $dataUsulan;		
		$return['data'] = $data;
		$return['dataDetil'] = $dataDetil;
      return $return;
	}
   
	function ParseTemplate($data = NULL)
   {    
		$data['data']['filePath'] = "images/usulan/".$data['data']['file'];

		if($data['data']['file']!=0){
			$data['data']['display'] = 'none';
		}
		
		$this->mrTemplate->AddVars('content', $data['data'], '');
		if (empty($data['dataDetil'])) {
            $this->mrTemplate->AddVar('data_grid', 'DATA_EMPTY', 'YES');
         } else {
            $this->mrTemplate->AddVar('data_grid', 'DATA_EMPTY', 'NO');
            $dataList = $data['dataDetil'];
				$data['start'] = 1;
				for ($i=0; $i<sizeof($dataList); $i++) {
					$no = $i+$data['start'];
					$dataList[$i]['nomor'] = $no;
					if ($no % 2 != 0)
						$dataList[$i]['class_name'] = 'table-common-even';
					else
						$dataList[$i]['class_name'] = '';
						
					if($dataList[$i]['jmlApprove']!=0){
						$dataList[$i]['jmlDO'] = $dataList[$i]['jmlApprove'];
					}
					if($dataList[$i]['nilaiSetuju']!=0){
						$dataList[$i]['brgNilai'] = $dataList[$i]['nilaiSetuju'];
					}
					
					$dataList[$i]['hargaHps'] = $dataList[$i]['brgHps']*$dataList[$i]['jmlDO'];
					$dataList[$i]['hargaUsulan'] = $dataList[$i]['brgNilai']*$dataList[$i]['jmlDO'];
					
					$this->mrTemplate->AddVars('data_item', $dataList[$i], '');
					$this->mrTemplate->parseTemplate('data_item', 'a');
				}
      }
	}
}
?>
