| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/wamp/www/simbada_2018/application/modules/ruangan/controllers/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Ruangan extends Userpage_Controller {
public function __construct()
{
parent::__construct();
$this->modul_name = 'ruangan';
$this->modul_display = 'Ruangan';
$this->view_daftar = 'ruangan_view';
$this->report_daftar = 'Daftar Ruangan';
$this->load->model('ruangan_model', 'data_model');
$this->message_aktivitas_dihapus = 'Data berhasil dihapus';
$this->message_aktivitas_gagal_dihapus = 'Data gagal dihapus';
}
public function index()
{
$this->daftar();
}
public function daftar()
{
$this->load->model('auth/login_model', 'auth');
$data['breadcrumbs'] = 'Daftar '.$this->modul_display;
$data['modul'] = $this->modul_name;
$data['report_daftar'] = $this->report_daftar;
$data['akses'] = $this->auth->get_level_akses($this->uri->slash_segment(1));
$data['grid']['fields'] = $this->data_model->get_data_fields();
$data['main_content'] = $this->view_daftar;
$this->load->view('layout/template', $data);
}
protected function validasi_form()
{
$this->form_validation->set_rules('kd_lokasi', 'Kode Lokasi', 'trim|required|max_length[50]|callback__cek_duplikasi');
$this->form_validation->set_rules('nm_lokasi', 'Nama Lokasi', 'trim|required|max_length[300]');
$this->form_validation->set_rules('alamat', 'Alamat', 'trim|required|max_length[500]');
$this->form_validation->set_rules('id_skpd', 'SKPD', 'trim|required');
$this->form_validation->set_message('required', '%s tidak boleh kosong.');
$this->form_validation->set_message('max_length', '%s tidak boleh melebihi %s karakter.');
$this->form_validation->set_message('_cek_duplikasi', 'Kode sudah ada.');
$this->form_validation->set_message('_cek_edit_data', 'Fungsi tidak bisa diubah, karena sudah digunakan di modul lain.');
}
public function _cek_duplikasi()
{
return $this->data_model->check_duplikasi();
}
public function get_daftar()
{
parent::get_daftar();
$result = $this->data_model->get_data($this->search_param);
$response = (object) NULL;
$response->sql = $this->db->queries;
$fields = $this->data_model->fieldmap_daftar;
for($i=0; $i<count($result); $i++)
{
$response->rows[$i]['id'] = $result[$i][$fields[0]];
$data = array();
for ($n=1; $n < count($fields); $n++)
{
$data[] = $result[$i][$fields[$n]];
}
$response->rows[$i]['cell'] = $data;
}
echo json_encode($response);
}
function get_skpd()
{
$q = $this->input->post('q');
$req_param = array('q' => $q);
$result = $this->data_model->get_skpd($req_param);
$response = (object) NULL;
$response->results = array();
if ($result){
for($i=0; $i<count($result); $i++){
$response->results[] = array(
'id' => $result[$i]['ID_SKPD'],
'text' => $result[$i]['NAMA_SKPD']
);
}
}
$response->sql = $this->db->queries;
echo json_encode($response);
}
protected function validasi_ruangan()
{
$this->form_validation->set_rules('kode', 'Kode Ruangan', 'required|trim|max_length[50]');
$this->form_validation->set_rules('nama', 'Nama Ruangan', 'required|trim|max_length[100]');
$this->form_validation->set_message('required', '%s tidak boleh kosong.');
$this->form_validation->set_message('max_length', '%s tidak boleh lebih dari %s');
}
public function proses_ruangan()
{
$response = (object) NULL;
$this->load->model('auth/login_model', 'auth');
$akses = $this->auth->get_level_akses($this->uri->slash_segment(1));
if($akses == '3')
{
$this->load->library('form_validation');
$this->validasi_ruangan();
if($this->form_validation->run() == TRUE)
{
$this->data_model->fill_data_ruangan();
$success = $this->data_model->save_data_ruangan();
if($success){
$response->isSuccess = TRUE;
$response->message = 'Data Ruangan berhasil disimpan';
$response->id = $this->data_model->id;
$response->sql = $this->db->queries;
}
else
{
$response->isSuccess = FALSE;
$response->message = 'Data Ruangan gagal disimpan';
$response->sql = $this->db->queries;
}
}
else
{
$response->isSuccess = FALSE;
$response->message = validation_errors();
}
}
else
{
$response->isSuccess = FALSE;
$response->message = 'Proses Gagal, Anda tidak memiliki hak akses';
}
echo json_encode($response);
}
public function get_ruangan($id = 0)
{
$page = $this->input->post('page') ? $this->input->post('page') : 0; // get the requested page
$limit = $this->input->post('rows') ? $this->input->post('rows') : 0; // get how many rows we want to have into the grid
$sidx = $this->input->post('sidx') ? $this->input->post('sidx') : 0; // get index row - i.e. user click to sort
$sord = $this->input->post('sord') ? $this->input->post('sord') : ''; // get the direction if(!$sidx) $sidx =1;
$req_param = array (
'id_lokasi' => $id,
"sort_by" => $sidx,
"sort_direction" => $sord,
);
$count = $this->data_model->get_data_ruangan($req_param, TRUE);
$response = (object) NULL;
$response->sql = $this->db->queries;
if($count == 0) // tidak ada data
{
echo json_encode($response);
return '';
}
$total_pages = ceil($count/$limit);
if ($page > $total_pages) $page = $total_pages;
$start = $limit * $page - $limit;
if($start < 0) $start = 0;
$req_param['limit'] = array(
'start' => $start,
'end' => $limit,
);
$result = $this->data_model->get_data_ruangan($req_param);
$response = (object) NULL;
$response->sql = $this->db->queries;
$response->page = $page;
$response->total = $total_pages;
$response->records = $count;
$response->sql = $this->db->queries;
$fields = $this->data_model->fields_ruangan;
for($i=0; $i<count($result); $i++)
{
$data = array();
for ($n=0; $n < count($fields); $n++)
{
$data[] = $result[$i][$fields[$n]];
}
$response->rows[$i]['id'] = $result[$i]['ID_RUANGAN'];
$response->rows[$i]['cell'] = $data;
}
echo json_encode($response);
}
public function hapus_ruangan()
{
$response = (object) NULL;
$this->load->model('auth/login_model', 'auth');
$akses = $this->auth->get_level_akses($this->uri->slash_segment(1));
if($akses !== 3)
{
$response->isSuccess = FALSE;
$response->message = 'Anda tidak memiliki Hak akses.';
echo json_encode($response);
return;
}
$id = $this->input->post('id');
$this->data_model->delete_data_ruangan($id);
$response->isSuccess = TRUE;
$response->message = 'Data ruangan telah dihapus';
echo json_encode($response);
}
}