<?php 



class M_laporan_rekap_unit_misioner extends CI_Model{	



    



    function __construct() {



        parent::__construct();



    }



    



    function kode_user(){



        return $this->session->userdata("kode_user");



    }



    function data_pka_periode($data){



        $sql = "SELECT pka.kode_pka,pka.unit_misioner,pka.unit_misioner,um.nama nama_um 



                FROM tb_pka pka 



                INNER JOIN tb_unit_misioner um ON um.id_unit_misioner = pka.unit_misioner



                WHERE pka.periode_thn = '$data[periode_thn]' AND pka.is_deleted = 0 AND pka.acc !=2 AND um.is_deleted = 0 /*AND pka.evaluasi =1*/



                GROUP BY pka.unit_misioner



                ORDER BY um.kode ASC";



        return $this->db->query($sql);



    }

    function data_pka_periode_no_ppg($data){



        $sql = "SELECT pka.kode_pka,pka.unit_misioner,pka.unit_misioner,um.nama nama_um 



                FROM tb_pka pka 



                INNER JOIN tb_unit_misioner um ON um.id_unit_misioner = pka.unit_misioner



                WHERE pka.periode_thn = '$data[periode_thn]' AND pka.is_deleted = 0 AND pka.acc !=2 AND um.is_deleted = 0 AND pka.unit_misioner != '18'  /*AND pka.evaluasi =1*/



                GROUP BY pka.unit_misioner



                ORDER BY um.kode ASC";



        return $this->db->query($sql);



    }





    function data_pka_periode_kode_pka($data){



        $sql = "SELECT pka.kode_pka



                FROM tb_pka pka 



                WHERE pka.unit_misioner = '$data[unit_misioner]' AND periode_thn = '$data[periode_thn]' AND pka.is_deleted = 0 AND pka.acc !=2 /*AND pka.evaluasi =1*/



                ";



        return $this->db->query($sql);



    }



    function ambil_penerimaan($data){



        $sql = "SELECT penerimaan FROM tb_pka_penerimaan WHERE kode_pka = '$data[kode_pka]'



                ";



        return $this->db->query($sql);



    }



    function ambil_pengeluaran($data){



        $sql = "SELECT pengeluaran FROM tb_pka_pengeluaran WHERE kode_pka = '$data[kode_pka]'



                ";



        return $this->db->query($sql);



    }



    function ambil_triwulan($data){



        $sql = "SELECT triwulan FROM tb_pka WHERE kode_pka = '$data[kode_pka]'



                ";



        return $this->db->query($sql);



    }



}