function feederKurikulum(){ var ds_prodireg = store_prodireg(); var ds_semester = store_semester(); var arr_berlaku = []; var start_year = 1997; var current_year = new Date().getFullYear(); for(var i = current_year;i >= start_year; i--){ var text = i +'/'+ (i+1); var arritem = [i, text]; arr_berlaku.push(arritem); } var ds_berlaku = new Ext.data.ArrayStore({ fields: ['val', 'text'], data : arr_berlaku }); var arr_wajib = [['A', 'Wajib'], ['B', 'Pilihan']]; var ds_wajib = new Ext.data.ArrayStore({ fields: ['val', 'text'], data : arr_wajib }); var ds_jsemester = new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'kurikulum_controller/get_jsemester', method: 'POST' }), autoLoad: true, root: 'data', fields: [ {name: 'idjnssemester', mapping: 'idjnssemester'}, {name: 'kdjnssemester', mapping: 'kdjnssemester'}, {name: 'nmjnssemester', mapping: 'nmjnssemester'}, {name: 'deskripsi', mapping: 'deskripsi'} ] }); var fnSelect = function(numfield, newValue, oldValue){ }; var ds_matakuliah = new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'kurikulum_controller/get_kurikulum_semester', method: 'POST' }), //autoLoad: true, root: 'data', fields: [ {name: 'idkurikulum', mapping: 'idkurikulum'}, {name: 'kdprodi', mapping: 'kdprodi'}, {name: 'thnmasuk', mapping: 'thnmasuk'}, {name: 'kdmk', mapping: 'kdmk'}, {name: 'idsemester', mapping: 'idsemester'}, {name: 'jmlsks', mapping: 'jmlsks'}, {name: 'skstatapmuka', mapping: 'skstatapmuka'}, {name: 'skspraktikum', mapping: 'skspraktikum'}, {name: 'sksprakteklap', mapping: 'sksprakteklap'}, {name: 'skssimulasi', mapping: 'skssimulasi'}, {name: 'jnskurikulum', mapping: 'jnskurikulum'}, {name: 'jnsmk', mapping: 'jnsmk'}, {name: 'stmk', mapping: 'stmk'}, {name: 'nilaihurufmin', mapping: 'nilaihurufmin'}, {name: 'bobotnilaimin', mapping: 'bobotnilaimin'}, {name: 'jml_kompetensi', mapping: 'jml_kompetensi'}, {name: 'nmmkind', mapping: 'nmmkind'} ] }); var grid_matakuliah = new Ext.grid.EditorGridPanel({ id: 'grid_matakuliah', title: 'Mata Kuliah', store: ds_matakuliah, autoScroll: true, frame: true, view: new Ext.grid.GridView({emptyText: '< Belum ada Data >'}), loadMask: true, height: 380, columnLines: true, tbar:[{ text: 'Export To Feeder', id: 'id_eks_feeder', iconCls: 'silk-book', handler: function() { export_to_feeder(); } }], listeners:{ afteredit:function(){ /* var jumlahsks = 0; var jumlahskswajib = 0; var jumlahskspilihan = 0; var total_store = grid_matakuliah.getStore().getCount(); for(var i = 0; i < total_store; i++) { var record = grid_matakuliah.getStore().getAt(i); var getjnsmk = record.get('jnsmk'); jumlahsks += parseFloat(record.get('jmlsks')); if(getjnsmk == 'A' || !getjnsmk){ jumlahskswajib += parseFloat(record.get('jmlsks')); }else{ jumlahskspilihan += parseFloat(record.get('jmlsks')); } } Ext.getCmp("tf.jumlahsks").setValue(jumlahsks); Ext.getCmp("tf.jumlahskswajib").setValue(jumlahskswajib); Ext.getCmp("tf.jumlahskspilihan").setValue(jumlahskspilihan); */ } }, columns: [new Ext.grid.RowNumberer(), { header: setHeaderGrid('Kode Mata Kuliah'), width: 100, dataIndex: 'kdmk', sortable: true, align:'left', },{ header: setHeaderGrid('Nama Mata Kuliah'), width: 210, dataIndex: 'nmmkind', sortable: true, align:'left', },{ header: setHeaderGrid('SKS Mata Kuliah'), width: 100, dataIndex: 'jmlsks', sortable: true, align:'left', editor: RH.getNumEditor('jmlsks', 'INTEGER', 0, 10, false, fnSelect), },{ header: setHeaderGrid('SKS Tatap Muka'), width: 100, dataIndex: 'skstatapmuka', sortable: true, align:'left', editor: RH.getNumEditor('skstatapmuka', 'INTEGER', 0, 10, false, fnSelect), xtype: 'numbercolumn', format:'0,000', },{ header: setHeaderGrid('SKS Praktikum'), width: 100, dataIndex: 'skspraktikum', sortable: true, align:'left', editor: RH.getNumEditor('skspraktikum', 'INTEGER', 0, 10, false, fnSelect), xtype: 'numbercolumn', format:'0,000', },{ header: setHeaderGrid('SKS Prakt. Lapangan'), width: 120, dataIndex: 'sksprakteklap', sortable: true, align:'left', editor: RH.getNumEditor('sksprakteklap', 'INTEGER', 0, 10, false, fnSelect), xtype: 'numbercolumn', format:'0,000', },{ header: setHeaderGrid('SKS Simulasi'), width: 100, dataIndex: 'skssimulasi', sortable: true, align:'left', editor: RH.getNumEditor('skssimulasi', 'INTEGER', 0, 10, false, fnSelect), xtype: 'numbercolumn', format:'0,000', },{ header: setHeaderGrid('Semester'), width: 100, dataIndex: 'idsemester', sortable: true, //editor: RH.getComboEditor('idsemester', false, ds_semester, 'kode', 'nama', fnSelect), },{ header: setHeaderGrid('Wajib?'), width: 100, dataIndex: 'jnsmk', sortable: true, renderer: fnkeyShowDetailWajib, editor: RH.getComboEditor('jnsmk', false, ds_wajib, 'val', 'text', fnSelect), }], }); var form_bp_general = new Ext.form.FormPanel({ id: 'form_export_feeder_kurikulum', title: 'Export Kurikulum', width: 900, Height: 1000, layout: { type: 'form', pack: 'center', align: 'center' }, autoScroll: true, items: [ { xtype: 'fieldset', layout: 'form', title: 'Data Kurikulum', height: 120, boxMaxHeight:330, labelWidth: 100, labelAlign: 'right', items: [{ xtype: 'textfield', id: 'tf.nmkurikulum', fieldLabel: 'Nama Kurikulum ', width: 490, allowBlank: false, },{ xtype: 'compositefield', fieldLabel: 'Program Studi ', items: [{ id: 'cb.prodi', xtype: 'combo', store: ds_prodireg, triggerAction: 'all', valueField: 'kdprodi', displayField: 'lnmprodi', forceSelection: true, submitValue: true, mode: 'local', allowBlank: false, editable: false, width: 220, listeners:{ change:function(){ reload_matakuliah(); } } },{ xtype: 'label', text: 'Mulai Berlaku : ', margins: '3 5 0 15', //top right bottom left },{ id: 'cb.berlaku', xtype: 'combo', store: ds_berlaku, triggerAction: 'all', valueField: 'val', displayField: 'text', forceSelection: true, submitValue: true, mode: 'local', allowBlank: false, editable: false, width: 90, listeners:{ change:function(){ reload_matakuliah(); } } },{ id: 'cb.jsemester', xtype: 'combo', store: ds_jsemester, triggerAction: 'all', valueField: 'kdjnssemester', displayField: 'nmjnssemester', forceSelection: true, submitValue: true, mode: 'local', allowBlank: false, editable: false, width: 70, listeners:{ change:function(){ reload_matakuliah(); } } }] },{ xtype: 'compositefield', fieldLabel: 'Aturan SKS ', items: [{ xtype: 'label', text: 'Lulus * : ', margins: '3 5 0 40', //top right bottom left },{ id: 'tf.jumlahsks', xtype: 'numericfield', width: 50, },{ xtype: 'label', text: ' Wajib * : ', margins: '3 5 0 40', //top right bottom left },{ id: 'tf.jumlahskswajib', xtype: 'numericfield', width: 50, },{ xtype: 'label', text: ' Pilihan * : ', margins: '3 5 0 40', //top right bottom left },{ id: 'tf.jumlahskspilihan', xtype: 'numericfield', width: 50, }] }] },grid_matakuliah ] }); SET_PAGE_CONTENT(form_bp_general); function setHeaderGrid(text, align){ var hAlign = 'center'; if(align =='c') hAlign = 'center'; if(align =='l') hAlign = 'left'; if(align =='r') hAlign = 'right'; return "

"+text+"

"; } function reload_matakuliah(){ var prodi = Ext.getCmp('cb.prodi').getValue(); var berlaku = Ext.getCmp('cb.berlaku').getValue(); var jsemester = Ext.getCmp('cb.jsemester').getValue(); if(prodi && berlaku && jsemester){ ds_matakuliah.setBaseParam('kdprodi',prodi); ds_matakuliah.setBaseParam('thnmasuk',berlaku); ds_matakuliah.setBaseParam('idjnssemester',jsemester); ds_matakuliah.load(); /* ds_matakuliah.load({ scope : this, callback: function(records, operation, success) { jumlahsks = 0; jumlahskswajib = 0; jumlahskspilihan = 0; ds_matakuliah.each(function (rec) { var getjnsmk = rec.get('jnsmk'); jumlahsks += parseFloat(rec.get('jmlsks')); if(getjnsmk == 'A' || !getjnsmk){ jumlahskswajib += parseFloat(rec.get('jmlsks')); }else{ jumlahskspilihan += parseFloat(rec.get('jmlsks')); } }); Ext.getCmp("tf.jumlahsks").setValue(jumlahsks); Ext.getCmp("tf.jumlahskswajib").setValue(jumlahskswajib); Ext.getCmp("tf.jumlahskspilihan").setValue(jumlahskspilihan); } }); */ } } function fnkeyShowDetailWajib(value){ if(value == 'A' || !value){ return 'Wajib'; }else{ return 'Pilihan'; } } function export_to_feeder(){ var nmkurikulum = Ext.getCmp("tf.nmkurikulum").getValue(); var prodi = Ext.getCmp("cb.prodi").getValue(); var berlaku = Ext.getCmp("cb.berlaku").getValue(); var jsemester = Ext.getCmp('cb.jsemester').getValue(); var jumlahsks = Ext.getCmp("tf.jumlahsks").getValue(); var jumlahskswajib = Ext.getCmp("tf.jumlahskswajib").getValue(); var jumlahskspilihan = Ext.getCmp("tf.jumlahskspilihan").getValue(); if (grid_matakuliah.getStore().getCount() == 0 || !nmkurikulum || !prodi || !berlaku || !jumlahsks) { Ext.MessageBox.alert("Informasi", "Data Tidak Boleh Kosong"); } else { var waitmsg = Ext.MessageBox.wait('Mengekspor...', 'Info'); var griddata = []; grid_matakuliah.getStore().each(function(rec){ var rowData = rec.data; griddata.push(rowData); }); console.log(griddata); var gridjson = JSON.stringify(griddata); Ext.Ajax.request({ url: BASE_URL + 'feeder/feeder_kurikulum_controller/insert_kurikulum', timeout: 1000000, params: { nmkurikulum : nmkurikulum, prodi : prodi, berlaku : berlaku, jsemester : jsemester, jumlahsks : jumlahsks, jumlahsks : jumlahsks, jumlahskswajib : jumlahskswajib, jumlahskspilihan : jumlahskspilihan, griddata : gridjson, }, success: function(response){ waitmsg.hide(); obj = Ext.util.JSON.decode(response.responseText); Ext.MessageBox.alert('Informasi', obj.message); nmkurikulum = Ext.getCmp("tf.nmkurikulum").setValue(''); Ext.getCmp("cb.prodi").setValue(''); Ext.getCmp("cb.berlaku").setValue(''); Ext.getCmp('cb.jsemester').setValue(''); Ext.getCmp("tf.jumlahsks").setValue(''); Ext.getCmp("tf.jumlahskswajib").setValue(''); Ext.getCmp("tf.jumlahskspilihan").setValue(''); ds_matakuliah.setBaseParam('kdprodi',''); ds_matakuliah.setBaseParam('thnmasuk',''); ds_matakuliah.setBaseParam('idjnssemester',''); ds_matakuliah.load(); } }); } } }