| 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_perubahan/SSHLumajang/application/modules/kua/models/ |
Upload File : |
<?php
class Kua_model extends Base_Model {
var $fieldmapFormAnggaran = array();
var $fieldmapRincian = array();
var $fieldmapPembahasan = array();
var $fieldmapTim = array();
var $fieldmapRek = array();
var $fieldmapBL = array();
var $form;
var $dataPendapatan;
var $dataBTL;
var $dataBL;
var $dataPenerimaan;
var $dataPengeluaran;
var $rek;
var $plfBL;
var $plfBTL;
var $fieldmap_daftar;
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->fieldmapFormAnggaran = array(
'tahun' => 'TAHUN',
'status' => 'STATUS',
'id_skpd' => 'ID_SKPD',
'ID_KEGIATAN' => 'ID_KEGIATAN',
'ID_REKENING' => 'ID_REKENING',
'PLAFON' => 'PLAFON',
'TIPE' => 'TIPE'
);
$this->fieldmapBL = array(
'tahun' => 'TAHUN',
'status' => 'STATUS',
'id_skpd' => 'ID_SKPD',
'ID_KEGIATAN' => 'ID_KEGIATAN',
'ID_REKENING' => 'ID_REKENING',
'plafon' => 'PLAFON',
'TIPE' => 'TIPE'
);
$this->fieldmap_daftar = array(
'KODE_SKPD_LKP',
'KODE_SKPD_LKP',
'NAMA_SKPD',
'PENDAPATAN',
'BTL_PLF',
'BL_PLF',
'PENERIMAAN_PEMB',
'PENGELUARAN_PEMB'
);
$this->fieldmap_filter = array(
'KODE_SKPD_LKP' => 's.kode_skpd_lkp',
'NAMA_SKPD' => 's.nama_skpd',
'PENDAPATAN' => "sum( iif(r.tipe = '4', a.plafon, 0) )",
'BTL_PLF' => "sum( iif(a.id_kegiatan is null and a.id_rekening is null and a.tipe='RKA21', a.plafon, 0) )",
'BTL_REK' => "sum( iif(a.id_kegiatan is null and a.id_rekening is not null and a.tipe='RKA21', a.plafon, 0) )",
'BL_PLF' => "sum( iif(a.id_kegiatan is null and a.id_rekening is null and a.tipe='RKA221', a.plafon, 0) )",
'BL_REK' => "sum( iif(a.id_kegiatan is not null and a.id_rekening is null and a.tipe='RKA221', a.plafon, 0) )",
'Penerimaan' => 'sum( iif((substring(r.KODE_REKENING from 1 for 3) =6.1), a.plafon, 0) )',
'Pengeluaran' => 'sum( iif((substring(r.KODE_REKENING from 1 for 3) =6.2), a.plafon, 0) )'
);
}
/*==============================CRUD========================================*/
function fill_data()
{
$dataPendapatan = json_decode($this->input->post('dataPendapatan'));
$dataBTL = json_decode($this->input->post('dataBTL'));
$dataBL = json_decode($this->input->post('dataBL'));
$dataPenerimaan = json_decode($this->input->post('dataPenerimaan'));
$dataPengeluaran = json_decode($this->input->post('dataPengeluaran'));
$this->purge_rinciPendapatan = $this->input->post('purge_rinciPendapatan'); $this->purge_rinciPendapatan = $this->purge_rinciPendapatan ? $this->purge_rinciPendapatan : NULL;
$this->purge_rinciBTL = $this->input->post('purge_rinciBTL'); $this->purge_rinciBTL = $this->purge_rinciBTL ? $this->purge_rinciBTL : NULL;
$this->purge_rinciBL = $this->input->post('purge_rinciBL'); $this->purge_rinciBL = $this->purge_rinciBL ? $this->purge_rinciBL : NULL;
$this->purge_rinciPenerimaan = $this->input->post('purge_rinciPenerimaan'); $this->purge_rinciPenerimaan = $this->purge_rinciPenerimaan ? $this->purge_rinciPenerimaan : NULL;
$this->purge_rinciPengeluaran = $this->input->post('purge_rinciPengeluaran'); $this->purge_rinciPengeluaran = $this->purge_rinciPengeluaran ? $this->purge_rinciPengeluaran : NULL;
foreach($this->fieldmapBL as $key => $value){
switch ($key){
case 'tahun' : $$key = $this->tahun; break;
case 'status' : $$key = $this->status; break;
case 'id_skpd' : $$key = $this->input->post('id_skpd'); break;
case 'plafon' : $$key = $this->input->post('plafon_bl')?$this->input->post('plafon_bl') : 0; break;
case 'TIPE' : $$key = 'RKA221'; break;
case 'ID_KEGIATAN' : $$key = NULL; break;
case 'ID_REKENING' : $$key = NULL; break;
default : $$key = $this->input->post($key);
}
//if(isset($$key))
$this->plfBL[$value] = $$key;
}
foreach($this->fieldmapBL as $key => $value){
switch ($key){
case 'tahun' : $$key = $this->tahun; break;
case 'status' : $$key = $this->status; break;
case 'id_skpd' : $$key = $this->input->post('id_skpd'); break;
case 'plafon' : $$key = $this->input->post('plafon_btl')?$this->input->post('plafon_btl') : 0; break;
case 'TIPE' : $$key = 'RKA21'; break;
case 'ID_KEGIATAN' : $$key = NULL; break;
case 'ID_REKENING' : $$key = NULL; break;
default : $$key = $this->input->post($key);
}
//if(isset($$key))
$this->plfBTL[$value] = $$key;
}
for ($i=0; $i <= count($dataPendapatan) - 1; $i++) {
foreach($this->fieldmapFormAnggaran as $key => $value){
switch ($key){
case 'tahun' : $$key = $this->tahun; break;
case 'status' : $$key = $this->status; break;
case 'id_skpd' : $$key = $this->input->post('id_skpd'); break;
default : $$key = isset($dataPendapatan[$i]->$key) ? $dataPendapatan[$i]->$key : NULL;
}
//if(isset($$key))
$this->dataPendapatan[$i][$value] = $$key;
}
}
for ($i=0; $i <= count($dataBTL) - 1; $i++) {
foreach($this->fieldmapFormAnggaran as $key => $value){
switch ($key){
case 'tahun' : $$key = $this->tahun; break;
case 'status' : $$key = $this->status; break;
case 'id_skpd' : $$key = $this->input->post('id_skpd'); break;
default : $$key = isset($dataBTL[$i]->$key) ? $dataBTL[$i]->$key : NULL;
}
//if(isset($$key))
$this->dataBTL[$i][$value] = $$key;
}
}
for ($i=0; $i <= count($dataBL) - 1; $i++) {
foreach($this->fieldmapFormAnggaran as $key => $value){
switch ($key){
case 'tahun' : $$key = $this->tahun; break;
case 'status' : $$key = $this->status; break;
case 'id_skpd' : $$key = $this->input->post('id_skpd'); break;
default : $$key = isset($dataBL[$i]->$key) ? $dataBL[$i]->$key : NULL;
}
if(isset($$key))
$this->dataBL[$i][$value] = $$key;
}
}
for ($i=0; $i <= count($dataPenerimaan) - 1; $i++) {
foreach($this->fieldmapFormAnggaran as $key => $value){
switch ($key){
case 'tahun' : $$key = $this->tahun; break;
case 'status' : $$key = $this->status; break;
case 'id_skpd' : $$key = $this->input->post('id_skpd'); break;
default : $$key = isset($dataPenerimaan[$i]->$key) ? $dataPenerimaan[$i]->$key : NULL;
}
//if(isset($$key))
$this->dataPenerimaan[$i][$value] = $$key;
}
}
for ($i=0; $i <= count($dataPengeluaran) - 1; $i++) {
foreach($this->fieldmapFormAnggaran as $key => $value){
switch ($key){
case 'tahun' : $$key = $this->tahun; break;
case 'status' : $$key = $this->status; break;
case 'id_skpd' : $$key = $this->input->post('id_skpd'); break;
default : $$key = isset($dataPengeluaran[$i]->$key) ? $dataPengeluaran[$i]->$key : NULL;
}
//if(isset($$key))
$this->dataPengeluaran[$i][$value] = $$key;
}
}
}
// ----- search advance ---- >>
function get_data_fields()
{
$fields = array(
'KODE_SKPD_LKP' => array('name' => 'Kode SKPD', 'kategori'=>'string'),
'NAMA_SKPD' => array('name' => 'Nama SKPD', 'kategori'=>'string'),
);
return $fields;
}
function insert_dataPendapatan()
{
if ($this->purge_rinciPendapatan)
{
for($i=0;$i<count($this->purge_rinciPendapatan);$i++)
{
$cek = $this->cek_kua_rekening($this->input->post('id_skpd'),$this->purge_rinciPendapatan[$i]);
if($cek){
$this->db->where('ID_KEGIATAN is null');
$this->db->where('ID_SKPD', $this->input->post('id_skpd'));
$this->db->where('ID_REKENING', $this->purge_rinciPendapatan[$i]);
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$del_rin = $this->db->delete('KUA_PPAS');
}
}
}
for ($i=0; $i <= count($this->dataPendapatan) - 1; $i++)
{
$cek = $this->cek_kua_rekening($this->dataPendapatan[$i]['ID_SKPD'],$this->dataPendapatan[$i]['ID_REKENING']);
if($cek){
$this->db->where('ID_SKPD', $this->dataPendapatan[$i]['ID_SKPD']);
$this->db->where('ID_REKENING', $this->dataPendapatan[$i]['ID_REKENING']);
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$this->db->update('KUA_PPAS', $this->dataPendapatan[$i]);
}
else{
$this->db->insert('KUA_PPAS', $this->dataPendapatan[$i]);
}
}
}
function insert_dataBTL()
{
if ($this->purge_rinciBTL)
{
for($i=0;$i<count($this->purge_rinciBTL);$i++)
{
$cek = $this->cek_kua_rekening($this->input->post('id_skpd'),$this->purge_rinciBTL[$i]);
if($cek){
$this->db->where('ID_KEGIATAN is null');
$this->db->where('ID_SKPD', $this->input->post('id_skpd'));
$this->db->where('ID_REKENING', $this->purge_rinciBTL[$i]);
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$del_rin = $this->db->delete('KUA_PPAS');
}
}
}
for ($i=0; $i <= count($this->dataBTL) - 1; $i++)
{
$cek = $this->cek_kua_rekening($this->dataBTL[$i]['ID_SKPD'],$this->dataBTL[$i]['ID_REKENING']);
if($cek){
$this->db->where('ID_SKPD', $this->dataBTL[$i]['ID_SKPD']);
$this->db->where('ID_REKENING', $this->dataBTL[$i]['ID_REKENING']);
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$this->db->update('KUA_PPAS', $this->dataBTL[$i]);
}
else{
$this->db->insert('KUA_PPAS', $this->dataBTL[$i]);
}
}
}
function insert_dataBL()
{
if ($this->purge_rinciBL)
{
for($i=0;$i<count($this->purge_rinciBL);$i++)
{
$cek = $this->cek_kua_kegiatan($this->input->post('id_skpd'),$this->purge_rinciBL[$i]);
if($cek){
$this->db->where('ID_REKENING is null');
$this->db->where('ID_SKPD', $this->input->post('id_skpd'));
$this->db->where('ID_KEGIATAN', $this->purge_rinciBL[$i]);
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$del_rin = $this->db->delete('KUA_PPAS');
}
}
}
for ($i=0; $i <= count($this->dataBL) - 1; $i++)
{
$cek = $this->cek_kua_kegiatan($this->dataBL[$i]['ID_SKPD'],$this->dataBL[$i]['ID_KEGIATAN']);
if($cek){
$this->db->where('ID_REKENING is null');
$this->db->where('ID_SKPD', $this->dataBL[$i]['ID_SKPD']);
$this->db->where('ID_KEGIATAN', $this->dataBL[$i]['ID_KEGIATAN']);
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$this->db->update('KUA_PPAS', $this->dataBL[$i]);
}
else{
$this->db->insert('KUA_PPAS', $this->dataBL[$i]);
}
}
}
function insert_dataPenerimaan()
{
if ($this->purge_rinciPenerimaan)
{
for($i=0;$i<count($this->purge_rinciPenerimaan);$i++)
{
$cek = $this->cek_kua_rekening($this->input->post('id_skpd'),$this->purge_rinciPenerimaan[$i]);
if($cek){
$this->db->where('ID_KEGIATAN is null');
$this->db->where('ID_SKPD', $this->input->post('id_skpd'));
$this->db->where('ID_REKENING', $this->purge_rinciPenerimaan[$i]);
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$del_rin = $this->db->delete('KUA_PPAS');
}
}
}
for ($i=0; $i <= count($this->dataPenerimaan) - 1; $i++)
{
$cek = $this->cek_kua_rekening($this->dataPenerimaan[$i]['ID_SKPD'],$this->dataPenerimaan[$i]['ID_REKENING']);
if($cek){
$this->db->where('ID_SKPD', $this->dataPenerimaan[$i]['ID_SKPD']);
$this->db->where('ID_REKENING', $this->dataPenerimaan[$i]['ID_REKENING']);
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$this->db->update('KUA_PPAS', $this->dataPenerimaan[$i]);
}
else{
$this->db->insert('KUA_PPAS', $this->dataPenerimaan[$i]);
}
}
}
function insert_dataPengeluaran()
{
if ($this->purge_rinciPengeluaran)
{
for($i=0;$i<count($this->purge_rinciPengeluaran);$i++)
{
$cek = $this->cek_kua_rekening($this->input->post('id_skpd'),$this->purge_rinciPengeluaran[$i]);
if($cek){
$this->db->where('ID_KEGIATAN is null');
$this->db->where('ID_SKPD', $this->input->post('id_skpd'));
$this->db->where('ID_REKENING', $this->purge_rinciPengeluaran[$i]);
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$del_rin = $this->db->delete('KUA_PPAS');
}
}
}
for ($i=0; $i <= count($this->dataPengeluaran) - 1; $i++)
{
$cek = $this->cek_kua_rekening($this->dataPengeluaran[$i]['ID_SKPD'],$this->dataPengeluaran[$i]['ID_REKENING']);
if($cek){
$this->db->where('ID_SKPD', $this->dataPengeluaran[$i]['ID_SKPD']);
$this->db->where('ID_REKENING', $this->dataPengeluaran[$i]['ID_REKENING']);
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$this->db->update('KUA_PPAS', $this->dataPengeluaran[$i]);
}
else{
$this->db->insert('KUA_PPAS', $this->dataPengeluaran[$i]);
}
}
}
function insert_dataPlafonBL()
{
$cek = $this->cek_kua_plafonBL($this->input->post('id_skpd'));
if($cek){
$this->db->where('ID_SKPD', $this->input->post('id_skpd'));
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$this->db->where('ID_REKENING is null');
$this->db->where('ID_KEGIATAN is null');
$this->db->where('TIPE','RKA221');
$this->db->update('KUA_PPAS', $this->plfBL);
}
else{
$this->db->insert('KUA_PPAS', $this->plfBL);
}
}
function insert_dataPlafonBTL()
{
$cek = $this->cek_kua_plafonBTL($this->input->post('id_skpd'));
if($cek){
$this->db->where('ID_SKPD', $this->input->post('id_skpd'));
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$this->db->where('ID_REKENING is null');
$this->db->where('ID_KEGIATAN is null');
$this->db->where('TIPE','RKA21');
$this->db->update('KUA_PPAS', $this->plfBTL);
}
else{
$this->db->insert('KUA_PPAS', $this->plfBTL);
}
}
function insert_data()
{
//$this->fill_data();
$this->db->trans_start();
$this->insert_dataPendapatan();
$this->insert_dataBTL();
$this->insert_dataBL();
$this->insert_dataPenerimaan();
$this->insert_dataPengeluaran();
$this->insert_dataPlafonBL();
$this->insert_dataPlafonBTL();
$this->db->trans_complete();
}
function update_data($id)
{
$this->fill_data();
$this->db->trans_start();
$this->insert_dataPendapatan();
$this->insert_dataBTL();
$this->insert_dataBL();
$this->insert_dataPenerimaan();
$this->insert_dataPengeluaran();
$this->insert_dataPlafonBL();
$this->insert_dataPlafonBTL();
$this->db->trans_complete();
}
function delete_data($id)
{
//hapus kua ppas
$this->db->trans_start();
$this->db->where('ID_SKPD', $id);
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$form = $this->db->delete('KUA_PPAS');
$this->db->trans_complete();
}
function cek_kua_plafonBL($ID_SKPD)
{
$this->db->trans_start();
$this->db->select("count(PLAFON) JUM_PLAFON");
$this->db->from('KUA_PPAS');
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$this->db->where('ID_SKPD', $ID_SKPD);
$this->db->where('ID_REKENING is null');
$this->db->where('ID_KEGIATAN is null');
$this->db->where('TIPE','RKA221');
$query = $this->db->get()->row_array();
if ($query['JUM_PLAFON'] > 0)
{
return TRUE;
}
else
{
return FALSE;
}
$this->db->trans_complete();
}
function cek_kua_plafonBTL($ID_SKPD)
{
$this->db->trans_start();
$this->db->select("count(PLAFON) JUM_PLAFON");
$this->db->from('KUA_PPAS');
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$this->db->where('ID_SKPD', $ID_SKPD);
$this->db->where('ID_REKENING is null');
$this->db->where('ID_KEGIATAN is null');
$this->db->where('TIPE','RKA21');
$query = $this->db->get()->row_array();
if ($query['JUM_PLAFON'] > 0)
{
return TRUE;
}
else
{
return FALSE;
}
$this->db->trans_complete();
}
function getnum_plafonBL($ID_SKPD)
{
$this->db->trans_start();
$this->db->select("count(PLAFON) JUM_PLAFON");
$this->db->from('KUA_PPAS');
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$this->db->where('ID_SKPD', $ID_SKPD);
$this->db->where('ID_REKENING is null');
$this->db->where('ID_KEGIATAN is null');
$this->db->where('TIPE','RKA221');
$query = $this->db->get()->row_array();
if ($query['JUM_PLAFON'] > 0)
{
return TRUE;
}
else
{
return FALSE;
}
$this->db->trans_complete();
}
function cek_kua_rekening($ID_SKPD,$ID_REKENING)
{
$this->db->trans_start();
$this->db->select("count(PLAFON) JUM_PLAFON");
$this->db->from('KUA_PPAS');
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$this->db->where('ID_SKPD', $ID_SKPD);
$this->db->where('ID_REKENING', $ID_REKENING);
$query = $this->db->get()->row_array();
if ($query['JUM_PLAFON'] > 0)
{
return TRUE;
}
else
{
return FALSE;
}
$this->db->trans_complete();
}
function cek_kua_kegiatan($ID_SKPD,$ID_KEGIATAN)
{
$this->db->trans_start();
$this->db->select("count(PLAFON) JUM_PLAFON");
$this->db->from('KUA_PPAS');
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$this->db->where('ID_SKPD', $ID_SKPD);
$this->db->where('ID_KEGIATAN', $ID_KEGIATAN);
$this->db->where('ID_REKENING is null');
$query = $this->db->get()->row_array();
if ($query['JUM_PLAFON'] > 0)
{
return TRUE;
}
else
{
return FALSE;
}
$this->db->trans_complete();
}
/*==============================END CRUD========================================*/
/*==============================GET DATA========================================*/
function get_data($param, $isCount=FALSE, $CompileOnly=False)
{
isset($param['limit']) && $param['limit'] ? $this->db->limit($param['limit']['end'], $param['limit']['start']) : '';
$this->db->trans_start();
$this->db->select("s.kode_skpd_lkp,
s.nama_skpd,
sum( iif(r.tipe = '4', a.plafon, 0) ) pendapatan,
sum( iif(a.id_kegiatan is null and a.id_rekening is null and a.tipe='RKA21', a.plafon, 0) ) btl_plf,
sum( iif(a.id_kegiatan is null and a.id_rekening is not null and a.tipe='RKA21', a.plafon, 0) ) btl_rek,
sum( iif(a.id_kegiatan is null and a.id_rekening is null and a.tipe='RKA221', a.plafon, 0) ) bl_plf,
sum( iif(a.id_kegiatan is not null and a.id_rekening is null and a.tipe='RKA221', a.plafon, 0) ) bl_rek,
sum( iif((substring(r.KODE_REKENING from 1 for 3) =6.1), a.plafon, 0) ) penerimaan_pemb,
sum( iif((substring(r.KODE_REKENING from 1 for 3) =6.2), a.plafon, 0) ) pengeluaran_pemb");
$this->db->from('kua_ppas a');
$this->db->join('V_SKPD S', 'A.ID_SKPD = S.ID_SKPD');
$this->db->join('REKENING R', 'R.ID_REKENING = A.ID_REKENING','LEFT OUTER');
$this->db->where('A.STATUS',$this->status);
$this->db->where('A.TAHUN',$this->tahun);
if ($this->id_skpd > 0) $this->db->where('A.ID_SKPD', $this->id_skpd);
$this->db->group_by('1,2');
// 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->having($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->having($wh);
}
}
}
}
// 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']);
}
if ($isCount) {
$ada = $this->db->get()->result_array();
return count($ada);
}
else
{
if ($CompileOnly)
{
return $this->db->get_compiled_select();
}
else
{
$result = $this->db->get()->result_array();
return $result;
}
}
$this->db->trans_complete();
}
function get_data_murni($ID_SKPD)
{
$this->db->trans_start();
$this->db->select('NR.NOMINAL as NOMINAL_MURNI');
$this->db->from('V_FORM_ANGGARAN_LKP as A');
$this->db->join('V_NOMINAL_RKA as NR','A.ID_FORM_ANGGARAN=NR.ID_FORM_ANGGARAN');
$this->db->where('A.STATUS',$this->session->userdata('STATUS_AWAL'));
$this->db->where('A.TAHUN',$this->tahun);
$this->db->where('A.TIPE','RKA');
$this->db->where('A.ID_SKPD',$ID_SKPD);
$result = $this->db->get();
if($result->num_rows() > 0)
{
return $result->row_array();
}
else{
return null;
}
$this->db->trans_complete();
}
function get_data_by_id($id)
{
$this->db->trans_start();
$this->db->select("A.TAHUN,A.STATUS,A.ID_SKPD,s.KODE_SKPD,s.KODE_SKPD_LKP,s.NAMA_SKPD,
(
select coalesce(a1.PLAFON, 0)
from KUA_PPAS a1
where a1.TAHUN=a.tahun and a1.STATUS=a.status and a1.ID_SKPD=a.id_skpd
and a1.tipe='RKA221' and a1.ID_KEGIATAN is null and a1.ID_REKENING is null
) PLAFON_BL,
(
select coalesce(a1.PLAFON, 0)
from KUA_PPAS a1
where a1.TAHUN=a.tahun and a1.STATUS=a.status and a1.ID_SKPD=a.id_skpd
and a1.tipe='RKA21' and a1.ID_KEGIATAN is null and a1.ID_REKENING is null
) PLAFON_BTL
");
$this->db->from('KUA_PPAS A');
$this->db->join('V_SKPD s', 'A.ID_SKPD = S.ID_SKPD ', 'LEFT');
$this->db->where('S.KODE_SKPD_LKP', $id);
$this->db->where('A.TAHUN', $this->tahun);
$this->db->where('A.STATUS', $this->status);
$this->db->group_by('1,2,3,4,5,6');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->row_array();
}
else
{
return FALSE;
}
$this->db->trans_complete();
}
function get_daftar_pendapatan($param)
{
$this->db->trans_start();
$this->db->select('I.ID_REKENING,R.KODE_REKENING,R.NAMA_REKENING,I.PLAFON');
$this->db->from('KUA_PPAS I');
$this->db->join('REKENING R','I.ID_REKENING=R.ID_REKENING');
$this->db->where('R.TIPE', '4');
$this->db->where('I.ID_SKPD', $param['id']);
$this->db->where('STATUS', $this->status);
$this->db->where('TAHUN', $this->tahun);
$this->db->order_by('R.ID_REKENING');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result_array();
}
else
{
return FALSE;
}
$this->db->trans_complete();
}
function get_daftar_BTL($param)
{
$this->db->trans_start();
$this->db->select('I.ID_REKENING,R.KODE_REKENING,R.NAMA_REKENING,I.PLAFON');
$this->db->from('KUA_PPAS I');
$this->db->join('REKENING R','I.ID_REKENING=R.ID_REKENING');
$this->db->where('R.TIPE', '5');
$this->db->where('R.KELOMPOK', '1');
$this->db->where('R.LEVEL_REKENING', '3');
//$this->db->where("(r.TIPE='6' or r.KODE_REKENING='5.1.1' or r.KODE_REKENING='5.1.3' or r.KODE_REKENING='5.1.4' or r.KODE_REKENING='5.1.5' or r.KODE_REKENING='5.1.6') ");
$this->db->where('I.ID_SKPD', $param['id']);
$this->db->where('I.STATUS', $this->status);
$this->db->where('I.TAHUN', $this->tahun);
$this->db->where('I.ID_KEGIATAN is null');
$this->db->order_by('R.ID_REKENING');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result_array();
}
else
{
return FALSE;
}
$this->db->trans_complete();
}
function get_daftar_BL($param)
{
$this->db->trans_start();
$this->db->select('I.ID_KEGIATAN,K.KODE_KEGIATAN_SKPD,K.NAMA_KEGIATAN,I.PLAFON');
$this->db->from('KUA_PPAS I');
$this->db->join('V_KEGIATAN_SKPD as K','K.ID_KEGIATAN = I.ID_KEGIATAN AND K.ID_SKPD = I.ID_SKPD');
$this->db->where('I.ID_SKPD', $param['id']);
$this->db->where('I.STATUS', $this->status);
$this->db->where('I.TAHUN', $this->tahun);
$this->db->where('I.ID_REKENING is null');
$this->db->order_by('K.KODE_KEGIATAN_SKPD');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result_array();
}
else
{
return FALSE;
}
$this->db->trans_complete();
}
function get_daftar_Penerimaan($param)
{
$this->db->trans_start();
$this->db->select('I.ID_REKENING,R.KODE_REKENING,R.NAMA_REKENING,I.PLAFON');
$this->db->from('KUA_PPAS I');
$this->db->join('REKENING R','I.ID_REKENING=R.ID_REKENING');
$this->db->where("r.KODE_REKENING='6' OR (substring(r.KODE_REKENING from 1 for 3) =6.1 ) ");
$this->db->where('I.ID_SKPD', $param['id']);
$this->db->where('STATUS', $this->status);
$this->db->where('TAHUN', $this->tahun);
$this->db->order_by('R.ID_REKENING');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result_array();
}
else
{
return FALSE;
}
$this->db->trans_complete();
}
function get_daftar_Pengeluaran($param)
{
$this->db->trans_start();
$this->db->select('I.ID_REKENING,R.KODE_REKENING,R.NAMA_REKENING,I.PLAFON');
$this->db->from('KUA_PPAS I');
$this->db->join('REKENING R','I.ID_REKENING=R.ID_REKENING');
$this->db->where("r.KODE_REKENING='6' OR (substring(r.KODE_REKENING from 1 for 3) =6.2 ) ");
$this->db->where('I.ID_SKPD', $param['id']);
$this->db->where('STATUS', $this->status);
$this->db->where('TAHUN', $this->tahun);
$this->db->order_by('R.ID_REKENING');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result_array();
}
else
{
return FALSE;
}
$this->db->trans_complete();
}
function get_data_skpd()
{
$this->db->trans_start();
$this->db->select('KODE_SKPD_LKP,NAMA_SKPD,ID_SKPD');
$this->db->from('V_SKPD');
$this->db->where('ID_SKPD', $this->session->userdata('ID_SKPD_LOGIN'));
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->row_array();
}
else
{
return FALSE;
}
$this->db->trans_complete();
}
/*model untuk 3 grid didalam tab*/
function get_daftar_rincian($param)
{
$result = $this->db->query("
select distinct
rk.ID_SKPD,
rk.ID_FORM_ANGGARAN,
p.KODE_PROGRAM,
p.NAMA_PROGRAM,
k.KODE_KEGIATAN_LKP,
k.NAMA_KEGIATAN,
fa.NOMINAL_ANGGARAN,
(select sum(fa2.NOMINAL_ANGGARAN) from FORM_ANGGARAN fa2 where fa2.ID_SKPD =fa.ID_SKPD and fa2.TIPE = 'RKA221') as jumlah
from v_rincian_rka_skpd_22_2 rk
left join FORM_ANGGARAN fa on fa.ID_FORM_ANGGARAN = rk.ID_FORM_ANGGARAN
left join v_kegiatan k on k.id_kegiatan = rk.id_kegiatan
left join V_PROGRAM_SKPD p on p.ID_PROGRAM = k.ID_PROGRAM
where rk.id_skpd = '".$param['id']."'
and rk.tahun = ".$this->tahun."
and rk.status ='".$this->status."'
order by rk.kode_program, rk.kode_kegiatan
")->result_array();
return $result;
}
function get_parent_rincian($id, $kode)
{
$result = $this->db->query("
select p.ID_PROGRAM, p.kode_program, p.nama_program, sum(fa.nominal_anggaran) PAGU
from v_form_anggaran_lkp fa
join v_kegiatan k on k.id_kegiatan = fa.id_kegiatan
join program p on p.id_program = k.id_program
where fa.tahun = ".$this->tahun."
and fa.status = '".$this->status."'
and fa.id_skpd = ".$id."
and p.KODE_PROGRAM = '".$kode."'
group by 1, 2, 3
")->row_array();
return $result;
}
function get_rincian_lokasi($id)
{
$result = $this->db->query("
select
l.LOKASI
from LOKASI_KEGIATAN lk
left join lokasi l on l.ID_LOKASI = lk.ID_LOKASI
where lk.ID_FORM_ANGGARAN = '".$id."'
")->result_array();
return $result;
}
function get_rincian_sumberdana($id)
{
$result = $this->db->query("
select
sd.NAMA_SUMBER_DANA
from SUMBER_DANA_KEGIATAN sdk
left join SUMBER_DANA sd on sd.ID_SUMBER_DANA = sdk.ID_SUMBER_DANA
where sdk.ID_FORM_ANGGARAN = '".$id."'
")->result_array();
return $result;
}
//----
function get_rkadpa($param)
{
$result = $this->db->query("
select *
from form_anggaran a
join v_skpd s on a.id_skpd = s.id_skpd
join v_bidang b on b.id_bidang = s.id_bidang
join status_anggaran st on a.tahun = st.tahun and a.status = st.status
left outer join pejabat_skpd ps on a.id_pejabat_skpd = ps.id_pejabat_skpd
where a.ID_SKPD ='".$param['id']."'
and a.TIPE = 'RKA'
")->result_array();
return $result;
}
function get_tipe($id_skpd)
{
$result = $this->db->query("
select r.id_rekening, r.id_parent_rekening, r.kode_rekening, r.nama_rekening,
ra.tipe, CASE
WHEN ra.tipe = '6' THEN sum(ra.PAGU_RELATIF)
ELSE sum(ra.PAGU) END AS pagu
from v_rincian_rka_skpd ra
join rekening r on ra.tipe = r.tipe and (r.kelompok = '' or r.kelompok is null)
where ra.id_skpd = '".$id_skpd."'
and ra.tahun = '".$this->tahun."' and ra.status = '".$this->status."'
group by r.id_rekening, r.id_parent_rekening, r.kode_rekening, r.nama_rekening, ra.tipe
order by r.kode_rekening
")->result_array();
return $result;
}
/*function get_tipe($id_skpd)
{
$this->db->trans_start();
$this->db->select('r.id_rekening, r.id_parent_rekening, r.kode_rekening, r.nama_rekening, ra.tipe');
$this->db->from('v_rincian_rka_skpd as ra');
$this->db->join('rekening r',"ra.tipe = r.tipe and (r.kelompok = '' or r.kelompok is null)");
if(ra.tipe == '6'){
$this->db->select('sum(nominal) as pagu');
$this->db->join('v_surplus_anggaran as vsr','vsr.TAHUN = ra.tahun AND vsr.STATUS=ra.status and vsr.id_skpd=ra.id_skpd');
}
else{
$this->db->select('sum(ra.pagu) as pagu');
}
$this->db->where('ra.id_skpd',$id_skpd);
$this->db->where('ra.tahun',$this->tahun);
$this->db->where('ra.status',$this->status);
$this->db->group_by('r.id_rekening, r.id_parent_rekening, r.kode_rekening, r.nama_rekening, ra.tipe');
$this->db->order_by('r.kode_rekening');
$result = $this->db->get()->result_array();
return $result;
$this->db->trans_complete();
}*/
function get_kelompok($id_skpd, $tipe)
{
$result = $this->db->query("
select r.id_rekening, r.id_parent_rekening, r.kode_rekening, r.nama_rekening,
ra.tipe, ra.kelompok, sum(ra.pagu) as pagu
from v_rincian_rka_skpd ra
join rekening r on ra.tipe = r.tipe and ra.kelompok = r.kelompok
and (r.jenis = '' or r.jenis is null)
where ra.id_skpd = '".$id_skpd."'
and ra.tahun = '".$this->tahun."' and ra.status = '".$this->status."'
and ra.tipe = '".$tipe."'
group by r.id_rekening, r.id_parent_rekening, r.kode_rekening, r.nama_rekening,
ra.tipe, ra.kelompok
order by r.kode_rekening
")->result_array();
return $result;
}
function get_jenis($id_skpd, $tipe, $kelompok)
{
$result = $this->db->query("
select r.id_rekening, r.id_parent_rekening, r.kode_rekening, r.nama_rekening,
ra.pagu, ra.tipe, ra.kelompok, ra.jenis
from v_rincian_rka_skpd ra
join rekening r on ra.tipe = r.tipe and ra.kelompok = r.kelompok
and ra.jenis = r.jenis and r.objek = ''
where ra.id_skpd = '".$id_skpd."'
and ra.tahun = '".$this->tahun."' and ra.status = '".$this->status."'
and ra.tipe = '".$tipe."' and ra.kelompok = '".$kelompok."'
order by r.kode_rekening
")->result_array();
return $result;
}
function get_surplus($id_skpd)
{
$result = $this->db->query("
select sum(nominal) as surplus
from v_surplus_anggaran
where tahun = '".$this->tahun."'
and status = '".$this->status."'
and id_skpd = '".$id_skpd."'
")->row_array();
return $result;
}
function get_netto($id_skpd)
{
$result = $this->db->query("
select sum(nominal) as netto
from v_pembiayaan_netto_anggaran
where tahun = '".$this->tahun."'
and status = '".$this->status."'
and id_skpd = '".$id_skpd."'
")->row_array();
return $result;
}
/*end 3 grid tab*/
function get_pejabat($id)
{
$this->db->select('ID_PEJABAT_SKPD, NAMA_PEJABAT, JABATAN');
$this->db->from('PEJABAT_SKPD');
$this->db->where('ID_SKPD', $id);
$this->db->where('AKTIF', '1');
$result = $this->db->get()->result_array();
return $result;
}
function get_opt_satuan()
{
$this->db->select('NAMA_SATUAN');
$this->db->from('SATUAN');
$result = $this->db->get()->result_array();
return $result;
}
function get_id_fa()
{
$this->db->distinct();
$this->db->select('s.kode_skpd_lkp');
$this->db->from('kua_ppas a');
$this->db->join('V_SKPD S', 'A.ID_SKPD = S.ID_SKPD');
$this->db->where('a.STATUS', $this->status);
$this->db->where('a.TAHUN', $this->tahun);
$this->db->order_by('s.kode_skpd_lkp');
$result = $this->db->get()->result_array();
//return $result;
if(count($result) > 0)
{
return $result;
}
else
{
return FALSE;
}
}
function cek_murni($skpd)
{
$this->db->select('f.ID_FORM_ANGGARAN');
$this->db->from('FORM_ANGGARAN f');
$this->db->join('RKA_DPA_SKPD_221 rk', 'rk.ID_FORM_ANGGARAN = f.ID_FORM_ANGGARAN', 'left');
$this->db->where('f.ID_SKPD', $skpd);
$this->db->where('f.STATUS', $this->session->userdata('STATUS_AWAL'));
$this->db->where('f.TAHUN', $this->tahun);
$this->db->where('f.TIPE', 'RKA');
$result = $this->db->get()->row_array();
if(count($result) > 0)
{
return $result;
}
else
{
return FALSE;
}
}
function get_jns_obj3($id_fa,$id_gl,$jns)
{
$this->db->query("
select distinct r2.kode_rekening, r2.nama_rekening, r2.id_rekening, r2.tipe,r2.kelompok,r2.jenis,r2.objek
from rincian_anggaran ra
join v_form_anggaran_lkp vfa on vfa.id_form_anggaran = ra.id_form_anggaran
join rekening r on ra.id_rekening = r.id_rekening
join rekening r2 on r.tipe = r2.tipe and r2.kelompok =r.kelompok
and r2.jenis = r.jenis and r2.objek =r.objek and r2.rincian = ''
where vfa.id_form_anggaran ='".$id_fa."'
and vfa.tahun ='".$this->tahun."'
and r2.tipe ='5'
and r2.kelompok ='2'
and r2.jenis ='2'
and vfa.status ='".$this->status."'
union
select distinct r2.kode_rekening, r2.nama_rekening, r2.id_rekening, r2.tipe,r2.kelompok,r2.jenis,r2.objek
from rincian_anggaran ra
join v_form_anggaran_lkp vfa on vfa.id_form_anggaran = ra.id_form_anggaran
join rekening r on ra.id_rekening = r.id_rekening
join rekening r2 on r.tipe = r2.tipe and r2.kelompok = r.kelompok
and r2.jenis = r.jenis and r2.objek = r.objek and r2.rincian = ''
where vfa.status ='".$this->session->userdata('STATUS_AWAL')."'
and vfa.id_form_anggaran ='".$id_gl."'
and vfa.tahun ='".$this->tahun."'
and r2.tipe ='5'
and r2.kelompok ='2'
and r2.jenis ='2'
order by 1
");
}
function cek_fa($id)
{
$this->db->select('ID_ANGGARAN_GLOBAL as ID');
$this->db->where('ID_FORM_ANGGARAN', $id);
$result = $this->db->get('FORM_ANGGARAN')->row_array();
return $result();
}
/*==============================END GET DATA========================================*/
function cek_rka($id)
{
$this->db->trans_start();
$this->db->select("*");
$this->db->from('KUA_PPAS');
$this->db->where('TAHUN', $this->input->post('TAHUN'));
$this->db->where('STATUS', $this->input->post('STATUS'));
$this->db->where('TIPE','RKA');
$this->db->where('STATUS', $this->status);
$this->db->where('ID_SKPD', $id);
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return FALSE;
}
else
{
return TRUE;
}
$this->db->trans_complete();
}
function cek_skpd($id)
{
$this->db->select("ID_SKPD");
$this->db->from("V_SKPD");
$this->db->where('KODE_SKPD_LKP', $id);
$result = $this->db->get()->row_array();
if($result > 0)
{
return $result;
}
else
{
return FALSE;
}
}
function get_data_kode($id)
{
$this->db->trans_start();
$this->db->select(
'A.KODE_KEGIATAN_SKPD,
A.ID_FORM_ANGGARAN,
S.NAMA_SKPD,
S.KODE_SKPD_LKP,
A.NAMA_KEGIATAN,
A.NOMINAL_ANGGARAN,
A.NOMINAL_ANGGARAN AS NOMINAL_RKA'
);
$this->db->from('V_FORM_ANGGARAN_LKP as A');
$this->db->join('V_SKPD as S', 'A.ID_SKPD = S.ID_SKPD ', 'LEFT');
if($this->session->userdata('STATUS_AWAL') != $this->status)
{
$this->db->select('
IIF(A.ID_FORM_ANGGARAN = A.ID_ANGGARAN_GLOBAL,null,FM.NOMINAL_ANGGARAN) as NOMINAL_MURNI
');
$this->db->join('V_FORM_ANGGARAN_LKP as FM', 'FM.ID_FORM_ANGGARAN = A.ID_ANGGARAN_GLOBAL ', 'LEFT');
}
$this->db->where('A.STATUS',$this->status);
$this->db->where('A.TAHUN',$this->tahun);
if($this->session->userdata('ID_SKPD_LOGIN'))
{
$this->db->where('A.ID_SKPD',$this->session->userdata('ID_SKPD_LOGIN'));
}
$this->db->where('A.TIPE','RKA');
$this->db->where_in('S.KODE_SKPD_LKP',$id);
$result = $this->db->get()->row_array();
$this->db->trans_complete();
if(count($result) > 0)
{
return $result;
}
else
{
return FALSE;
}
}
function get_rek($id)
{
$this->db->trans_start();
$result = $this->db->query("SELECT r.ID_REKENING, r.KODE_REKENING, r.NAMA_REKENING, r.LEVEL_REKENING, r.ID_PARENT_REKENING FROM REKENING r WHERE ID_REKENING IN ($id)
ORDER BY r.KODE_REKENING ASC");
$this->db->trans_complete();
return $result;
}
function get_keg($id,$id_skpd)
{
$this->db->trans_start();
$result = $this->db->query("SELECT A.ID_KEGIATAN,A.KODE_KEGIATAN_SKPD,A.NAMA_KEGIATAN,K.KODE_KEGIATAN_LKP FROM V_KEGIATAN_SKPD as A LEFT JOIN V_KEGIATAN as K ON K.ID_KEGIATAN = A.ID_KEGIATAN WHERE A.ID_KEGIATAN IN ($id) AND A.ID_SKPD=$id_skpd
ORDER BY A.KODE_KEGIATAN_SKPD ASC");
$this->db->trans_complete();
return $result;
}
function get_data_subrekeningBL($skpd,$kegiatan)
{
$tahun = $this->tahun;
$status = $this->status;
$status1 = "'".$status."'";
//returns the query string
$this->db->trans_start();
$this->db->select(
'R.ID_REKENING,
R.KODE_REKENING,
R.NAMA_REKENING,
(select FA.PLAFON
from KUA_PPAS FA
where FA.TAHUN = '.$tahun.'
and FA.STATUS = '.$status1.'
and FA.ID_SKPD = '.$skpd.'
and FA.ID_KEGIATAN = '.$kegiatan.'
and R.ID_REKENING=FA.ID_REKENING
) PAGU
');
$this->db->from('REKENING R');
$this->db->where('R.LEVEL_REKENING','3');
$this->db->where('R.TIPE', '5');
$this->db->where('R.KELOMPOK', '2');
$this->db->order_by('R.KODE_REKENING');
$result = $this->db->get();
return $result;
$this->db->trans_complete();
}
function proses_form_RekeningBL($skpd,$kegiatan)
{
/* if($this->input->post('PLAFON_BL')==''){
$plafon_bl = 0;
}
else{
$plafon_bl = $this->input->post('PLAFON_BL');
} */
$plafon_bl = $this->input->post('PLAFON');
$this->fill_data();
$this->db->trans_start();
$cek_kegiatan = $this->cek_kua_kegiatan($skpd,$kegiatan);
if(!$cek_kegiatan){
$new_kegiatan = array('TAHUN'=>$this->tahun,'STATUS'=>$this->status,
'ID_SKPD'=>$skpd,'ID_KEGIATAN'=>$kegiatan,'PLAFON'=>0,'TIPE'=>'RKA221');
$this->db->insert('KUA_PPAS', $new_kegiatan);
}
$cek = $this->cek_kua_rekening_kegiatan($skpd,$kegiatan,$this->input->post('ID_REKENING'));
$new_satuan = array('TAHUN'=>$this->tahun,'STATUS'=>$this->status,
'ID_SKPD'=>$skpd,'ID_KEGIATAN'=>$kegiatan,'ID_REKENING'=>$this->input->post('ID_REKENING'),'PLAFON'=>$plafon_bl,'TIPE'=>'RKA221');
if($cek){
$this->db->where('ID_SKPD', $skpd);
$this->db->where('ID_KEGIATAN', $kegiatan);
$this->db->where('ID_REKENING', $this->input->post('ID_REKENING'));
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$this->db->update('KUA_PPAS', $new_satuan);
}
else{
$this->db->insert('KUA_PPAS', $new_satuan);
}
//print_r($this->db->queries);
$this->db->trans_complete();
}
function cek_kua_rekening_kegiatan($ID_SKPD,$ID_KEGIATAN,$ID_REKENING)
{
$this->db->trans_start();
$this->db->select("count(PLAFON) plafon_exists");
$this->db->from('KUA_PPAS');
$this->db->where('TAHUN', $this->tahun);
$this->db->where('STATUS', $this->status);
$this->db->where('ID_SKPD', $ID_SKPD);
$this->db->where('ID_KEGIATAN', $ID_KEGIATAN);
$this->db->where('ID_REKENING', $ID_REKENING);
$result = $this->db->get()->row_array();
if ($result['PLAFON_EXISTS'] > 0)
{
return TRUE;
}
else
{
return FALSE;
}
$this->db->trans_complete();
}
}