/******************************************************************* App. Name : SISTEM INFORMASI MONITORING DAN EVALUASI Module : /apps/js/mon/kinerja.js Desc. : JS - Kelola Realisasi Kinerja OPD Created By : Siau Pheng (siaupheng@3fonia.com). Created Date : December 7th, 2011. Last Modified : September 7th, 2026. (c) 2011 - 2026, 3FONIA Software; WWW.3FONIA.COM. *******************************************************************/ var KinerjaJS = { 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); $('#Nama_OPD').val(''); $('#Hak_Bln').val(1); $('#Hak_Tw').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]); $('#Hak_Bln').val(acell[3]); $('#Hak_Tw').val(acell[4]); this.show_hide(2); }, prog_select: function(acell){ $('#ProgID').val(acell[1]); $('#Nama_PROG').val(acell[2]); this.show_hide(3); }, prog_real: function(acell){ $('#ProgID').val(acell[1]); new Request({ url: this.PHP, sendParam: ['data=detail-prog','Hak_Tw','ORGID','OPDID','ProgID','DPAProgID='+acell[0]], onSuccess: (txt) => { const tombol = [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}]; if ($('#Hak_Tw').val()==0) tombol.pop(); this.winProg = FoniaJS.showWindow('Prog', 'Detail Capaian Program', txt, 'xl', tombol, () => { $('#winProg').find('#butWSimpan').click(() => this.prog_save()); }); } }).send(); }, prog_save: function(){ var _kosong = 0; $(':input[id^="Prog_TW_"]').each((i,e) => { var _id = e.id.replace('Prog_TW', ''); if (e.value && e.value.trim() !== '' && parseFloat(e.value) > 0) { var _sumber = $('#Sumber_TW'+_id); _catat = $('#Catat_TW'+_id); _sumber.removeClass("is-valid is-invalid") _catat.removeClass("is-valid is-invalid") if (_sumber.val() === '') { _kosong++; _sumber.addClass("is-invalid").focus(); } else { _sumber.addClass("is-valid") } if (_catat.val() === '') { _kosong++; _catat.addClass("is-invalid").focus(); } else { _catat.addClass("is-valid") } } }); if (_kosong > 0) { FoniaJS.showError('Tolong lengkapi Sumber Data / Eviden.'); return false; } var _param = ['data=tabel-prog','mode_detail=update','Hak_Tw','ORGID','OPDID','ProgID','DPAProgID']; $(':input[id^="Prog_TW_"]').each((i,e) => { _param.push(e.id); }); $(':input[id^="Sumber_TW_"]').each((i,e) => { _param.push(e.id); }); $(':input[id^="Catat_TW_"]').each((i,e) => { _param.push(e.id); }); new Request.JSONF({ url: this.PHP, sendParam: _param, onSuccess: () => { FoniaJS.closeWindow(this.winProg); FoniaJS.showInfo('Sukses menyimpan Capaian Program.'); } }).send(); }, keg_select: function(acell){ $('#KegID').val(acell[1]); $('#Nama_KEG').val(acell[2]); this.show_hide(4); }, sub_select: function(acell){ $('#SubID').val(acell[1]); $('#Nama_SUB').val(acell[2]); this.show_hide(5); }, sub_ubah: function(acell){ $('#SubID').val(acell[1]); new Request({ url: this.PHP, sendParam: ['data=detail-sub','Hak_Bln','ORGID','OPDID','ProgID','KegID','SubID='+acell[1],'DPASubID='+acell[0]], onSuccess: (txt) => { const tombol = [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}]; if ($('#Hak_Bln').val()==0) tombol.pop(); this.winDSub = FoniaJS.showWindow('DSub', 'Kinerja dan Informasi Sub Kegiatan', txt, 'xl', tombol, () => { $('#winDSub') .find('#butWSimpan').click(() => this.sub_save()).end() .find('#FileEviden1').off('change').change(() => { const allow_ext = ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'png', 'jpg', 'mpg', 'mp4']; var fd = new FormData(), files = $('#FileEviden1')[0].files[0]; var filext = files.name.split('.').pop().toLowerCase(); if ($.inArray(filext, allow_ext) === -1) { FoniaJS.showError('Jenis File tidak dapat diterima !'); return false; } fd.append('Eviden1', files); fd.append('ORGID', $('#ORGID').val()); fd.append('OPDID', $('#OPDID').val()); fd.append('DPASubID', $('#DPASubID').val()); $.ajax({ url: this.PHP + '?data=eviden-upload', type: 'post', data: fd, contentType: false, processData: false, success: (ares) => { var _dok = $('#LabelEviden1'); _dok.removeClass("btn-outline-success btn-outline-danger") if (ares && ares.result !== 0){ FoniaJS.showInfo('Sukses upload file Dokumen Eviden !'); $('#Eviden_Name').html(ares.Eviden_Name); $('#Eviden_TW').val(ares.Eviden_TW); _dok.addClass("btn-outline-success") } else { _dok.addClass("btn-outline-danger"); FoniaJS.showError(ares.message ?? 'Ada masalah dalam proses upload Dokumen Eviden !'); } } }); }); this.data_query('tabel-eviden'); }); } }).send(); }, sub_save: function(){ var _kosong = 0; var _evi = $('#Real_TW').val(); if (_evi && _evi.trim() !== '' && parseFloat(_evi) > 0) { var _dok = $('#LabelEviden1'); _dok.removeClass("btn-outline-success btn-outline-danger") if (parseInt($('#Eviden_TW').val()) === 0) { _kosong++; _dok.addClass("btn-outline-danger"); } else { _dok.addClass("btn-outline-success") } var _catat = $('#Real_Catatan'); _catat.removeClass("is-valid is-invalid") if (_catat.val() === '') { _kosong++; _catat.addClass("is-invalid").focus(); } else { _catat.addClass("is-valid") } } if (_kosong > 0) { FoniaJS.showError('Tolong lengkapi Eviden / Catatan.'); return false; } var _param = ['data=tabel-sub','Hak_Bln','ORGID','OPDID','ProgID','KegID','SubID','DPASubID','Real_Catatan','Real_No_Kontrak','Real_Pelaksana','DPASubOutputID','Real_TW','mode_detail=update']; new Request.JSONF({ url: this.PHP, sendParam: _param, onSuccess: () => { FoniaJS.closeWindow(this.winDSub); FoniaJS.showInfo('Sukses menyimpan Kinerja Sub Kegiatan.'); } }).send(); }, eviden_open_doc: function(nfile){ FoniaJS.showConfirm('Konfirmasi', 'Yakin akan buka file Dokumen ?', () => { window.open(nfile); }, 'info'); }, eviden_open_pdf: function(nfile){ var dpdf = new cPDF(nfile); dpdf.set_zoom(100); dpdf.showPDF(); }, eviden_hapus: function(id, nama){ FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus "'+nama+'" ?', () => { new Request.JSON({ url: this.PHP, sendParam: ['data=tabel-eviden','mode_detail=delete','ORGID','OPDID','ProgID','KegID','SubID','DPASubID','DPAEvidenID='+id], onSuccess: (ajson) => { FoniaJS.showInfo('Proses hapus file sukses!'); this.create_Eviden_Table(ajson); } }).send(); }, 'danger'); }, akun_ubah: function(acell){ new Request({ url: this.PHP, sendParam: ['data=detail-akun','Hak_Bln','ORGID','OPDID','ProgID','KegID','SubID','DPAAkunID='+acell[0]], onSuccess: (txt) => { const tombol = [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}]; if ($('#Hak_Bln').val()==0) tombol.pop(); this.winDAkun = FoniaJS.showWindow('DAkun', 'Detail Akun', txt, 'xl', tombol, () => { $('#winDAkun') .find('#butWSimpan').click(() => this.akun_save()).end() .find('#RealK_Tot').keyup((e) => { this.oc_RealK(); if ((e.keyCode || e.which || 0)==13) FoniaJS.setFocus('#RealF_Tot'); }).attr('title', 'Total Realisasi Keuangan S/D Bulan ini !').end() .find('#RealF_Tot').keyup((e) => { this.oc_RealF(); if ((e.keyCode || e.which || 0)==13) FoniaJS.setFocus('#RealN_Tot'); }).attr('title', 'Total Realisasi Fisik S/D Bulan ini !').end() .find('#RealN_Tot').keyup((e) => { this.oc_RealN(); if ((e.keyCode || e.which || 0)==13) $('#winDAkun').find('#butWSimpan').focus(); }).attr('title', 'Total Realisasi Non-Fisik S/D Bulan ini !').end() if (parseInt($('#Hak_Bln').val())==1) FoniaJS.setFocus('#RealK_Tot'); }); } }).send(); }, akun_save: function(){ var treal = FoniaJS.StrToFloat($('#RealK_Tot').val()); var tpagu = parseFloat($('#PAGURP').val()); if (treal > tpagu) { FoniaJS.showError('Total Realisasi tidak boleh melebihi Total Pagu !'); FoniaJS.setFocus('#RealK_Tot'); return; } /*var real_lalu = FoniaJS.StrToFloat($('#RealF_Las').val()); var real_psn = FoniaJS.StrToFloat($('#RealF_Tot').val()); if (real_psn < real_lalu){ FoniaJS.showError('Realisasi Fisik lebih rendah dari Bulan lalu !'); FoniaJS.setFocus('#RealF_Tot'); return; }*/ new Request.JSONF({ url: this.PHP, sendParam: ['data=tabel-akun','mode_detail=update','Hak_Bln','ORGID','OPDID','ProgID','KegID','SubID','DPAAkunID','AkunID','RealK_Bln','RealF_Bln','RealN_Bln'], onSuccess: (adata) => { FoniaJS.closeWindow(this.winDAkun); FoniaJS.showInfo('Sukses menyimpan Realisasi Akun.'); } }).send(); }, create_Eviden_Table: function(ajson) { var opsi = { responsive: true, columnDefs: [{responsivePriority:1,targets:0}, {responsivePriority:2,targets:-1}, {orderable:false,targets:-1}], dom: 'r<"row"<"col-sm-12"t>><"row"<"col-sm-12 col-md-6"<"toolbar">><"col-sm-12 col-md-6"p>>', autoWidth: false, processing: true, searching: false }; opsi.drawCallback = function(){ $('#tabelEviden tbody').on('click', '.fon-tabel-dt', (e) => { var tr = $(e.currentTarget).closest('tr'); var row = otabel.row(tr); if (row.child.isShown()){ row.child.hide(); tr.removeClass('shown'); }else{ if (otabel.row('.shown').length){ $('.fon-tabel-dt', otabel.row('.shown').node()).click(); } var _dt_id = $('
'); row.child(_dt_id).show(); tr.addClass('shown'); ValidKinerjaJS.eviden_form(row.data(), _dt_id); } }); $('#tabelEviden tbody').on('click', 'td.dtr-control', (e) => { var tr = $(e.currentTarget).closest('tr'); var row = otabel.row(tr); if (row.child.isShown()){ row.child.hide(); tr.removeClass('dt-hasChild parent'); }else{ var ind = 0; var tampil = '