[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
BACKUP C 19-12
/
XAMPP74
/
htdocs
/
simaku-aset
/
application
/
controllers
/
master
/
[
Home
]
File: Items.php
<?php defined('BASEPATH') or exit('No direct script access allowed'); class Items extends CI_Controller { function __construct() { parent::__construct(); if ($this->session->userdata('wewenang') != "admin") { redirect('login'); } $this->load->model('M_crud', 'model', TRUE); $this->load->model('M_master', 'model_master', TRUE); $this->model->set('tbl_items', 'id'); } public function index() { $q = $this->Minfo->info()->row(); $data['namapt'] = !empty($q->namapt) ? $q->namapt : $this->config->item('nameAPP'); $data['title'] = 'Item/Barang'; $data['menu_master'] = 'in'; $data['logo'] = !empty($q->logo) ? $q->logo : ''; $data['nama_feild'] = 'item_name'; $data['view'] = 'admin/master/index'; $data['js'] = 'admin/master/item_js'; $this->load->view('admin/beranda', $data); } public function show() { header('Content-Type: application/json; charset=utf-8'); $get = $this->model_master->read_items_category(); $data = $get->result_array(); echo json_encode([ 'status' => 200, 'data' => $data, 'total' => $get->num_rows() ]); } public function store() { header('Content-Type: application/json; charset=utf-8'); try { $data = [ "item_code" => "AST00" . $this->model_master->read_items_category()->num_rows() + 1, "item_name" => $this->input->post("item_name"), "item_note" => $this->input->post("item_note"), "umur_aset" => $this->input->post("umur_aset"), "kategori_id" => $this->input->post("kategori_id"), "created_by" => $this->session->userdata('username'), "item_status" => 1, ]; $get = $this->model->create($data); echo json_encode([ 'status' => 200, 'message' => 'Items add.', 'data' => $get, 'total' => 0 ]); } catch (ValidatorException $e) { echo json_encode([ 'status' => 304, 'data' => $e->getMessage(), ]); } } public function update() { try { $id = $this->input->post("id"); $data = [ "item_name" => $this->input->post("item_name"), "item_note" => $this->input->post("item_note"), "umur_aset" => $this->input->post("umur_aset"), "kategori_id" => $this->input->post("kategori_id"), "updated_by" => $this->session->userdata('username'), ]; $get = $this->model->update($data, $id); echo json_encode([ 'status' => 200, 'message' => 'Items update.', 'data' => $get, ]); } catch (ValidatorException $e) { echo json_encode([ 'status' => 304, 'message' => $e->getMessage(), ]); } } public function destroy() { try { $id = $this->input->post("id"); $get = $this->model->delete($id); if ($get) { echo json_encode([ 'status' => 200, 'message' => 'Items deleted.', 'deleted' => $get, ]); } } catch (Exception $e) { return response(['status' => 304, 'message' => $e->getMessage()]); } } public function drowdownItems() { $get = $this->model->read(); $data = $get->result_array(); echo json_encode($data); } public function drowdownKategori() { $get = $this->model_master->read_all_kategori_aset(); $data = $get->result_array(); echo json_encode($data); } }