| 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 : /wamp/www/sipapbd_2019/application/modules/lokasi/controllers/ |
Upload File : |
<?php
class Lokasi extends Userpage_Controller {
public function __construct()
{
parent::__construct();
$this->modul_name = 'lokasi';
$this->modul_display = 'Lokasi';
$this->view_daftar = 'lokasi_view';
$this->report_daftar = 'Daftar Lokasi';
$this->load->model('lokasi_model', 'data_model');
}
public function index()
{
$this->daftar();
}
public function daftar()
{
$this->load->model('auth/login_model', 'auth');
$data['main_content'] = 'lokasi_view';
$data['modul'] = 'lokasi';
$data['report_daftar'] = $this->report_daftar;
$data['breadcrumbs'] = 'Daftar '.$this->modul_display;
$data['akses'] = $this->auth->get_level_akses($this->uri->slash_segment(1));
$data['grid']['fields'] = $this->data_model->get_data_fields();
$this->load->view('layout/template', $data);
}
function get_daftar()
{
parent::get_daftar();
$count = $this->data_model->get_data($this->search_param, TRUE);
$response = (object) NULL;
$response->sql = $this->db->queries;
if($count == 0) // tidak ada data
{
echo json_encode($response);
return '';
}
$page = $this->page;
$limit = $this->limit;
$total_pages = ceil($count/$limit);
if ($page > $total_pages) $page = $total_pages;
$start = $limit * $page - $limit;
if($start < 0) $start = 0;
$this->search_param['limit'] = array(
'start' => $start,
'end' => $limit
);
$result = $this->data_model->get_data($this->search_param);
$response->page = $page;
$response->total = $total_pages;
$response->records = $count;
$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);
}
protected function validasi_form()
{
$this->form_validation->set_rules('lokasi', 'Lokasi', 'trim|required|callback__cek_duplikasi');
$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', 'lokasi sudah ada.');
}
public function _cek_duplikasi()
{
return $this->data_model->check_duplikasi_lokasi();
}
}