function pSetBiayaTahapan(){ var ds_jbiaya = store_jbiaya(); var ds_tahun = store_tahun(); var ds_stsmt = store_stsmt(); var ds_sttahapan = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'setbiayatahapan_controller/get_sttahapan', method: 'POST' }), autoLoad: true, root: 'data', fields: [ { name: "idsttahapan", mapping: "idsttahapan" } , { name: "kdsttahapan", mapping: "kdsttahapan" } , { name: "nmsttahapan", mapping: "nmsttahapan" } ] }); var wAddEditStoresObj = new Object({ jbiaya: ds_jbiaya, tahun: ds_tahun, stsmt:ds_stsmt, sttahapan:ds_sttahapan}); var fields_setbiayatahapan = RH.storeFields('idsetbiayatahapan','idsttahapan','idjnsbiaya', 'kdjnsbiaya','nmjnsbiaya','thnmasuk','kdstsemester','nmthnakademik','nominal','persentase', 'tglawal','tglakhir','periode','kdsttahapan','nmsttahapan'); var pageSize = 18; var ds_setbiayatahapan = RH.JsonStore({ url : BASE_URL + 'setbiayatahapan_controller/get_setbiayatahapan', fields : fields_setbiayatahapan, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_setbiayatahapan = RH.searchComp({ id : 'sb_setbiayatahapan', fields : ['nmjnsbiaya:Jenis Biaya','thnmasuk:Tahun Masuk','nmthnakademik:Tahun Akademik - Semester'], selected : 'idstatus', store : ds_setbiayatahapan }); // COLUMN MODEL var cm_setbiayatahapan = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: 'Jenis Biaya',width: 100, dataIndex: 'kdjnsbiaya', sortable: true },{ header: 'Tahun Masuk', width: 100, dataIndex: 'thnmasuk', sortable: true, renderer: render_null, },{ header: 'Tahun Akademik - Semester', width: 200, dataIndex: 'nmthnakademik', sortable: true, renderer: render_null, },{ header: 'Tahapan', width: 100, dataIndex: 'nmsttahapan', sortable: true },{ header: 'Nominal', width: 100, dataIndex: 'nominal', sortable: true, xtype: 'numbercolumn', format:'0,000', align:'right' },{ header: 'Persentase', width: 100, dataIndex: 'persentase', sortable: true, renderer: render_persen, align:'right' },{ header: 'Periode', width: 150, dataIndex: 'periode', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_setbiayatahapan = RH.GridPanel_T1({ ds: ds_setbiayatahapan, cm: cm_setbiayatahapan, singleSelect: true, searchComp: sb_setbiayatahapan, allowAdd: true, fnAdd: fnAddSetbiayaTahapan, pageSize: pageSize, cellclick: onCellSetbiayaTahapanClick }); var fp_setbiayatahapan = RH.GPContainer1({ title: 'Setting Biaya Tahapan', iconCls:'silk-money', gridPanel: gp_setbiayatahapan, }); SET_PAGE_CONTENT(fp_setbiayatahapan); /** FUNCTIONS */ function render_null(value) { if (value) { return value; } else { return '-'; } } function render_persen(value) { if (value) { return value + ' %'; } else { return '-'; } } function onCellSetbiayaTahapanClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditSetbiayaTahapan(grid, record)}); RH.DeleteClick(e, function(){fnDeleteSetbiayaTahapan(grid, record)}); } function reloadSetbiayaTahapan(){ ds_setbiayatahapan.reload(); } function fnAddSetbiayaTahapan(){ var grid = gp_setbiayatahapan; wEntrySetbiayaTahapan(false, grid, null, wAddEditStoresObj); } function fnEditSetbiayaTahapan(grid, record){ wEntrySetbiayaTahapan(true, grid, record, wAddEditStoresObj); } function fnDeleteSetbiayaTahapan(grid, record){ var url = BASE_URL + 'setbiayatahapan_controller/delete_setbiayatahapan'; var params = new Object({ idsetbiayatahapan : record.data['idsetbiayatahapan'], }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT KELAS PROGRAM STUDI */ function wEntrySetbiayaTahapan(isUpdate, grid, record, wAddEditStoresObj){ var winTitle = (isUpdate)?'Setting Biaya Tahapan (Edit)':'Setting Biaya Tahapan (Entry)'; /** DATA SOURCE GRUP KELAS PROGRAM STUDI */ var ds_jbiaya = wAddEditStoresObj.jbiaya; var ds_tahun = wAddEditStoresObj.tahun; var ds_stsmt = wAddEditStoresObj.stsmt; var ds_sttahapan = wAddEditStoresObj.sttahapan; /** FORM ENTRY/EDIT MATA-KULIAH */ var setbiayatahapan_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.setbiayatahapan', buttonAlign: 'left', labelWidth: 200, labelAlign: 'right', bodyStyle: 'padding:0px 5px 0px 5px', // atas, kanan, bawah, kiri monitorValid: true, autoHeight:true, autoWidth:true, layout: 'form', frame: false, defaultType:'textfield', items: [ { xtype: 'fieldset', title: 'Jenis Biaya', layout: 'form', items: [{ xtype: 'textfield', id: 'tf.idsetbiayatahapan', fieldLabel: 'ID Setbiayatahapan', hidden: true, disabled: true },{ xtype: 'combo', id: 'cb.idjnsbiaya', fieldLabel: 'Jenis Biaya', store: ds_jbiaya, valueField: 'idjnsbiaya', displayField: 'kdjnsbiaya', triggerAction: 'all', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', selectOnFocus:false, width: 125, editable: false, listeners:{ select : function(){ var jnsbiaya = Ext.getCmp('cb.idjnsbiaya').getValue(); if(jnsbiaya=="2" || jnsbiaya=="5") { Ext.getCmp('cb.kdstsemester').allowBlank = true; Ext.getCmp('cb.kdstsemester').setValue(''); Ext.getCmp('cb.kdstsemester').disable(); Ext.getCmp('cb.thnmasuk').allowBlank = false; Ext.getCmp('cb.thnmasuk').enable(); } else { Ext.getCmp('cb.thnmasuk').allowBlank = true; Ext.getCmp('cb.thnmasuk').setValue(''); // Ext.getCmp('cb.thnmasuk').disable(); Ext.getCmp('cb.kdstsemester').allowBlank = false; Ext.getCmp('cb.kdstsemester').enable(); } cek_setbiayatahapan(); } } },{ xtype: 'combo', id: 'cb.thnmasuk', fieldLabel: 'Tahun Masuk', store: ds_tahun, valueField: 'kode', displayField: 'nama', triggerAction: 'all', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', selectOnFocus:false, //false spy ga fokus setelah dipilih width: 125, editable: false, listeners:{ select : function(){ cek_setbiayatahapan(); } } }, { xtype: 'combo', id: 'cb.kdstsemester', fieldLabel: 'Tahun Akademik - Semester', store: ds_stsmt, valueField: 'kdstsemester', displayField: 'nmsmt', triggerAction: 'all', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', selectOnFocus:false, //false spy ga fokus setelah dipilih width: 175, editable: false, listeners:{ select : function(){ cek_setbiayatahapan(); } } }, { xtype: 'combo', id: 'cb.idsttahapan', fieldLabel: 'Tahapan', store: ds_sttahapan, valueField: 'idsttahapan', displayField: 'nmsttahapan', triggerAction: 'all', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', selectOnFocus:false, //false spy ga fokus setelah dipilih width: 175, editable: false, listeners:{ select : function(){ cek_setbiayatahapan(); } } }] }, { xtype: 'fieldset', title: 'Nilai (Pilih Satu)', layout: 'form', items: [{ xtype: 'numericfield', fieldLabel: 'Nominal', id: 'nf.nominal', width: 125, allowBlank: false, listeners: { 'change': function(field, newVal, oldVal){ if(newVal) { Ext.getCmp('tf.persentase').allowBlank = true; Ext.getCmp('tf.persentase').setValue(''); Ext.getCmp('tf.persentase').disable(); Ext.getCmp('nf.nominal').allowBlank = false; Ext.getCmp('nf.nominal').enable(); } else { Ext.getCmp('tf.persentase').allowBlank = false; Ext.getCmp('tf.persentase').enable(); Ext.getCmp('nf.nominal').allowBlank = false; Ext.getCmp('nf.nominal').enable(); } } } }, { xtype: 'numberfield', fieldLabel: 'Persentase', id: 'tf.persentase', width: 125, allowBlank: false, listeners: { 'change': function(field, newVal, oldVal){ if(newVal) { Ext.getCmp('nf.nominal').allowBlank = true; Ext.getCmp('nf.nominal').setValue(''); Ext.getCmp('nf.nominal').disable(); Ext.getCmp('tf.persentase').allowBlank = false; Ext.getCmp('tf.persentase').enable(); } else { Ext.getCmp('tf.persentase').allowBlank = false; Ext.getCmp('tf.persentase').enable(); Ext.getCmp('nf.nominal').allowBlank = false; Ext.getCmp('nf.nominal').enable(); } } } }] }, { xtype: 'fieldset', title: 'Batas Waktu', layout: 'form', items: [{ xtype: 'datefield', id: 'df.tglawal', fieldLabel: 'Dari Tanggal', allowBlank: false, width: 150, value: new Date() },{ xtype: 'datefield', id: 'df.tglakhir', fieldLabel: 'Sampai Tanggal', allowBlank: false, width: 150, value: new Date() }] }], bbar: [{ xtype: 'textfield', id: 'hidealertbiayatahapanx', width: 90, hidden: true },{ xtype: 'label', text: '', id: 'alertbiayatahapanx', style: 'color: red;font-size:15px;', }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveSetbiayaTahapan(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wSetbiayaTahapan.close(); } }] }); var wSetbiayaTahapan = new Ext.Window({ title: winTitle, height: 500, width: 700, modal: true, closable:false, resizable:true, items: [setbiayatahapan_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setSetbiayaTahapanForm(isUpdate, record); wSetbiayaTahapan.show(); /** FORM FUNCTIONS */ function cek_setbiayatahapan() { var idjnsbiaya = RH.getCompValue('cb.idjnsbiaya'); var thnmasuk = RH.getCompValue('cb.thnmasuk'); var kdstsemester = RH.getCompValue('cb.kdstsemester'); var idsttahapan = RH.getCompValue('cb.idsttahapan'); var labelalertbiayatahapanx = Ext.getCmp('alertbiayatahapanx'); if (idjnsbiaya == '2' || idjnsbiaya == '5') { if(idjnsbiaya=='' || thnmasuk=='' || idsttahapan=='') return; } else { if(idjnsbiaya=='' || kdstsemester=='' || idsttahapan=='') return; } //var waitmsgcheck = Ext.MessageBox.wait('Checking Data...', 'Info'); Ext.Ajax.request({ url: BASE_URL + 'setbiayatahapan_controller/get_count_setbiayatahapan', method: 'POST', params :{ idjnsbiaya: idjnsbiaya, thnmasuk: thnmasuk, kdstsemester: kdstsemester, idsttahapan: idsttahapan }, scope: this, async:false, waitMsg: "Checking...", success: function(result){ //waitmsgcheck.hide(); var jsonData = Ext.decode(result.responseText); //bisa utk Ext3 dan Ext4 if (jsonData.result!='0') { labelalertbiayatahapanx.setText('Setting Biaya Tahapan Sudah Ada'); RH.setCompValue('hidealertbiayatahapanx', 'Setting Biaya Tahapan Sudah Ada'); } else { labelalertbiayatahapanx.setText(''); RH.setCompValue('hidealertbiayatahapanx', ''); } } }); } function setSetbiayaTahapanForm(isUpdate, record){ if(isUpdate){ if(record != null){ RH.disableComp('cb.idjnsbiaya'); //RH.disableComp('cb.thnmasuk'); RH.disableComp('cb.kdstsemester'); RH.disableComp('cb.idsttahapan'); RH.setCompValue('tf.idsetbiayatahapan', record.data['idsetbiayatahapan']); RH.setCompValue('cb.idjnsbiaya', record.data['idjnsbiaya']); RH.setCompValue('cb.thnmasuk', record.data['thnmasuk']); RH.setCompValue('cb.kdstsemester', record.data['kdstsemester']); RH.setCompValue('cb.idsttahapan', record.data['idsttahapan']); RH.setCompValue('nf.nominal', record.data['nominal']); RH.setCompValue('tf.persentase', record.data['persentase']); RH.setCompValue('df.tglawal', record.data['tglawal']); RH.setCompValue('df.tglakhir', record.data['tglakhir']); if(record.data['nominal']) { Ext.getCmp('tf.persentase').allowBlank = true; Ext.getCmp('tf.persentase').setValue(''); Ext.getCmp('tf.persentase').disable(); Ext.getCmp('nf.nominal').allowBlank = false; Ext.getCmp('nf.nominal').enable(); } else if(record.data['persentase']) { Ext.getCmp('nf.nominal').allowBlank = true; Ext.getCmp('nf.nominal').setValue(''); Ext.getCmp('nf.nominal').disable(); Ext.getCmp('tf.persentase').allowBlank = false; Ext.getCmp('tf.persentase').enable(); } return; } } } function fnSaveSetbiayaTahapan(){ var alertx = RH.getCompValue('hidealertbiayatahapanx'); if(alertx != ''){ return; }; var idForm = 'frm.setbiayatahapan'; var sUrl = BASE_URL +'setbiayatahapan_controller/insert_setbiayatahapan'; var sParams = new Object({ idsetbiayatahapan : RH.getCompValue('tf.idsetbiayatahapan'), idsttahapan : RH.getCompValue('cb.idsttahapan'), idjnsbiaya : RH.getCompValue('cb.idjnsbiaya'), thnmasuk : RH.getCompValue('cb.thnmasuk'), kdstsemester : RH.getCompValue('cb.kdstsemester'), nominal : RH.getCompValue('nf.nominal'), persentase : RH.getCompValue('tf.persentase'), 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 +'setbiayatahapan_controller/update_setbiayatahapan'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wSetbiayaTahapan, msgWait, msgSuccess, msgFail, msgInvalid); } }