| 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:/simbada/application/modules/penyusutan/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 = 0, canEdit = <?php echo $canEdit ? 'true' : 'false'; ?>;
$(document).ready(function() {
params = {
container : $('#search'),
grid : grid,
cols : <?php echo json_encode($grid['fields']); ?>,
}
Search.init(params);
grid.jqGrid({
url:'<?php echo base_url().$modul?>/get_daftar',
editurl:'<?php echo base_url().$modul?>/proses',
datatype:'json',
mtype:'POST',
colNames:[
'Kode Barang',
'Nama Barang',
'Penyusutan'
],
colModel:[
{name:'kd_maba', width:150, sortable:false},
{name:'nm_maba', width:750, sortable:false},
{name:'penyusutan', width:100, sortable:false, editable:true, editoptions:{
<?php if ($this->app_config['periode_penyusutan'] == 1) { ?>
maxlength: 3,
<?php } else { ?>
maxlength: 2,
<?php } ?>
size: 25, maxlengh: 30,
dataInit: function(element) {
$(element).keypress(function(e){
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
return false;
}
});
}
}
},
],
pager:'#pager',
rowNum:100,
scroll:1,
rownumbers:true,
viewrecords:true,
gridview:true,
shrinkToFit:false,
autowidth:true,
height:'400',
recordtext:'{2} baris',
sortname: 'kd_maba',
prmNames:{npage:'5'},
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: false,
addtext: 'Tambah',
addfunc:add_row,
edit: canEdit,
edittext: 'Ubah',
editfunc:edit_row,
del: false,
deltext: 'Hapus',
delfunc:del_row,
search:false,
refresh:true,
refreshtext:'Refresh',
},{},{},{},{});
function add_row(){
//
}
function edit_row(id){
if (!canEdit) return;
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){
//
}
function oneditfunc(id){
$('#'+id+'_penyusutan').focus();
}
function beforesavefunc(opt, id){
penyusutan = $('#'+id+'_penyusutan').val();
// Cek inputan kolom penyusutan
if (penyusutan == '' || penyusutan == 0) {
show_warning('Kolom penyusutan tidak boleh kosong.');
return false;
}
<?php
if ($this->app_config['periode_penyusutan'] == 1) {
?>
if (penyusutan < 12) {
show_warning('Periode : Bulanan, Penyusutan minimal 12.');
return false;
} else if (penyusutan > 600) {
show_warning('Periode : Bulanan, Penyusutan maksimal 600.');
return false;
}
<?php
} else {
?>
if (penyusutan < 1) {
show_warning('Periode : Tahunan, Penyusutan minimal 1.');
return false;
} else if (penyusutan > 50) {
show_warning('Periode : Tahunan, Penyusutan maksimal 50.');
return false;
}
<?php
}
?>
}
function aftersavefunc(id, resp){
oresp = JSON.parse(resp.responseText);
newid = oresp.id;
grid.jqGrid('setCell',id,'param','0');
if (oresp.isSuccess){
show_info(oresp.message, 'Sukses');
grid.jqGrid('setCell',id,'last_changed',oresp.last_changed);
if (newid !== id){
data = $(this).jqGrid('getRowData', id);
data.id = newid;
data.last_changed = oresp.last_changed;
$(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){
oresp = JSON.parse(resp.responseText);
return oresp.isSuccess;
}
function errorfunc(id, resp){
oresp = JSON.parse(resp.responseText);
show_error(oresp.message, 'Gagal');
}
function afterrestorefunc(){
$(this).focus();
}
function getNewid(){
return 'new_' + parseFloat((new Date().getTime() + '').slice(7))+ Math.round(Math.random() * 100);
}
});
</script>