| 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/simbada_2018/application/modules/lokasi/models/ |
Upload File : |
<?php
class Lokasi_model extends Base_Model {
var $fieldmap_daftar;
var $fieldmap_filter;
var $fieldmap_lokasi;
var $data_lokasi;
function __construct()
{
parent::__construct();
$this->fieldmap_daftar = array(
'ID_KODE_LOKASI',
'KODE_LOKASI',
'NAMA_LOKASI',
'ALAMAT',
'ID_SKPD',
'NAMA_SKPD',
);
$this->fieldmap_filter = array(
'kd_lokasi' => 'k.KODE_LOKASI',
'nm_lokasi' => 'k.NAMA_LOKASI',
'alamat' => 'k.ALAMAT',
'nm_skpd' => 's.NAMA_SKPD'
);
$this->fieldmap_lokasi = array(
'id' => 'ID_KODE_LOKASI',
'kd_lokasi' => 'KODE_LOKASI',
'nm_lokasi' => 'NAMA_LOKASI',
'alamat' => 'ALAMAT',
'id_skpd' => 'ID_SKPD'
);
}
function fill_data()
{
foreach($this->fieldmap_lokasi as $key => $value){
switch ($key){
default : $$key = $this->input->post($key) ? $this->input->post($key) : NULL;
}
if(isset($$key))
$this->data_lokasi[$value] = $$key;
}
}
// ----- search advance ---- >>
function get_data_fields()
{
$fields = array(
'kd_lokasi' => array('name' => 'Kode Lokasi', 'kategori'=>'string'),
'nm_lokasi' => array('name' => 'Nama Lokasi', 'kategori'=>'string'),
'alamat' => array('name' => 'Alamat', 'kategori'=>'string'),
'nm_skpd' => array('name' => 'SKPD', 'kategori'=>'string')
);
return $fields;
}
function insert_lokasi()
{
$id = $this->data_lokasi['ID_KODE_LOKASI'];
$this->db->select('1')->from('KODE_LOKASI')->where('ID_KODE_LOKASI', $id);
$rs = $this->db->get()->row_array();
if ($rs)
{
$this->db->where('ID_KODE_LOKASI', $id);
$this->db->update('KODE_LOKASI', $this->data_lokasi);
$this->check_trans_status('UPDATE LOKASI FAILED');
}
else
{
$id = $this->get_id('g_id_kode_lokasi');
$this->data_lokasi['ID_KODE_LOKASI'] = $id;
$this->db->insert('KODE_LOKASI', $this->data_lokasi);
$this->check_trans_status('INSSERT LOKASI FAILED');
}
$this->id = $id;
}
function save_detail()
{
$this->insert_lokasi();
}
function build_query_hapus($id=0)
{
$this->db->where('ID_KODE_LOKASI', $id)->delete('KODE_LOKASI');
$this->check_trans_status('DELETE LOKASI FAILED');
}
function build_query_daftar()
{
$this->db->select('
k.ID_KODE_LOKASI
, k.ID_SKPD
, s.NAMA_SKPD
, k.KODE_LOKASI
, k.NAMA_LOKASI
, k.ALAMAT
, k.KABUPATEN
, k.CHILD_COUNT
');
$this->db->from('KODE_LOKASI k');
$this->db->join('SKPD s', 'k.ID_SKPD = s.ID_SKPD');
if ($this->session->userdata('id_skpd') !== 0)
{
$this->db->where('s.ID_SKPD', $this->session->userdata('id_skpd'));
}
}
function check_duplikasi()
{
$id = $this->input->post('id') ? $this->input->post('id') : NULL;
$kode = $this->input->post('kd_lokasi') ? $this->input->post('kd_lokasi') : NULL;
$this->db->select('COUNT(1) DUP')
->where('a.ID_KODE_LOKASI <>', $id)
->where('a.KODE_LOKASI', $kode);
$rs = $this->db->get('KODE_LOKASI a')->row_array();
return (integer) $rs['DUP'] < 1;
}
function check_dependency($id)
{
$this->db->select('COUNT(b.ID_KODE_LOKASI) DEPEDENCY_DATA');
$this->db->from('INVENTARIS b');
$this->db->where('b.ID_KODE_LOKASI', $id);
$result = $this->db->get()->row_array();
if ($result && ($result['DEPEDENCY_DATA'] > 0))
{
return FALSE;
}
else
{
return TRUE;
}
}
function get_skpd($param)
{
$this->db->select('
r.ID_SKPD
, r.NAMA_SKPD
');
$this->db->from('SKPD r');
$this->db->order_by('r.NAMA_SKPD' , 'asc');
if ($param['q'] != ''){
$this->db->where('(r.NAMA_SKPD containing '.$this->db->escape($param['q']).')');
}
if ($this->session->userdata('id_skpd') !== 0)
{
$this->db->where('r.ID_SKPD', $this->session->userdata('id_skpd'));
}
$result = $this->db->get()->result_array();
return $result;
}
}