function pStsemester(){ /** DATA STORES */ var ds_thnakademik = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_thnakademik ', method: 'POST' }), root: 'data', autoLoad: true, fields: [{ name: "idthnakademik" }, { name: "nmthnakademik" }] }); var ds_jsemester = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_jsemester ', method: 'POST' }), root: 'data', autoLoad: true, fields: [{ name: "idjnssemester" }, { name: "nmjnssemester" }] }); var ds_status = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_status ', method: 'POST' }), root: 'data', autoLoad: true, fields: [{ name: "idstatus" }, { name: "nmstatus" }] }); var wFormStoresObj = new Object({ thnakademik:ds_thnakademik, jsemester: ds_jsemester, ststatus: ds_status }); /** MAIN GRID PANEL PROPERTIES */ var fields_stsemester = RH.storeFields('kdstsemester', 'idthnakademik', 'nmthnakademik', 'idjnssemester', 'nmjnssemester', 'idstatus', 'nmstatus', 'deskripsi'); var pageSize = 18; var ds_stsemester = RH.JsonStore({ url : BASE_URL + 'stsemester_controller/get_stsemester', fields : fields_stsemester, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_stsemester = RH.searchComp({ id : 'sb_stsemester', fields : ['kdstsemester:Semester','nmthnakademik:Tahun Akademik','deskripsi:Deskripsi'], selected : 'kdstsemester', store : ds_stsemester, //textWidth: 100, }); /** COLUMN MODEL & RENDERER */ function renderThnakademik(value) { return RH.getRecordFieldValue(ds_thnakademik, 'nmthnakademik', 'idthnakademik', value); } function renderJsemester(value) { return RH.getRecordFieldValue(ds_jsemester, 'nmjnssemester', 'idjnssemester', value); } function renderStstatus(value) { return RH.getRecordFieldValue(ds_status, 'nmstatus', 'idstatus', value); } var cm_stsemester = new Ext.grid.ColumnModel([ { header: 'Semester',width: 80, dataIndex: 'kdstsemester', sortable: true }, { header: 'Tahun Akademik', width: 100, dataIndex: 'nmthnakademik', sortable: true }/* , { header: 'Tahun Akademik', width: 100, dataIndex: 'idthnakademik', renderer: renderThnakademik, sortable: true } */, { header: 'Jenis Semester', width: 100, dataIndex: 'idjnssemester', renderer: renderJsemester, sortable: true }, { header: 'Status', width: 100, dataIndex: 'idstatus', renderer: renderStstatus, sortable: true }, { header: 'Deskripsi', width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_stsemester = RH.GridPanel_T1({ ds: ds_stsemester, cm: cm_stsemester, singleSelect: true, searchComp: sb_stsemester, allowAdd: true, fnAdd: fnAddStsemester, pageSize: pageSize, cellclick: onCellStSemesterClick }); var fp_stsemester = RH.GPContainer1({ title: 'Status Semester/Semester Pelaporan', iconCls:'silk-calendar', gridPanel: gp_stsemester, }); SET_PAGE_CONTENT(fp_stsemester); /** FUNCTIONS */ function onCellStSemesterClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditStsemester(grid, record)}); RH.DeleteClick(e, function(){fnDeleteStsemester(grid, record)}); } function reloadStsemester(){ ds_stsemester.reload(); } function fnAddStsemester(){ var grid = gp_stsemester; wform_stsemester(false, grid, null, wFormStoresObj); } function fnEditStsemester(grid, record){ wform_stsemester(true, grid, record, wFormStoresObj); } function fnDeleteStsemester(grid, record){ var url = BASE_URL + 'stsemester_controller/delete_stsemester'; var params = new Object({ kdstsemester : record.data['kdstsemester'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT STATUS SEMESTER */ function wform_stsemester(isUpdate, grid, record, storesObj){ var winTitle = (isUpdate)?'Status Semester (Edit)':'Status Semester (Entry)'; /** DATA STORES */ var ds_thnakademik = storesObj.thnakademik; var ds_jsemester = storesObj.jsemester; var ds_status = storesObj.ststatus; /** THE FORM */ var stsemester_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.stsemester', buttonAlign: 'left', labelWidth: 150, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 250, width: 500, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'tf.frm.kdstsemester', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ xtype: 'combo', id: 'cb.frm.idthnakademik', fieldLabel: 'Tahun Akademik', store: ds_thnakademik, triggerAction: 'all', valueField: 'idthnakademik', displayField: 'nmthnakademik', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 300, allowBlank: false, editable:false, },{ xtype: 'combo', id: 'cb.frm.idjnssemester', fieldLabel: 'Jenis Semester', store: ds_jsemester, triggerAction: 'all', valueField: 'idjnssemester', displayField: 'nmjnssemester', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 300, allowBlank: false, editable:false, },{ xtype: 'combo', id: 'cb.frm.idstatus', fieldLabel: 'Status', store: ds_status, triggerAction: 'all', valueField: 'idstatus', displayField: 'nmstatus', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 300, allowBlank: false, editable:false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { var idstat = Ext.getCmp('cb.frm.idstatus').getValue(); var status; var getrec = (record==null) ? '0':record.data['idstatus']; Ext.Ajax.request({ url: BASE_URL + 'stsemester_controller/cekaktifsmt', method: 'POST', success: function(response) { status = response.responseText; if (status == idstat){ if (getrec != '1'){ Ext.MessageBox.alert("Informasi", "Status Semester Aktif Sudah Ada, Silahkan Tidak Aktifkan Terlebih Dahulu"); } else { fnSaveStsemester(); } } else { fnSaveStsemester(); } } }); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wStsemester.close(); } }] }); var wStsemester = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [stsemester_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setStsemesterForm(isUpdate, record); wStsemester.show(); /** FORM FUNCTIONS */ function setStsemesterForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ Ext.getCmp('tf.frm.kdstsemester').disable(); RH.setCompValue('tf.frm.kdstsemester', record.data['kdstsemester']); RH.setCompValue('cb.frm.idthnakademik', record.data['idthnakademik']); RH.setCompValue('cb.frm.idjnssemester', record.data['idjnssemester']); RH.setCompValue('cb.frm.idstatus', record.data['idstatus']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveStsemester(){ var idForm = 'frm.stsemester'; var sUrl = BASE_URL +'stsemester_controller/insert_stsemester'; var sParams = getInsertStsemesterParams(); 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 +'stsemester_controller/update_stsemester'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wStsemester, msgWait, msgSuccess, msgFail, msgInvalid); //wStsemester.close(); } // GET PARAMETERS FOR INSERT/UPDATE function getInsertStsemesterParams(){ return new Object({ kdstsemester : RH.getCompValue('tf.frm.kdstsemester'), idthnakademik : RH.getCompValue('cb.frm.idthnakademik'), idjnssemester : RH.getCompValue('cb.frm.idjnssemester'), idstatus : RH.getCompValue('cb.frm.idstatus'), deskripsi : RH.getCompValue('ta.frm.deskripsi') }); } function cekaktifsmt(){ } }