| 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_2019/application/modules/urusan/models/ |
Upload File : |
<?php
class Urusan_model extends Base_Model {
var $fieldmap_daftar;
var $fieldmap_filter;
var $fieldmap_urusan;
var $data;
function __construct()
{
parent::__construct();
$this->fieldmap_daftar = array(
'ID_URUSAN',
'KODE_URUSAN',
'NAMA_URUSAN',
);
$this->fieldmap_filter = array(
'kode' => 'a.KODE_URUSAN',
'nama' => 'a.NAMA_URUSAN',
);
$this->fieldmap_urusan = array(
'id' => 'ID_URUSAN',
'kode' => 'KODE_URUSAN',
'nama' => 'NAMA_URUSAN',
);
}
function fill_data()
{
foreach($this->fieldmap_urusan as $key => $value){
switch ($key){
default : $$key = $this->input->post($key) ? $this->input->post($key) : NULL;
}
if(isset($$key))
$this->data[$value] = $$key;
}
}
// ----- search advance ---- >>
function get_data_fields()
{
$fields = array(
'kode' => array('name' => 'Kode Urusan', 'kategori'=>'string'),
'nama' => array('name' => 'Nama Urusan', 'kategori'=>'string'),
);
return $fields;
}
function insert_urusan()
{
$id = $this->data['ID_URUSAN'];
$this->db->select('1')->from('URUSAN')->where('ID_URUSAN', $id);
$rs = $this->db->get()->row_array();
if ($rs)
{
$this->db->where('ID_URUSAN', $id);
$this->db->update('URUSAN', $this->data);
$this->check_trans_status('UPDATE URUSAN FAILED');
}
else
{
$id = $this->get_id('g_id_urusan');
$this->data['ID_URUSAN'] = $id;
$this->db->insert('URUSAN', $this->data);
$this->check_trans_status('INSERT URUSAN FAILED');
}
$this->id = $id;
}
function save_detail()
{
$this->insert_urusan();
}
function build_query_hapus($id=0)
{
$this->db->where('ID_URUSAN', $id)->delete('URUSAN');
$this->check_trans_status('DELETE URUSAN FAILED');
}
function build_query_daftar()
{
$this->db->select('
a.ID_URUSAN
, a.KODE_URUSAN
, a.NAMA_URUSAN
');
$this->db->from('URUSAN a');
}
function check_duplikasi_urusan()
{
$id = $this->input->post('id') ? $this->input->post('id') : NULL;
$kode = $this->input->post('kode') ? $this->input->post('kode') : NULL;
$this->db->select('COUNT(1) DUP')
->where('a.ID_URUSAN <>', $id)
->where('a.KODE_URUSAN', $kode);
$rs = $this->db->get('URUSAN a')->row_array();
return (integer) $rs['DUP'] < 1;
}
function check_dependency($id)
{
$this->db->select("
(SELECT COUNT(b.ID_URUSAN) FROM BIDANG b WHERE b.ID_URUSAN = a.ID_URUSAN) BIDANG_PAKAI
");
$this->db->where('a.ID_URUSAN', $id);
$result = $this->db->get('URUSAN a')->row_array();
return !($result['BIDANG_PAKAI'] > 0);
}
function check_edit_data()
{
$id = $this->input->post('id') ? $this->input->post('id') : NULL;
$this->db->select('COUNT(s.ID_URUSAN) JML_DATA' );
$this->db->from('BIDANG s');
$this->db->where('s.ID_URUSAN', $id);
$result = $this->db->get()->row_array();
if ($result && ($result['JML_DATA'] > 0))
{
return FALSE;
}
else
{
return TRUE;
}
}
}