139 lines
4.0 KiB
PHP
139 lines
4.0 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class ManageUnitService 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);
|
|
$datUnitService = $this->Dashboard->getData_UnitService();
|
|
$datJenis = $this->Dashboard->getData_Jenis_BIAYANot0();
|
|
|
|
$no = 0;
|
|
foreach ($datUnitService as $key) {
|
|
$datSns = $this->Dashboard->getData_SnService_byUNITSERVICE($key['ID_UNITSERVICE']);
|
|
if ($datSns==TRUE) {
|
|
$lock = 1;
|
|
} else {
|
|
$lock = 0;
|
|
}
|
|
$datUnitService[$no++] += ['LOCK' => $lock];
|
|
}
|
|
|
|
if ($datShm[0]['UNITSERVICE_SHM']==0) {
|
|
$akses = "Tidak Berhak";
|
|
$datUnitService = NULL;
|
|
} else if ($datShm[0]['UNITSERVICE_SHM']==1) {
|
|
$akses = "Hanya Baca";
|
|
} else if ($datShm[0]['UNITSERVICE_SHM']==2) {
|
|
$akses = "Akses Penuh";
|
|
}
|
|
|
|
$data = [
|
|
'sidebar' => "dashboard",
|
|
'navChild' => "",
|
|
'unitservice' => $datUnitService,
|
|
'jenis' => $datJenis,
|
|
'hak' => $datShm[0]['UNITSERVICE_SHM'],
|
|
'akses' => $akses,
|
|
];
|
|
$this->load->view('master/UnitService', $data);
|
|
}
|
|
|
|
public function simpan() {
|
|
$method = $this->input->post('method');
|
|
$id_unitservice = $this->input->post('id');
|
|
$id_jenis = $this->input->post('id_jenis');
|
|
$nama_unitservice = $this->input->post('nama_unitservice');
|
|
|
|
$nama_unitservice = strtoupper($nama_unitservice);
|
|
|
|
$datUnitService = $this->Dashboard->getData_UnitService_byNAMA($nama_unitservice);
|
|
if ($datUnitService==TRUE) {
|
|
$this->session->set_flashdata('data_same', 'error');
|
|
redirect('ManageUnitService');
|
|
}
|
|
|
|
$input = [
|
|
'NAMA_UNITSERVICE' => $nama_unitservice,
|
|
'JENIS_ID' => $id_jenis
|
|
];
|
|
$action = $this->Dashboard->create('unitservice', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'ditambah');
|
|
redirect('ManageUnitService');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'ditambah');
|
|
redirect('ManageUnitService');
|
|
}
|
|
|
|
}
|
|
|
|
public function ubah() {
|
|
$method = $this->input->post('method');
|
|
$id_unitservice = $this->input->post('id_unitserviceed');
|
|
$id_jenis = $this->input->post('id_jenised');
|
|
$nama_unitservice = $this->input->post('nama_unitserviceed');
|
|
|
|
$nama_unitservice = strtoupper($nama_unitservice);
|
|
|
|
$datUnitService = $this->Dashboard->getData_UnitService_byNAMA($nama_unitservice, $id_unitservice);
|
|
if ($datUnitService==TRUE) {
|
|
$this->session->set_flashdata('data_same', 'error');
|
|
redirect('ManageUnitService');
|
|
}
|
|
|
|
$update = [
|
|
'NAMA_UNITSERVICE' => $nama_unitservice,
|
|
'JENIS_ID' => $id_jenis
|
|
];
|
|
$action = $this->Dashboard->update('unitservice', $update, 'ID_UNITSERVICE', $id_unitservice);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'diubah');
|
|
redirect('ManageUnitService');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'diubah');
|
|
redirect('ManageUnitService');
|
|
}
|
|
|
|
}
|
|
|
|
public function hapus() {
|
|
$id_unitservice = $this->input->post('id_unitservicedel');
|
|
|
|
$datUnitService = $this->Dashboard->getData_SnService_byUNITSERVICE($id_unitservice);
|
|
if ($datUnitService==TRUE) {
|
|
$this->session->set_flashdata('data_used', 'error');
|
|
redirect('ManageUnitService');
|
|
}
|
|
|
|
$action = $this ->Dashboard->delete('unitservice', $id_unitservice, 'ID_UNITSERVICE');
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'dihapus');
|
|
redirect('ManageUnitService');
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dihapus');
|
|
redirect('ManageUnitService');
|
|
}
|
|
|
|
}
|
|
|
|
}
|