copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class ManageServiceCenter 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);
|
||||
$datServiceCenter = $this->Dashboard->getData_ServiceCenter();
|
||||
|
||||
$no = 0;
|
||||
foreach ($datServiceCenter as $key) {
|
||||
$datKsv = $this->Dashboard->getData_KlaimService_bySERVICECENTER($key['ID_SERVICECENTER']);
|
||||
if ($datKsv==TRUE) {
|
||||
$lock = 1;
|
||||
} else {
|
||||
$lock = 0;
|
||||
}
|
||||
$datServiceCenter[$no++] += ['LOCK' => $lock];
|
||||
}
|
||||
|
||||
if ($datShm[0]['SERVICECENTER_SHM']==0) {
|
||||
$akses = "Tidak Berhak";
|
||||
$datServiceCenter = NULL;
|
||||
} else if ($datShm[0]['SERVICECENTER_SHM']==1) {
|
||||
$akses = "Hanya Baca";
|
||||
} else if ($datShm[0]['SERVICECENTER_SHM']==2) {
|
||||
$akses = "Akses Penuh";
|
||||
}
|
||||
|
||||
$data = [
|
||||
'sidebar' => "dashboard",
|
||||
'navChild' => "",
|
||||
'servicecenter' => $datServiceCenter,
|
||||
'hak' => $datShm[0]['SERVICECENTER_SHM'],
|
||||
'akses' => $akses,
|
||||
];
|
||||
$this->load->view('master/ServiceCenter', $data);
|
||||
}
|
||||
|
||||
public function simpan() {
|
||||
$method = $this->input->post('method');
|
||||
$id_servicecenter = $this->input->post('id');
|
||||
$nama_servicecenter = $this->input->post('nama_servicecenter');
|
||||
$alamat_servicecenter = $this->input->post('alamat_servicecenter');
|
||||
|
||||
$nama_servicecenter = strtoupper($nama_servicecenter);
|
||||
$alamat_servicecenter = preg_replace('/\R+/', " " , $alamat_servicecenter);
|
||||
|
||||
$datServiceCenter = $this->Dashboard->getData_ServiceCenter_byNAMA($nama_servicecenter);
|
||||
if ($datServiceCenter==TRUE) {
|
||||
$this->session->set_flashdata('data_same', 'error');
|
||||
redirect('ManageServiceCenter');
|
||||
}
|
||||
|
||||
$input = [
|
||||
'NAMA_SERVICECENTER' => $nama_servicecenter,
|
||||
'ALAMAT_SERVICECENTER' => $alamat_servicecenter
|
||||
];
|
||||
$action = $this->Dashboard->create('servicecenter', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'ditambah');
|
||||
redirect('ManageServiceCenter');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'ditambah');
|
||||
redirect('ManageServiceCenter');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function ubah() {
|
||||
$method = $this->input->post('method');
|
||||
$id_servicecenter = $this->input->post('id_servicecentered');
|
||||
$nama_servicecenter = $this->input->post('nama_servicecentered');
|
||||
$alamat_servicecenter = $this->input->post('alamat_servicecentered');
|
||||
|
||||
$nama_servicecenter = strtoupper($nama_servicecenter);
|
||||
$alamat_servicecenter = preg_replace('/\R+/', " " , $alamat_servicecenter);
|
||||
|
||||
$datServiceCenter = $this->Dashboard->getData_ServiceCenter_byNAMA($nama_servicecenter, $id_servicecenter);
|
||||
if ($datServiceCenter==TRUE) {
|
||||
$this->session->set_flashdata('data_same', 'error');
|
||||
redirect('ManageServiceCenter');
|
||||
}
|
||||
|
||||
$update = [
|
||||
'NAMA_SERVICECENTER' => $nama_servicecenter,
|
||||
'ALAMAT_SERVICECENTER' => $alamat_servicecenter
|
||||
];
|
||||
$action = $this->Dashboard->update('servicecenter', $update, 'ID_SERVICECENTER', $id_servicecenter);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'diubah');
|
||||
redirect('ManageServiceCenter');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'diubah');
|
||||
redirect('ManageServiceCenter');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function hapus() {
|
||||
$id_servicecenter = $this->input->post('id_servicecenterdel');
|
||||
|
||||
$datKlaimService = $this->Dashboard->getData_KlaimService_bySERVICECENTER($id_servicecenter);
|
||||
if ($datKlaimService==TRUE) {
|
||||
$this->session->set_flashdata('data_used', 'error');
|
||||
redirect('ManageServiceCenter');
|
||||
}
|
||||
|
||||
$action = $this ->Dashboard->delete('servicecenter', $id_servicecenter, 'ID_SERVICECENTER');
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'dihapus');
|
||||
redirect('ManageServiceCenter');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'dihapus');
|
||||
redirect('ManageServiceCenter');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user