/** DETIL#: JADWAL KULIAH ===================================== */ function cJadwalKuliah(kdprodi, kdstsemester, kdmk, nidu, idklsmhs, jmlmhs){ var fields_jdwkul = RH.storeFields('idjk','kdprodi', 'kdstsemester', 'kdmk', 'nidu', 'idhari', 'nmhari','idjam', 'darijam','sampaijam', 'jmlmhs','idruangan', 'klsparalel', 'kdruangan', 'nmruangan','kapasitas','selisih'); //from jadwalkuliah join ruangan /** GRID STORE: JADWAL KULIAH */ var pageSize = 3; var ds_jdwkul = RH.JsonStore({ url : BASE_URL + 'jadwal_controller/get_jadwalkuliah', fields : fields_jdwkul, limit: pageSize, params: [ {key:'kdprodi', value: kdprodi} ,{key:'kdstsemester', value: kdstsemester} ,{key:'kdmk', value: kdmk} ,{key:'nidu', value: nidu} ,{key:'idklsmhs', value: idklsmhs} //,{key:'jmlmhs', value: jmlmhs} ], enableSearch: false, }); /** GRID COLUMN MODEL */ var cm_jdwkul = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: 'Hari', width:60, dataIndex: 'nmhari', sortable: true }, { header: 'Mulai', width: 60, dataIndex: 'darijam', align:'center' }, { header: 'Selesai', width: 60, dataIndex: 'sampaijam', align:'center' }, { header: 'Kelas
Paralel', width:60, dataIndex: 'klsparalel', align:'center' }, { header: 'Jumlah
Mhsw', width: 60, dataIndex: 'jmlmhs', align:'right' }, { header: 'Ruangan', width:60, dataIndex: 'nmruangan', }, { header: 'Kapasitas', width:60, dataIndex: 'kapasitas', align:'right' }, { header: 'Selisih', width:60, dataIndex: 'selisih', align:'right' }, RH.DeleteColumn() ] ); var allowadd =(jmlmhs=='0') ? false:true; /** GRID PANEL */ var gp_jdwkul = RH.GridPanel_T1({ id: 'gp_jdwkul', ds: ds_jdwkul, cm: cm_jdwkul, singleSelect: true, searchComp: { xtype:'tbfill'}, allowAdd: allowadd, fnAdd: fnGetEntry, pageSize: pageSize, cellclick: onCellJdwkulClick });return gp_jdwkul; function onCellJdwkulClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); RH.DeleteClick(e, function(){fnDeleteJdwkul(grid, record)}); } function fnDeleteJdwkul(grid, record){ var url = BASE_URL + 'jadwal_controller/delete_jadwalkuliah'; var params = new Object({ idjk : record.data['idjk'], idjam : record.data['idjam'] }); RH.deleteGridRecord(url, params, grid ); } /** FORM ENTRY JADWAL-KULIAH */ function fnGetEntry(){ var ds_hari = store_hari(); var ds_ruangan = store_ruangan(); var ds_tipekelas = store_tipekelas(); var ds_klsparalel = store_klsparalel(); var ds_grid = new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'jadwal_controller/get_jamkul', method: 'POST' }), baseParams: { idjk:'' }, root: 'data', totalProperty: 'results', autoLoad: true, fields: [{ name: "idjam", mapping: "idjam" }, { name: "kdjam", mapping: "kdjam" }, { name: "darijam", mapping: "darijam" }, { name: "sampaijam", mapping: "sampaijam" }, { name: "pilih", mapping: "pilih", type: 'bool' }] }); var cm = new Ext.grid.ColumnModel({ // specify any defaults for each column defaults: { sortable: true // columns are not sortable by default }, columns: [ { xtype: 'checkcolumn', header: '
Pilih
', width: 40, dataIndex: 'pilih', sortable: true }, { header: '
Jam
Ke-
', width: 40, dataIndex: 'kdjam', sortable: true, align: 'center' }, { header: '
Dari Jam
', width: 70, dataIndex: 'darijam', sortable: true }, { header: '
Sampai Jam
', width: 80, dataIndex: 'sampaijam', sortable: true } ] }); var grid_nya = new Ext.grid.EditorGridPanel({ store: ds_grid, frame: false, autoScroll: true, height: 385, autoWidth: true, id: 'gridjamkuliah', buttonAlign: 'left', defaults: { anchor: '-10' }, forceFit: true, columnLines: true, cm: cm, clicksToEdit: 1, listeners: { rowdblclick: function rowdblClick(grid, rowIdx) { } } }); var fAddJdwkul = new Ext.form.FormPanel({ xtype:'form', id: 'frm.addJdwkul', buttonAlign: 'left', labelWidth: 120, labelAlign: 'right', bodyStyle: 'padding:3px 3px 3px 3px', // atas, kanan, bawah, kiri monitorValid: true, height: 500, width: 700, layout: 'column', frame: false, defaultType:'textfield', items: [{ columnWidth: .55, xtype: 'panel', border: false, bodyStyle: 'padding:0px 0px 0px 0px', items: [{ layout: 'form', border: false, items: [{ xtype: 'fieldset', title: 'Waktu', layout: 'form', id:'fswaktu', height: 450, items: [{ xtype: 'combo', id: 'cb.frm.hari', fieldLabel: 'Hari', width: 150, store: ds_hari, valueField: 'kode', displayField: 'nama', triggerAction: 'all', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', allowBlank: false, editable: false },{ xtype:'container', layout:'hbox', fieldLabel: 'Waktu/Jam Ke-:', items:[grid_nya] }] }] }] }, { columnWidth: .45, xtype: 'panel', border: false, bodyStyle: 'padding:0px 0px 0px 0px', items: [{ layout: 'form', border: false, items: [{ xtype: 'fieldset', title: 'Tempat', layout: 'form', id:'fstempat', height: 450, items: [ RH.ActionCombo({ id: 'cb.frm.ruangan', label: 'Ruangan', width: 150, data: ds_ruangan, key: 'idruangan', display: 'nmruangan', cannotEmpty:true, fnSelect: cb_ruangan_selected }), { id: 'tf.frm.tiperuangan', xtype:'textfield', fieldLabel: 'Tipe Ruangan', width: 80, disabled: true, align:'right' }, { xtype: 'combo', id: 'cb.frm.tipekelas', fieldLabel: 'Tipe Kelas', width: 150, store: ds_tipekelas, valueField: 'idtipekelas', displayField: 'nmtipekelas', forceSelection: true, submitValue: true, mode: 'local', triggerAction: 'all', emptyText:'Pilih...', editable: false, allowBlank: false, listeners:{ } }, { id: 'nf.frm.jmlmhs', xtype:'numberfield', fieldLabel: 'Jumlah Mahasiswa', value:jmlmhs, width: 80, disabled: true, align:'right' }, { id: 'nf.frm.kapasitas', xtype:'numberfield', fieldLabel: 'Kapasitas', width: 80, disabled: true, align:'right' }, { id: 'nf.frm.selisih', xtype:'numberfield', width: 80, disabled: true, align:'right' }, { xtype:'label', id:'lb.infokapasitas', margins: '0 0 0 0', text:'', style: 'color: black;font-size:12px;', } /* RH.ActionCombo({ id: 'cb.frm.klsparalel', label: 'Kelas Paralel', width: 80, data: ds_klsparalel, key: 'klsparalel', display: 'klsparalel', cannotEmpty:true, fnSelect: cb_klsparalel_selected }), { xtype: 'combo', id: 'cb.frm.ruangan', fieldLabel: 'Ruangan', width: 150, store: ds_ruangan, valueField: 'idruangan', displayField: 'nmruangan', forceSelection: true, submitValue: true, mode: 'local', triggerAction: 'all', emptyText:'Pilih...', editable: false, allowBlank: false, listeners:{ scope: this, select: cb_ruangan_selected } },*/] }] }] }], buttons: [{ text: 'Simpan', iconCls:'silk-save', id:'btn-simpan-kuliah', handler: function() { fnSaveJdwkul('frm.addJdwkul'); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wAddJdwkul.close(); } }] }); var wAddJdwkul = new Ext.Window({ title: 'Jadwal Kuliah', modal: true, closable:false, items: [fAddJdwkul] }).show(); function cb_klsparalel_selected(combo, records){ var klsparalel = records.data['klsparalel']; Ext.Ajax.request({ url: BASE_URL + 'jadwal_controller/get_jmlmhs', method: 'POST', params :{ kdstsemester: kdstsemester, kdprodi : kdprodi, kdmk : kdmk, nidu : nidu, idklsmhs : idklsmhs, klsparalel : klsparalel }, scope: this, async:false, waitMsg: "sedang proses...", success: function(result){ var jsonData = Ext.decode(result.responseText); //bisa utk Ext3 dan Ext4 var jmlmhs = jsonData.jmlmhs; RH.setCompValue('nf.frm.jmlmhs', jmlmhs); var kapasitas = RH.getCompValue('nf.frm.kapasitas'); if(kapasitas!=null && kapasitas !=''){ setSelisihAndInfo(kapasitas, jmlmhs); } } }); } function cb_ruangan_selected(combo, records){ var tiperuangan = records.data['nmtiperuangan']; var kapasitas = records.data['kapasitas']; var jmlmhs = RH.getCompValue('nf.frm.jmlmhs'); RH.setCompValue('tf.frm.tiperuangan', tiperuangan); RH.setCompValue('nf.frm.kapasitas', kapasitas); setSelisihAndInfo(kapasitas, jmlmhs); } function setSelisihAndInfo(kapasitas, jmlmhs){ var selisih = kapasitas - jmlmhs; var info = ''; if(kapasitas > jmlmhs) { info = 'Kapasitas Ruangan Masih Cukup'; Ext.getCmp('btn-simpan-kuliah').enable(); } if(kapasitas == jmlmhs) { info = 'Ruangan Sudah Penuh'; Ext.getCmp('btn-simpan-kuliah').enable(); } if(kapasitas < jmlmhs) { info = 'Kapasitas Ruangan Tidak Cukup!'; Ext.getCmp('btn-simpan-kuliah').disable();} RH.setCompValue('nf.frm.selisih', selisih); Ext.getCmp('lb.infokapasitas').setText(info); } function fnSaveJdwkul(namaForm){ var waktu = get_waktu(); var sParams = new Object({ idkelas : idklsmhs, idtipekelas : RH.getCompValue('cb.frm.tipekelas'), kdstsemester: kdstsemester, kdprodi : kdprodi, mat_kdprodi : kdprodi, kdmk : kdmk, nidu : nidu, idhari : RH.getCompValue('cb.frm.hari'), idruangan : RH.getCompValue('cb.frm.ruangan'), waktu : waktu }); var form_nya = Ext.getCmp(namaForm); form_nya.getForm().submit({ url: BASE_URL + 'jadwal_controller/insert_jadwalkuliah', method: 'POST', params: sParams, waitMsg: 'Tunggu, sedang proses...', success: function() { Ext.MessageBox.alert("Informasi", "Simpan Data Berhasil"); wAddJdwkul.close(); ds_jdwkul.reload(); }, failure: function() { Ext.MessageBox.alert("Informasi", "SImpan Data Gagal"); } }); } function get_waktu() { var par=''; var a= 1; var c = ';'; grid_nya.getStore().each(function(rec){ // ambil seluruh grid prodi var rowData = rec.data; if (a == grid_nya.getStore().getCount()) { c = '' } var j = (rowData['pilih']) ? 1 : 0; par += rowData['idjam'] + 'x' + rowData['darijam'] + 'x' + rowData['sampaijam'] + 'x' + j + 'x' + // pilih c; a= a+1; }); return par; } } } /** DETIL#: JADWAL Ujian ===================================== */ function cJadwalUjian(kdprodi, kdstsemester, kdmk, nidu, idklsmhs, jmlmhs){ var fields_jdwuji = RH.storeFields('idju','kdprodi', 'kdstsemester', 'kdmk', 'nidu', 'idhari', 'nmhari', 'tglujian','idjnsujian','kdjnsujian','nmjnsujian', 'darijam','sampaijam', 'jmlmhs','idruangan', 'klsparalel', 'kdruangan', 'nmruangan','kapasitas','selisih'); /** GRID STORE: JADWAL UJIAN */ var pageSize = 3; var ds_jdwuji = RH.JsonStore({ url : BASE_URL + 'jadwal_controller/get_jadwalujian', fields : fields_jdwuji, limit: pageSize, params: [ {key:'kdprodi', value: kdprodi} ,{key:'kdstsemester', value: kdstsemester} ,{key:'kdmk', value: kdmk} ,{key:'nidu', value: nidu} ,{key:'idklsmhs', value: idklsmhs} ,{key:'jmlmhs', value: jmlmhs} ], enableSearch: false, }); /** GRID COLUMN MODEL */ var cm_jdwuji = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: 'Hari', width:60, dataIndex: 'nmhari', hidden:true, sortable: true }, { header: 'Jenis
Ujian', width: 60, dataIndex: 'kdjnsujian'//'nmjnsujian', }, { header: 'Tanggal', width:70, dataIndex: 'tglujian',sortable: true, //renderer: RH.convertToDate }, { header: 'Mulai', width: 60, dataIndex: 'darijam', align:'center' }, { header: 'Selesai', width: 60, dataIndex: 'sampaijam', align:'center' }, { header: 'Kelas
Paralel', width: 60, hidden:true, dataIndex: 'klsparalel', align:'center' }, { header: 'Jml
Mhsw', width: 55, dataIndex: 'jmlmhs', align:'right' }, { header: 'Ruangan', width:70, dataIndex: 'nmruangan', }, { header: 'Kapasitas', width:60, dataIndex: 'kapasitas', align:'right' }, { header: 'Selisih', width:50, dataIndex: 'selisih', align:'right' }, RH.DeleteColumn() ] ); /** GRID PANEL */ var gp_jdwuji = RH.GridPanel_T1({ ds: ds_jdwuji, cm: cm_jdwuji, singleSelect: true, searchComp: { xtype:'tbfill'}, allowAdd: true, fnAdd: fnGetEntry, pageSize: pageSize, cellclick: onCellJdwujiClick });return gp_jdwuji; function onCellJdwujiClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); RH.DeleteClick(e, function(){fnDeleteJdwuji(grid, record)}); } function fnDeleteJdwuji(grid, record){ var url = BASE_URL + 'jadwal_controller/delete_jadwalujian'; var params = new Object({ idju : record.data['idju'] }); RH.deleteGridRecord(url, params, grid ); } /** FORM ENTRY JADWAL-UJIAN */ function fnGetEntry(){ var ds_hari = store_hari(); var ds_ruangan = store_ruangan(); var ds_jam = store_jam(); var ds_jujian = store_jujian(); var ds_klsparalel = store_klsparalel(); var valjam=0, valkap=0; var fAddJdwuji = new Ext.form.FormPanel({ xtype:'form', id: 'frm.addJdwuji', buttonAlign: 'left', labelWidth: 120, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 260, width: 600, layout: 'form', frame: false, defaultType:'textfield', items: [ /*{ xtype: 'combo', id: 'cb.frm.hari', fieldLabel: 'Hari', width: 150, store: ds_hari, valueField: 'kode', displayField: 'nama', triggerAction: 'all', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', allowBlank: true, editable: false },*/ { xtype: 'combo', id: 'cb.frm.jujian', fieldLabel: 'Jenis Ujian', width: 200, store: ds_jujian, valueField: 'idjnsujian', displayField: 'nmjnsujian', triggerAction: 'all', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', allowBlank: false, editable: false },{ xtype: 'datefield', id: 'df.frm.tgl', fieldLabel: 'Tanggal Ujian', value: new Date(), width: 100 }, { xtype: 'compositefield', items: [{ xtype: 'textfield', fieldLabel:'Waktu (hh:mm:ss)', id: 'tf.frm.darijam', enableKeyEvents: true, listeners: { change: function(value){ validatetime(); // Function call on event change } }, width: 100, allowBlank: false }, { xtype: 'label', id: 'lb.garing3', text: 's.d' },{ xtype: 'textfield', id: 'tf.frm.sampaijam', enableKeyEvents: true, listeners: { change: function(value){ validatetime(); // Function call on event change } }, width: 100, allowBlank: false },{ xtype: 'label', id: 'alerttime', text: '' }] }, /* RH.TimeRangeCombos({ labels:['Waktu','s.d'], ids:['tf.frm.darijam','tf.frm.sampaijam'], space:20, store: ds_jam, valueField:'kode', displayField:'nama' }), */ /* { xtype: 'combo', id: 'cb.frm.klsparalel', fieldLabel: 'Kelas Paralel', width: 100, store: ds_klsparalel, valueField: 'klsparalel', displayField: 'klsparalel', forceSelection: true, submitValue: true, mode: 'local', triggerAction: 'all', emptyText:'Pilih...', editable: false, allowBlank: false, }, */ { id: 'nf.frm.jmlmhs', xtype:'numberfield', fieldLabel: 'Jumlah Mahasiswa', value:jmlmhs, width: 100, disabled: true, align:'right' },{ xtype: 'combo', id: 'cb.frm.ruangan', fieldLabel: 'Ruangan', width: 150, store: ds_ruangan, valueField: 'idruangan', displayField: 'nmruangan', forceSelection: true, submitValue: true, mode: 'local', triggerAction: 'all', emptyText:'Pilih...', editable: false, allowBlank: false, listeners:{ scope: this, select: cb_ruangan_selected } },{ id: 'nf.frm.kapasitas', xtype:'numberfield', fieldLabel: 'Kapasitas', width: 100, disabled: true, align:'right' },{ xtype:'container', layout:'hbox', fieldLabel: 'Selisih', items:[{ id: 'nf.frm.selisih', xtype:'numberfield', width: 100, disabled: true, align:'right' },{ xtype:'label', id:'lb.infokapasitas', margins: '0 0 0 6', text:'' }] }], buttons: [{ text: 'Simpan', iconCls:'silk-save', id:'btn-simpan-ujian', handler: function() { fnSaveJdwuji(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wAddJdwuji.close(); } }] }); var wAddJdwuji = new Ext.Window({ title: 'Jadwal Ujian', modal: true, closable:false, items: [fAddJdwuji] }).show(); function cb_ruangan_selected(combo, records){ var kapasitas = records.data['kapasitas']; var selisih = kapasitas - jmlmhs; var info = ''; if(kapasitas > jmlmhs) { info = 'Kapasitas Ruangan Masih Cukup'; Ext.getCmp('btn-simpan-ujian').enable(); valkap=1;} if(kapasitas == jmlmhs) { info = 'Ruangan Sudah Penuh'; Ext.getCmp('btn-simpan-ujian').enable(); valkap=1} if(kapasitas < jmlmhs) { info = 'Kapasitas Ruangan Tidak Cukup'; Ext.getCmp('btn-simpan-ujian').disable(); valkap=0} RH.setCompValue('nf.frm.kapasitas', kapasitas); RH.setCompValue('nf.frm.selisih', selisih); Ext.getCmp('lb.infokapasitas').setText(info); } function validatetime() { var labelalerttime = Ext.getCmp('alerttime'); var isValid = /^([0-1]?[0-9]|2[0-4]):([0-5][0-9])(:[0-5][0-9])?$/.test(Ext.getCmp('tf.frm.darijam').getValue()); var isValid2 = /^([0-1]?[0-9]|2[0-4]):([0-5][0-9])(:[0-5][0-9])?$/.test(Ext.getCmp('tf.frm.sampaijam').getValue()); labelalerttime.setText('Format jam sesuai'); Ext.getCmp('btn-simpan-ujian').enable(); valjam=1; if (!isValid) { labelalerttime.setText('Format jam salah'); Ext.getCmp('btn-simpan-ujian').disable(); valjam=0; } if (!isValid2) { labelalerttime.setText('Format jam salah'); Ext.getCmp('btn-simpan-ujian').disable(); valjam=0; } } function fnSaveJdwuji(){ if (valjam !=1 || valjam !=1) { Ext.getCmp('btn-simpan-ujian').disable(); return;} var sParams = new Object({ kdstsemester: kdstsemester, kdprodi : kdprodi, kdmk : kdmk, nidu : nidu, idhari : null, //RH.getCompValue('cb.frm.hari'), tglujian : RH.getCompValue('df.frm.tgl'), darijam : RH.getCompValue('tf.frm.darijam'), sampaijam : RH.getCompValue('tf.frm.sampaijam'), idjnsujian : RH.getCompValue('cb.frm.jujian'), idruangan : RH.getCompValue('cb.frm.ruangan'), klsparalel : RH.getCompValue('cb.frm.klsparalel'), }); RH.InsertToGrid({ formId: 'frm.addJdwuji', url: BASE_URL +'jadwal_controller/insert_jadwalujian', params: sParams, grid: gp_jdwuji, window: wAddJdwuji, }); } } }