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

class ViewInputSumberInformasi extends HtmlResponse {
   function TemplateModule() {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/sumber_informasi/template');
		$this->SetTemplateFile('input_sumber_informasi.html');
	}
   
   function ProcessRequest() {
      $smbrInfoObj = new AppSumberInformasi();
      
      $idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);
      $dataSmbrInfo = $smbrInfoObj->GetDataSumberInformasiById($idDec);
      
      
      $msg = Messenger::Instance()->Receive(__FILE__);      
      $return['classWarning'] = $msg[0][1];
		$return['Pesan'] = $msg[0][0];
      
      $return['decDataId'] = $idDec;
		$return['dataSmbrInfo'] = $dataSmbrInfo;
      return $return;         
   }
   
   function ParseTemplate($data = NULL){
      $dataSmbrInfo = $data['dataSmbrInfo'];
      
      //filter tambah atau edit
      if ($_REQUEST['dataId']=='') {
			$url="addSumberInformasi";
			$tambah="Tambah";
		} else {
			$url="updateSumberInformasi";
			$tambah="Ubah";
		}
      
      if ($data['Pesan']) {
			$this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
         $this->mrTemplate->AddVar('warning_box', 'CLASS_WARNING', $data['classWarning']);
			$this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', $data['Pesan']);
		}
      
      $this->mrTemplate->AddVar('content', 'JUDUL', $tambah);
      $this->mrTemplate->AddVar('content', 'SMBR_INFO_NAMA',empty($dataSmbrInfo[0]['smbrinfo_nama'])?$data['data']['smbrinfo_nama']:$dataSmbrInfo[0]['smbrinfo_nama']);
		$this->mrTemplate->AddVar('content', 'URL_ACTION', Dispatcher::Instance()->GetUrl('sumber_informasi', $url, 'do', 'html') . "&dataId=" . Dispatcher::Instance()->Encrypt($data['decDataId']));
		$this->mrTemplate->AddVar('content', 'DATAID', Dispatcher::Instance()->Decrypt($_GET['dataId']));
		$this->mrTemplate->AddVar('content', 'PAGE', Dispatcher::Instance()->Decrypt($_GET['page']));
   }
}
?>
