220 lines
8.5 KiB
PHP
220 lines
8.5 KiB
PHP
<?php
|
|
//-------------ID menu = 5
|
|
|
|
class St_accesscontrol extends CI_Controller {
|
|
|
|
//-----------start variables for check action access----------//
|
|
public $vartambah = null;
|
|
public $varedit = null;
|
|
public $vardelete = null;
|
|
public $varview = null;
|
|
|
|
public $parent = 'Setting';
|
|
public $title = 'Access Control';
|
|
public $link = 'st_accesscontrol';
|
|
public $index = 'index.php/st_accesscontrol';
|
|
public $maincontent = 'setting/accesscontrol/';
|
|
public $viewcontent = 'v_accesscontrol';
|
|
public $formcontent = 'form_accesscontrol';
|
|
public $okadd = 'Anda berhasil ADD Access Control Baru';
|
|
public $okedit = 'Anda berhasil EDIT Access Control';
|
|
public $okdelete = 'Anda berhasil DELETE Access Control';
|
|
public $okdisabled = 'Anda berhasil DISABLED Access Control';
|
|
public $okactive = 'Anda berhasil ACTIVE Access Control';
|
|
public $idmenu = '4';
|
|
|
|
//-----------start variables for check action access----------//
|
|
|
|
function __construct(){
|
|
parent::__construct();
|
|
$this->check_isvalidated();
|
|
$this->load->helper(array('form', 'date'));
|
|
}
|
|
private function check_isvalidated(){
|
|
if(! $this->session->userdata('validated')){
|
|
redirect('index.php/ps_login');
|
|
}
|
|
//--------------start check access this form page-------------//
|
|
$this->db->where('am_fk_rolegroup_id', $this->session->userdata('s_IDRoleGroup'));
|
|
$this->db->where('am_fk_menu_id', $this->idmenu);
|
|
$this->db->where('am_access', 1);
|
|
$cekMenu = $this->db->get('access_menu');
|
|
$rowcount = $cekMenu->num_rows();
|
|
if($rowcount==0){
|
|
redirect('index.php');
|
|
}else{
|
|
foreach ($cekMenu->result() as $cm)
|
|
{
|
|
$this->vartambah= $cm->am_create;
|
|
$this->varedit = $cm->am_edit;
|
|
$this->vardelete= $cm->am_delete;
|
|
$this->varview = $cm->am_view;
|
|
}
|
|
}
|
|
//--------------end check access this form page-------------//
|
|
}
|
|
|
|
public function index($error = NULL) {
|
|
$data['title'] = $this->title;
|
|
$data['parent'] = $this->parent;
|
|
$data['link'] = $this->link;
|
|
$data['main_content'] = $this->maincontent.$this->viewcontent;
|
|
$data['error'] = $error;
|
|
|
|
$this->load->model('m_st_accesscontrol');
|
|
$accesscontrol = $this->m_st_accesscontrol->index();
|
|
$this->load->vars('ma', $accesscontrol);
|
|
|
|
$this->load->model('m_st_rolegroup');
|
|
$rolegroup = $this->m_st_rolegroup->rolegroupst();
|
|
$this->load->vars('mr', $rolegroup);
|
|
|
|
$this->load->view('includes/template', $data);
|
|
}
|
|
|
|
// fungsi untuk menampilkan form tambah data
|
|
public function add() {
|
|
//----start validate page tambah-------//
|
|
if($this->vartambah==null){redirect($this->index);}
|
|
//----end validate page tambah---------//
|
|
$data['titlebefore'] = $this->title;
|
|
$data['parent'] = $this->parent;
|
|
$data['title'] = 'Tambah '.$this->title;
|
|
$data['link'] = $this->link;
|
|
$data['actionform'] = 'prosesadd';
|
|
$data['main_content'] = $this->maincontent.$this->formcontent;
|
|
|
|
$this->load->view('includes/template', $data);
|
|
}
|
|
|
|
//fungsi untuk memproses penambahan dengan memanggil model
|
|
public function prosesadd() {
|
|
//----start validate page tambah-------//
|
|
if($this->vartambah==null){redirect($this->index);}
|
|
//----end validate page tambah---------//
|
|
$this->load->helper('form');
|
|
$this->load->helper('url');
|
|
$this->load->library('form_validation');
|
|
$this->form_validation->set_rules('nama','Nama Role Group','required');
|
|
|
|
if($this->form_validation->run()==FALSE){
|
|
$data['parent'] = $this->parent;
|
|
$data['titlebefore'] = $this->title;
|
|
$data['title'] = 'Tambah '.$this->title;
|
|
$data['link'] = $this->link;
|
|
$data['actionform'] = 'prosesadd';
|
|
$data['main_content'] = $this->maincontent.$this->formcontent;
|
|
|
|
$this->load->view('includes/template', $data);
|
|
}else{
|
|
$this->load->model('m_st_rolegroup');
|
|
$this->m_st_rolegroup->insert();
|
|
$this->session->set_flashdata('message', $this->okadd);
|
|
redirect($this->index);
|
|
}
|
|
}
|
|
|
|
//fungsi untuk menampilkan form edit data dengan data terpilih
|
|
public function edit($id) {
|
|
//----start validate page edit-------//
|
|
if($this->varedit==null){redirect($this->index);}
|
|
//----end validate page edit---------//
|
|
$data['parent'] = $this->parent;
|
|
$data['titlebefore'] = $this->title;
|
|
$data['title'] = 'Edit '.$this->title;
|
|
$data['link'] = $this->link;
|
|
$data['actionform'] = 'prosesedit';
|
|
$data['main_content'] = $this->maincontent.$this->formcontent;
|
|
|
|
$this->load->model('m_st_rolegroup');
|
|
$rolegroup = $this->m_st_rolegroup->edit($id);
|
|
$this->load->vars('mr', $rolegroup);
|
|
|
|
$this->load->view('includes/template', $data);
|
|
}
|
|
|
|
//funsi untuk memproses update data
|
|
public function prosesedit() {
|
|
//----start validate page edit-------//
|
|
if($this->varedit==null){redirect($this->index);}
|
|
//----end validate page edit---------//
|
|
$id = $this->input->post('id');
|
|
$this->load->helper('form');
|
|
$this->load->helper('url');
|
|
$this->load->library('form_validation');
|
|
$this->form_validation->set_rules('nama','Nama Role Group','required');
|
|
|
|
if($this->form_validation->run()==FALSE){
|
|
$data['parent'] = $this->parent;
|
|
$data['titlebefore'] = $this->title;
|
|
$data['title'] = 'Edit '.$this->title;
|
|
$data['link'] = $this->link;
|
|
$data['actionform'] = 'prosesedit';
|
|
$data['main_content'] = $this->maincontent.$this->formcontent;
|
|
|
|
$this->load->model('m_st_rolegroup');
|
|
$rolegroup = $this->m_st_rolegroup->edit($id);
|
|
$this->load->vars('mr', $rolegroup);
|
|
|
|
$this->load->view('includes/template', $data);
|
|
}
|
|
else{
|
|
$this->session->set_flashdata('message', $this->okedit);
|
|
$this->load->model('m_st_rolegroup');
|
|
$this->m_st_rolegroup->prosesedit();
|
|
redirect($this->index);
|
|
}
|
|
}
|
|
|
|
//fungsi untuk menampilkan form view data dengan data terpilih
|
|
public function view($id) {
|
|
//----start validate page view-------//
|
|
if($this->varview==null){redirect($this->index);}
|
|
//----end validate page view---------//
|
|
$data['parent'] = $this->parent;
|
|
$data['titlebefore'] = $this->title;
|
|
$data['title'] = 'View '.$this->title;
|
|
$data['link'] = $this->link;
|
|
$data['actionform'] = 'prosesview';
|
|
$data['main_content'] = $this->maincontent.$this->formcontent;
|
|
|
|
$this->load->model('m_st_rolegroup');
|
|
$rolegroup = $this->m_st_rolegroup->edit($id);
|
|
$this->load->vars('mr', $rolegroup);
|
|
|
|
$this->load->view('includes/template', $data);
|
|
}
|
|
|
|
//fungsi untuk delete
|
|
function delete($id) {
|
|
//----start validate page delete-------//
|
|
if($this->vardelete==null){redirect($this->index);}
|
|
//----end validate page delete---------//
|
|
$this->session->set_flashdata('message', $this->okdelete);
|
|
$this->load->model('m_st_rolegroup');
|
|
$this->m_st_rolegroup->delete($id);
|
|
redirect($this->index);
|
|
}
|
|
|
|
function disabled($id) {
|
|
//----start validate page delete-------//
|
|
if($this->varedit==null){redirect($this->index);}
|
|
//----end validate page delete---------//
|
|
$this->session->set_flashdata('message', $this->okdisabled);
|
|
$this->load->model('m_st_rolegroup');
|
|
$this->m_st_rolegroup->disabled($id);
|
|
redirect($this->index);
|
|
}
|
|
|
|
function active($id) {
|
|
//----start validate page delete-------//
|
|
if($this->varedit==null){redirect($this->index);}
|
|
//----end validate page delete---------//
|
|
$this->session->set_flashdata('message', $this->okactive);
|
|
$this->load->model('m_st_rolegroup');
|
|
$this->m_st_rolegroup->active($id);
|
|
redirect($this->index);
|
|
}
|
|
}
|
|
|
|
?>
|