function pSrtketkul(){ /** COMMON STORES */ var ds_prodireg = store_prodireg(); var ds_stsmt = store_stsmt(); 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_pimpinansrtketkul = 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 wAddEditStoresObj = new Object({ prodi: ds_prodireg, stsemester: ds_stsmt, setuju: ds_stsetuju, pimpin: ds_pimpinansrtketkul /* ,pimpinan: ds_pimpinansrtketkuledit */}); var fields_srtketkul = RH.storeFields( 'idsrtkuliah','ttl','alamatasal','kdthnakademik','nmjnssemester','nmpimpinan','tglsrtkuliah','nosrtkuliah', 'nim','kdfakultas','kdprodi','idpimpinan','nmortu','idstsetuju','nmmhs','nmprodi','nmstsetuju','kdstsemester', 'nmfakultas', 'tglpersetujuan'); var pageSize = 20; var ds_srtketkul = RH.JsonStore({ url : BASE_URL + 'srtketkul_controller/get_srtketkul', fields : fields_srtketkul, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_srtketkul = RH.searchComp({ id : 'sb_srtketkul', fields : ['nim:NPM', 'nosrtkuliah:No.Surat'], selected : 'nim', store : ds_srtketkul }); //GRID KOLOM// var cm_srtketkul = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('No.Surat'), width: 100, dataIndex: 'nosrtkuliah', sortable: true }, { header: RH.h3('Tgl.Surat'),width: 100, dataIndex: 'tglsrtkuliah', sortable: true, renderer : Ext.util.Format.dateRenderer('d/m/Y') }, { header: RH.h3('NPM'),width: 100, dataIndex: 'nim', sortable: true }, { header: RH.h3('Nama Mahasiswa'),width: 150, dataIndex: 'nmmhs', sortable: true }, { header: RH.h3('Fakultas'),width: 150, dataIndex: 'nmfakultas', sortable: true }, { header: RH.h3('Program Studi'),width: 150, dataIndex: 'nmprodi', sortable: true }, { header: RH.h3('Tahun Akademik'),width: 150, dataIndex: 'kdthnakademik', sortable: true }, { header: RH.h3('Status'),width: 100, dataIndex: 'nmstsetuju', sortable: true }, RH.EditColumn(), /* RH.DeleteColumn(), */ RH.PrintColumn() ] ); // Selection Model UNTUK PAGING MANUAL var sm_srtketkul = new Ext.grid.RowSelectionModel({ singleSelect: true }); // Grid View var gv_srtketkul = new Ext.grid.GridView({emptyText: '< Belum ada Data >'}); /** THE GRID */ var gp_srtketkul = new Ext.grid.EditorGridPanel({ ds: ds_srtketkul, cm: cm_srtketkul, singleSelect: true, //searchComp: sb_srtketkul, allowAdd: true, //fnAdd: fnAddsrtketkul, //pageSize: pageSize, //cellclick: onCellsrtketkulClick sm: sm_srtketkul, view: gv_srtketkul, 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_srtketkul], bbar: new Ext.PagingToolbar({ store: ds_srtketkul, displayInfo: true, pageSize: pageSize, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { cellclick: onCellsrtketkulClick } }); var fp_srtketkul = new Ext.Panel({ title: 'Surat Keterangan Masih Kuliah', 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(){ reloadGridSrtketkul(); } }) ] },{ 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(){ reloadGridSrtketkul(); }, }/* ,{ xtype: 'textfield', id: 'hidden.idsrtkuliah', hidden:true, } */) ] }] }] },{ region: 'center', layout:'form', autoScroll:true, items:[{ xtype: 'panel', layout:'fit', height:520, title:'Data Surat Keterangan Masih Kuliah', id:'fp.master', frame:true, items: [gp_srtketkul], 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 != '') { fnAddsrtketkul(); } } }] }], }], //gridPanel: gp_srtketkul, }); SET_PAGE_CONTENT(fp_srtketkul); /** FUNCTIONS */ function reloadGridSrtketkul(){ //remove detail RH.removeDetail('fp.detil'); //reload master-grid ds_srtketkul.reload({ params: { kdprodi: RH.getCompValue('cb.prodi-stru', true), kdstsemester: RH.getCompValue('cb.smt-stru', true) } }); } function onCellsrtketkulClick(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 idsrtkuliah = record.data['idsrtkuliah']; //RH.removeDetail('fp.detil'); //RH.setCompValue('hidden.idsrtkuliah', idsrtkuliah); //var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditsrtketkul(grid, record)}); RH.DeleteClick(e, function(){fnDeletesrtketkul(grid, record)}); RH.PrintClick(e, function(){fnPrintsrtketkul(grid, record)}); return true; } function reloadsrtketkul(){ ds_srtketkul.reload(); } function fnAddsrtketkul(){ var combo_stsmt = Ext.getCmp('cb.smt-stru'); var combo_prodi = Ext.getCmp('cb.prodi-stru'); var grid = gp_srtketkul; wform_srtketkul(false, grid, combo_prodi, combo_stsmt, null, wAddEditStoresObj); } function fnPrintsrtketkul(grid, record){ var nim = record.data['nim'] RH.ShowReport(BASE_URL + 'surat/surat_ket_kuliah/get_surat_ketkul/' +nim); } function fnEditsrtketkul(grid, record){ var combo_stsmt = Ext.getCmp('cb.smt-stru'); var combo_prodi = Ext.getCmp('cb.prodi-stru'); //wform_srtketkul(true, grid, record); wform_srtketkul(true, grid, combo_prodi, combo_stsmt, record, wAddEditStoresObj); } function fnDeletesrtketkul(grid, record){ var url = BASE_URL + 'srtketkul_controller/delete_srtketkul'; var params =new Object({ idsrtkuliah : record.data['idsrtkuliah'] }); RH.deleteGridRecord(url, params, grid ); } } /** GRID FORM */ function wform_srtketkul(isUpdate, grid, combo_prodi, combo_stsmt, record, wAddEditStoresObj){ var winTitle = (isUpdate)?'Surat Keterangan Masih Kuliah (Edit)':'Surat Keterangan Masih Kuliah (Entry)'; var ds_prodireg = wAddEditStoresObj.prodi; var ds_stsmt = wAddEditStoresObj.stsemester; var ds_stsetuju = wAddEditStoresObj.setuju; var ds_pimpinanobj = wAddEditStoresObj.pimpin; //var ds_pimpinansrtketkuledit = wAddEditStoresObj.pimpinan; //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 srtketkul_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.srtketkul', buttonAlign: 'left', labelWidth: 250, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri //monitorValid: true, height: 330, width: 700, autoScroll: true, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'idsrtkuliah', hidden: true, xtype: 'textfield' }, { id: 'tf.frm.nosrtketkul', fieldLabel: 'No.Surat', width: 250, allowBlank: false, xtype: 'textfield' }, { xtype: 'datefield', id: 'df.tglsrtkuliah', fieldLabel: 'Tgl.Surat', 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() { wGridMhsProdi('srt_ketkul',kdprodi);} //,kdstsemester }] }, { id: 'tf.frm.nmmhs', fieldLabel: 'Nama Mahasiswa', width: 250, allowBlank: false, disabled: true, xtype: 'textfield' }, { 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.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() { fnSaveSrtketkul(); } }, { text: 'Kembali', iconCls:'', handler:function() { wSrtketkul.close(); } }] }); /** SET THE FORM UNTUK MEMASUKKAN NILAI PRODI DAN SEMESTER DI FORM */ setForm(); var wSrtketkul = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [srtketkul_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setsrtketkul(isUpdate, record); wSrtketkul.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 setsrtketkul(isUpdate, record){ if(isUpdate){ if(record != null){ Ext.getCmp('tf.frm.nosrtketkul').disable(); Ext.getCmp('btncari').disable(); Ext.getCmp('df.tglpersetujuan').enable(); Ext.getCmp('cb.frm.idpimpinan').enable(); RH.setCompValue('idsrtkuliah', record.data['idsrtkuliah']); RH.setCompValue('tf.frm.nosrtketkul', record.data['nosrtkuliah']); RH.setCompValue('cb.frm.kdstsemester', record.data['kdstsemester']); RH.setCompValue('tf.frm.nmmhs', record.data['nmmhs']); RH.setCompValue('tf.frm.programstudi', record.data['kdprodi']); RH.setCompValue('df.tglsrtkuliah', record.data['tglsrtkuliah']); RH.setCompValue('tf.frm.nim', record.data['nim']); RH.setCompValue('tf.frm.fakultas', record.data['nmfakultas']); RH.setCompValue('kode_fakultas', record.data['kdfakultas']); //RH.setCompValue('tf.frm.ttl', record.data['ttl']); //RH.setCompValue('tf.frm.alamat', record.data['alamatasal']); //RH.setCompValue('tf.frm.nmortu', record.data['nmortu']); 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 fnSaveSrtketkul(){ var idForm = 'frm.srtketkul'; var sUrl = BASE_URL +'srtketkul_controller/insert_srtketkul'; var sParams = getInsertSrtketkulParams(); 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 +'srtketkul_controller/update_srtketkul'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wSrtketkul, msgWait, msgSuccess, msgFail, msgInvalid); } function getInsertSrtketkulParams(){ return new Object({ idsrtkuliah : RH.getCompValue('idsrtkuliah'), nosrtkuliah : RH.getCompValue('tf.frm.nosrtketkul'), tglsrtkuliah : RH.getCompValue('df.tglsrtkuliah'), nim : RH.getCompValue('tf.frm.nim'), kdfakultas : RH.getCompValue('kode_fakultas'), kdprodi : RH.getCompValue('tf.frm.programstudi'), idstsetuju : RH.getCompValue('cb.frm.idstsetuju'), idpimpinan : RH.getCompValue('cb.frm.idpimpinan'), tglpersetujuan : RH.getCompValue('df.tglpersetujuan'), kdstsemester : RH.getCompValue('cb.frm.kdstsemester'), }); } }