copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
use Restserver\Libraries\REST_Controller;
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
require APPPATH . 'libraries/REST_Controller.php';
|
||||
require APPPATH . 'libraries/Format.php';
|
||||
|
||||
class ManageMenu extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ModelDashboard', 'Dashboard');
|
||||
$this->load->model('AllModels', 'Amod');
|
||||
$this->load->library(['datatables', 'form_validation']);
|
||||
$this->form_validation->set_error_delimiters('', '');
|
||||
$this->Dashboard->ceklogin();
|
||||
}
|
||||
public function output_json($data, $encode = true)
|
||||
{
|
||||
if ($encode) $data = json_encode($data);
|
||||
$this->output->set_content_type('application/json')->set_output($data);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$id_karyawan = $this->session->userdata('id_karyawan');
|
||||
$datMenu = $this->Dashboard->getData_Menu();
|
||||
|
||||
$no = 0;
|
||||
foreach ($datMenu as $key) {
|
||||
$datShm = $this->Dashboard->getData_SetHakMenu_byMENU($key['ID_MENU']);
|
||||
if ($datShm==TRUE) {
|
||||
$lock = 1;
|
||||
} else {
|
||||
$lock = 0;
|
||||
}
|
||||
$datMenu[$no++] += ['LOCK' => $lock];
|
||||
}
|
||||
|
||||
if ($id_karyawan==1) {
|
||||
$akses = "Akses Penuh";
|
||||
$hak = 2;
|
||||
} else {
|
||||
$akses = "Tidak Berhak";
|
||||
$hak = 0;
|
||||
$datMenu = NULL;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'sidebar' => "dashboard",
|
||||
'navChild' => "",
|
||||
'menu' => $datMenu,
|
||||
'hak' => $hak,
|
||||
'akses' => $akses,
|
||||
];
|
||||
$this->load->view('master/Menu', $data);
|
||||
}
|
||||
|
||||
public function simpan() {
|
||||
$nama_menu = $this->input->post('nama_menu');
|
||||
$kode_menu = $this->input->post('kode_menu');
|
||||
$kode_menu = strtoupper($kode_menu);
|
||||
|
||||
$datMenu = $this->Dashboard->getData_Menu_byKODE_byNAMA($kode_menu, $nama_menu);
|
||||
if ($datMenu==TRUE) {
|
||||
$this->session->set_flashdata('data_same', 'error');
|
||||
redirect('ManageMenu');
|
||||
}
|
||||
|
||||
$input = [
|
||||
'KODE_MENU' => $kode_menu,
|
||||
'NAMA_MENU' => $nama_menu
|
||||
];
|
||||
$action = $this->Dashboard->create('menu', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'ditambah');
|
||||
redirect('ManageMenu');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'ditambah');
|
||||
redirect('ManageMenu');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function ubah() {
|
||||
$id_menu = $this->input->post('id_menued');
|
||||
$nama_menu = $this->input->post('nama_menued');
|
||||
$kode_menu = $this->input->post('kode_menued');
|
||||
$kode_menu = strtoupper($kode_menu);
|
||||
|
||||
$datMenu = $this->Dashboard->getData_Menu_byKODE_byNAMA($kode_menu, $nama_menu, $id_menu);
|
||||
if ($datMenu==TRUE) {
|
||||
$this->session->set_flashdata('data_same', 'error');
|
||||
redirect('ManageMenu');
|
||||
}
|
||||
|
||||
$update = [
|
||||
'KODE_MENU' => $kode_menu,
|
||||
'NAMA_MENU' => $nama_menu
|
||||
];
|
||||
$action = $this->Dashboard->update('menu', $update, 'ID_MENU', $id_menu);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'diubah');
|
||||
redirect('ManageMenu');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'diubah');
|
||||
redirect('ManageMenu');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function hapus() {
|
||||
$id = $this->input->post('id_menudel');
|
||||
|
||||
$datMenu = $this->Dashboard->getData_SetHakMenu_byMENU($id);
|
||||
if ($datMenu==TRUE) {
|
||||
$this->session->set_flashdata('data_used', 'error');
|
||||
redirect('ManageMenu');
|
||||
}
|
||||
|
||||
$action = $this->Dashboard->delete('menu', $id, 'ID_MENU');
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'dihapus');
|
||||
redirect('ManageMenu');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'dihapus');
|
||||
redirect('ManageMenu');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user