| 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/sipkd_2016/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_fungsi = array(
'id' => 'ID_FUNGSI',
'kode' => 'KODE_FUNGSI',
'nama' => 'NAMA_FUNGSI',
);
}
function fill_data()
{
foreach($this->fieldmap_fungsi 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;
}
// Kode Fungsi hanya boleh dipakai sekali
function check_duplikasi_fungsi()
{
$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.kode_fungsi', $kode)
->where('a.id_fungsi <>', $id);
$rs = $this->db->get('fungsi a')->row_array();
return (integer) $rs['DUP'] < 1;
}
/* Simpan data Fungsi */
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('insert fungsi failed');
}
$this->id = $id;
}
function save_detail()
{
$this->insert_fungsi();
}
/* query hapus */
function build_query_hapus($id=0)
{
$this->db->where('id_fungsi', $id)->delete('fungsi');
$this->check_trans_status('delete fungsi failed');
}
/* Query daftar */
function build_query_daftar()
{
$this->db->select("
a.id_fungsi,
a.kode_fungsi,
a.nama_fungsi
");
$this->db->from('fungsi a');
}
function check_dependency($id)
{
$this->db->select("
(select count(b.ID_FUNGSI) from BIDANG b where b.ID_FUNGSI = a.ID_FUNGSI) BIDANG_PAKAI,
");
$this->db->where('a.ID_FUNGSI', $id);
$result = $this->db->get('FUNGSI a')->row_array();
return !($result['BIDANG_PAKAI'] > 0);
}
}