| 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_2018/application/modules/gudang/models/ |
Upload File : |
<?php
class Gudang_model extends Base_Model {
var $fieldmap_daftar;
var $fieldmap_filter;
var $fieldmap_gudang;
var $data;
function __construct()
{
parent::__construct();
$this->fieldmap_daftar = array(
'ID_GUDANG',
'ID_SKPD',
'KODE_SKPD_LKP',
'NAMA_SKPD',
'KODE_GUDANG',
'NAMA_GUDANG'
);
$this->fieldmap_filter = array(
'kd_skpd' => 'v.KODE_SKPD_LKP',
'nm_skpd' => 'v.NAMA_SKPD',
'kd_gud' => 'g.KODE_GUDANG',
'nm_gud' => 'g.NAMA_GUDANG'
);
$this->fieldmap_gudang = array(
'id' => 'ID_GUDANG',
'id_skpd' => 'ID_SKPD',
'kd_gud' => 'KODE_GUDANG',
'nm_gud' => 'NAMA_GUDANG'
);
}
function fill_data()
{
foreach($this->fieldmap_gudang 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(
'kd_skpd' => array('name' => 'Kode SKPD', 'kategori'=>'string'),
'nm_skpd' => array('name' => 'Nama SKPD', 'kategori'=>'string'),
'kd_gud' => array('name' => 'Kode Gudang', 'kategori'=>'string'),
'nm_gud' => array('name' => 'Nama Gudang', 'kategori'=>'string')
);
return $fields;
}
function insert_gudang()
{
$id = $this->data['ID_GUDANG'];
$this->db->select('1')->from('GUDANG')->where('ID_GUDANG', $id);
$rs = $this->db->get()->row_array();
if ($rs)
{
$this->db->where('ID_GUDANG', $id);
$this->db->update('GUDANG', $this->data);
$this->check_trans_status('update GUDANG failed');
}
else
{
$id = $this->get_id('G_ID_GUDANG');
$this->data['ID_GUDANG'] = $id;
$this->db->insert('GUDANG', $this->data);
$this->check_trans_status('insert GUDANG failed');
}
$this->id = $id;
}
function save_detail()
{
$this->insert_gudang();
}
/* query hapus */
function build_query_hapus($id=0)
{
$this->db->where('ID_GUDANG', $id)->delete('GUDANG');
$this->check_trans_status('delete GUDANG failed');
}
/* Query daftar */
function build_query_daftar()
{
$this->db->select("
g.ID_GUDANG,
g.ID_SKPD,
v.KODE_SKPD_LKP,
v.NAMA_SKPD,
g.KODE_GUDANG,
g.NAMA_GUDANG
");
$this->db->from('GUDANG g');
$this->db->join('V_SKPD v', 'g.ID_SKPD = v.ID_SKPD');
if ($this->session->userdata('id_skpd') !== 0)
{
$this->db->where('g.ID_SKPD', $this->session->userdata('id_skpd'));
}
}
function check_duplikasi_gudang()
{
$id = $this->input->post('id') ? $this->input->post('id') : NULL;
$kd_gud = $this->input->post('kd_gud') ? $this->input->post('kd_gud') : NULL;
$this->db->select('count(r.ID_GUDANG) DUP')
->where('r.KODE_GUDANG', $kd_gud)
->where('r.ID_GUDANG <>', $id);
$rs = $this->db->get('GUDANG r')->row_array();
return (integer) $rs['DUP'] <= 0;
}
function check_dependency($id)
{
//
}
}