| 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/application/modules/tahun_anggaran/views/ |
Upload File : |
<fieldset>
<legend><?php echo $breadcrumbs;?></legend>
</fieldset>
<div id="grid_container">
<div id="search" class="row">
</div>
<table id="grid"></table>
<div id="pager"></div>
</div>
<script>
<?php
$akses = isset($akses) ? $akses : 0;
$canEdit = $akses >= 3;
$canPrint = $akses >= 2;
?>
var grid = $('#grid'), id = last = lastp = 0, canEdit = <?php echo $canEdit ? 'true' : 'false'; ?>;
$(document).ready(function() {
inisialisasi();
params = {
container : $('#search'),
grid : grid,
cols : <?php echo json_encode($grid['fields']); ?>,
}
Search.init(params);
grid.jqGrid({
url:'<?php echo base_url().$modul?>/get_tahun',
editurl:'<?php echo base_url().$modul?>/proses',
datatype: 'json',
mtype: 'POST',
colNames: ['Tahun', 'Status Awal'],
colModel: [
{name: 'tahun', key: true, width: 100, editable: true, edittype: 'text', editoptions:{maxlength:4}},
{name: 'status', width: 600, editable:true, editoptions:{dataInit:initselect2_status}},
],
pager:'#pager',
rowNum:1000000,
scroll:true,
rownumbers:true,
viewrecords:true,
gridview:true,
shrinkToFit:false,
autowidth:true,
height:'400',
recordtext:'{2} baris',
sortname: 'tahun',
subGrid:true,
subGridRowExpanded: subGridRowExpanded,
onSelectRow: function(id){
if(id && id!==last){
$(this).restoreRow(last);
last=id;
}
},
ondblClickRow: edit_row,
});
grid.jqGrid('bindKeys', {"onEnter": edit_row});
grid.jqGrid('navGrid', '#pager', {
add: canEdit,
addtext: 'Tambah',
addfunc:add_row,
edit: canEdit,
edittext: 'Ubah',
editfunc:edit_row,
del:canEdit,
deltext: 'Hapus',
delfunc:del_row,
search:false,
refresh: true,
refreshtext:'Refresh',
},{},{},{},{});
function add_row(){
if (!canEdit) return;
var curid = $(this).jqGrid('getGridParam','selrow');
// jika daftar status di expand, di collapse dulu
var sub = $('#grid_'+curid);
if (sub.length > 0){
$(this).jqGrid('collapseSubGridRow', curid);
}
var newid = --id;
var editparam = {
keys : true,
aftersavefunc: aftersavefunc,
beforeSaveRow: beforesavefunc,
afterrestorefunc: afterrestorefunc,
oneditfunc: oneditfunc,
successfunc: successfunc,
errorfunc: errorfunc,
restoreAfterError: false,
}
$(this).jqGrid('addRowData', newid, {});
$("#"+newid).addClass("jqgrid-new-row");
$(this).jqGrid('editRow', newid, editparam);
$(this).jqGrid('setSelection', newid);
}
function edit_row(id){
var row = $(this).jqGrid('getRowData', id);
if (!canEdit) return;
var editparam = {
keys : true,
aftersavefunc: aftersavefunc,
beforeSaveRow: beforesavefunc,
afterrestorefunc: afterrestorefunc,
oneditfunc: oneditfunc,
successfunc: successfunc,
errorfunc: errorfunc,
restoreAfterError: false,
}
$(this).jqGrid('editRow', id, editparam);
last = id;
}
function del_row(id){
var self = this, row = $(this).jqGrid('getRowData', id);
if (!canEdit) return;
var grid = $(this),
question = 'Hapus Tahun dari daftar ?';
confirmation(question).then(function(answer){
if (!answer) return;
// jika daftar status di expand, di collapse dulu
var sub = $('#grid_'+id+'_t');
if (sub.length > 0){
$(self).jqGrid('collapseSubGridRow', id);
}
$.ajax({
url: '<?php echo base_url().$modul?>/hapus',
type: "post",
dataType: "json",
data: { id: id},
success: function(res){
if(res.isSuccess == true) {
show_info(res.message, 'Sukses');
grid.jqGrid('delRowData', id);
}
else {
show_error(res.message, 'Gagal');
if(res.error=="exist") grid.trigger('reloadGrid');
}
},
});
});
}
function oneditfunc(id){
// focus ke elemen pertama
$('#'+id+'_tahun').focus();
}
function beforesavefunc(opt, id){
/* remove select2 */
$('#'+id+'_status').select2('destroy');
// pastikan tahun sudah diisi
}
function aftersavefunc(id, resp){
var oresp = JSON.parse(resp.responseText);
var newid = oresp.id;
if (oresp.isSuccess){
show_info(oresp.message, 'Sukses');
$(this).trigger('reloadGrid');
setTimeout(function() { $('#grid').jqGrid('setSelection', id, true); }, 500);
if (newid !== id){
var data = $(this).jqGrid('getRowData', id);
data.id = newid;
$(this).jqGrid('addRowData', newid, data, 'after', id);
$(this).jqGrid('delRowData', id);
$(this).jqGrid('setSelection', newid)
last = id;
}
}
else {
show_error(oresp.message, 'Gagal');
return false;
}
// $(this).focus();
}
function successfunc(resp){
var oresp = JSON.parse(resp.responseText);
return oresp.isSuccess;
}
function errorfunc(id, resp){
var oresp = JSON.parse(resp.responseText);
show_error(oresp.message, 'Gagal');
}
function afterrestorefunc(){
$(this).focus();
}
query_status = function(option){
var id = grid.jqGrid('getGridParam', 'selrow'),
tahun = $('#'+id+'_tahun').val();
$.ajax({
url: "<?php echo base_url()?>pilih/status",
type: 'POST',
dataType: 'json',
data: {
'q': option.term,
'tahun': tahun,
},
success: function (data) {
if(option.term.length > 0){
data.results.push({id: option.term, text: option.term });
}
option.callback({
results: data.results
});
}
});
}
function initselect2_status(el){
var oid = el.id;
$(el).select2({
minimumInputLength: 0,
query: query_status,
placeholder: 'Pilih Status Awal',
allowClear: true,
openOnEnter: false,
dropdownAutoWidth : true,
initSelection: function(element, callback){
var data = {'text': element.val()};
callback(data);
},
});
$(el).on('change', function(e){
$(e.target).val(e.added ? e.added.text : '');
});
$('#s2id_' + oid).on('keyup', function(e){
if (e.keyCode === 13) {
ev = $.Event('keydown');
ev.keyCode= 13;
$(el).trigger(ev);
}
});
}
/* satatus */
function subGridRowExpanded(subgrid_id, row_id){
var tblStatus, pgrStatus;
tblStatus = subgrid_id+"_t"; pgrStatus = subgrid_id+"p_";
$("#"+subgrid_id).html("<table id='"+tblStatus+"' class='scroll'></table><div id='"+pgrStatus+"' class='scroll'></div>");
$("#"+tblStatus).jqGrid({
url:'<?php echo base_url().$modul ?>/get_status'+'/'+row_id,
editurl:'<?php echo base_url().$modul?>/proses_status',
datatype:'json',
mtype:'POST',
colNames:['Status', 'Tgl. RKA', 'No. DPA', 'Tgl. DPA', 'No. APBD', 'Tgl. APBD', 'No. Perkada', 'Tgl. Perkada'],
colModel:[
{name:'status', key: true, width: 150, editable:true, edittype:'text', editoptions:{maxlength:20}},
{name:'tgl_rka', width: 80, editable:true, edittype:'text', editoptions:{class: 'datepicker'}, align: 'center'},
{name:'no_dpa', width: 120, editable:true, edittype:'text', editoptions:{maxlength:50}},
{name:'tgl_dpa', width: 80, editable:true, edittype:'text', editoptions:{class: 'datepicker'}, align: 'center'},
{name:'no_apbd', width: 120, editable:true, edittype:'text', editoptions:{maxlength:50}},
{name:'tgl_apbd', width: 80, editable:true, edittype:'text', editoptions:{class: 'datepicker'}, align: 'center'},
{name:'no_perkada', width: 120, editable:true, edittype:'text', editoptions:{maxlength:50}},
{name:'tgl_perkada', width: 80, editable:true, edittype:'text', editoptions:{class: 'datepicker'}, align: 'center'},
],
rownumbers:true,
rowNum:10,
pager:"#"+pgrStatus,
sortorder:'asc',
viewrecords:true,
gridview:true,
height: '100%',
onSelectRow: function(id){
if(id && id!==lastp){
$(this).restoreRow(lastp);
lastp=id;
}
},
ondblClickRow:dblClickStatus,
loadComplete: function(){
$(this).jqGrid('setGridParam', {tahun: row_id});
}
});
$("#"+tblStatus).jqGrid('bindKeys', { "onEnter": edit_status});
$("#"+tblStatus).jqGrid( 'navGrid', "#"+pgrStatus, {
add: canEdit,
addtext: 'Tambah',
addfunc: add_status,
edit: canEdit,
edittext: 'Ubah',
editfunc: edit_status,
del: canEdit,
deltext: 'Hapus',
delfunc: del_status,
search: false,
searchtext: 'Cari',
refresh: true,
refreshtext: 'Refresh',
},{},{},{},{});
}
function add_status(){
if (!canEdit) return;
var tahun = $(this).jqGrid('getGridParam', 'tahun'),
addparam = {
rowID : --id,
position :"last",
addRowParams : {
keys : true,
aftersavefunc: aftersave_status,
beforeSaveRow: beforesave_status,
oneditfunc: onedit_status,
afterrestorefunc: afterrestore_status,
successfunc: successfunc,
errorfunc: errorfunc,
extraparam:{tahun: tahun},
restoreAfterError: false,
}
}
$(this).jqGrid('addRow', addparam);
}
function dblClickStatus(id, irow, icol, e){
e.stopPropagation();
edit_status.call(this, id);
}
function edit_status(id){
if (!canEdit) return;
var tahun = $(this).jqGrid('getGridParam', 'tahun'),
editparam = {
keys : true,
aftersavefunc: aftersave_status,
beforeSaveRow: beforesave_status,
oneditfunc: onedit_status,
afterrestorefunc: afterrestore_status,
successfunc: successfunc,
errorfunc: errorfunc,
extraparam:{tahun: tahun, oldstatus: id},
restoreAfterError: false,
}
$(this).jqGrid('editRow', id, editparam);
lastp = id;
return false;
}
function del_status(id){
if (!canEdit) return;
var grid = $(this),
tahun = $(this).jqGrid('getGridParam', 'tahun'),
question = 'Hapus Status dari daftar ?';
confirmation(question).then(function(answer){
if (!answer) return;
$.ajax({
url: '<?php echo base_url().$modul?>/hapus_status',
type: "post",
dataType: "json",
data: { tahun: tahun, status: id},
success: function(res){
if (res.isSuccess) show_info(res.message, 'Sukses');
else show_error(res.message, 'Gagal');
if(res.isSuccess == true) {
grid.jqGrid('delRowData', id);
}
},
});
});
}
function aftersave_status(id, resp){
var oresp = JSON.parse(resp.responseText);
var newid = oresp.id;
if (oresp.isSuccess){
show_info(oresp.message, 'Sukses');
if (newid !== id){
data = $(this).jqGrid('getRowData', id);
data.id = newid;
$(this).jqGrid('addRowData', newid, data, 'after', id);
$(this).jqGrid('delRowData', id);
$(this).jqGrid('resetSelection')
$(this).jqGrid('setSelection', newid)
last = id;
}
}
else {
show_error(oresp.message, 'Gagal');
}
$(this).focus();
}
function beforesave_status(opt, id){
var status = $('#'+id+'_status').val();
if (status == '' ){
show_warning('Status belum di isi.', 'Perhatian');
return false;
}
}
function onedit_status(id){
// focus ke elemen pertama
$('#'+id+'_status').focus();
$('.datepicker').datepicker();
}
function successfunc(resp){
oresp = JSON.parse(resp.responseText);
return oresp.isSuccess;
}
function errorfunc(id, resp){
oresp = JSON.parse(resp.responseText);
show_error(oresp.message, 'Gagal');
}
function afterrestore_status(id){
$(this).focus();
}
grid.gridResize();
});
</script>