<?php
/**
* @package ViewVerifikasi
* @copyright Copyright (c) PT Gamatechno Indonesia
* @Analyzed By Dyan Galih <galih@gamatechno.com>
* @author
* @version 0.1
* @startDate 2011-02-07
* @lastUpdate 2011-02-07
* @description View Verifkasi
*/

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

class ViewVerifikasi extends HtmlResponse {

   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot').'module/pb_usulan_verifikasi/template');
      $this->SetTemplateFile('view_verifikasi.html');
   }

   function ProcessRequest() {
      $objUsulan = new VerifikasiUsulan();
		$id = $_GET['id']->integer()->Raw();
      $dataUsulan = $objUsulan->getDataUsulanById($id);
		$data = $dataUsulan[0];
		$dataDetil = $dataUsulan;
		$approval = 6;
		$cbApproval = $objUsulan->getDataStatusApproval();
      Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'approval', array('approval', $cbApproval, $approval, false, ''), Messenger::CurrentRequest);
		
		$return['data'] = $data;
		$return['dataDetil'] = $dataDetil;
      return $return;
   }

   function ParseTemplate($data = NULL) {
		$data['data']['url_action'] = Dispatcher::Instance()->GetUrl('pb_usulan_verifikasi', 'verifikasiUsulan', 'do', 'json');
		$data['data']['url_back'] = Dispatcher::Instance()->GetUrl('pb_usulan_verifikasi', 'usulanVerifikasi', 'view', 'html');
		
		$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'] = '';
					
					$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');
				}
      }
   }
}
?>