<?php
class M_st_rolegroup extends CI_Model {

    function index() {
        $this->db->order_by('mr_name', 'ASC');
        $query = $this->db->get('master_rolegroup');
        return $query->result();
    }
    
    function rolegroupst() {
        $this->db->order_by('mr_name', 'ASC');
        $this->db->where('mr_status', 1);
        $query = $this->db->get('master_rolegroup');
        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('master_rolegroup', $insert);
    }
    
    function edit($id) {
        $this->db->where('mr_id', $id);
        $query = $this->db->get('master_rolegroup');
        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('master_rolegroup', $update);
    }

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