copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class ManageJenis 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);
|
||||
$datJenis = $this->Dashboard->getData_Jenis();
|
||||
|
||||
$no = 0;
|
||||
foreach ($datJenis as $key) {
|
||||
$datBarang = $this->Dashboard->getData_Barang_byJENIS($key['ID_JENIS']);
|
||||
if ($datBarang==TRUE) {
|
||||
$lock = 1;
|
||||
} else {
|
||||
$lock = 0;
|
||||
}
|
||||
$datJenis[$no++] += ['LOCK' => $lock];
|
||||
}
|
||||
|
||||
if ($datShm[0]['JENIS_SHM']==0) {
|
||||
$akses = "Tidak Berhak";
|
||||
$datJenis = NULL;
|
||||
} else if ($datShm[0]['JENIS_SHM']==1) {
|
||||
$akses = "Hanya Baca";
|
||||
} else if ($datShm[0]['JENIS_SHM']==2) {
|
||||
$akses = "Akses Penuh";
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'sidebar' => "dashboard",
|
||||
'navChild' => "",
|
||||
'jenis' => $datJenis,
|
||||
'hak' => $datShm[0]['JENIS_SHM'],
|
||||
'akses' => $akses,
|
||||
];
|
||||
$this->load->view('master/Jenis', $data);
|
||||
}
|
||||
|
||||
public function simpan() {
|
||||
$method = $this->input->post('method');
|
||||
$id_jenis = $this->input->post('id');
|
||||
$nama_jenis = $this->input->post('nama_jenis');
|
||||
$type_jenis = $this->input->post('type_jenis');
|
||||
$tgl = date('d/m/Y H:i:s');
|
||||
|
||||
$input = [
|
||||
'NAMA_JENIS' => $nama_jenis,
|
||||
'TYPE_JENIS' => $type_jenis,
|
||||
'LAST_UPDATE' => $tgl,
|
||||
'KOMISI_DEALER' => '0',
|
||||
'KOMISI_USER' => '0',
|
||||
'BIAYA_SERVICE' => '0'
|
||||
];
|
||||
$action = $this->Dashboard->create('jenis', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'ditambah');
|
||||
redirect('ManageJenis');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'ditambah');
|
||||
redirect('ManageJenis');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function ubah() {
|
||||
$method = $this->input->post('method');
|
||||
$id_jenis = $this->input->post('id_jenised');
|
||||
$nama_jenis = $this->input->post('nama_jenised');
|
||||
$type_jenis = $this->input->post('type_jenised');
|
||||
$tgl = date('d/m/Y H:i:s');
|
||||
|
||||
if ($id_jenis<=6) {
|
||||
$this->session->set_flashdata('data_sistem', 'error');
|
||||
redirect('ManageJenis');
|
||||
}
|
||||
|
||||
$datBarang = $this->Dashboard->getData_Barang_byJENIS($id_jenis);
|
||||
if ($datBarang==TRUE) {
|
||||
$this->session->set_flashdata('data_used', 'error');
|
||||
redirect('ManageJenis');
|
||||
}
|
||||
|
||||
$update = [
|
||||
'NAMA_JENIS' => $nama_jenis,
|
||||
'TYPE_JENIS' => $type_jenis,
|
||||
'LAST_UPDATE' => $tgl,
|
||||
];
|
||||
$action = $this->Jenis->update('jenis', $update, 'ID_JENIS', $id_jenis);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'diubah');
|
||||
redirect('ManageJenis');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'diubah');
|
||||
redirect('ManageJenis');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function hapus() {
|
||||
$id = $this->input->post('id_jenisdel');
|
||||
|
||||
if ($id<=6) {
|
||||
$this->session->set_flashdata('data_sistem', 'error');
|
||||
redirect('ManageJenis');
|
||||
}
|
||||
|
||||
$datBarang = $this->Dashboard->getData_Barang_byJENIS($id);
|
||||
if ($datBarang==TRUE) {
|
||||
$this->session->set_flashdata('data_used', 'error');
|
||||
redirect('ManageJenis');
|
||||
}
|
||||
|
||||
$action = $this ->Jenis->delete('jenis', $id, 'ID_JENIS');
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'dihapus');
|
||||
redirect('ManageJenis');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'dihapus');
|
||||
redirect('ManageJenis');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user