copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
<?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 ManagePosisi extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ModelDashboard', 'Dashboard');
|
||||
$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');
|
||||
$datShm = $this->Dashboard->getData_SetHakMaster_byKARYAWAN($id_karyawan);
|
||||
$datPosisi = $this->Dashboard->getData_Posisi();
|
||||
|
||||
$no = 0;
|
||||
foreach ($datPosisi as $key) {
|
||||
$datKontak = $this->Dashboard->getData_Kontak_byPOSISI($key['ID_POSISI']);
|
||||
if ($datKontak==TRUE) {
|
||||
$lock = 1;
|
||||
} else {
|
||||
$lock = 0;
|
||||
}
|
||||
$datPosisi[$no++] += ['LOCK' => $lock];
|
||||
}
|
||||
|
||||
if ($datShm[0]['POSISI_SHM']==0) {
|
||||
$akses = "Tidak Berhak";
|
||||
$datPosisi = NULL;
|
||||
} else if ($datShm[0]['POSISI_SHM']==1) {
|
||||
$akses = "Hanya Baca";
|
||||
} else if ($datShm[0]['POSISI_SHM']==2) {
|
||||
$akses = "Akses Penuh";
|
||||
}
|
||||
|
||||
$data = [
|
||||
'sidebar' => "dashboard",
|
||||
'navChild' => "",
|
||||
'posisi' => $datPosisi,
|
||||
'hak' => $datShm[0]['POSISI_SHM'],
|
||||
'akses' => $akses,
|
||||
];
|
||||
$this->load->view('master/Posisi', $data);
|
||||
}
|
||||
|
||||
public function simpan() {
|
||||
$method = $this->input->post('method');
|
||||
$id = $this->input->post('id_posisi');
|
||||
$nama_posisi = $this->input->post('nama_posisi');
|
||||
|
||||
$input = [
|
||||
'NAMA_POSISI' => $nama_posisi
|
||||
];
|
||||
$action = $this->Dashboard->create('posisi', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'ditambah');
|
||||
redirect('ManagePosisi');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'ditambah');
|
||||
redirect('ManagePosisi');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function ubah() {
|
||||
$method = $this->input->post('method');
|
||||
$id_posisi = $this->input->post('id_posisied');
|
||||
$nama_posisi = $this->input->post('nama_posisied');
|
||||
|
||||
$update = [
|
||||
'NAMA_POSISI' => $nama_posisi
|
||||
];
|
||||
$action = $this->Dashboard->update('posisi', $update, 'ID_POSISI', $id_posisi);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'diubah');
|
||||
redirect('ManagePosisi');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'diubah');
|
||||
redirect('ManagePosisi');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function hapus() {
|
||||
$method = $this->input->post('method');
|
||||
$id = $this->input->post('id_posisidel');
|
||||
|
||||
$datPosisi = $this->Dashboard->getData_Kontak_byPOSISI($id);
|
||||
if ($datPosisi==TRUE) {
|
||||
$this->session->set_flashdata('data_used', 'error');
|
||||
redirect('ManagePosisi');
|
||||
}
|
||||
|
||||
$action = $this->Dashboard->delete('posisi', $id, 'ID_POSISI');
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'dihapus');
|
||||
redirect('ManagePosisi');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'dihapus');
|
||||
redirect('ManagePosisi');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user