| 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/core/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*********************************************************************************************
SUPER CLASS dari semua Model Mutasi
*********************************************************************************************/
class HmutasiMasuk_Model extends Base_Model{
var $tipe;
var $id;
var $nomor;
var $fieldmap_mutasi;
var $data_mutasi;
var $fieldmap_daftar_aggregate; // variabel untuk menampung kolom yang di aggregate (sum, count, dll)
var $sort_default;
function __construct()
{
parent::__construct();
$this->sort_default = array();
$this->fieldmap_mutasi = array(
'id' => 'ID_MUTASI',
'jenis_kib' => 'JENIS_KIB',
'no_sk' => 'NO_SRT_KEPUTUSAN',
'tgl_sk' => 'TGL_SRT_KEPUTUSAN',
'jenis_mutasi' => 'JENIS_MUTASI',
'id_skpd' => 'ID_SKPD',
'id_skpd_tujuan' => 'SKPD_TUJUAN',
'tahun_mutasi' => 'TAHUN',
'ket' => 'DESKRIPSI'
);
$this->fieldmap_daftar_aggregate = array();
}
function get_grid_model()
{
}
function fill_data()
{
/* ambil data Mutasi */
foreach($this->fieldmap_mutasi as $key => $value)
{
switch ($key)
{
case 'tgl_sk' : $$key = $this->input->post('tgl_sk') ? prepare_date($this->input->post('tgl_sk')) : NULL; break;
default : $$key = $this->input->post($key) ? $this->input->post($key) : NULL;
}
if(isset($$key))
$this->data_mutasi[$value] = $$key;
}
/* pengambilan data lain di override di modul Mutasi */
}
function insert_mutasi()
{
if (isset($this->data_mutasi['ID_MUTASI']))
{
$this->db->where('ID_MUTASI', $this->data_mutasi['ID_MUTASI']);
$this->db->update('MUTASIPENYALURAN', $this->data_mutasi);
$this->check_trans_status('UPDATE MUTASI FAILED');
$this->id = $this->data_mutasi['ID_MUTASI'];
}
else
{
$id = $this->get_id('G_ID_MUTASI');
$this->data_mutasi['ID_MUTASI'] = $id;
$this->id = $id;
if ($this->data_mutasi['JENIS_MUTASI'] == 'Dipindah ke SKPD lain')
{
$this->data_mutasi['STATUS_APPROVE'] = 2;
}
$this->db->insert('MUTASIPENYALURAN', $this->data_mutasi);
$this->check_trans_status('INSERT MUTASI FAILED');
}
}
function save_detail()
{
// fungsi ini di override di modul Inventaris
}
function save_data()
{
$this->db->trans_begin();
try {
$this->insert_mutasi();
$this->save_detail();
}
catch(Exception $e){
//TODO : log error to file
}
if ($this->db->trans_status() === FALSE)
{
$this->id = NULL;
$this->nomor = NULL;
$this->last_error_id = $this->db->_error_number();
$this->last_error_message = $this->db->_error_message();
$this->db->trans_rollback();
return FALSE;
}
$this->db->trans_commit();
return TRUE;
}
function delete_data($id)
{
$this->db->trans_begin();
try {
$this->build_query_hapus($id);
}
catch(Exception $e){
//TODO : log error to file
}
if ($this->db->trans_status() === FALSE)
{
$this->last_error_id = $this->db->_error_number();
$this->last_error_message = $this->db->_error_message();
$this->db->trans_rollback();
return FALSE;
}
$this->db->trans_commit();
return TRUE;
}
// jika aktivitas sudah masuk bud, maka yang bisa diubah hanya Setup Jurnal
function fill_data_bku()
{
foreach($this->fieldmap_aktivitas as $key => $value){
switch ($key)
{
case 'id' : $$key = $this->input->post($key) ? prepare_date($this->input->post($key)) : NULL; $this->data_aktivitas[$value] = $$key; break;
case 'jurnal' : $$key = $this->input->post($key) ? prepare_date($this->input->post($key)) : NULL; $this->data_aktivitas[$value] = $$key; break;
}
}
}
function save_data_bku()
{
try {
$this->db->where('ID_AKTIVITAS', $this->data_aktivitas['ID_AKTIVITAS']);
$this->db->update('AKTIVITAS_BLUD', $this->data_aktivitas);
$this->check_trans_status('update aktivitas_blud failed');
$this->id = $this->data_aktivitas['ID_AKTIVITAS'];
}
catch(Exception $e){
//TODO : log error to file
}
if ($this->db->trans_status() === FALSE)
{
$this->id = NULL;
$this->nomor = NULL;
$this->last_error_id = $this->db->_error_number();
$this->last_error_message = $this->db->_error_message();
$this->db->trans_rollback();
return FALSE;
}
$this->db->trans_commit();
return TRUE;
}
function build_query_daftar()
{
// di override di modul Aktivitas
}
function build_query_form($id=0)
{
// di override di modul Aktivitas
}
function build_query_hapus()
{
// di override di modul Aktivitas
}
// override get_data dari base_model
function get_data($param, $isCount=FALSE, $CompileOnly=False)
{
$this->build_query_daftar();
isset($param['limit']) && $param['limit'] ? $this->db->limit($param['limit']['end'], $param['limit']['start']) : '';
// proses parameter pencarian, jika ada
if (isset($param['search_mode']) && $param['search_mode'] !=='' )
{
// proses pencarian singkat (simple search)
if ($param['search_mode'] == 'ss')
{
foreach($this->fieldmap_filter as $key => $value){
$flt[$key] = array('search_str' => $param['q'], 'search_op' => 'cn');
}
if (count($flt) > 0)
{
$swhere = get_where_str($flt, $this->fieldmap_filter);
if ($swhere) {
$swhere = build_or_where($swhere);
$this->db->where($swhere);
}
}
}
// proses pencarian lanjut (advanced search)
else if ($param['search_mode'] == 'as') {
$fields = $this->get_data_fields();
if (is_array($param['q']) && count($param['q']) > 0)
{
foreach ($param['q'] as $key=>$val) {
$kolom = $val['c'];
$search_str = isset($val['s']) ? $val['s'] : '';
$search_str2 = isset($val['s2']) ? $val['s2'] : '';
$flt[$kolom] = array(
'search_str' => $search_str,
'search_str2' => $search_str2,
'search_op' => $val['o'],
'search_datatype' => $fields[$kolom]['kategori'],
);
}
if (count($flt) > 0)
{
$wh = get_where_str($flt, $this->fieldmap_filter);
$this->db->where($wh);
}
}
}
}
//grouping
$this->db->group_by('
m.ID_MUTASI
, m.NO_SRT_KEPUTUSAN
, m.ID_SKPD
, v_skpd.KODE_SKPD_LKP
, v_skpd.NAMA_SKPD
, m.JENIS_KIB
, m.DESKRIPSI
, m.STATUS_APPROVE
');
if ($isCount) {
$this->db->ar_select = array();
$this->db->ar_select[] = 'count(*) cnt';
foreach( $this->fieldmap_daftar_aggregate as $agg_key => $agg_value)
{
$this->db->ar_select[] = "coalesce(".$agg_value.", 0) ".$agg_key;
}
$result = $this->db->get()->result_array();
return count($result);
}
else
{
// proses jika ada pengurutan
if (isset($param['sort_by']) && $param['sort_by'] != null && !$isCount && $ob = get_order_by_str($param['sort_by'], $this->fieldmap_filter))
{
$this->db->order_by($ob, $param['sort_direction']);
}
// urutkan sesuai default jika ada
else {
if (count($this->sort_default) > 0){
$this->db->_protect_identifiers = FALSE;
$urutan = implode( ',', $this->sort_default);
$this->db->order_by( $urutan );
$this->db->_protect_identifiers = TRUE;
}
}
if ($CompileOnly)
{
return $this->db->get_compiled_select();
}
else
{
$result = $this->db->get();
return $result->result_array();
}
}
}
function get_prev_id($id)
{
$this->db->select('coalesce(max(inv.ID_INVENTARIS), 0) ID_INVENTARIS');
$this->db->from('INVENTARIS inv');
$this->db->where('inv.ID_INVENTARIS < ', $id);
$result = $this->db->get()->row_array();
return $result['ID_INVENTARIS'];
}
function get_next_id($id)
{
$this->db->select('coalesce(min(inv.ID_INVENTARIS), 0) ID_INVENTARIS');
$this->db->from('INVENTARIS inv');
$this->db->where('inv.ID_INVENTARIS > ', $id);
$result = $this->db->get()->row_array();
return $result['ID_INVENTARIS'];
}
function check_dependency($id)
{
return TRUE; // fungsi ini di override di modul Inventaris
}
}