<?php 


class M_request_revisi_pka extends CI_Model{	


    


    function __construct() {


        parent::__construct();


    }


    


    function kode_user(){


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


    }


    function data_pka(){


        $kode_user = $this->kode_user();


    }


    function data_request_revisi_pka(){


        $sql = "SELECT rr.*,u.username,um.nama nama_um,pka.periode_thn FROM tb_req_revisi rr 


                LEFT JOIN tb_user u ON rr.created_by = u.kode_user


                LEFT JOIN tb_unit_misioner um ON u.unit_misioner = um.id_unit_misioner


                LEFT JOIN tb_pka pka ON rr.no_pka = pka.no_pka


                WHERE rr.is_deleted =0


                ORDER BY rr.created_at DESC


        ";


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


    }


    function terima_revisi($data){


        $sql = "UPDATE `tb_req_revisi` 


                SET status = '1' 


                WHERE id_req_rev = '$data[id_req_rev]'


        ";


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


    }


    function update_status_pka($data){


        $sql = "UPDATE `tb_pka` 


                SET acc = '2' 


                WHERE no_pka = '$data[no_pka]'


        ";


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


    }


    function tolak_revisi($data){


        $sql = "UPDATE `tb_req_revisi` 


                SET status = '2' 


                WHERE id_req_rev = '$data[id_req_rev]'


        ";


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


    }











}