| 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_2017/application/modules/fungsi/models/ |
Upload File : |
<?php
class Fungsi_model extends Base_Model {
var $fieldmap_daftar;
var $fieldmap_filter;
var $fieldmap_fungsi;
var $data;
function __construct()
{
parent::__construct();
$this->fieldmap_daftar = array(
'ID_FUNGSI',
'KODE_FUNGSI',
'NAMA_FUNGSI',
);
$this->fieldmap_filter = array(
'kode' => 'a.KODE_FUNGSI',
'nama' => 'a.NAMA_FUNGSI',
);
$this->fieldmap_urusan = array(
'id' => 'ID_FUNGSI',
'kode' => 'KODE_FUNGSI',
'nama' => 'NAMA_FUNGSI',
);
}
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 Fungsi', 'kategori'=>'string'),
'nama' => array('name' => 'Nama Fungsi', 'kategori'=>'string'),
);
return $fields;
}
function insert_fungsi()
{
$id = $this->data['ID_FUNGSI'];
$this->db->select('1')->from('FUNGSI')->where('ID_FUNGSI', $id);
$rs = $this->db->get()->row_array();
if ($rs)
{
$this->db->where('ID_FUNGSI', $id);
$this->db->update('FUNGSI', $this->data);
$this->check_trans_status('UPDATE FUNGSI FAILED');
}
else
{
$id = $this->get_id('g_id_fungsi');
$this->data['ID_FUNGSI'] = $id;
$this->db->insert('FUNGSI', $this->data);
$this->check_trans_status('INSSERT FUNGSI FAILED');
}
$this->id = $id;
}
function save_detail()
{
$this->insert_fungsi();
}
function build_query_hapus($id=0)
{
$this->db->where('ID_FUNGSI', $id)->delete('FUNGSI');
$this->check_trans_status('DELETE FUNGSI FAILED');
}
function build_query_daftar()
{
$this->db->select('
a.ID_FUNGSI
, a.KODE_FUNGSI
, a.NAMA_FUNGSI
');
$this->db->from('FUNGSI a');
}
function check_duplikasi()
{
$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_FUNGSI <>', $id)
->where('a.KODE_FUNGSI', $kode);
$rs = $this->db->get('FUNGSI a')->row_array();
return (integer) $rs['DUP'] < 1;
}
function check_dependency($id)
{
$this->db->select('COUNT(b.ID_FUNGSI) DEPEDENCY_DATA');
$this->db->from('BIDANG b');
$this->db->where('b.ID_FUNGSI', $id);
$result = $this->db->get()->row_array();
if ($result && ($result['DEPEDENCY_DATA'] > 0))
{
return FALSE;
}
else
{
return TRUE;
}
}
function check_edit_data()
{
$id = $this->input->post('id') ? $this->input->post('id') : NULL;
$this->db->select('COUNT(b.ID_FUNGSI) DEPEDENCY_DATA');
$this->db->from('BIDANG b');
$this->db->where('b.ID_FUNGSI', $id);
$result = $this->db->get()->row_array();
if ($result && ($result['DEPEDENCY_DATA'] > 0))
{
return FALSE;
}
else
{
return TRUE;
}
}
}