<?php
class M_st_rolegroup extends CI_Model {

    function index() {
        $this->db->join('master_menu', 'mm_id = mu_tipeuser_id', 'LEFT');
        $this->db->order_by('mr_name', 'ASC');
        $query = $this->db->get('access_menu');
        return $query->result();
    }
    
    function insert() {
        $setstatus = 0;
        if($this->input->post('status')==1){
            $setstatus = 1;
        }
        $insert = array(
            'mr_name'       => $this->input->post('nama'),
            'mr_status'     => $setstatus,
        );
        $insert = $this->db->insert('access_menu', $insert);
    }
    
    function edit($id) {
        $this->db->where('mr_id', $id);
        $query = $this->db->get('access_menu');
        return $query;
    }
    
    function prosesedit() {
        $setstatus = 0;
        if($this->input->post('status')==1){
            $setstatus = 1;
        }
        $update = array(
            'mr_name'       => $this->input->post('nama'),
            'mr_status'     => $setstatus,
        );
        $id = $this->input->post('id');
        $this->db->where('mr_id', $id);
        $this->db->update('access_menu', $update);
    }

    function delete($id) {
        $this->db->where('mr_id', $id);
        $this->db->delete('access_menu');
    }
    
    function disabled($id) {
        $update = array(
            'mr_status'     => 0,
        );
        $this->db->where('mr_id', $id);
        $this->db->update('access_menu', $update);
    }
    
    function active($id) {
        $update = array(
            'mr_status'     => 1,
        );
        $this->db->where('mr_id', $id);
        $this->db->update('access_menu', $update);
    }
}
?>