<?php 



class M_prioritas_kegiatan extends CI_Model{	



    



    function __construct() {



        parent::__construct();



    }



    



    function kode_user(){



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



    }



    function data_prioritas_kegiatan(){



        $sql = "SELECT * FROM tb_prioritas_kegiatan WHERE is_deleted = 0 ";



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



    }



    function simpan_prioritas_kegiatan($data){



        $kode_user = $this->kode_user();



        $sql = "INSERT INTO `tb_prioritas_kegiatan`  (`nama`, `keterangan`, `created_at`, `created_by`) 



                VALUES                          ('$data[nama]','$data[keterangan]',NOW(),'$kode_user')";



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



    }



    function ambil_prioritas_kegiatan($data){



        $sql = "SELECT * FROM tb_prioritas_kegiatan WHERE id_prioritas_kegiatan = '$data[id_prioritas_kegiatan]'";



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



    }



    function update_prioritas_kegiatan($data){



        $kode_user = $this->kode_user();



        $sql = "UPDATE `tb_prioritas_kegiatan` SET `nama`='$data[nama]',`keterangan`='$data[keterangan]',`updated_at`=NOW(),`updated_by`='$kode_user' WHERE id_prioritas_kegiatan = '$data[id_prioritas_kegiatan]'";



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



    }



    function hapus_prioritas_kegiatan($data){



        $sql = "UPDATE `tb_prioritas_kegiatan` SET `is_deleted`='1' WHERE id_prioritas_kegiatan = '$data[id_prioritas_kegiatan]'";



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



    }



}