<?php 



class M_jenis_kegiatan extends CI_Model{	



    



    function __construct() {



        parent::__construct();



    }



    



    function kode_user(){



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



    }



    



    function data_jenis_kegiatan(){



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



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



    }



    function simpan_jenis_kegiatan($data){



        $kode_user = $this->kode_user();



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



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



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



    }



    function ambil_jenis_kegiatan($data){



        $sql = "SELECT * FROM tb_jenis_kegiatan WHERE id_jenis_kegiatan = '$data[id_jenis_kegiatan]'";



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



    }



    function update_jenis_kegiatan($data){



        $kode_user = $this->kode_user();



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



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



    }



    function hapus_jenis_kegiatan($data){



        $sql = "UPDATE `tb_jenis_kegiatan` SET `is_deleted`='1' WHERE id_jenis_kegiatan = '$data[id_jenis_kegiatan]'";



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



    }



}