Files
emonev/apps/js/mon/renja.js
T

475 lines
20 KiB
JavaScript

/*******************************************************************
App. Name : SISTEM INFORMASI MONITORING DAN EVALUASI
Module : /apps/js/mon/renja.js
Desc. : JS - Kelola Data Renja OPD
Created By : Siau Pheng ([email protected]).
Created Date : October 28th, 2011.
Last Modified : May 24th, 2026.
(c) 2011 - 2026, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var RenjaJS = {
PHP: '',
KODE: '',
loading: function(){
$('#butOPD').click(() => {
if ($('#OPDID').val()>0) this.show_hide(1);
});
$('#butPROG').click(() => {
if ($('#ProgID').val()>0) this.show_hide(2);
});
$('#butKEG').click(() => {
if ($('#KegID').val()>0) this.show_hide(3);
});
$('#butSUB').click(() => {
if ($('#SubID').val()>0) this.show_hide(4);
});
this.show_hide(1);
},
show_hide: function(no){
$('#divOPD').addClass('d-none'); $('#butOPD').removeClass('btn-secondary').addClass('btn-info');
$('#divPROG').addClass('d-none'); $('#butPROG').removeClass('btn-secondary').addClass('btn-info');
$('#divKEG').addClass('d-none'); $('#butKEG').removeClass('btn-secondary').addClass('btn-info');
$('#divSUB').addClass('d-none'); $('#butSUB').removeClass('btn-secondary').addClass('btn-info');
$('#divAKUN').addClass('d-none');
if (no == 1) {
$('#OPDID').val(0);
$('#ORGID').val(0);
$('#AK_Bidu').val('');
$('#K_Bidu1').val('');
$('#Nama_OPD').val('');
$('#Hak_Renja').val(1);
}
if (no <= 1) {
$('#ProgID').val(0);
$('#Nama_PROG').val('');
$('#butOPD').removeClass('btn-info').addClass('btn-secondary');
}
if (no <= 2) {
$('#KegID').val(0);
$('#Nama_KEG').val('');
$('#butPROG').removeClass('btn-info').addClass('btn-secondary');
}
if (no <= 3) {
$('#SubID').val(0);
$('#Nama_SUB').val('');
$('#butKEG').removeClass('btn-info').addClass('btn-secondary');
}
if (no <= 4) {
$('#butSUB').removeClass('btn-info').addClass('btn-secondary');
}
if (no == 1) { $('#divOPD').removeClass('d-none'); this.data_query('tabel-opd'); }
if (no == 2) { $('#divPROG').removeClass('d-none'); this.data_query('tabel-prog'); }
if (no == 3) { $('#divKEG').removeClass('d-none'); this.data_query('tabel-keg'); }
if (no == 4) { $('#divSUB').removeClass('d-none'); this.data_query('tabel-sub'); }
if (no == 5) { $('#divAKUN').removeClass('d-none'); this.data_query('tabel-akun'); }
},
opd_select: function(acell){
$('#OPDID').val(acell[0]);
$('#ORGID').val(acell[1]);
$('#Nama_OPD').val(acell[2]);
$('#AK_Bidu').val(acell[3]);
$('#K_Bidu1').val(acell[4]);
$('#Hak_Renja').val(acell[5]);
this.show_hide(2);
},
prog_select: function(acell){
$('#ProgID').val(acell[1]);
$('#Nama_PROG').val(acell[2]);
this.show_hide(3);
},
prog_brow: function() {
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_Prog" placeholder="Kunci Pencarian" type="text"><button class="btn btn-info shadow-none" type="button" id="butSearch">Cari</button><button class="btn btn-secondary shadow-none" type="button" id="butAll">Semua</button></div></div></div><div id="divBrowProg">&nbsp;</div>');
this.winBProg = FoniaJS.showWindow('BProg', 'Daftar Program', _isi, 900, '', () => {
$('#winBProg')
.find('#Cari_Prog').keydown((e) => {
var key = e.keyCode || e.which || 0;
if (key==13 && e.target.value!='') this.data_query('brow-prog');
}).end()
.find('#butSearch').click((e) => {
this.data_query('brow-prog');
}).end()
.find('#butAll').click(() => {
$('#winBProg').find('#Cari_Prog').val('');
this.data_query('brow-prog');
});
this.data_query('brow-prog');
});
},
prog_brow_select: function(acell) {
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-prog','mode_detail=insert','Hak_Renja','ORGID','OPDID','K_Bidu1','ProgID='+acell[0],'K_Bidu='+acell[1],'K_Prog='+acell[2]],
onSuccess: () => {
FoniaJS.closeWindow(this.winBProg);
FoniaJS.showInfo("Program baru telah ditambahkan.");
}
}).send();
},
prog_edit: function(acell){
$('#ProgID').val(acell[1]);
new Request({
url: this.PHP,
sendParam: ['data=detail-prog','Hak_Renja','ORGID','OPDID','ProgID','DPAProgID='+acell[0]],
onSuccess: (txt) => {
this.winProg = FoniaJS.showWindow('Prog', 'Detail Program', txt, 'xl', [{},{i:'butTutup'}], () => {
this.data_query('tabel-prog-indi');
});
}
}).send();
},
prog_indi_batal: function(){
var dt = $('#divProgIndiTabel').DataTable(), tr, l_row;
tr = $('#butBatalIndi').closest('tr');
l_row = dt.row(tr.prev('tr'));
if (l_row.child.isShown()) l_row.nodes().to$().find('.fon-tabel-dt').click();
if (l_row.data()[0]=='0') l_row.remove().draw(true);
},
prog_indi_add: function(){
var dt = $('#divProgIndiTabel').DataTable(), l_row;
dt.order([1,'asc']);
l_row = dt.row(':last');
if (!dt.data().count() || l_row.data()[0]!=='0'){
dt.row.add(['0','','','','<a class="table-icon fon-tabel-dt" tabindex="-1" title="Detail"><i class="bi-plus-circle-dotted"></i></a>']).draw(true);
l_row = dt.row(':last');
}
if (!l_row.child.isShown()) l_row.nodes().to$().find('.fon-tabel-dt').click();
},
prog_indi_form: function(acell, div){
new Request.JSON({
url: this.PHP,
sendParam: ['data=detail-prog-indi','Hak_Renja','ORGID','OPDID','ProgID','DPAProgIndiID='+acell[0]],
onSuccess: (adata) => {
$(div).html(adata.html);
$(div)
.find('#butSimpanIndi').click(() => this.prog_indi_save()).end()
.find('#butBatalIndi').click(() => this.prog_indi_batal());
}
}).send();
},
prog_indi_del: function(acell){
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <b>"'+acell[1]+'"</b> ?', () => {
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-prog-indi','mode_detail=delete','Hak_Renja','ORGID','OPDID','ProgID','DPAProgIndiID='+acell[0]],
onSuccess: () => FoniaJS.showInfo('Proses hapus data sukses!')
}).send();
}, 'danger');
},
prog_indi_save: function(){
if ($('#Text_Indi').val()==''){
FoniaJS.showInfo('Mohon lengkapi data Indikator Program !');
return false;
}
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-prog-indi','mode_detail','Hak_Renja','ORGID','OPDID','ProgID','DPAProgIndiID','TipeDataID','Status_Indi','Text_Indi','Target_Indi','Satuan_Indi'],
onSuccess: () => FoniaJS.showInfo('Sukses menyimpan Indikator Program.')
}).send();
},
keg_select: function(acell){
$('#KegID').val(acell[1]);
$('#Nama_KEG').val(acell[2]);
this.show_hide(4);
},
keg_brow: function() {
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_Keg" placeholder="Kunci Pencarian" type="text"><button class="btn btn-info shadow-none" type="button" id="butSearch">Cari</button><button class="btn btn-secondary shadow-none" type="button" id="butAll">Semua</button></div></div></div><div id="divBrowKeg">&nbsp;</div>');
this.winBKeg = FoniaJS.showWindow('BKeg', 'Daftar Kegiatan', _isi, 'xl', '', () => {
$('#winBKeg')
.find('#Cari_Keg').keydown((e) => {
var key = e.keyCode || e.which || 0;
if (key==13 && e.target.value!='') this.data_query('brow-keg');
}).end()
.find('#butSearch').click((e) => {
this.data_query('brow-keg');
}).end()
.find('#butAll').click(() => {
$('#winBKeg').find('#Cari_Keg').val('');
this.data_query('brow-keg');
});
this.data_query('brow-keg');
});
},
keg_brow_select: function(acell) {
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-keg','mode_detail=insert','Hak_Renja','ORGID','OPDID','ProgID','KegID='+acell[0],'K_Keg='+acell[1]],
onSuccess: () => {
FoniaJS.closeWindow(this.winBKeg);
FoniaJS.showInfo("Kegiatan baru telah ditambahkan.");
}
}).send();
},
sub_select: function(acell){
$('#SubID').val(acell[1]);
$('#Nama_SUB').val(acell[2]);
this.show_hide(5);
},
sub_brow: function() {
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_Sub" placeholder="Kunci Pencarian" type="text"><button class="btn btn-info shadow-none" type="button" id="butSearch">Cari</button><button class="btn btn-secondary shadow-none" type="button" id="butAll">Semua</button></div></div></div><div id="divBrowSub">&nbsp;</div>');
this.winBSub = FoniaJS.showWindow('BSub', 'Daftar Sub Kegiatan', _isi, 'xl', '', () => {
$('#winBSub')
.find('#Cari_Sub').keydown((e) => {
var key = e.keyCode || e.which || 0;
if (key==13 && e.target.value!='') this.data_query('brow-sub');
}).end()
.find('#butSearch').click((e) => {
this.data_query('brow-sub');
}).end()
.find('#butAll').click(() => {
$('#winBSub').find('#Cari_Sub').val('');
this.data_query('brow-sub');
});
this.data_query('brow-sub');
});
},
sub_brow_select: function(acell) {
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-sub','mode_detail=insert','Hak_Renja','ORGID','OPDID','ProgID','KegID','SubID='+acell[0],'K_Sub='+acell[1]],
onSuccess: () => {
FoniaJS.closeWindow(this.winBSub);
FoniaJS.showInfo("Sub Kegiatan baru telah ditambahkan.");
}
}).send();
},
sub_edit: function(acell){
$('#SubID').val(acell[1]);
new Request({
url: this.PHP,
sendParam: ['data=detail-sub','Hak_Renja','ORGID','OPDID','ProgID','KegID','SubID='+acell[1],'DPASubID='+acell[0]],
onSuccess: (txt) => {
const tombol = [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}];
if ($('#Hak_Renja').val()==0) tombol.pop();
this.winSub = FoniaJS.showWindow('Sub', 'Detail Sub Kegiatan', txt, 'xl', tombol, () => {
$('#winSub').find('#butWSimpan').click(() => this.sub_save());
$('#formSub').validate({
rules: {
required: true,
Waktu1: {required:true, min:1},
Waktu2: {required:true, min:1},
Target_Output: {required:true, min:1},
}
});
//this.data_query('tabel-sub-output')
});
}
}).send();
},
/*sub_output_batal: function(){
var dt = $('#divSubOutputTabel').DataTable(), tr, l_row;
tr = $('#butBatalOutput').closest('tr');
l_row = dt.row(tr.prev('tr'));
if (l_row.child.isShown()) l_row.nodes().to$().find('.fon-tabel-dt').click();
if (l_row.data()[0]=='0') l_row.remove().draw(true);
},
sub_output_add: function(){
var dt = $('#divSubOutputTabel').DataTable(), l_row;
dt.order([1,'asc']);
l_row = dt.row(':last');
if (!dt.data().count() || l_row.data()[0]!=='0'){
dt.row.add(['0','','','<a class="table-icon fon-tabel-dt" tabindex="-1" title="Detail"><i class="bi-plus-circle-dotted"></i></a>']).draw(true);
l_row = dt.row(':last');
}
if (!l_row.child.isShown()) l_row.nodes().to$().find('.fon-tabel-dt').click();
},
sub_output_form: function(acell, div){
new Request.JSON({
url: this.PHP,
sendParam: ['data=detail-sub-output','Hak_Renja','ORGID','OPDID','ProgID','KegID','SubID','DPASubOutputID='+acell[0]],
onSuccess: (adata) => {
$(div).html(adata.html);
$(div)
.find('#butBatalOutput').click((e) => this.sub_output_batal()).end()
.find('#butSimpanOutput').click((e) => this.sub_output_save());
}
}).send();
},
sub_output_del: function(acell){
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <b>"'+acell[1]+'"</b> ?', () => {
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-sub-output','mode_detail=delete','Hak_Renja','ORGID','OPDID','ProgID','KegID','SubID','DPASubOutputID='+acell[0]],
onSuccess: () => FoniaJS.showInfo('Proses hapus data sukses!')
}).send();
}, 'danger');
},
sub_output_save: function(){
if ($('#Text_Output').val()==''){
FoniaJS.showInfo('Mohon lengkapi data Output Sub Kegiatan !');
return false;
}
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-sub-output','mode_detail','Hak_Renja','ORGID','OPDID','ProgID','KegID','SubID','DPASubOutputID','Text_Output','Target_Output','Satuan_Output','Status_Output'],
onSuccess: () => FoniaJS.showInfo('Sukses menyimpan Output Sub Kegiatan.')
}).send();
},*/
sub_hapus: function(acell){
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <b>"'+acell[2]+'"</b> ?', () => {
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-sub','mode_detail=delete','Hak_Renja','ORGID','OPDID','ProgID','KegID','SubID','DPASubID='+acell[0]],
onSuccess: () => FoniaJS.showInfo('Proses hapus data sukses!')
}).send();
}, 'danger');
},
sub_save: function(){
$('#formSub').submit();
if (true !== $('#formSub').validate().checkForm()) return false;
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-sub','mode_detail=update','Hak_Renja','ORGID','OPDID','ProgID','KegID','SubID','DPASubID','Lokasi','Waktu1','Waktu2','Pagu_Dpn','DPASubOutputID','Text_Output','Sasaran_Output','Target_Output','Satuan_Output','Status_Output'],
onSuccess: () => {
FoniaJS.closeWindow(this.winSub);
FoniaJS.showInfo('Sukses menyimpan detail Sub Kegiatan.');
}
}).send();
},
akun_detail: function(mode, ID){
new Request({
url: this.PHP,
sendParam: ['data=detail-akun','Hak_Renja','ORGID','OPDID','ProgID','KegID','SubID','DPAAkunID='+ID],
onSuccess: (txt) => {
const tombol = [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}];
if ($('#Hak_Renja').val()==0) tombol.pop();
this.winDAkun = FoniaJS.showWindow('DAkun', 'Detail Akun', txt, 900, tombol, () => {
$('#winDAkun').find('#butWSimpan').click(() => this.akun_save());
this.Hitung_Akun();
});
}
}).send();
},
akun_tambah: function(){
this.akun_detail('insert', 0);
},
akun_ubah: function(acell){
this.akun_detail('update', acell[0]);
},
akun_hapus: function(acell){
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <b>"'+acell[3]+'"</b> ?', () => {
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-akun','mode_detail=delete','Hak_Renja','ORGID','OPDID','ProgID','KegID','SubID','DPAAkunID='+acell[0]],
onSuccess: () => FoniaJS.showInfo('Proses hapus data sukses!')
}).send();
}, 'danger');
},
akun_save: function(){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-akun','mode_detail','Hak_Renja','ORGID','OPDID','ProgID','KegID','SubID','AkunID','K_Akun','Volume','SatuanID','Harga_Satuan','Renc_Keu','Renc_Fisik','DPAAkunID'],
onSuccess: () => {
FoniaJS.closeWindow(this.winDAkun);
FoniaJS.showInfo('Sukses menyimpan detail Akun.');
}
}).send();
},
data_query: function(tipe, mode){
if (tipe=="tabel-opd"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-opd']
}).send();
} else if (tipe=="tabel-prog"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-prog','Hak_Renja','ORGID','OPDID']
}).send();
} else if (tipe=="tabel-prog-indi"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=tabel-prog-indi','Hak_Renja','ORGID','OPDID','ProgID']
}).send();
} else if (tipe=="tabel-keg" || tipe=="tabel-prog-indi"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data='+tipe,'Hak_Renja','ORGID','OPDID','ProgID']
}).send();
} else if (tipe=="tabel-sub"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data='+tipe,'Hak_Renja','ORGID','OPDID','ProgID','KegID']
}).send();
} else if (tipe=="tabel-akun" || tipe=="tabel-sub-output"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data='+tipe,'Hak_Renja','ORGID','OPDID','ProgID','KegID','SubID']
}).send();
} else if (tipe=="brow-prog"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-prog','ORGID','OPDID','AK_Bidu','Cari_Prog'],
onSuccess: () => FoniaJS.setFocus('#Cari_Prog')
}).send();
} else if (tipe=="brow-keg"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-keg','ORGID','OPDID','ProgID','Cari_Keg'],
onSuccess: () => FoniaJS.setFocus('#Cari_Keg')
}).send();
} else if (tipe=="brow-sub"){
new Request.JSONF({
url: this.PHP,
sendParam: ['data=brow-sub','ORGID','OPDID','ProgID','KegID','Cari_Sub'],
onSuccess: () => FoniaJS.setFocus('#Cari_Sub')
}).send();
}
},
Hitung_Akun: function(){
var harga = FoniaJS.StrToFloat($('#Harga_Satuan').val());
var volume = FoniaJS.StrToFloat($('#Volume').val());
$('#Pagu_Ini').val(FoniaJS.FloatToStr(harga * volume, 2));
$('#Renc_Keu').val(FoniaJS.FloatToStr(harga * volume, 2));
},
oc_ProgTipe: function(){
new Request.JSON({
url: this.PHP,
sendParam: ['data=change-tipedata','Hak_Renja','TipeDataID','Status_Indi','Target_Indi'],
onSuccess: (ajson) => {
$('#inputStatus').html(ajson.status);
$('#inputTarget').html(ajson.target);
}
}).send();
}
};