<?php
class Report_model extends CI_Model{

function inv_sum($po_id){
    
                    $this->db->select('sum(pay_amount) as chqsum,pay_chkid');
                    $this->db->from('mes_payment');
                    $this->db->where('pay_stetus',1);
                    $this->db->where('pay_invid', $po_id);
                    $this->db->where('pay_type', 1);
                    $hasilpaychq=$this->db->get();
                    $invhq= $hasilpaychq->result();
                    $inv['invpay'] = $invhq[0]->chqsum; 
                    $inv['pay_chkid'] = $invhq[0]->pay_chkid; 
                    
                    $this->db->select('sum(pay_amount) as cashsum');
                    $this->db->from('mes_payment');
                    $this->db->where('pay_stetus',1);
                    $this->db->where('pay_invid', $po_id);
                    $this->db->where('pay_type', 0);
                    $hasilpaych=$this->db->get();
                    $invch= $hasilpaych->result();
                    $inv['invpaych'] = $invch[0]->cashsum; 
                    
                    $this->db->select('sum(ret_amount) as trnsum');
                    $this->db->from('inv_return');
                    $this->db->where('ret_stetus',1);
                    $this->db->where('ret_invnum', $po_id);
                    $hasiltrn = $this->db->get();
                    $invtrn = $hasiltrn->result();
                    $inv['invtrnusm']= $invtrn[0]->trnsum; 
            
        return $inv;             
                    
}
    
}

?>