| 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_2020_sekolah/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',
'LAST_CHANGED',
'PARAM'
);
$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',
'last_changed' => 'LAST_CHANGED',
);
}
function fill_data()
{
foreach($this->fieldmap_fungsi as $key => $value){
switch ($key){
case 'last_changed' : $$key = date('d.m.Y.H.i.s'); break;
default : $$key = $this->input->post($key) ? $this->input->post($key) : NULL;
}
if(isset($$key))
$this->data[$value] = $$key;
}
}
function cek_exist()
{
if($this->input->post('id') > 0){
$this->db->select('count(fa.id_fungsi) fungsi_exists');
$this->db->from('FUNGSI fa');
$this->db->where('fa.id_fungsi',$this->input->post('id'));
$result = $this->db->get()->row_array();
if($result && $result['FUNGSI_EXISTS'] > 0)
{
return 1;
}
else{
return 0;
}
}
else{
return 1;
}
}
function cek_changed()
{
if($this->input->post('id') > 0 || $this->input->post('last_changed') !=''){
$this->db->select('fa.last_changed');
$this->db->from('FUNGSI fa');
$this->db->where('fa.id_fungsi',$this->input->post('id'));
$result = $this->db->get()->row_array();
if($result)
{
if($result['LAST_CHANGED'] <= $this->input->post('last_changed')){
return 1;
}
else{
return $result['LAST_CHANGED'];
}
}
else{
return 1;
}
}
else{
return 1;
}
}
// ----- 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;
$this->last_changed = $this->get_last_changed('fungsi','id_fungsi',$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,
a.last_changed,
0 param
");
$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);
}
}