function pJwlkrs(){ var ds_stsemester = store_stsmt(); var ds_prodi = store_prodireg(); var ds_jkrs = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_jkrs', method: 'POST' }), autoLoad: true, root: 'data', fields: [ { name: "idjnskrs", mapping: "idjnskrs" } , { name: "nmjnskrs", mapping: "nmjnskrs" } ] }); var wAddEditStoresObj = new Object({ prodi: ds_prodi, stsemester: ds_stsemester, jkrs: ds_jkrs }); var fields_jwlkrs = RH.storeFields('idjadwalkrs','idjnskrs','kdstsemester', 'kdprodi','tglawal','tglakhir','nmjnskrs','nmprodi','nmthnakademik', 'mindppkrs','mindpputs','mindppuas'); var pageSize = 20; var ds_jwlkrs = RH.JsonStore({ url : BASE_URL + 'jadwalkrs_controller/get_jadwalkrs', fields : fields_jwlkrs, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_jwlkrs = RH.searchComp({ id : 'sb_jwlkrs', fields : ['nmprodi:Program Studi','kdstsemester:Status Semester'], selected : 'idjadwalkrs', store : ds_jwlkrs }); // COLUMN MODEL var cm_jwlkrs = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Jenis KRS'),width: 100, dataIndex: 'nmjnskrs', sortable: true },{ header: RH.h3('Program Studi'),width: 200, dataIndex: 'nmprodi', sortable: true },{ header: RH.h3('Semester'), width: 150, dataIndex: 'nmthnakademik', sortable: true }, { header: RH.h3('Tanggal Awal'), width: 100, dataIndex: 'tglawal', sortable: true }, { header: RH.h3('Tanggal Akhir'), width: 100, dataIndex: 'tglakhir', sortable: true }, { header: RH.h3('Min. DPP KRS'), width: 100, dataIndex: 'mindppkrs', align: 'center', sortable: true, renderer: function(value) { return value + ' %'; } }, { header: RH.h3('Min. DPP UTS'), width: 100, dataIndex: 'mindpputs', align: 'center', sortable: true, renderer: function(value) { return value + ' %'; } }, { header: RH.h3('Min. DPP UAS'), width: 100, dataIndex: 'mindppuas', align: 'center', sortable: true, renderer: function(value) { return value + ' %'; } }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_jwlkrs = RH.GridPanel_T1({ ds: ds_jwlkrs, cm: cm_jwlkrs, singleSelect: true, searchComp: sb_jwlkrs, allowAdd: true, fnAdd: fnAddJwlkrs, pageSize: pageSize, cellclick: onCellJwlkrsClick }); var fp_jwlkrs = RH.GPContainer1({ title: 'Jadwal KRS/PKRS', iconCls:'silk-house', gridPanel: gp_jwlkrs, }); SET_PAGE_CONTENT(fp_jwlkrs); /** FUNCTIONS */ function onCellJwlkrsClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditJwlkrs(grid, record)}); RH.DeleteClick(e, function(){fnDeleteJwlkrs(grid, record)}); } function reloadJwlkrs(){ ds_jwlkrs.reload(); } function fnAddJwlkrs(){ var grid = gp_jwlkrs; wEntryJwlkrs(false, grid, null, wAddEditStoresObj); } function fnEditJwlkrs(grid, record){ wEntryJwlkrs(true, grid, record, wAddEditStoresObj); } function fnDeleteJwlkrs(grid, record){ var url = BASE_URL + 'jadwalkrs_controller/delete_jadwalkrs'; var params = new Object({ kdprodi : record.data['kdprodi'], kdstsemester : record.data['kdstsemester'], idjnskrs : record.data['idjnskrs'], idjadwalkrs : record.data['idjadwalkrs'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT SET BOBOT NILAI */ function wEntryJwlkrs(isUpdate, grid, record, wAddEditStoresObj){ var winTitle = (isUpdate)?'Jadwal KRS/PKRS (Edit)':'Jadwal KRS/PKRS (Entry)'; /** DATA SOURCE GRUP SET BOBOT NILAI */ var ds_prodi = wAddEditStoresObj.prodi; var ds_stsemester = wAddEditStoresObj.stsemester; var ds_jkrs = wAddEditStoresObj.jkrs; /** FORM ENTRY/EDIT JADWAL KRS/PKRS */ var jwlkrs_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.jwlkrs', buttonAlign: 'left', labelWidth: 150, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, width: 500, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'idjadwalkrs', fieldLabel: 'ID Jadwal KRS', hidden: true, }, { xtype: 'combo', id: 'cb.frm.jkrs', fieldLabel: 'Jenis KRS', store: ds_jkrs, triggerAction: 'all', valueField: 'idjnskrs', displayField: 'nmjnskrs', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 100, editable: false }, { xtype: 'combo', id: 'cb.frm.kdprodi', fieldLabel: 'Program Studi', allowBlank: false, editable:false, store: ds_prodi, triggerAction: 'all', valueField: 'kdprodi', displayField: 'lnmprodi', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 300, },{ xtype: 'combo', id: 'cb.frm.kdstsemester', fieldLabel: 'Semester', store: ds_stsemester, triggerAction: 'all', valueField: 'kdstsemester', displayField: 'nmsmt', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 200, allowBlank: false, },{ xtype: 'datefield', id: 'df.tglawal', fieldLabel: 'Tanggal Awal', value: new Date(), allowBlank: false, width: 100 },{ xtype: 'datefield', id: 'df.tglakhir', fieldLabel: 'Tanggal Akhir', value: new Date(), allowBlank: false, width: 100 },{ xtype: 'numericfield', id: 'mindppkrs', fieldLabel: 'Min. DPP KRS', width: 100, },{ xtype: 'numericfield', id: 'mindpputs', fieldLabel: 'Min. DPP UTS', width: 100, },{ xtype: 'numericfield', id: 'mindppuas', fieldLabel: 'Min. DPP UAS', width: 100, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveJwlkrs(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wJwlkrs.close(); } }] }); var wJwlkrs = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [jwlkrs_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setJwlkrsForm(isUpdate, record); wJwlkrs.show(); /** FORM FUNCTIONS */ function setJwlkrsForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('cb.frm.kdprodi'); //RH.disableComp('cb.frm.kdstsemester'); RH.setCompValue('cb.frm.jkrs', record.data['idjnskrs']); RH.setCompValue('cb.frm.kdprodi', record.data['kdprodi']); RH.setCompValue('cb.frm.kdstsemester', record.data['kdstsemester']); RH.setCompValue('df.tglawal', record.data['tglawal']); RH.setCompValue('df.tglakhir', record.data['tglakhir']); RH.setCompValue('idjadwalkrs', record.data['idjadwalkrs']); RH.setCompValue('mindppkrs', record.data['mindppkrs']); RH.setCompValue('mindpputs', record.data['mindpputs']); RH.setCompValue('mindppuas', record.data['mindppuas']); return; } } } function fnSaveJwlkrs(){ var idForm = 'frm.jwlkrs'; var sUrl = BASE_URL +'jadwalkrs_controller/insert_jadwalkrs'; var sParams = new Object({ idjnskrs : RH.getCompValue('cb.frm.jkrs'), kdprodi : RH.getCompValue('cb.frm.kdprodi'), kdstsemester : RH.getCompValue('cb.frm.kdstsemester'), tglawal : RH.getCompValue('df.tglawal'), tglakhir : RH.getCompValue('df.tglakhir'), }); var msgWait = 'Tunggu, sedang proses menyimpan...'; var msgSuccess = 'Tambah data berhasil'; var msgFail = 'Tambah data gagal'; var msgInvalid = 'Data belum valid (data primer belum terisi)!'; if(isUpdate){ sUrl = BASE_URL +'jadwalkrs_controller/update_jadwalkrs'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wJwlkrs, msgWait, msgSuccess, msgFail, msgInvalid); } }