<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Bank_model extends CI_Model{
	
	  	public function bank_all(){
		$this->db->where('is_delete', 0);
		$this->db->where('companyID', element('compID', $this->session->userdata('logged_in')));
		$query = $this->db->get('comp_bank');
		
		if($query->num_rows() >= 1){
			return $query->result();
		}else{
			return FALSE;
		}
	}
	public function bank_insert($newbank){
		$sql = $this->db->insert_string('comp_bank', $newbank);
		$query = $this->db->query($sql);
		if($query === TRUE){
			return TRUE;
		} else {
			$last_query = $this->db->last_query();
			return $last_query;
		}
	}
	public function bank_edit($updatebank, $ID){
		$this->db->where('ID', $ID);
		$query = $this->db->update('comp_bank', $updatebank); 
		if($query === TRUE){
			return TRUE;
		} else {
			return FALSE;
		}
	}

	public function bank_delete($deletebank, $ID){
		$this->db->where('ID', $ID);
		$query = $this->db->update('comp_bank', $deletebank); 
		if($query === TRUE){
			return TRUE;
		} else {
			return FALSE;
		}
	}
	
	public function bank_id($ID){
	    $this->db->where('ID', $ID);
		$query = $this->db->get('comp_bank', 1);		
		if($query->num_rows() == 1){
			return $query->result();
		}else{
			return false;
		}
	}
	
		//public function bank_allopt(){
		//$this->db->select('ID');
		//$this->db->select('bankName');
	   // $this->db->where('companyID', element('compID', $this->session->userdata('logged_in')));
		//$this->db->where('is_delete', 0);
		//$this->db->order_by('bankName');
		//$query = $this->db->get('comp_bank');
    	//if($query->result()){
       		//$result = $query->result();
        	//return $result;
    	//} 	
	//}
}