function virtual_account(){ /** COMMON STORES */ var ds_prodireg = store_prodireg(); var ds_years = store_tahun(); /** STORE for GRID COLUMN EDITOR type COMBO */ /** MAIN GRID STORE: ds_mhsIKULUM */ var fields_mhs = RH.storeFields( 'nim' , 'nmmhs' , 'kdjnskelamin' , 'thnmasuk' , 'nmprodi' , 'nmstawalmhs' , 'nmstaktifmhs' , 'novadpp' , 'novadpk'); var ds_mhs = RH.JsonStore({ url : BASE_URL + 'mahasiswa_controller/get_mhs_va', fields : fields_mhs, params: [ {key:'kdprodi', id:'cb.prodi-mhs'} ,{key:'thnmasuk', id:'cb.thmasuk-mhs'} ], enableSearch: true, }); //SEARCH COMPONENT var recnim = ''; /** FUNCTION for GRID COLUMN EDITOR */ /** GRID COLUMN MODEL */ var cm_mhs = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer({width: 35}), //for rows numbering { header: 'NPM', width: 100, dataIndex: 'nim', sortable: true, },{ header: 'Nama Mahasiswa', width: 220, dataIndex: 'nmmhs', sortable: true, },{ header: 'L/P', width: 60, dataIndex: 'kdjnskelamin', sortable: true, align: 'center' }/* ,{ header: 'Thn.Masuk', width: 70, dataIndex: 'thnmasuk', align: 'center', sortable: true, } */,{ header: 'Prodi', width: 200, dataIndex: 'nmprodi', sortable: true, },{ header: 'St.Masuk Mhs', width: 100, dataIndex: 'nmstawalmhs', sortable: true, },{ header: 'St.Mahasiswa', width: 100, dataIndex: 'nmstaktifmhs', sortable: true, },{ header: 'No. Virtual Account DPP', width: 150, dataIndex: 'novadpp', sortable: true, editor: { xtype: 'textfield', id: 'novadpp', name: 'novadpp', maskRe: /[0-9]/, enableKeyEvents: true, listeners: { specialkey: function(f,e){ if (e.getKey() == e.ENTER) { var field = this.getId(); var value = this.getValue(); update_va_mhs(field, value, recnim); } } } } },{ header: 'No. Virtual Account DPK', width: 150, dataIndex: 'novadpk', sortable: true, editor: { xtype: 'textfield', id: 'novadpk', name: 'novadpk', maskRe: /[0-9]/, enableKeyEvents: true, listeners: { specialkey: function(f,e){ if (e.getKey() == e.ENTER) { var field = this.getId(); var value = this.getValue(); update_va_mhs(field, value, recnim); } } } } }] ); var cari_mhs = [new Ext.ux.grid.Search({ iconCls: 'btn_search', minChars: 1, autoFocus: true, autoHeight: true, position: 'top', mode: 'local', width: 200 })]; var gp_mhs = new Ext.grid.EditorGridPanel({ plugins: cari_mhs, ds: ds_mhs, cm: cm_mhs, //sm: new Ext.grid.RowSelectionModel({ singleSelect: true}), clicksToEdit: 1, //for cell editing (single click =1, dblclick=2) forceFit: true, //autoHeight: true, autoScroll: true, autoSizeColumns: true, enableColumnResize: true, enableColumnHide: false, enableColumnMove: false, enableHdaccess: false, columnLines: true, loadMask: true, frame: true, layout: 'anchor', tbar:[{ xtype: 'label', text: ' Kode Unla: ', style:'font-size: 12px;margin-left:10px;margin-right:5px', },{ xtype: 'textfield', fieldLabel: 'Kode Unla', id:'tf.kodeunla', width:100, maskRe: /[0-9]/, },{ xtype: 'label', text: ' Kode Biaya DPP: ', style:'font-size: 12px;margin-left:10px;margin-right:5px', },{ xtype: 'textfield', fieldLabel: 'Kode Biaya DPP', id:'tf.kodedpp', width:100, maskRe: /[0-9]/, },{ xtype: 'label', text: ' Kode Biaya DPK: ', style:'font-size: 12px;margin-left:10px;margin-right:5px', },{ xtype: 'textfield', fieldLabel: 'Kode Biaya DPK', id:'tf.kodedpk', width:100, maskRe: /[0-9]/, },{ text: 'Auto Generate', iconCls: 'silk-save', id:'bt-generate', handler: function(){ autogenerate_vamhs(); } },'->'], listeners: { cellclick: onCellVaClick } }); function onCellVaClick(grid, rowIndex, columnIndex, e) { var record = ds_mhs.getAt(rowIndex); recnim = record.data['nim']; } var fp_daftar_mhs = RH.GPContainer1_wHeaders({ title: 'Setting Virtual Account Mahasiswa', iconCls:'silk-money', gridPanel: gp_mhs, headerLabelWidth: 140, headers: [{ xtype: 'container', layout: 'hbox', items:[{ layout:'form', labelWidth:90, labelAlign:'right', items: [ RH.ActionCombo({ id: 'cb.prodi-mhs', label: 'Program Studi', width: 350, data: ds_prodireg, key: 'kdprodi', display: 'lnmprodi', fnSelect: function(){ reloadGridmhs(); } }) ] },{ layout:'form', labelWidth:160, labelAlign:'right', items: [ RH.ActionCombo({ id: 'cb.thmasuk-mhs', label: 'Thn.Masuk/Angkatan', width: 100, data: ds_years, key: 'kode', display: 'nama', fnSelect: function(){ reloadGridmhs(); } }) ] }] }], }); SET_PAGE_CONTENT(fp_daftar_mhs); function reloadGridmhs(){ if (RH.getCompValue('cb.prodi-mhs', true) && RH.getCompValue('cb.thmasuk-mhs', true)) { ds_mhs.reload({ params: { kdprodi: RH.getCompValue('cb.prodi-mhs', true), thnmasuk: RH.getCompValue('cb.thmasuk-mhs', true) } }); } } function autogenerate_vamhs() { var par=''; var count= 1; var endpar = ';'; var novadpp = ''; var novadpk = ''; var kodeunla = Ext.getCmp('tf.kodeunla').getValue(); var kodedpp = Ext.getCmp('tf.kodedpp').getValue(); var kodedpk = Ext.getCmp('tf.kodedpk').getValue(); if (kodeunla=="") { Ext.MessageBox.alert("Info", "Isi " + Ext.getCmp('tf.kodeunla').fieldLabel); return; } if (kodeunla.length < 5) { Ext.MessageBox.alert("Info", Ext.getCmp('tf.kodeunla').fieldLabel + " Minimal 5 Angka"); return; } if (kodeunla.length > 5) { Ext.MessageBox.alert("Info", Ext.getCmp('tf.kodeunla').fieldLabel + " Maksimal 5 Angka"); return; } //==================== if (kodedpp=="") { Ext.MessageBox.alert("Info", "Isi " + Ext.getCmp('tf.kodedpp').fieldLabel); return; } if (kodedpp.length < 3) { Ext.MessageBox.alert("Info", Ext.getCmp('tf.kodedpp').fieldLabel + " Minimal 3 Angka"); return; } if (kodedpp.length > 3) { Ext.MessageBox.alert("Info", Ext.getCmp('tf.kodedpp').fieldLabel + " Maksimal 3 Angka"); return; } //==================== if (kodedpk=="") { Ext.MessageBox.alert("Info", "Isi " + Ext.getCmp('tf.kodedpk').fieldLabel); return; } if (kodedpk.length < 3) { Ext.MessageBox.alert("Info", Ext.getCmp('tf.kodedpk').fieldLabel + " Minimal 3 Angka"); return; } if (kodedpk.length > 3) { Ext.MessageBox.alert("Info", Ext.getCmp('tf.kodedpk').fieldLabel + " Maksimal 3 Angka"); return; } gp_mhs.getStore().each(function(rec){ var rowData = rec.data; if (count == gp_mhs.getStore().getCount()) { endpar = '' } novadpp = kodeunla + rowData['nim'].substr(-10) + kodedpp; novadpk = kodeunla + rowData['nim'].substr(-10) + kodedpk; par += rowData['nim'] + ':' + novadpp + ':' + novadpk + ':' + endpar; count = count+1; }); var kdprodi = RH.getCompValue('cb.prodi-mhs'); var thnmasuk = RH.getCompValue('cb.thmasuk-mhs'); if(kdprodi && thnmasuk){ var waitmsgupdate = Ext.MessageBox.wait('Menyimpan Data Virtual Account...', 'Info'); Ext.Ajax.request({ url: BASE_URL + 'mahasiswa_controller/save_va_mhs', params: { par: par }, success: function() { waitmsgupdate.hide(); Ext.MessageBox.alert("Info", "Simpan Data Berhasil"); gp_mhs.getStore().reload(); }, failure: function() { waitmsgupdate.hide(); Ext.MessageBox.alert("Info", "Simpan Data Gagal"); } }); }else{ Ext.MessageBox.alert("Info", "Silahkan Pilih Program Studi dan Thn.Masuk/Angkatan"); } } function update_va_mhs(field, value, recnim) { if (value=="") { Ext.MessageBox.alert("Info", "Isi No. Virtual Account " + field.substr(-3).toUpperCase()); return; } if (value.length < 18) { Ext.MessageBox.alert("Info", "No. Virtual Account " + field.substr(-3).toUpperCase() + " Minimal 18 Angka"); return; } if (value.length > 18) { Ext.MessageBox.alert("Info", "No. Virtual Account " + field.substr(-3).toUpperCase() + " Maksimal 18 Angka"); return; } Ext.Ajax.request({ url: BASE_URL + 'mahasiswa_controller/update_va_mhs', params: { field: field, value: value, recnim: recnim, }, success: function() { gp_mhs.getStore().reload(); }, failure: function() { Ext.MessageBox.alert("Info", "Update Data Gagal"); } }); } }