copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
<?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 ManageKuartal 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);
|
||||
$datKuartal = $this->Dashboard->getData_Kuartal();
|
||||
$tgl = date('Y-m-d');
|
||||
|
||||
$no = 0;
|
||||
foreach ($datKuartal as $key) {
|
||||
$datMk = $this->Dashboard->getData_ManajemenKuartal_byKUARTAL($key['ID_KUARTAL']);
|
||||
if ($datMk==TRUE) {
|
||||
$lock = 1;
|
||||
} else {
|
||||
$lock = 0;
|
||||
}
|
||||
$datKuartal[$no++] += ['LOCK' => $lock];
|
||||
}
|
||||
|
||||
if ($datShm[0]['KUARTAL_SHM']==0) {
|
||||
$akses = "Tidak Berhak";
|
||||
$datKuartal = NULL;
|
||||
} else if ($datShm[0]['KUARTAL_SHM']==1) {
|
||||
$akses = "Hanya Baca";
|
||||
} else if ($datShm[0]['KUARTAL_SHM']==2) {
|
||||
$akses = "Akses Penuh";
|
||||
}
|
||||
|
||||
$data = [
|
||||
'sidebar' => "dashboard",
|
||||
'navChild' => "",
|
||||
'kuartal' => $datKuartal,
|
||||
'hak' => $datShm[0]['KUARTAL_SHM'],
|
||||
'akses' => $akses,
|
||||
'tgl' => $tgl,
|
||||
];
|
||||
|
||||
$this->load->view('master/Kuartal', $data);
|
||||
}
|
||||
|
||||
public function simpan() {
|
||||
$method = $this->input->post('method');
|
||||
$id = $this->input->post('id_kuartal');
|
||||
$nama_kuartal = $this->input->post('nama_kuartal');
|
||||
$awal_kuartal = $this->input->post('awal_kuartal');
|
||||
$akhir_kuartal = $this->input->post('akhir_kuartal');
|
||||
|
||||
$input = [
|
||||
'NAMA_KUARTAL' => $nama_kuartal,
|
||||
'AWAL_KUARTAL' => $awal_kuartal,
|
||||
'AKHIR_KUARTAL' => $akhir_kuartal
|
||||
];
|
||||
$action = $this->Dashboard->create('kuartal', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'ditambah');
|
||||
redirect('ManageKuartal');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'ditambah');
|
||||
redirect('ManageKuartal');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function ubah() {
|
||||
$method = $this->input->post('method');
|
||||
$id_kuartal = $this->input->post('id_kuartaled');
|
||||
$nama_kuartal = $this->input->post('nama_kuartaled');
|
||||
$awal_kuartal = $this->input->post('awal_kuartaled');
|
||||
$akhir_kuartal = $this->input->post('akhir_kuartaled');
|
||||
|
||||
$update = [
|
||||
'NAMA_KUARTAL' => $nama_kuartal,
|
||||
'AWAL_KUARTAL' => $awal_kuartal,
|
||||
'AKHIR_KUARTAL' => $akhir_kuartal
|
||||
];
|
||||
$action = $this->Dashboard->update('kuartal', $update, 'ID_KUARTAL', $id_kuartal);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'diubah');
|
||||
redirect('ManageKuartal');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'diubah');
|
||||
redirect('ManageKuartal');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function hapus() {
|
||||
$method = $this->input->post('method');
|
||||
$id = $this->input->post('id_kuartaldel');
|
||||
|
||||
$datMk = $this->Dashboard->getData_ManajemenKuartal_byKUARTAL($id);
|
||||
if ($datMk==TRUE) {
|
||||
$this->session->set_flashdata('data_used', 'error');
|
||||
redirect('ManageKuartal');
|
||||
}
|
||||
|
||||
$action = $this->Dashboard->delete('kuartal', $id, 'ID_KUARTAL');
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'dihapus');
|
||||
redirect('ManageKuartal');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'dihapus');
|
||||
redirect('ManageKuartal');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user