[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
xampp
/
htdocs
/
simaku-aset
/
application
/
controllers
/
master
/
[
Home
]
File: Rooms.php
<?php defined('BASEPATH') or exit('No direct script access allowed'); class Rooms extends CI_Controller { function __construct() { parent::__construct(); if ($this->session->userdata('wewenang') != "admin") { redirect('login'); } $this->load->model('Minfo', '', TRUE); $this->load->model('M_crud', 'model', TRUE); $this->load->model('M_master', 'model_master', TRUE); $this->model->set('tbl_rooms', 'id'); } public function index() { $q = $this->Minfo->info()->row(); $data['namapt'] = !empty($q->namapt) ? $q->namapt : $this->config->item('nameAPP'); $data['title'] = 'Ruang'; $data['nama_feild'] = 'room'; $data['menu_master'] = 'in'; $data['logo'] = !empty($q->logo) ? $q->logo : 'logo'; $data['view'] = 'admin/master/index'; $data['js'] = 'admin/master/rooms_js'; $this->load->view('admin/beranda', $data); } public function show() { header('Content-Type: application/json; charset=utf-8'); // $get = $this->model_master->read_all_rooms_view_aset(); $get = $this->model_master->read_rooms(); $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 = [ "building_id" => $this->input->post("building_id"), "room_note" => $this->input->post("room_note"), "floor" => $this->input->post("floor"), "room" => $this->input->post("room"), "room_code" => $this->input->post("room_code"), "room_status" => 1, ]; $get = $this->model->create($data); echo json_encode([ 'status' => 200, 'message' => 'Data 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 = [ "building_id" => $this->input->post("building_id"), "room_note" => $this->input->post("room_note"), "floor" => $this->input->post("floor"), "room" => $this->input->post("room"), "room_code" => $this->input->post("room_code"), "room" => $this->input->post("room"), ]; $get = $this->model->update($data, $id); echo json_encode([ 'status' => 200, 'message' => 'Data 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' => 'Data deleted.', 'deleted' => $get, ]); } } catch (Exception $e) { return response(['status' => 304, 'message' => $e->getMessage()]); } } public function drowdownBuilding() { $get = $this->model_master->read_all_building(); $data = $get->result_array(); echo json_encode($data); } }