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

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

class ViewInventarisasiPenyesuaian extends HtmlResponse
{
   function TemplateModule ()
   {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot').
         'module/'.Dispatcher::Instance()->mModule.'/template');
      $this->SetTemplateFile('view_inventarisasi_penyesuaian.html');
   }
   
   function ProcessRequest ()
   {
      $Obj = new AppInventarisasi();
      
      // inisialisasi messaging
		$msg = Messenger::Instance()->Receive(__FILE__);
        @$this->Data = $msg[0][0];
		@$this->Pesan = $msg[0][1];
		@$this->css = $msg[0][2];
      // ---------
      
      // inisialisasi default value
      $data = array();
      if (is_array($this->Data))
         $data = $this->Data;
      else
      {
         $result = $Obj->GetPenyesuaianData($_GET['id']->Integer()->Raw());
         if ($result == false)
         {
            $url = Dispatcher::Instance()->GetUrl(Dispatcher::Instance()->mModule, 'inventarisasi', 'view', 'html');
            if (isset($_GET['ascomponent']) AND $_GET['ascomponent'] == '1') $url .= "&ascomponent=1";
            $this->RedirectTo($url);
            return null;
         }
         else
         {
            if (!is_array($this->Data)) $data = $result;
            if (@$data['pengadaanId'] == @$result['pengadaanId']) $isChangeJmlAset = true;
            $diffJmlAset = @$result['jumlahDO'];
         }
      }
      
      $return['data'] = $data;
      // ---------
      
      // inisialisasi link address
      $return['url']['action'] = Dispatcher::Instance()->GetUrl(Dispatcher::Instance()->mModule, 'inventarisasiPenyesuaian', 'do', 'html')."&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)
   {
      if ($data == null) return null;
      
      //set Label
      $this->TemplateLabeling();
      
      // render message box
      if($this->Pesan)
      {
         $msg = '';
         if (count($this->Pesan) > 1) foreach ($this->Pesan as $value)
            $msg .= "\t$value<br/>\n";
         else $msg .= $this->Pesan[0];
         
			$this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
			$this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', $msg);
			$this->mrTemplate->AddVar('warning_box', 'CLASS_PESAN', $this->css);
		}
      // ---------
      
      // render link
      $this->mrTemplate->AddVars('content', $data['url'], 'URL_');
      // ---------
      
      // render default value
      if (!isset($data['data']['mstPenystnUmrEkoOld'])) $data['data']['mstPenystnUmrEkoOld'] = $data['data']['mstPenystnUmrEko'];
      if (!isset($data['data']['mstPenystnNilaiPerolehanOld'])) $data['data']['mstPenystnNilaiPerolehanOld'] =  number_format($data['data']['mstPenystnNilaiPerolehan'],1,',','.');
      if (!isset($data['data']['mstPenystnNilaiResiduOld'])) $data['data']['mstPenystnNilaiResiduOld'] =  number_format($data['data']['mstPenystnNilaiResidu'],1,',','.');
      $this->mrTemplate->AddVars('content', $data['data'], '');
      // ---------
   }
}
?>