function pSrtberhenti(){ /** 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_pimpinansrtberhenti = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_pimpinan', method: 'POST' }), baseParams: { kdfakultas:'' }, autoLoad: true, root: 'data', fields: [ { name: "idpimpinan", mapping: "idpimpinan" } , { name: "nmpimpinan", mapping: "nmpimpinan" } , { name: "kdfakultas", mapping: "kdfakultas" } ] }); var ds_stberhentimhs = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_stberhentimhs', method: 'POST' }), autoLoad: true, root: 'data', fields: [ { name: "idstberhentimhs", mapping: "idstberhentimhs" } , { name: "nmstberhentimhs", mapping: "nmstberhentimhs" } ] }); var wAddEditStoresObj = new Object({ prodi: ds_prodireg, stsemester: ds_stsmt, setuju: ds_stsetuju, pimpin: ds_pimpinansrtberhenti, stberhentimhs: ds_stberhentimhs}); var fields_srtberhenti = RH.storeFields( 'idsrtberhentimhs','nomor','tglkeluar','kdstsemester','nim','idberhentimhs','idstsetuju', 'tglpersetujuan','idpimpinan','kdthnakademik','nmjnssemester','nmmhs','nmprodi','nmstberhentimhs', 'nmstsetuju','nmpimpinan','idstberhentimhs','kdfakultas','nmfakultas'); var pageSize = 20; var ds_srtberhenti = RH.JsonStore({ url : BASE_URL + 'srtberhenti_controller/get_srtberhenti', fields : fields_srtberhenti, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_srtberhenti = RH.searchComp({ id : 'sb_srtberhenti', fields : ['nim:NPM', 'nomor:No.Surat'], selected : 'nim', store : ds_srtberhenti }); //GRID KOLOM// var cm_srtberhenti = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('No.Surat'),width: 120, dataIndex: 'nomor', sortable: true }, { header: RH.h3('Tgl.Keluar'),width: 120, dataIndex: 'tglkeluar', sortable: true }, { header: RH.h3('NPM'),width: 150, dataIndex: 'nim', sortable: true }, { header: RH.h3('Nama Mahasiswa'),width: 200, dataIndex: 'nmmhs', sortable: true }, { header: RH.h3('Program Studi'),width: 180, dataIndex: 'nmprodi', sortable: true }, { header: RH.h3('Status Keluar'),width: 110, dataIndex: 'nmstberhentimhs', sortable: true }, { header: RH.h3('Status'),width: 120, dataIndex: 'nmstsetuju', sortable: true }, RH.EditColumn(), /* RH.DeleteColumn(), */ RH.PrintColumn() ] ); // Selection Model UNTUK PAGING MANUAL var sm_srtberhenti = new Ext.grid.RowSelectionModel({ singleSelect: true }); // Grid View var gv_srtberhenti = new Ext.grid.GridView({emptyText: '< Belum ada Data >'}); /** THE GRID */ var gp_srtberhenti = new Ext.grid.EditorGridPanel({ ds: ds_srtberhenti, cm: cm_srtberhenti, singleSelect: true, //searchComp: sb_srtberhenti, allowAdd: true, //fnAdd: fnAddsrtberhenti, //pageSize: pageSize, //cellclick: onCellsrtberhentiClick sm: sm_srtberhenti, view: gv_srtberhenti, 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_srtberhenti], bbar: new Ext.PagingToolbar({ store: ds_srtberhenti, displayInfo: true, pageSize: pageSize, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { cellclick: onCellsrtberhentiClick } }); var fp_srtberhenti = new Ext.Panel({ title: 'Surat Pemberhentian Mahasiswa', 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(){ reloadGridSrtberhenti(); } }) ] },{ 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(){ reloadGridSrtberhenti(); }, }/* ,{ xtype: 'textfield', id: 'hidden.idsrtberhentimhs', hidden:true, } */) ] }] }] },{ region: 'center', layout:'form', autoScroll:true, items:[{ xtype: 'panel', layout:'fit', height:520, title:'Data Surat Pemberhentian', id:'fp.master', frame:true, items: [gp_srtberhenti], 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 != '') { fnAddsrtberhenti(); } } }] }], }], //gridPanel: gp_srtberhenti, }); SET_PAGE_CONTENT(fp_srtberhenti); /** FUNCTIONS */ function reloadGridSrtberhenti(){ //remove detail RH.removeDetail('fp.detil'); //reload master-grid ds_srtberhenti.reload({ params: { kdprodi: RH.getCompValue('cb.prodi-stru', true), kdstsemester: RH.getCompValue('cb.smt-stru', true) } }); } function onCellsrtberhentiClick(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 idsrtberhentimhs = record.data['idsrtberhentimhs']; //RH.removeDetail('fp.detil'); //RH.setCompValue('hidden.idsrtberhentimhs', idsrtberhentimhs); //var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditsrtberhenti(grid, record)}); RH.DeleteClick(e, function(){fnDeletesrtberhenti(grid, record)}); RH.PrintClick(e, function(){fnPrintsrtberhenti(grid, record)}); return true; } function reloadsrtberhenti(){ ds_srtberhenti.reload(); } function fnAddsrtberhenti(){ var combo_stsmt = Ext.getCmp('cb.smt-stru'); var combo_prodi = Ext.getCmp('cb.prodi-stru'); var grid = gp_srtberhenti; wform_srtberhenti(false, grid, combo_prodi, combo_stsmt, null, wAddEditStoresObj); } function fnPrintsrtberhenti(grid, record){ var nim = record.data['nim'] RH.ShowReport(BASE_URL + 'surat/surat_pemberhentian/get_surat_pemberhentian/' +nim); } function fnEditsrtberhenti(grid, record){ var combo_stsmt = Ext.getCmp('cb.smt-stru'); var combo_prodi = Ext.getCmp('cb.prodi-stru'); //wform_srtberhenti(true, grid, record); wform_srtberhenti(true, grid, combo_prodi, combo_stsmt, record, wAddEditStoresObj); } function fnDeletesrtberhenti(grid, record){ var url = BASE_URL + 'srtberhenti_controller/delete_srtberhenti'; var params =new Object({ idsrtberhentimhs : record.data['idsrtberhentimhs'] }); RH.deleteGridRecord(url, params, grid ); } } /** GRID FORM */ function wform_srtberhenti(isUpdate, grid, combo_prodi, combo_stsmt, record, wAddEditStoresObj){ var winTitle = (isUpdate)?'Surat Pemberhentian (Edit)':'Surat Pemberhentian (Entry)'; var ds_prodireg = wAddEditStoresObj.prodi; var ds_stsmt = wAddEditStoresObj.stsemester; var ds_stsetuju = wAddEditStoresObj.setuju; var ds_pimpinanobj = wAddEditStoresObj.pimpin; var ds_stberhentimhs = wAddEditStoresObj.stberhentimhs; //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 srtberhenti_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.srtberhenti', buttonAlign: 'left', labelWidth: 250, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri //monitorValid: true, height: 350, width: 700, autoScroll: true, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'hf.frm.idsrtberhentimhs', hidden: true, xtype: 'textfield' }, { id: 'tf.frm.nomor', fieldLabel: 'No.Surat', width: 250, allowBlank: false, xtype: 'textfield' }, { xtype: 'datefield', id: 'df.tglkeluar', 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_berhenti',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.idstberhentimhs', fieldLabel: 'Status Keluar', store: ds_stberhentimhs, triggerAction: 'all', valueField: 'idstberhentimhs', displayField: 'nmstberhentimhs', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 250, editable: 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 } ], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler:function() { fnSaveSrtberhenti(); } }, { text: 'Kembali', iconCls:'', handler:function() { wSrtberhenti.close(); } }] }); /** SET THE FORM UNTUK MEMASUKKAN NILAI PRODI DAN SEMESTER DI FORM */ setForm(); var wSrtberhenti = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [srtberhenti_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setsrtberhenti(isUpdate, record); wSrtberhenti.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 setsrtberhenti(isUpdate, record){ if(isUpdate){ if(record != null){ Ext.getCmp('tf.frm.nomor').disable(); Ext.getCmp('btncari').disable(); Ext.getCmp('df.tglpersetujuan').enable(); RH.setCompValue('hf.frm.idsrtberhentimhs', record.data['idsrtberhentimhs']); RH.setCompValue('tf.frm.nomor', record.data['nomor']); RH.setCompValue('df.tglkeluar', record.data['tglkeluar']); RH.setCompValue('tf.frm.nim', record.data['nim']); RH.setCompValue('tf.frm.nmmhs', record.data['nmmhs']); RH.setCompValue('tf.frm.fakultas', record.data['nmfakultas']); RH.setCompValue('kode_fakultas', record.data['kdfakultas']); RH.setCompValue('cb.frm.idstberhentimhs', record.data['idstberhentimhs']); RH.setCompValue('cb.frm.idstsetuju', record.data['idstsetuju']); RH.setCompValue('cb.frm.idpimpinan', record.data['idpimpinan']); return; } } } function fnSaveSrtberhenti(){ var idForm = 'frm.srtberhenti'; var sUrl = BASE_URL +'srtberhenti_controller/insert_srtberhenti'; var sParams = getInsertSrtberhentiParams(); 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 +'srtberhenti_controller/update_srtberhenti'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wSrtberhenti, msgWait, msgSuccess, msgFail, msgInvalid); } function getInsertSrtberhentiParams(){ return new Object({ idsrtberhentimhs: RH.getCompValue('hf.frm.idsrtberhentimhs'), nomor : RH.getCompValue('tf.frm.nomor'), tglkeluar : RH.getCompValue('df.tglkeluar'), kdstsemester : RH.getCompValue('cb.frm.kdstsemester'), nim : RH.getCompValue('tf.frm.nim'), nmmhs : RH.getCompValue('tf.frm.nmmhs'), nmprodi : RH.getCompValue('tf.frm.programstudi'), idstberhentimhs : RH.getCompValue('cb.frm.idstberhentimhs'), idstsetuju : RH.getCompValue('cb.frm.idstsetuju'), tglpersetujuan : RH.getCompValue('df.tglpersetujuan'), idpimpinan : RH.getCompValue('cb.frm.idpimpinan'), }); } }