function import_dpp(){
var fields_va = RH.storeFields('idva','tglva','jamva',
'keterangan','nmfile','userid','nmlengkap');
var pageSize = 18;
var ds_va = RH.JsonStore({
url : BASE_URL + 'import_dpp_controller/get_importvabank',
fields : fields_va,
limit: pageSize,
enableSearch: true,
});
//SEARCH COMPONENT
var sb_va = RH.searchComp({
id : 'sb_va',
fields : ['tglva:Tanggal','jamva:Jam','keterangan:Keterangan','nmfile:File','nmlengkap:Importer'],
selected : 'tglva',
store : ds_va
});
// COLUMN MODEL
var cm_va = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
{
header: RH.h3('Tanggal'),width: 100,
dataIndex: 'tglva',
sortable: true
}, {
header: RH.h3('Jam'), width: 100,
dataIndex: 'jamva',
sortable: true
}, {
header: RH.h3('Keterangan'), width: 300,
dataIndex: 'keterangan',
sortable: true
}, {
header: RH.h3('File'), width: 300,
dataIndex: 'nmfile',
sortable: true
}, {
header: RH.h3('Importer'), width: 200,
dataIndex: 'nmlengkap',
sortable: true
},
RH.EditColumn(), RH.DeleteColumn()
]
);
/** THE GRID */
var gp_va = RH.GridPanel_T1({
ds: ds_va,
cm: cm_va,
singleSelect: true,
searchComp: sb_va,
allowAdd: true,
fnAdd: fnAddVa,
pageSize: pageSize,
cellclick: onCellVaClick
});
var fp_va = RH.GPContainer1({
title: 'Import Pembayaran DPP/DPK via Transfer Bank', iconCls:'silk-money',
gridPanel: gp_va,
}); SET_PAGE_CONTENT(fp_va);
/**
FUNCTIONS
*/
function onCellVaClick(grid, rowIndex, columnIndex, e) {
var record = grid.getStore().getAt(rowIndex); // Get the Record
RH.EditClick(e, function(){fnEditVa(grid, record)});
RH.DeleteClick(e, function(){fnDeleteVa(grid, record)});
}
function reloadVa(){
ds_va.reload();
}
function fnAddVa(){
var grid = gp_va;
wEntryVa(false, grid, null);
}
function fnEditVa(grid, record){
wEntryVa(true, grid, record);
}
function fnDeleteVa(grid, record){
var url = BASE_URL + 'import_dpp_controller/delete_va';
var params = new Object({
idvax : record.data['idva'],
filex : record.data['nmfile']
});
Ext.Msg.show({
title: 'Konfirmasi',
msg: 'Hapus data yang dipilih?
Catatan: Data Kuitansi Akan Terhapus',
buttons: Ext.Msg.YESNO,
icon: Ext.MessageBox.QUESTION,
fn: function (response) {
if ('yes' !== response) {
return;
}
Ext.Ajax.request({
url: url,
method: 'POST',
params: params,
success: function() {
Ext.Msg.alert("Info", "Hapus Data Berhasil");
grid.getStore().reload();
},
failure: function(result){
Ext.MessageBox.alert("Info", "Hapus Data Gagal");
}
});
}
});
}
function wEntryVa(isUpdate, grid, record){
var winTitle = (isUpdate)?'IMPORT DPP/DPK (Edit)':'IMPORT DPP/DPK (Entry)';
var SYS_DATE = new Date();
var ds_grid = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: BASE_URL + 'import_dpp_controller/preview_data',
method: 'POST'
}),
root: 'data',
totalProperty: 'results',
autoLoad: false,
fields: [{
name: "nokuitansi",
mapping: "nokuitansi"
},
{
name: "tglkuitansi",
mapping: "tglkuitansi"
},
{
name: "jamkuitansi",
mapping: "jamkuitansi"
},
{
name: "noref",
mapping: "noref"
},
{
name: "idjnsbiaya",
mapping: "idjnsbiaya"
},
{
name: "kdjnsbiaya",
mapping: "kdjnsbiaya"
},
{
name: "kdstsemester",
mapping: "kdstsemester"
},
{
name: "nmthnakademik",
mapping: "nmthnakademik"
},
{
name: "nim",
mapping: "nim"
},
{
name: "nmmhs",
mapping: "nmmhs"
},
{
name: "jmlbayar",
mapping: "jmlbayar"
},
{
name: "useridinput",
mapping: "useridinput"
},
{
name: "idstkuitansi",
mapping: "idstkuitansi"
},
{
name: "nmstkuitansi",
mapping: "nmstkuitansi"
}],
listeners: {
load: function(store, records, options) {
Ext.getCmp('count').setValue(ds_grid.getCount());
if (ds_grid.getCount()>0) {
Ext.getCmp('bsimpanimport').enable();
}
}
}
});
var grid_nya = new Ext.grid.EditorGridPanel({
store: ds_grid,
frame: true,
height: 350,
autoWidth: true,
bodyStyle: 'padding:3px 3px 3px 3px',
id: 'grid_nya',
autoScroll: true,
autoSizeColumns: true,
columnLines: true,
loadMask: true,
layout: 'anchor',
tbar: [{
text: 'Simpan', id: 'bsimpanimport', iconCls:'silk-save', disabled: true,
handler: function() {
fnSaveVa();
}
}, {
text: 'Kembali', iconCls:'silk-arrow-undo',
handler: function() {
wVa.close();
}
}],
columns: [
new Ext.grid.RowNumberer({ width: 35 }),
{
header: 'No. Kuitansi',
width: 120, align: 'left',
dataIndex: 'nokuitansi',
sortable: true
},{
header: 'Tanggal Transaksi',
width: 120, align: 'center',
dataIndex: 'tglkuitansi',
sortable: true
},{
header: 'Jam Transaksi',
width: 100, align: 'center',
dataIndex: 'jamkuitansi',
sortable: true
},{
header: 'No. Reff',
width: 130, align: 'left',
dataIndex: 'noref',
sortable: true
},{
header: 'Jenis Biaya',
width: 80, align: 'center',
dataIndex: 'kdjnsbiaya',
sortable: true
},{
header: 'Tahun Akademik - Semester',
width: 170, align: 'center',
dataIndex: 'nmthnakademik',
sortable: true
},{
header: 'NIM',
width: 100, align: 'center',
dataIndex: 'nim',
sortable: true
},{
header: 'Nama Mahasiswa',
width: 200, align: 'left',
dataIndex: 'nmmhs',
sortable: true
},{
header: 'Jumlah Bayar',
width: 80, align: 'right',
dataIndex: 'jmlbayar',
sortable: true,
xtype: 'numbercolumn', format:'0,000', align:'right'
},{
header: 'Status',
width: 80, align: 'center',
dataIndex: 'nmstkuitansi',
sortable: true
}],
bbar:['->',{
text: 'Total Data: '
},{
xtype: 'textfield',
fieldLabel: '',
labelStyle: 'width:160px',
id: 'count',
width: 50,
listeners: {}
}]
});
/**
FORM ENTRY/EDIT IMPORT DPP
*/
var va_form = new Ext.form.FormPanel({
xtype:'form',
id: 'va_form',
buttonAlign: 'left',
labelWidth: 200, labelAlign: 'right',
bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri
monitorValid: true,
height: 550, width: 1300,
layout: 'form',
frame: true,
fileUpload: true,
defaultType:'textfield',
items: [{
xtype:'fieldset',
title: 'Header Data',
items :[{
layout: 'column',
border: false,
items: [{
columnWidth: .50,
layout: 'form',
border: false,
items: [{
xtype: 'textarea',
fieldLabel: 'Keterangan',
id: 'keterangan',
width: 250,
height: 50,
listeners: {}
}]
},
{
columnWidth: .50,
layout: 'form',
border: false,
items: [{
xtype: 'textfield',
fieldLabel: 'Importer',
id: 'importer',
readOnly:true,
width: 200,
value:USERNAME,
listeners: {}
},
{
xtype: 'compositefield',
name: 'time',
fieldLabel: 'Tanggal / Jam',
id: 'time',
items: [{
xtype: 'datefield',
fieldLabel: '',
id: 'tglva',
width: 100,
name: 'tglva'
},
{
xtype: 'textfield',
fieldLabel: '',
id: 'jamva',
readOnly:true,
width: 95,
name: 'jamva'
}]
},
{
xtype: 'textfield',
fieldLabel: '',
labelStyle: 'width:160px',
id: 'userid',
hidden:true,
width: 150,
value:USERID,
listeners: {}
}]
}]
}]
},
{
xtype:'fieldset',
title: 'Detail Data',
items :[{
layout: 'column',
border: false,
items: [{
columnWidth: .63,
layout: 'form',
border: false,
items: [{
xtype: 'fileuploadfield',
id: 'f_excel',
emptyText: 'Select an file',
fieldLabel: 'File Excel',
name: 'f_excel',
anchor: '99%',
buttonText: '',
buttonCfg: {
iconCls: 'silk-page-copy'
},
listeners: {
valid: function() {
}
}
}]
},
{
columnWidth: .37,
layout: 'form',
border: false,
items: [{
xtype: 'button',
text: 'Preview Data',
id: 'btn_preview',
width: 70,
handler: function() {
get_data('va_form');
}
}]
}]
},grid_nya]
}]
});
var wVa = new Ext.Window({
title: winTitle,
modal: true, closable:false,
items: [va_form]
});
/**
CALL SET FORM AND SHOW THE FORM (WINDOW)
*/
setVaForm(isUpdate, record);
wVa.show();
/**
FORM FUNCTIONS
*/
function setVaForm(isUpdate, record){
if(isUpdate){
if(record != null){
RH.setCompValue('keterangan', record.data['keterangan']);
RH.setCompValue('tglva', record.data['tglva']);
RH.setCompValue('jamva', record.data['jamva']);
RH.setCompValue('userid', record.data['userid']);
RH.setCompValue('importer', record.data['nmlengkap']);
RH.setCompValue('f_excel', record.data['nmfile']);
Ext.getCmp('tglva').disable();
Ext.getCmp('jamva').disable();
Ext.getCmp('userid').disable();
Ext.getCmp('importer').disable();
Ext.getCmp('f_excel').disable();
Ext.getCmp('btn_preview').disable();
ds_grid.proxy.conn.url = BASE_URL + 'import_dpp_controller/get_imported';
ds_grid.setBaseParam('idva',record.data['idva']);
ds_grid.reload();
return;
}
} else {
Ext.getCmp('tglva').setValue(SYS_DATE);
setInterval(function() {
var d = new Date();
var t = d.toLocaleTimeString();
if (Ext.getCmp('jamva'))
Ext.getCmp('jamva').setValue(t);
}, 1000);
}
}
//ambil record hasil import dari excel======================================
function get_data(namaForm) {
var form_nya = Ext.getCmp(namaForm);
var xls = Right(Ext.getCmp('f_excel').getValue(),3);
if (xls) {
if (xls=="xls") {
//grid_nya.getStore().removeAll();
ds_grid.removeAll();
form_nya.getForm().submit({
url: BASE_URL + 'import_dpp_controller/upload_data',
method: 'POST',
waitMsg: 'Tunggu, sedang proses...',
success: function(form_nya, o) {
ds_grid.setBaseParam('excel',Ext.getCmp('f_excel').getValue());
ds_grid.load();
}
,
failure: function() {
Ext.MessageBox.alert('Informasi', 'Proses Import Gagal');
}
});
} else {
Ext.MessageBox.alert('Informasi', 'File Harus Berekstensi .xls');
Ext.getCmp('f_excel').setValue();
}
} else {
Ext.MessageBox.alert('Informasi', 'Pilih File Excel');
}
}
//ambil record grid======================================
function get_record() {
var par='';
var a= 1;
var c = ';';
ds_grid.each(function(rec){
var rowData = rec.data; // get record
if (a == ds_grid.getCount()) {
c = ''
}
par += rowData['tglkuitansi'] + 'x' +
rowData['jamkuitansi'] + 'x' +
rowData['noref'] + 'x' +
rowData['idjnsbiaya'] + 'x' +
rowData['kdjnsbiaya'] + 'x' +
rowData['kdstsemester'] + 'x' +
rowData['nim'] + 'x' +
rowData['jmlbayar'] + 'x' +
RH.getCompValue('keterangan') + 'x' +
USERID + 'x' +
rowData['idstkuitansi'] + 'x' +
c;
a= a+1;
});
return par;
}
function fnSaveVa(){
var xls = Right(Ext.getCmp('f_excel').getValue(),3);
var msgSuccess = "";
var msgFail = "";
var sUrl="";
var param_record = get_record();
if(!isUpdate){
sUrl = BASE_URL +'import_dpp_controller/import_transfer';
var sParams = new Object({
record_par : param_record,
tglva : RH.getCompValue('tglva'),
jamva : RH.getCompValue('jamva'),
keterangan : RH.getCompValue('keterangan'),
nmfile : RH.getCompValue('f_excel'),
userid : RH.getCompValue('userid'),
});
msgFail = "Simpan Data Gagal";
} else {
sUrl = BASE_URL +'import_dpp_controller/update_transfer';
var sParams = new Object({
idva : record.data['idva'],
keterangan : RH.getCompValue('keterangan'),
});
msgFail = "Update Data Gagal";
}
if (xls && ds_grid.getCount() !=0) {
if (xls=="xls") {
var waitmhssave = Ext.MessageBox.wait('Menyimpan Data...', 'Info');
Ext.Ajax.request({
url: sUrl,
method: 'POST',
params: sParams,
success: function(result) {
waitmhssave.hide();
var jsonData = Ext.decode(result.responseText);
if(!isUpdate){
msgSuccess = 'Simpan Data Berhasil,' + '
' +
jsonData.sucessed + ' Data Success, ' +
jsonData.failed + ' Data Failure';
} else {
msgSuccess = "Update Data Berhasil";
}
Ext.MessageBox.alert("Informasi", msgSuccess);
ds_va.reload();
wVa.close();
},
failure: function() {
waitmhssave.hide();
Ext.MessageBox.alert("Informasi", msgFail);
}
});
} else {
Ext.MessageBox.alert('Informasi', 'File Harus Berekstensi .xls');
Ext.getCmp('f_excel').setValue();
}
} else {
Ext.MessageBox.alert('Informasi', 'Lengkapi Data');
}
}
function Right(str, n){
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else {
var iLen = String(str).length;
return String(str).substring(iLen, iLen - n);
}
}
}
}