121 lines
3.1 KiB
PHP
121 lines
3.1 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class ManageJabatan 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);
|
|
$datJabatan = $this->Dashboard->getData_Jabatan();
|
|
|
|
$no = 0;
|
|
foreach ($datJabatan as $key) {
|
|
$datKaryawan = $this->Dashboard->getData_Karyawan_byJABATAN($key['ID_JABATAN']);
|
|
if ($datKaryawan==TRUE) {
|
|
$lock = 1;
|
|
} else {
|
|
$lock = 0;
|
|
}
|
|
$datJabatan[$no++] += ['LOCK' => $lock];
|
|
}
|
|
|
|
if ($datShm[0]['JABATAN_SHM']==0) {
|
|
$akses = "Tidak Berhak";
|
|
$datJabatan = NULL;
|
|
} else if ($datShm[0]['JABATAN_SHM']==1) {
|
|
$akses = "Hanya Baca";
|
|
} else if ($datShm[0]['JABATAN_SHM']==2) {
|
|
$akses = "Akses Penuh";
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "dashboard",
|
|
'navChild' => "",
|
|
'jabatan' => $datJabatan,
|
|
'hak' => $datShm[0]['JABATAN_SHM'],
|
|
'akses' => $akses,
|
|
];
|
|
$this->load->view('master/Jabatan', $data);
|
|
}
|
|
|
|
|
|
public function simpan() {
|
|
$method = $this->input->post('method');
|
|
$id_jabatan = $this->input->post('id');
|
|
$nama_jabatan = $this->input->post('nama_jabatan');
|
|
|
|
$nama_jabatan = strtoupper($nama_jabatan);
|
|
|
|
$input = [
|
|
'NAMA_JABATAN' => $nama_jabatan
|
|
];
|
|
$action = $this->Dashboard->create('jabatan', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'ditambah');
|
|
redirect('ManageJabatan');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'ditambah');
|
|
redirect('ManageJabatan');
|
|
}
|
|
|
|
}
|
|
|
|
public function ubah() {
|
|
$method = $this->input->post('method');
|
|
$id_jabatan = $this->input->post('id_jabataned');
|
|
$nama_jabatan = $this->input->post('nama_jabataned');
|
|
|
|
$nama_jabatan = strtoupper($nama_jabatan);
|
|
|
|
$update = [
|
|
'NAMA_JABATAN' => $nama_jabatan
|
|
];
|
|
$action = $this->Dashboard->update('jabatan', $update, 'ID_JABATAN', $id_jabatan);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diubah');
|
|
redirect('ManageJabatan');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diubah');
|
|
redirect('ManageJabatan');
|
|
}
|
|
|
|
}
|
|
|
|
public function hapus() {
|
|
$id = $this->input->post('id_jabatandel');
|
|
|
|
$datKaryawan = $this->Dashboard->getData_Karyawan_byJABATAN($id);
|
|
if ($datKaryawan==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$action = $this->Dashboard->delete('jabatan', $id, 'ID_JABATAN');
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'dihapus');
|
|
redirect('ManageJabatan');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dihapus');
|
|
redirect('ManageJabatan');
|
|
}
|
|
}
|
|
|
|
}
|