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

class ViewInputJenisPembayaran extends HtmlResponse {

   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot').'module/jenis_pembayaran/template');
      $this->SetTemplateFile('input_jenis_pembayaran.html');
   }

   function ProcessRequest() {
      $jnsObj = new AppJenisPembayaran();
      $id = Dispatcher::Instance()->Decrypt($_GET['dataId']->Raw());      
    
      if(!empty($id))
         $data['dataJenisBayar'] = $jnsObj->GetDataJenisPembayaranById($id);
      //print_r($_GET);
      
      //pesan
      $msg = Messenger::Instance()->Receive(__FILE__);
      $data['pesan'] = $msg[0][1];
      $data['css'] = $msg[0][2];
         
      return $data;
   }
   
   function ParseTemplate($data = NULL) {
      if($data['pesan']) {
         $this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
         $this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', $data['pesan']);
         $this->mrTemplate->AddVar('warning_box', 'CLASS_PESAN', $data['css']);
      }
		
		$dataJenisPembayaran= $data['dataJenisBayar'];
      
		if ($_REQUEST['dataId']=='') {
			$tambah="Tambah";
		} else {
			$tambah="Ubah";
		}
     
		$this->mrTemplate->AddVar('content', 'URL_KEMBALI', Dispatcher::Instance()->GetUrl('jenis_pembayaran', 'jenisPembayaran', 'view', 'html') );            
      $this->mrTemplate->AddVar('content', 'JUDUL', $tambah);
		$this->mrTemplate->AddVar('content', 'ID', Dispatcher::Instance()->Decrypt($_GET['dataId']));
		$this->mrTemplate->AddVar('content', 'PAGE', Dispatcher::Instance()->Decrypt($_GET['page']));
		
		if(empty($data['dataJenisBayar'])){     
         $this->mrTemplate->AddVar('content', 'URL_ACTION', Dispatcher::Instance()->GetUrl('jenis_pembayaran', 'addJenisPembayaran', 'do', 'html') );
      }else{
         foreach ($data['dataJenisBayar'] as $key => $value) {
            $value['URL_ACTION'] = Dispatcher::Instance()->GetUrl('jenis_pembayaran', 'updateJenisPembayaran', 'do', 'html');
            
				$this->mrTemplate->AddVars("content", $value);
            $this->mrTemplate->ParseTemplate("content", "a");			
         }
      }  
    }

}
?>
