copy dari repo om Irfan

This commit is contained in:
2026-06-13 16:02:07 +10:00
commit db327c0305
5376 changed files with 2770667 additions and 0 deletions
@@ -0,0 +1,137 @@
<?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 ManageModel 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);
$datModel = $this->Dashboard->getData_Model();
$no = 0;
foreach ($datModel as $key) {
$datBarang = $this->Dashboard->getData_Barang_byMODEL($key['ID_MODEL']);
if ($datBarang==TRUE) {
$lock = 1;
} else {
$lock = 0;
}
$datModel[$no++] += ['LOCK' => $lock];
}
if ($datShm[0]['MODEL_SHM']==0) {
$akses = "Tidak Berhak";
$datModel = NULL;
} else if ($datShm[0]['MODEL_SHM']==1) {
$akses = "Hanya Baca";
} else if ($datShm[0]['MODEL_SHM']==2) {
$akses = "Akses Penuh";
}
$data = [
'sidebar' => "dashboard",
'navChild' => "",
'model' => $datModel,
'hak' => $datShm[0]['MODEL_SHM'],
'akses' => $akses,
];
$this->load->view('master/Model', $data);
}
public function simpan() {
$method = $this->input->post('method');
$id = $this->input->post('id_model');
$nama_model = $this->input->post('nama_model');
$nama_model = strtoupper($nama_model);
$datModel = $this->Dashboard->getData_Model_byNAMA($nama_model);
if ($datModel==TRUE) {
$this->session->set_flashdata('data_same', 'error');
redirect('ManageModel');
}
$input = [
'NAMA_MODEL' => $nama_model
];
$action = $this->Dashboard->create('model', $input);
if ($action) {
$this->session->set_flashdata('success', 'ditambah');
redirect('ManageModel');
} else {
$this->session->set_flashdata('failed', 'ditambah');
redirect('ManageModel');
}
}
public function ubah() {
$method = $this->input->post('method');
$id_model = $this->input->post('id_modeled');
$nama_model = $this->input->post('nama_modeled');
$nama_model = strtoupper($nama_model);
$datModel = $this->Dashboard->getData_Model_byNAMA($nama_model, $id_model);
if ($datModel==TRUE) {
$this->session->set_flashdata('data_same', 'error');
redirect('ManageModel');
}
$update = [
'NAMA_MODEL' => $nama_model
];
$action = $this->Dashboard->update('model', $update, 'ID_MODEL', $id_model);
if ($action) {
$this->session->set_flashdata('success', 'diubah');
redirect('ManageModel');
} else {
$this->session->set_flashdata('failed', 'diubah');
redirect('ManageModel');
}
}
public function hapus() {
$method = $this->input->post('method');
$id = $this->input->post('id_modeldel');
$datModel = $this->Dashboard->getData_Barang_byMODEL($id);
if ($datModel==TRUE) {
$this->session->set_flashdata('data_used', 'error');
redirect('ManageModel');
}
$action = $this->Dashboard->delete('model', $id, 'ID_MODEL');
if ($action) {
$this->session->set_flashdata('success', 'dihapus');
redirect('ManageModel');
} else {
$this->session->set_flashdata('failed', 'dihapus');
redirect('ManageModel');
}
}
}