function pSrtpernyataan(){ /** COMMON STORES */ var ds_prodireg = store_prodireg(); var ds_stsmt = store_stsmt(); var ds_jbiaya = store_jbiaya(); var ds_stsetuju = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_stsetuju', method: 'POST' }), autoLoad: true, root: 'data', fields: [ { name: "idstsetuju", mapping: "idstsetuju" } , { name: "nmstsetuju", mapping: "nmstsetuju" } ] }); var ds_pimpinansrtpernyataan = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_pimpinan_surat', method: 'POST' }), baseParams: { kdfakultas:'' }, autoLoad: true, root: 'data', fields: [ { name: "idpimpinan", mapping: "idpimpinan" } , { name: "nmpimpinan", mapping: "nmpimpinan" } , { name: "kdfakultas", mapping: "kdfakultas" } ] }); var ds_semester = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_semester_srtpernyataan', method: 'POST' }), autoLoad: true, root: 'data', fields: [ { name: "idsemester", mapping: "idsemester" } , { name: "tingkat", mapping: "tingkat" } ] }); var wAddEditStoresObj = new Object({ prodi: ds_prodireg, stsemester: ds_stsmt, setuju: ds_stsetuju, pimpin: ds_pimpinansrtpernyataan, semester: ds_semester, jbiaya: ds_jbiaya}); var fields_srtpernyataan = RH.storeFields( 'idsrtpernyataan','tglpermohonan','kdstsemester','idsemester','nim','nmortu','idjnsbiaya', 'sisabiaya', 'idstsetuju','idpimpinan','tglpelunasan','tglpersetujuan','kdthnakademik','nmjnssemester', 'nmmhs','kdprodi','nmprodi','alamatsurat','kdsemester','nmsemester','tingkat','biaya','kdstsetuju','nmstsetuju', 'nmpimpinan','biayakuliah','kdfakultas','nmfakultas'); var pageSize = 20; var ds_srtpernyataan = RH.JsonStore({ url : BASE_URL + 'srtpernyataan_controller/get_srtpernyataan', fields : fields_srtpernyataan, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_srtpernyataan = RH.searchComp({ id : 'sb_srtpernyataan', fields : ['nim:NPM','nmmhs:Nama'], selected : 'nim', store : ds_srtpernyataan }); //GRID KOLOM// var cm_srtpernyataan = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Tgl.Permohonan'),width: 100, dataIndex: 'tglpermohonan', sortable: true }, { header: RH.h3('NPM'),width: 100, dataIndex: 'nim', sortable: true }, { header: RH.h3('Nama Mahasiswa'),width: 200, dataIndex: 'nmmhs', sortable: true }, { header: RH.h3('Program Studi'),width: 150, dataIndex: 'nmprodi', sortable: true }, { header: RH.h3('Tahun Akademik'),width: 120, dataIndex: 'kdthnakademik', sortable: true }, { header: RH.h3('Tingkat/ Semester'),width: 120, dataIndex: 'idsemester', align: 'center', sortable: true, renderer: function(value, p, r) {return r.data['tingkat'] + ' / ' + r.data['kdsemester']} }, { header: RH.h3('Sisa Biaya'),width: 100, dataIndex: 'biayakuliah', sortable: true, xtype: 'numbercolumn', format:'0,000', align:'right', }, { header: RH.h3('Status'),width: 110, dataIndex: 'nmstsetuju', sortable: true }, RH.EditColumn(), /* RH.DeleteColumn(), */ RH.PrintColumn() ] ); // Selection Model UNTUK PAGING MANUAL var sm_srtpernyataan = new Ext.grid.RowSelectionModel({ singleSelect: true }); // Grid View var gv_srtpernyataan = new Ext.grid.GridView({emptyText: '< Belum ada Data >'}); /** THE GRID */ var gp_srtpernyataan = new Ext.grid.EditorGridPanel({ ds: ds_srtpernyataan, cm: cm_srtpernyataan, singleSelect: true, //searchComp: sb_srtpernyataan, allowAdd: true, //fnAdd: fnAddsrtpernyataan, //pageSize: pageSize, //cellclick: onCellsrtpernyataanClick sm: sm_srtpernyataan, view: gv_srtpernyataan, clicksToEdit: 1, //for cell editing (single click =1, dblclick=2) forceFit: true, //autoHeight: true, layout:'anchor', //autoSizeColumns: true, //autoExpandColumn: 'nmmkind', autoScroll:true, //enableColumnResize: true, columnLines: true, loadMask: true, tbar:[sb_srtpernyataan], bbar: new Ext.PagingToolbar({ store: ds_srtpernyataan, displayInfo: true, pageSize: pageSize, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { cellclick: onCellsrtpernyataanClick } }); var fp_srtpernyataan = new Ext.Panel({ title: 'Surat Pernyataan', iconCls:'silk-report', xtype: 'form', buttonAlign: 'left', bodyStyle: 'padding: 5px', border: false, layout: 'border', waitMsg: 'Waiting...', maskDisabled: false, monitorValid: true, autoScroll:true, frame: true, items: [{ xtype: 'fieldset', flex: 1, region:'north', layout:'form', autoHeight:true, items: [{ xtype: 'container', layout: 'hbox', items:[{ layout:'form', labelWidth:90, labelAlign:'right', items: [ RH.ActionCombo({ id: 'cb.prodi-stru', label: 'Program Studi', width: 300, data: ds_prodireg, key: 'kdprodi', display: 'lnmprodi', fnSelect: function(){ reloadGridSrtpernyataan(); } }) ] },{ layout:'form', labelWidth:200, labelAlign:'right', items: [ RH.ActionCombo({ id: 'cb.smt-stru', label: 'Tahun Akademik-Semester', width: 160, data: ds_stsmt, key: 'kdstsemester', display: 'nmsmt', fnSelect: function(){ reloadGridSrtpernyataan(); }, }/* ,{ xtype: 'textfield', id: 'hidden.idsrtpernyataan', hidden:true, } */) ] }] }] },{ region: 'center', layout:'form', autoScroll:true, items:[{ xtype: 'panel', layout:'fit', height:520, title:'Data Surat Pernyataan', id:'fp.master', frame:true, items: [gp_srtpernyataan], tbar: [{ text: 'Tambah', id: 'idadd-stmhssmt', iconCls: 'silk-add', handler:function(){ var prodi = Ext.getCmp('cb.prodi-stru').getRawValue(); var tahun = Ext.getCmp('cb.smt-stru').getRawValue(); if(prodi == '') { Ext.Msg.alert("Info", "Program Studi Harus Diisi"); } else if(tahun == '') { Ext.Msg.alert("Info", "Tahun Akademik Harus Diisi"); } else if(prodi != '' && tahun != '') { fnAddsrtpernyataan(); } } }] }], }], //gridPanel: gp_srtpernyataan, }); SET_PAGE_CONTENT(fp_srtpernyataan); /** FUNCTIONS */ function reloadGridSrtpernyataan(){ //remove detail RH.removeDetail('fp.detil'); //reload master-grid ds_srtpernyataan.reload({ params: { kdprodi: RH.getCompValue('cb.prodi-stru', true), kdstsemester: RH.getCompValue('cb.smt-stru', true) } }); } function onCellsrtpernyataanClick(grid, rowIndex, columnIndex, e) { var t = e.getTarget(); var record = grid.getStore().getAt(rowIndex); // Get the Record var kdprodi = record.data['kdprodi']; var kdstsemester = record.data['kdstsemester']; var idsrtpernyataan = record.data['idsrtpernyataan']; //RH.removeDetail('fp.detil'); //RH.setCompValue('hidden.idsrtpernyataan', idsrtpernyataan); //var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditsrtpernyataan(grid, record)}); RH.DeleteClick(e, function(){fnDeletesrtpernyataan(grid, record)}); RH.PrintClick(e, function(){fnPrintsrtpernyataan(grid, record)}); return true; } function reloadsrtpernyataan(){ ds_srtpernyataan.reload(); } function fnAddsrtpernyataan(){ var combo_stsmt = Ext.getCmp('cb.smt-stru'); var combo_prodi = Ext.getCmp('cb.prodi-stru'); var grid = gp_srtpernyataan; wform_srtpernyataan(false, grid, combo_prodi, combo_stsmt, null, wAddEditStoresObj); } function fnPrintsrtpernyataan(grid, record){ var nim = record.data['nim'] RH.ShowReport(BASE_URL + 'surat/surat_pernyataan/get_surat_pernyataan/' + nim); } function fnEditsrtpernyataan(grid, record){ var combo_stsmt = Ext.getCmp('cb.smt-stru'); var combo_prodi = Ext.getCmp('cb.prodi-stru'); //wform_srtpernyataan(true, grid, record); wform_srtpernyataan(true, grid, combo_prodi, combo_stsmt, record, wAddEditStoresObj); } function fnDeletesrtpernyataan(grid, record){ var url = BASE_URL + 'srtpernyataan_controller/delete_srtpernyataan'; var params =new Object({ idsrtpernyataan : record.data['idsrtpernyataan'] }); RH.deleteGridRecord(url, params, grid ); } } /** GRID FORM */ function wform_srtpernyataan(isUpdate, grid, combo_prodi, combo_stsmt, record, wAddEditStoresObj){ var winTitle = (isUpdate)?'Surat Pernyataan (Edit)':'Surat pernyataan (Entry)'; var ds_prodireg = wAddEditStoresObj.prodi; var ds_stsmt = wAddEditStoresObj.stsemester; var ds_stsetuju = wAddEditStoresObj.setuju; var ds_pimpinanobj = wAddEditStoresObj.pimpin; var ds_semester = wAddEditStoresObj.semester; var ds_jbiaya = wAddEditStoresObj.jbiaya; //VARIABEL YANG DIAMBIL NILAINYA DARI COMBO PRODI DAN SEMESTER //var ds_stsmt = combo_stsmt.getStore(); //var ds_prodireg = combo_prodi.getStore(); var kdstsemester = combo_stsmt.getValue(); var kdprodi = combo_prodi.getValue(); var srtpernyataan_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.srtpernyataan', buttonAlign: 'left', labelWidth: 250, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri //monitorValid: true, height: 520, width: 700, autoScroll: true, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'idsrtpernyataan', hidden: true, xtype: 'textfield' }, { xtype: 'datefield', id: 'df.tglpermohonan', fieldLabel: 'Tgl.Permohonan', value: new Date(), width: 100 }, { xtype: 'compositefield', name: 'nim', fieldLabel: 'NPM', id: 'nim', items: [{ id: 'tf.frm.nim', xtype:'textfield', fieldLabel: 'NPM', width: 150, allowBlank: false, disabled: true, }, { xtype: 'button', fieldLabel: 'Cari', hidden:false, labelStyle: 'width:160px', id: 'btncari', name: 'btncari', width: 50, handler: function() { wGridMhsPernyataan('srt_pernyataan',kdprodi,kdstsemester);} //,kdstsemester }] }, { id: 'tf.frm.nmmhs', fieldLabel: 'Nama Mahasiswa', width: 250, allowBlank: false, disabled: true, xtype: 'textfield' }, { id: 'tf.frm.nmortu', fieldLabel: 'Nama Orangtua', width: 250, allowBlank: false, disabled: true, }, { id: 'tf.frm.alamatortu', xtype: 'textarea', fieldLabel: 'Alamat Orangtua', width: 250, allowBlank: false, disabled: true, }, { id: 'tf.frm.fakultas', fieldLabel: 'Fakultas', width: 250, allowBlank: false, disabled: true, xtype: 'textfield' }, { xtype: 'combo', id: 'tf.frm.programstudi', fieldLabel: 'Program Studi', store: ds_prodireg, triggerAction: 'all', valueField: 'kdprodi', displayField: 'lnmprodi', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 250, allowBlank: false, editable: false }, { xtype: 'combo', id: 'cb.frm.kdstsemester', fieldLabel: 'Tahun Akademik-Semester', store: ds_stsmt, triggerAction: 'all', valueField: 'kdstsemester', displayField: 'nmsmt', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 250, allowBlank: false }, { xtype: 'combo', id: 'cb.frm.idsemester', fieldLabel: 'Tingkat/ Semester', store: ds_semester, triggerAction: 'all', valueField: 'idsemester', displayField: 'tingkat', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 80, editable: false, readOnly: true, disabled: true, }, { xtype: 'combo', fieldLabel: 'Jenis Biaya', id: 'cb.jbiaya-byr', store: ds_jbiaya, valueField: 'idjnsbiaya', displayField: 'kdjnsbiaya', editable: false, allowBlank: false, triggerAction: 'all', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 80, listeners:{ select: function() { getbiaya(); } } }, { fieldLabel: 'Jenis Kelas', id: 'idjnskelas', hidden: true, readOnly: true, disabled: true, }, { fieldLabel: 'Id Pekerjaan Ortu', id: 'tf.frm.idpekerjaanortu', hidden: true, readOnly: true, disabled: true, }, { fieldLabel: 'Tahun Masuk', name: 'idthnmasuk', xtype: 'textfield', id: 'idthnmasuk', readOnly: true, disabled: true, hidden: true, }, { xtype: 'numericfield', fieldLabel: 'Biaya', id: 'tf.frm.nmbiaya', readOnly: true, disabled: true, width: 150, decimalSeparator: ',', decimalPrecision: 2, alwaysDisplayDecimals: true, useThousandSeparator: true, thousandSeparator: '.', value: 0, //disabledCls: 'af-item-disabled',tf.frm.biayasisa tf.frm.nmbiaya }, { xtype: 'numericfield', fieldLabel: 'Tunggakan', id: 'tf.frm.biayasisa', readOnly: true, disabled: true, width: 150, decimalSeparator: ',', decimalPrecision: 2, alwaysDisplayDecimals: true, useThousandSeparator: true, thousandSeparator: '.', value: 0, //disabledCls: 'af-item-disabled', }, { xtype: 'datefield', id: 'df.tglpelunasan', fieldLabel: 'Tgl.Pelunasan', value: new Date(), width: 100 }, { xtype: 'combo', id: 'cb.frm.idstsetuju', fieldLabel: 'Status', store: ds_stsetuju, triggerAction: 'all', valueField: 'idstsetuju', displayField: 'nmstsetuju', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 250, allowBlank: false, editable: false, listeners:{ select: function() { var sts = Ext.getCmp('cb.frm.idstsetuju').getRawValue(); if (sts == "Disetujui"){ Ext.getCmp('df.tglpersetujuan').enable(); Ext.getCmp('df.tglpersetujuan').setValue(new Date()) } else if (sts == "Tidak Disetujui") { Ext.getCmp('df.tglpersetujuan').disable(); Ext.getCmp('df.tglpersetujuan').setValue(null); } } } }, { xtype: 'datefield', id: 'df.tglpersetujuan', fieldLabel: 'Tgl.Disetujui', value: new Date(), disabled: true, width: 100 }, { fieldLabel: 'Kode Fakultas', id: 'kode_fakultas', hidden: true, xtype: 'textfield', validator: function(value){ if(value){ ds_pimpinanobj.setBaseParam('kdfakultas', value); ds_pimpinanobj.load(); Ext.getCmp('cb.frm.idpimpinan').enable(); }else{ Ext.getCmp('cb.frm.idpimpinan').disable(); } } }, { xtype: 'combo', id: 'cb.frm.idpimpinan', fieldLabel: 'Pimpinan', store: ds_pimpinanobj, triggerAction: 'all', valueField: 'idpimpinan', displayField: 'nmpimpinan', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 250, editable: false, disabled: true } ], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler:function() { fnSaveSrtpernyataan(); } }, { text: 'Kembali', iconCls:'', handler:function() { wSrtpernyataan.close(); } }] }); /** SET THE FORM UNTUK MEMASUKKAN NILAI PRODI DAN SEMESTER DI FORM */ setForm(); var wSrtpernyataan = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [srtpernyataan_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setsrtpernyataan(isUpdate, record); wSrtpernyataan.show(); /** FUNCTIONS BUAT MANGGIL KDPRODI DAN KDSEMESTER */ function setForm(){ Ext.getCmp('tf.frm.programstudi').disable(); Ext.getCmp('cb.frm.kdstsemester').disable(); RH.setCompValue('tf.frm.programstudi', kdprodi); RH.setCompValue('cb.frm.kdstsemester', kdstsemester); } /** FORM FUNCTIONS */ function setsrtpernyataan(isUpdate, record){ if(isUpdate){ if(record != null){ Ext.getCmp('btncari').disable(); Ext.getCmp('cb.frm.idpimpinan').enable(); Ext.getCmp('df.tglpersetujuan').enable(); RH.setCompValue('idsrtpernyataan', record.data['idsrtpernyataan']); RH.setCompValue('tf.frm.fakultas', record.data['nmfakultas']); RH.setCompValue('kode_fakultas', record.data['kdfakultas']); RH.setCompValue('cb.frm.kdstsemester', record.data['kdstsemester']); RH.setCompValue('df.tglpermohonan', record.data['tglpermohonan']); RH.setCompValue('tf.frm.nim', record.data['nim']); RH.setCompValue('tf.frm.nmmhs', record.data['nmmhs']); RH.setCompValue('tf.frm.nmortu', record.data['nmortu']); RH.setCompValue('tf.frm.alamatortu', record.data['alamatortu']); RH.setCompValue('tf.frm.nmbiaya', record.data['biayakuliah']); RH.setCompValue('cb.frm.idsemester', record.data['idsemester']); RH.setCompValue('cb.jbiaya-byr', record.data['idjnsbiaya']); RH.setCompValue('tf.frm.biayasisa', record.data['sisabiaya']); RH.setCompValue('df.tglpelunasan', record.data['tglpelunasan']); RH.setCompValue('cb.frm.idstsetuju', record.data['idstsetuju']); RH.setCompValue('df.tglpersetujuan', record.data['tglpersetujuan']); RH.setCompValue('cb.frm.idpimpinan', record.data['idpimpinan']); return; } } } function getbiaya(){ //getbiaya Ext.Ajax.request({ url: BASE_URL + 'kwitansi_controller/get_biaya_byr', method: 'POST', params :{ nim: RH.getCompValue('tf.frm.nim'), kdprodi: RH.getCompValue('tf.frm.programstudi'), thmasuk: RH.getCompValue('idthnmasuk'), idjnskls: RH.getCompValue('idjnskelas'), idjnsbiaya: RH.getCompValue('cb.jbiaya-byr'), kdjnsbiaya: Ext.getCmp('cb.jbiaya-byr').getRawValue(), kdstsemester: RH.getCompValue('cb.frm.kdstsemester') }, scope: this, async:false, //waitMsg: "Biaya sedang diproses...", success: function(result){ var jsonData = Ext.decode(result.responseText); //bisa utk Ext3 dan Ext4 var dataArray = jsonData.data; if (jsonData.result=='0') { } else { if(dataArray == null || dataArray =='') return; var data = dataArray[0]; if(data == null || data =='') return; if(data.biaya == null || data.biaya == '' || data.biaya == '0') return; var sisa = parseFloat(data.sisa); var status = (sisa > 0)? 'Belum Lunas' : 'LUNAS'; RH.setCompValue('tf.frm.nmbiaya', parseFloat(data.biaya)); RH.setCompValue('tf.frm.biayasisa', sisa); } } }); } function fnSaveSrtpernyataan(){ var idForm = 'frm.srtpernyataan'; var sUrl = BASE_URL +'srtpernyataan_controller/insert_srtpernyataan'; var sParams = getInsertSrtpernyataanParams(); 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 +'srtpernyataan_controller/update_srtpernyataan'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wSrtpernyataan, msgWait, msgSuccess, msgFail, msgInvalid); } function getInsertSrtpernyataanParams(){ return new Object({ idsrtpernyataan : RH.getCompValue('idsrtpernyataan'), kdstsemester : RH.getCompValue('cb.frm.kdstsemester'), tglpermohonan : RH.getCompValue('df.tglpermohonan'), nim : RH.getCompValue('tf.frm.nim'), nmortu : RH.getCompValue('tf.frm.nmortu'), alamatortu : RH.getCompValue('tf.frm.alamatortu'), idpekerjaanortu : RH.getCompValue('tf.frm.idpekerjaanortu'), idjnsbiaya : RH.getCompValue('cb.jbiaya-byr'), idsemester : RH.getCompValue('cb.frm.idsemester'), biayakuliah : RH.getCompValue('tf.frm.nmbiaya'), sisabiaya : RH.getCompValue('tf.frm.biayasisa'), tglpelunasan : RH.getCompValue('df.tglpelunasan'), idstsetuju : RH.getCompValue('cb.frm.idstsetuju'), tglpersetujuan : RH.getCompValue('df.tglpersetujuan'), idpimpinan : RH.getCompValue('cb.frm.idpimpinan'), }); } }