function pSetBiayaWisuda(){ /** COMMON STORES didef di parent*/ ds_thnakademik = new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'setbiayawisuda_controller/get_thnakademik', method: 'POST' }), totalProperty: 'results', root: 'data', autoLoad: true, fields: [{ name: 'idthnakademik', mapping: 'idthnakademik' },{ name: 'kdthnakademik', mapping: 'kdthnakademik' },{ name: 'nmthnakademik', mapping: 'nmthnakademik' },{ name: 'deskripsi', mapping: 'deskripsi' }] }); var ds_jenjangstudi = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_jenjangstudi ', method: 'POST' }), autoLoad: true, root: 'data', fields: [ { name: "kode", mapping: "kode" } , { name: "nama", mapping: "nama" } ] }); var storesObj = {thnakademik:ds_thnakademik,jenjangstudi:ds_jenjangstudi}; /**====================*/ var fields_setbiayawisuda = RH.storeFields('idsetbiayawisuda','nmsetbiayawisuda','idthnakademik','kdthnakademik', 'nmthnakademik','biaya','idstatus','kdjenjangstudi','nmjenjangstudi','nmstatus','catatan'); var ds_setbiayawisuda = RH.JsonStore({ url : BASE_URL + 'setbiayawisuda_controller/get_setbiayawisuda', fields : fields_setbiayawisuda, limit: 15, enableSearch: true, }); //SEARCH COMPONENT var sb_setbiayawisuda = RH.searchComp({ id : 'sb_setbiayawisuda', comboWidth:200, textWidth:200, fields : ['nmsetbiayawisuda:Nama', 'nmthnakademik:Tahun Akademik', 'nmjenjangstudi:Jenjang Studi', 'biaya:Biaya', 'nmstatus:Status', 'catatan:Catatan'], selected : 'nmthnakademik', store : ds_setbiayawisuda }); var cm_setbiayawisuda = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: 'Nama', dataIndex: 'nmsetbiayawisuda', width: 300, sortable: true, }, { header: 'Tahun Akademik', dataIndex: 'nmthnakademik', width: 200, sortable: true, }, { header: 'Jenjang Studi', dataIndex: 'nmjenjangstudi', width: 150, sortable: true, }, { header: 'Biaya', dataIndex: 'biaya', width: 100, sortable: true, xtype: 'numbercolumn', format:'0,000', align:'right' }, { header: 'Status', dataIndex: 'nmstatus', width: 85, sortable: true }, { header: 'Catatan', dataIndex: 'catatan', width: 200, sortable: true }, { header: 'Edit', id: 'col.edit', width: 50, sortable: false, renderer: RH.column_edit, }, { header: 'Delete', id: 'col.delete', width: 50, sortable: false, renderer: RH.column_delete, }] ); var sm_setbiayawisuda = new Ext.grid.RowSelectionModel({ singleSelect: true }); var gv_setbiayawisuda = new Ext.grid.GridView({ emptyText: '< Belum ada Data >' }); var gp_setbiayawisuda = new Ext.grid.GridPanel({ ds: ds_setbiayawisuda, cm: cm_setbiayawisuda, sm: sm_setbiayawisuda, view: gv_setbiayawisuda, height:200, autoScroll:true, autoSizeColumns: true, enableColumnResize: true, enableColumnHide: false, enableColumnMove: false, enableHdaccess: false, columnLines: true, loadMask: true, tbar: [{ text: 'Tambah', id: 'tb.add-setbiayawisuda', iconCls: 'silk-add', handler: function() { fnAdd(); } }, {xtype:'tbfill'} , sb_setbiayawisuda //RH.searchBar() ], bbar: new Ext.PagingToolbar({ store: ds_setbiayawisuda, displayInfo: true, pageSize: 15, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { cellclick: onCellClick } }); //SET_PAGE_CONTENT(gp_setbiayawisuda); var fp_setbiayawisuda = new Ext.Panel({ title: 'Setting Biaya Wisuda', iconCls:'silk-money', buttonAlign: 'left', bodyStyle: 'padding: 5px', border: false, layout:'fit', waitMsg: 'Waiting...', maskDisabled: false, monitorValid: true, frame: true, items: [gp_setbiayawisuda], }); SET_PAGE_CONTENT(fp_setbiayawisuda); function onCellClick(grid, rowIndex, columnIndex, e) { var t = e.getTarget(); var record = grid.getStore().getAt(rowIndex); // Get the Record if (t.className == 'imgEdit') { fnEdit(grid, record); return true; } if (t.className == 'imgDelete') { fnDelete(grid, record); return true; } return false; } function fnAdd(){ var grid = gp_setbiayawisuda; wEntrySetbiayaWisuda(false, grid, null, storesObj); } function fnEdit(grid, record){ wEntrySetbiayaWisuda(true, grid, record, storesObj); } function fnDelete(grid,record){ var url = BASE_URL + 'setbiayawisuda_controller/delete_setbiayawisuda'; var params = new Object({ idsetbiayawisuda : record.data['idsetbiayawisuda'] }); RH.deleteGridRecord(url, params, gp_setbiayawisuda ); } } function wEntrySetbiayaWisuda(isUpdate, grid, record, storesObj) { var winTitle = (isUpdate)?'Setting Biaya Wisuda (Edit)':'Setting Biaya Wisuda (Entry)'; var ds_thnakademik = storesObj.thnakademik; var ds_jenjangstudi = storesObj.jenjangstudi; var fEntry = new Ext.form.FormPanel({ border: false, frame: true, id: 'f.Entry', labelAlign: 'right', labelWidth: 150, buttonAlign: 'left', bodyStyle: 'padding:5px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 250, width: 500, layout: { type: 'form', pack: 'center', align: 'center' }, items: [{ xtype: 'textfield', fieldLabel: 'Nama', id : 'tf.nmsetbiayawisuda', width : 300 },{ xtype: 'combo', id: 'cb.thnakademik', fieldLabel: 'Tahun Akademik', store: ds_thnakademik, valueField: 'idthnakademik', displayField: 'nmthnakademik', triggerAction: 'all', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', selectOnFocus:false, //false spy ga fokus setelah dipilih width: 175, editable: false, listeners:{ select: function(combo, record){ } } },{ xtype: 'combo', id: 'cb.jenjangstudi', fieldLabel: 'Jenjang Studi', store: ds_jenjangstudi, triggerAction: 'all', valueField: 'kode', displayField: 'nama', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 150, },{ xtype: 'numericfield', fieldLabel: 'Biaya', id: 'nf.biaya', width: 125, allowBlank: false },{ xtype: 'combo', id: 'cb.idstatus', fieldLabel: 'Status', store: ds_status, valueField: 'idstatus', displayField: 'nmstatus', triggerAction: 'all', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', selectOnFocus:false, //false spy ga fokus setelah dipilih width: 125, allowBlank: false, editable: false },{ xtype: 'textarea', fieldLabel: 'Catatan', id : 'ta.catatan', width : 300, height : 55, }], bbar: [{ id:'btn_simpan',text: 'Simpan', iconCls:'silk-save', handler: function() { fnSave(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { win.close(); } }] }); var win = new Ext.Window({ title: winTitle, modal: true, items: [fEntry] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setForm(isUpdate, record); win.show(); function setForm(isUpdate, record){ if(isUpdate){ if(record != null){ RH.disableComp('cb.thnakademik'); RH.disableComp('cb.jenjangstudi'); RH.setCompValue('tf.nmsetbiayawisuda', record.data['nmsetbiayawisuda']); RH.setCompValue('cb.thnakademik', record.data['idthnakademik']); RH.setCompValue('cb.jenjangstudi', record.data['kdjenjangstudi']); RH.setCompValue('nf.biaya', record.data['biaya']); RH.setCompValue('cb.idstatus', record.data['idstatus']); RH.setCompValue('ta.catatan', record.data['catatan']); return; } } } function fnSave(){ if(RH.isEmpty('tf.nmsetbiayawisuda')){ RH.warning('Nama harus diisi'); return; }; if(RH.isEmpty('cb.thnakademik')){ RH.warning('Tahun Akademik harus diisi'); return; }; if(RH.isEmpty('cb.jenjangstudi')){ RH.warning('Jenjang Studi harus diisi'); return; }; if(RH.isEmpty('nf.biaya') || Ext.getCmp('nf.biaya').getValue() <= 0){ RH.warning('Biaya harus diisi'); return; }; if(RH.isEmpty('cb.idstatus')){ RH.warning('Status harus diisi'); return; }; var url = BASE_URL + 'setbiayawisuda_controller/insert_setbiayawisuda'; var params = new Object({ nmsetbiayawisuda : RH.getCompValue('tf.nmsetbiayawisuda'), idthnakademik : RH.getCompValue('cb.thnakademik'), kdjenjangstudi : RH.getCompValue('cb.jenjangstudi'), biaya : RH.getCompValue('nf.biaya'), idstatus : RH.getCompValue('cb.idstatus'), catatan : RH.getCompValue('ta.catatan') }); var msgSuccess = 'Simpan Data Berhasil'; var msgFail = 'Simpan Data Gagal'; if(isUpdate){ url = BASE_URL + 'setbiayawisuda_controller/update_setbiayawisuda'; params.idsetbiayawisuda = record.data['idsetbiayawisuda']; msgSuccess = 'Update Data Berhasil'; msgFail = 'Update Data Gagal'; } var form = RH.getForm('f.Entry'); if(form){ Ext.Ajax.request({ url: url, params: params, method: 'POST', scope: this, async:false, success: function(result) { Ext.Msg.alert("Info", msgSuccess); grid.getStore().reload(); win.close(); }, failure: function() { Ext.Msg.alert("Info", msgFail); } }); } } }