<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot').
   'module/'.Dispatcher::Instance()->mModule.'/business/Rekap.class.php';

//set Label for module
require_once GTFWConfiguration::GetValue( 'application', 'docroot').
   'module/label/response/Label.proc.class.php';

class PopupRekap 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/'.Dispatcher::Instance()->mModule.'/template');
      $this->SetTemplateFile('popup_rekap.html');
   }
	
	function ProcessRequest()
   {
		$Obj = new Rekap;
      
      // Inisialisasi Data Grid
		$data = $Obj->PopUpList();
      $return['data'] = $data;
      // ---------
      
		return $return;
	}
	
   function TemplateLabeling(){
      $ObjLabel = new GetModuleLabel();
      $arrLabel = $ObjLabel->GetLabel();
      
      //patTemplate name yang memiliki label2 dinamic
      $arrContent=array("content");
      
      for($i=0;$i<count($arrContent);$i++){
         for($j=0;$j<count($arrLabel);$j++){
            $this->mrTemplate->AddVar($arrContent[$i],$arrLabel[$j]['labelCode'],$arrLabel[$j]['labelName']);
         }
      }
   }
   
	function ParseTemplate($data = NULL)
   {
      //set Label
      $this->TemplateLabeling();
      
      if (empty($data['data']))
      {
			$this->mrTemplate->AddVar('tabel_data', 'DATA_EMPTY', 'YES');
         return;
      }
      else $this->mrTemplate->AddVar('tabel_data', 'DATA_EMPTY', 'NO');
      
      $i = 1;
      foreach ($data['data'] as $value)
      {
         $value['nomor'] = $i;
         $value['class_name'] = ($i % 2) ? 'table-common-even' : '';
			//format number
			$value['total1_view'] = number_format($value['total1'],2,',','.');
			$value['total2_view'] = number_format($value['total2'],2,',','.');
         $this->mrTemplate->AddVars('data_item', $value, '');
         $this->mrTemplate->parseTemplate('data_item', 'a');
         $i++;
      }
	}
}
?>
