function pSetkrs(){ var ds_prodi = store_prodireg(); var ds_siskrs = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_siskrs', method: 'POST' }), autoLoad: true, root: 'data', fields: [ { name: "idsiskrs", mapping: "idsiskrs" } , { name: "kdsiskrs", mapping: "kdsiskrs" } , { name: "nmsiskrs", mapping: "nmsiskrs" } ] }); var ds_idsemester = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_semester', method: 'POST' }), autoLoad: true, root: 'data', fields: [ { name: "kode", mapping: "kode" } , { name: "nama", mapping: "nama" } ] }); var wAddEditStoresObj = new Object({ prodi: ds_prodi, semester: ds_idsemester, siskrs: ds_siskrs }); var fields_setkrs = RH.storeFields('kdprodi','nmprodi','idsemester','kdsemester','nmsemester','tingkat','idsiskrs','kdsiskrs','nmsiskrs'); var pageSize = 20; var ds_setkrs = RH.JsonStore({ url : BASE_URL + 'settingkrs_controller/get_settingkrs', fields : fields_setkrs, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_setkrs = RH.searchComp({ id : 'sb_setkrs', fields : ['nmprodi:Program Studi','idsemester:Semester'], selected : 'nmprodi', store : ds_setkrs }); // COLUMN MODEL var cm_setkrs = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Program Studi'),width: 200, dataIndex: 'nmprodi', sortable: true },{ header: RH.h3('Semester'),width: 200, dataIndex: 'nmsemester', sortable: true },{ header: RH.h3('Sistem KRS'), width: 150, dataIndex: 'nmsiskrs', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_setkrs = RH.GridPanel_T1({ ds: ds_setkrs, cm: cm_setkrs, singleSelect: true, searchComp: sb_setkrs, allowAdd: true, fnAdd: fnAddSetkrs, pageSize: pageSize, cellclick: onCellSetkrsClick }); var fp_Setkrs = RH.GPContainer1({ title: 'Sistem KRS Online', iconCls:'silk-house', gridPanel: gp_setkrs, }); SET_PAGE_CONTENT(fp_Setkrs); /** FUNCTIONS */ function onCellSetkrsClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditSetkrs(grid, record)}); RH.DeleteClick(e, function(){fnDeleteSetkrs(grid, record)}); } function reloadSetkrs(){ ds_setkrs.reload(); } function fnAddSetkrs(){ var grid = gp_setkrs; wEntrySetkrs(false, grid, null, wAddEditStoresObj); } function fnEditSetkrs(grid, record){ wEntrySetkrs(true, grid, record, wAddEditStoresObj); } function fnDeleteSetkrs(grid, record){ var url = BASE_URL + 'settingkrs_controller/delete_settingkrs'; var params = new Object({ kdprodi : record.data['kdprodi'], idsemester : record.data['idsemester'], }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT SET BOBOT NILAI */ function wEntrySetkrs(isUpdate, grid, record, wAddEditStoresObj){ var winTitle = (isUpdate)?'Setting KRS Online (Edit)':'Setting KRS Online (Entry)'; /** DATA SOURCE GRUP SET BOBOT NILAI */ var ds_prodi = wAddEditStoresObj.prodi; var ds_semester = wAddEditStoresObj.semester; var ds_siskrs = wAddEditStoresObj.siskrs; /** FORM ENTRY/EDIT JADWAL KRS/PKRS */ var setkrs_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.setkrs', buttonAlign: 'left', labelWidth: 150, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 200, width: 500, layout: 'form', frame: false, defaultType:'textfield', items: [ { 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.semester', fieldLabel: 'Semester', store: ds_semester, triggerAction: 'all', valueField: 'kode', displayField: 'nama', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 200, allowBlank: false, },{ xtype: 'combo', id: 'cb.frm.siskrs', fieldLabel: 'Jenis KRS', allowBlank: false, editable:false, store: ds_siskrs, triggerAction: 'all', valueField: 'idsiskrs', displayField: 'nmsiskrs', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 100 }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { if(isUpdate){ fnSaveSetkrs(); } else { Ext.Ajax.request({ url: BASE_URL + 'settingkrs_controller/getcountsetkrs', method: 'POST', params: { kdprodi : RH.getCompValue('cb.frm.kdprodi'), idsemester : RH.getCompValue('cb.frm.semester'), }, success: function(response) { cn = response.responseText; if (cn==1){ Ext.MessageBox.alert("Informasi", "Setting KRS Untuk Prodi " + Ext.getCmp('cb.frm.kdprodi').getRawValue() + " Semester " + Ext.getCmp('cb.frm.semester').getRawValue() + " Sudah Ada"); } else { fnSaveSetkrs(); } } }); } } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wSetkrs.close(); } }] }); var wSetkrs = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [setkrs_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setSetkrsForm(isUpdate, record); wSetkrs.show(); /** FORM FUNCTIONS */ function setSetkrsForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ RH.disableComp('cb.frm.kdprodi'); RH.disableComp('cb.frm.semester'); RH.setCompValue('cb.frm.kdprodi', record.data['kdprodi']); RH.setCompValue('cb.frm.semester', record.data['idsemester']); RH.setCompValue('cb.frm.siskrs', record.data['idsiskrs']); return; } } } function fnSaveSetkrs(){ var idForm = 'frm.setkrs'; var sUrl = BASE_URL +'settingkrs_controller/insert_settingkrs'; var sParams = new Object({ kdprodi : RH.getCompValue('cb.frm.kdprodi'), idsemester : RH.getCompValue('cb.frm.semester'), idsiskrs : RH.getCompValue('cb.frm.siskrs'), }); 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 +'settingkrs_controller/update_settingkrs'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wSetkrs, msgWait, msgSuccess, msgFail, msgInvalid); } }