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

/*  
 * Author : Fachri Nugraha
 * 
 */
class M_sub_type extends CI_Model {
    public $table       = 'am_accountsubtype';
    
	
	function get_sub_type_master($value,$field) {
        $this->db->_protect_identifiers = true;
		
		$this->db->select("AccountSubTypeID, AccountTypeName, AccountTypeDesc, AccountBSStatus,
		(case when AccountAutoStatus=1 then 'Yes'
                            else 'No' end) as AccountAutoStatus,
							(case when StatusSelected=1 then 'Yes'
                            else 'No' end) as StatusSelected
		");
        $this->db->from('am_accountsubtype');
		$this->db->like($field, $value);
        $query = $this->db->get();
        
		if($query->num_rows() > 0){
            return $query->result();
        }
        else{
            return false;
        }
    }
	
	function get_sub_type_master_empty() {
        $this->db->_protect_identifiers = true;
		
		$this->db->select("AccountSubTypeID, AccountTypeName, AccountTypeDesc,StatusSelected,
		(case when AccountAutoStatus=1 then 'Yes'
                            else 'No' end) as AccountAutoStatus,
							(case when StatusSelected=1 then 'Yes'
                            else 'No' end) as StatusSelected");
        $this->db->from('am_accountsubtype');
        $query = $this->db->get();
        
		if($query->num_rows() > 0){
            return $query->result();
        }
        else{
            return false;
        }
    }
	
	function update($data, $AccountSubTypeID) {
		$this->db->update($this->table, $data, array('AccountSubTypeID' => $AccountSubTypeID));
    }
}

/* End of file M_branchinfo.php */
/* Location: ./application/models/M_branchinfo.php */