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

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

class ViewLogKondisi extends HtmlResponse
{
   function TemplateModule()
   {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot').
         'module/inventarisasi/template');
      $this->SetTemplateFile('view_log_kondisi.html');
   }
   
	function ProcessRequest()
   {
      $Obj = new AppInventarisasi;
      
      // Inisialisasi link URL
      $return['link']['url_back'] = Dispatcher::Instance()->GetUrl('inventarisasi', 'inventarisasi', 'view', 'html');
      // ---------
      
      // Generate dataGrid
      $return['dataHeader'] = $Obj->GetLogHeader($_GET['id']->Integer()->Raw());
      $return['dataBody'] = $Obj->GetLogKondisiBody($_GET['id']->Integer()->Raw());
      // ---------
	  
      //utk cetak rtf---
	  $return['id']=$_GET['id']->Integer()->Raw();
	  
      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();
      
      // render link
      $this->mrTemplate->AddVars('content', $data['link'], '');
      
      // header
      $this->mrTemplate->AddVars('content', $data['dataHeader'], '');
	  
	  //cetak Rtf
	  $this->mrTemplate->AddVar('content', 'URL_CETAK', Dispatcher::Instance()->GetUrl(Dispatcher::Instance()->mModule, 'cetakLogKondisi', 'view', 'html').'&id='.$data['id']);
      
      // body
      $i = 1;
      foreach ($data['dataBody'] as $value)
      {
         $value['number'] = $i;
         $value['class_name'] = ($i % 2) ? '' : 'table-common-even';
         $this->mrTemplate->AddVars('data_log', $value, '');
         $this->mrTemplate->parseTemplate('data_log', 'a');
         $i++;
      }
	}
}
?>
