<?php
class PaymentHeadModel extends CI_Model {
    function __construct() {
        parent::__construct();
        $this->load->database();
    }

    public function add_paymenthead($data){
        $this->db->insert('PAYMENTHEADS',$data);
        return true;
    }

    public function update_paymenthead($id, $data){
        $this->db->where(array('ID'=>$id));
        $this->db->update('PAYMENTHEADS', $data);
        return true;
    }
    public function get_paymenthead($id){
        $this->db->where('ID', $id);
        $query = $this->db->get('PAYMENTHEADS');
        return $query->result();
    }

    public function delete_paymenthead($id){
        $this->db->where('ID', $id);
        $this->db->delete('PAYMENTHEADS');
        return true;
    }

    function all_paymentheads($pagelisttype=''){
        $this->db->select('*');
        $this->db->from('PAYMENTHEADS');
        $this->db->order_by("PAYMENTHEAD", "asc");
        $this->db->where(array('ID!=' => 'DEPOSIT'));
//        $this->db->where(array('ID!=' => 'PURCHASE'));
//	$this->db->where(array('ID!=' => 'PURCHASERETURN'));
        $query = $this->db->get();
        if($query->num_rows()>0){
            return $query->result(); 
        } else {
            return null;
        }
    }

    function all_paymentheadsList($pagelisttype=''){
        $this->db->select('PAYMENTHEADS.ID,PAYMENTHEADS.PAYMENTHEAD,PAYMENTHEADS.TAXCAT,TAXCATEGORIES.NAME');
        $this->db->from('PAYMENTHEADS');
        $this->db->join('TAXCATEGORIES', 'TAXCATEGORIES.ID=PAYMENTHEADS.TAXCAT', 'left');
        $this->db->order_by("PAYMENTHEADS.PAYMENTHEAD", "asc");
        $this->db->where(array('PAYMENTHEADS.ID!=' => 'DEPOSIT'));
        $this->db->where(array('PAYMENTHEADS.ID!=' => 'PURCHASE'));
	$this->db->where(array('PAYMENTHEADS.ID!=' => 'PURCHASERETURN'));
        $query = $this->db->get();
        if($query->num_rows()>0){
            return $query->result(); 
        } else {
            return null;
        }
    }
}
