Files
shopee-apps/application/controllers/notused/ManageProgram.php
T
2026-06-13 16:02:07 +10:00

142 lines
3.8 KiB
PHP

<?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 ManageProgram 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);
$datProgram = $this->Dashboard->getData_Program();
$no = 0;
foreach ($datProgram as $key) {
$datLkpr = $this->Dashboard->getData_LinkKlaimProgram_byPROGRAM($key['ID_PROGRAM']);
if ($datLkpr==TRUE) {
$lock = 1;
} else {
$lock = 0;
}
$datProgram[$no++] += ['LOCK' => $lock];
}
if ($datShm[0]['PROGRAM_SHM']==0) {
$akses = "Tidak Berhak";
$datProgram = NULL;
} else if ($datShm[0]['PROGRAM_SHM']==1) {
$akses = "Hanya Baca";
} else if ($datShm[0]['PROGRAM_SHM']==2) {
$akses = "Akses Penuh";
}
$data = [
'sidebar' => "dashboard",
'navChild' => "",
'program' => $datProgram,
'hak' => $datShm[0]['PROGRAM_SHM'],
'akses' => $akses,
];
$this->load->view('master/Program', $data);
}
public function simpan() {
$method = $this->input->post('method');
$id = $this->input->post('id_program');
$kode_program = $this->input->post('kode_program');
$nama_program = $this->input->post('nama_program');
$datProgram = $this->Dashboard->getData_Program_byNAMA($nama_program);
if ($datProgram==TRUE) {
$this->session->set_flashdata('data_same', 'error');
redirect('ManageProgram');
}
$kode_program = strtoupper($kode_program);
$input = [
'KODE_PROGRAM' => $kode_program,
'NAMA_PROGRAM' => $nama_program,
];
$action = $this->Dashboard->create('program', $input);
if ($action) {
$this->session->set_flashdata('success', 'ditambah');
redirect('ManageProgram');
} else {
$this->session->set_flashdata('failed', 'ditambah');
redirect('ManageProgram');
}
}
public function ubah() {
$method = $this->input->post('method');
$id_program = $this->input->post('id_programed');
$kode_program = $this->input->post('kode_programed');
$nama_program = $this->input->post('nama_programed');
$datProgram = $this->Dashboard->getData_Program_byNAMA($nama_program, $id_program);
if ($datProgram==TRUE) {
$this->session->set_flashdata('data_same', 'error');
redirect('ManageProgram');
}
$kode_program = strtoupper($kode_program);
$update = [
'KODE_PROGRAM' => $kode_program,
'NAMA_PROGRAM' => $nama_program,
];
$action = $this->Dashboard->update('program', $update, 'ID_PROGRAM', $id_program);
if ($action) {
$this->session->set_flashdata('success', 'diubah');
redirect('ManageProgram');
} else {
$this->session->set_flashdata('failed', 'diubah');
redirect('ManageProgram');
}
}
public function hapus() {
$method = $this->input->post('method');
$id = $this->input->post('id_programdel');
$datLkpr = $this->Dashboard->getData_LinkKlaimProgram_byPROGRAM($id);
if ($datLkpr==TRUE) {
$this->session->set_flashdata('data_used', 'error');
redirect('ManageProgram');
}
$action = $this->Dashboard->delete('program', $id, 'ID_PROGRAM');
if ($action) {
$this->session->set_flashdata('success', 'dihapus');
redirect('ManageProgram');
} else {
$this->session->set_flashdata('failed', 'dihapus');
redirect('ManageProgram');
}
}
}