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

class PopupBarang 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_pengadaan_barang/template');
      $this->SetTemplateFile('popup_barang.html');
   }
	
	function ProcessRequest()
   {
		$Obj = new BarangUsulan;
		$data = $Obj->GetDataBarangUsulan();
		$return['data'] = $data;
      return $return;
	}
   
	function ParseTemplate($data = NULL)
   {
		if (sizeof($data['data']) === 0)
		{
			$this->mrTemplate->AddVar('data', 'DATA_EMPTY', 'YES');
			return;
		}	else {
			$this->mrTemplate->AddVar('data', 'DATA_EMPTY', 'NO');
			
			$i = 1;
			foreach ($data['data'] as $value)
			{
				$value['class_name'] = ($i % 2) ? 'table-common-even' : '';
				
				$this->mrTemplate->AddVars('data_item', $value, '');
				$this->mrTemplate->parseTemplate('data_item', 'a');
								
				$i++;
			}
      }
	}
}
?>
