<?php

class Bank extends Database {

   protected $mSqlFile= 'module/aset_ref_bank/business/bank.sql.php';
   
   function __construct($connectionNumber=0) {
	 $this->userId=Security::Instance()->mAuthentication->GetCurrentUser()->GetUserId();
      parent::__construct($connectionNumber);
      #$this->setDebugOn();     
   }
//==GET==      
   function GetData ($offset, $limit, $data) { 
      if(!isset($data['bank_cabang']))   
	     $data['bank_cabang']='';
	  
	  if(!isset($data['bank_alamat']))   
	     $data['bank_alamat']='';
	  
	    if(!isset($data['bank_nama']))   
	     $data['bank_nama']='';
	  
      $result = $this->Open($this->mSqlQueries['get_data'], array('%'.$data['bank_cabang'].'%',
                                                                  '%'.$data['bank_alamat'].'%',  
																  '%'.$data['bank_nama'].'%',                                                                															  
																  $offset,$limit));  																	  
	  return $result;
   }
   

   function GetCount () { 	 
     $result = $this->Open($this->mSqlQueries['get_count'], array());															  
     return $result[0]['total'];    
   }
   
      
   function GetDataById($id) {      
      $result = $this->Open($this->mSqlQueries['get_data_by_id'], array($id));									 	  
	  if($result)
	     return $result[0];
	  else
	     return $result;	  
   }
     
   function DoAdd($data) {
      
      @$ret = $this->Execute($this->mSqlQueries['do_add'], array(trim($data['bank_nama']),
		                                                        trim($data['bank_cabang']),
															    trim($data['bank_alamat']),
																trim($data['bank_account']),
																trim($data['bank_pemilik']),
																trim($data['bank_asing']),
																trim($data['bank_logo']),
																$this->userId
															    ));
    return $ret;  
   }
   
  	function DoUpdate($data) {
     @$ret = $this->Execute($this->mSqlQueries['do_update'], array(trim($data['bank_nama']),
		                                                          trim($data['bank_cabang']),
															      trim($data['bank_alamat']),
																  trim($data['bank_account']),
																  trim($data['bank_pemilik']),
																  trim($data['bank_asing']),
																  trim($data['bank_logo']),
																  $this->userId,
																  trim($data['bank_id'])
															    ));        		  
		//$this->mdebug();  
      return $ret;
    }   
	
	function DoDelete($id) {
	   $ret = $this->Execute($this->mSqlQueries['do_delete'], array($id));	 
       return $ret;
	}
   
    function DoAddRekening($data) {
      
      $ret = $this->Execute($this->mSqlQueries['do_add_rekening'], array(trim($data['no_rekening']),
		                                                    			 trim($data['nama_bank_rekening'])
															    ));
    return $ret; 
   }



   
}
?>
