<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/aset_ref_bank/response/ProcessBank.proc.class.php';

class ViewInputBank extends HtmlResponse {

   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot') .
         'module/aset_ref_bank/template');
      $this->SetTemplateFile('input_bank.html');
   }
   
   function ViewInputBank() {
     $this->proc = new ProcessBank();   
   }
   
   function ProcessRequest() {  
	  $this->data['action']='add'; //inisialisasi
	  
	  if(isset($_GET['grp'])) { //action pengeditan
	    $grp=Dispatcher::Instance()->Decrypt($_GET['grp']);	        
        $this->data = $this->proc->Bank->GetDataById($grp);	
        $this->data['action']='edit';						
		
		if(sizeof(@$data) > 0 ) {
	     $return['data']=$data[0];		  
	    }			
	  }    
	          
		$tmp=$this->proc->parsingUrl(__FILE__);	
		
		if(isset($tmp['data'])) {
		  $this->data = $tmp['data'];
          if(trim($this->data['bank_id']) != '')		  
             $this->data['bank_id'] = Dispatcher::Instance()->Encrypt($this->data['bank_id']);  
		}	

		if(isset($tmp['msg']))
		  $return['msg']=$tmp['msg'];       
		   
      return @$return;
   }

   function ParseTemplate($data = NULL) {     
   //debug($data);
      if (isset ($data['msg'])) {	     
         $this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
         $this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', $data['msg']['message']);
      }      
       
      if ($this->data['action']=='add') {
         $url="addBank";
         $tambah="Tambah";         
      } else {	
         $url="updateBank";
         $tambah="Ubah";	       
	  }
	  
	  $url = Dispatcher::Instance()->GetUrl('aset_ref_bank',$url , 'do' ,'html');
	  
	  @$this->data['link_logo'] = "document/logobank/".$this->data['bank_logo'];
	  
	  $this->mrTemplate->AddVars('content',  $this->data, "DATA_");
	 
	  $this->mrTemplate->AddVar('content', 'DATA_ACTION', $this->data['action']);
	  $this->mrTemplate->AddVar('content', 'ACTION', $tambah);
	  $this->mrTemplate->AddVar('content', 'URL_ACTION', $url);
		

	
   }
}
?>
