function pSuratPindahan(){ /** 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_pimpinansrtpindah = 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_kopertis = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_kopertis', method: 'POST' }), autoLoad: true, root: 'data', fields: [ { name: "idkopertis", mapping: "idkopertis" } , { name: "nmkopertis", mapping: "nmkopertis" } ] }); var ds_stakreditasi = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_stakreditasi ', method: 'POST' }), autoLoad: true, root: 'data', fields: [ { name: "idstakreditasi", mapping: "idstakreditasi" } , { name: "nmstakreditasi", mapping: "nmstakreditasi" } ] }); var wAddEditStoresObj = new Object({ prodi: ds_prodireg, stsemester: ds_stsmt, setuju: ds_stsetuju, pimpin: ds_pimpinansrtpindah ,kopertis: ds_kopertis, stakreditasi: ds_stakreditasi}); var fields_srtpindahan = RH.storeFields( 'idsrtpindahmhs','nosrtpindahmhs','tglpermohonan','tglpersetujuan','nim','kdstsemester', 'idstakreditasi','idstsetuju','kdptitbpti','idkopertis','idpimpinan','nmdatajenjangstudi', 'nmmhs','nmprodi','nmptitbpti','kdthnakademik','nmjnssemester','nmstsetuju','kdfakultas','nmfakultas'); var pageSize = 20; var ds_srtpindahan = RH.JsonStore({ url : BASE_URL + 'srtpindahan_controller/get_srtpindahan', fields : fields_srtpindahan, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_srtpindahan = RH.searchComp({ id : 'sb_srtpindahan', fields : ['nim:NPM', 'nosrtpindahmhs:No.Surat'], selected : 'nim', store : ds_srtpindahan }); //GRID KOLOM// var cm_srtpindahan = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('No.Surat'),width: 100, dataIndex: 'nosrtpindahmhs', sortable: true }, { 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: 150, dataIndex: 'nmmhs', sortable: true }, { header: RH.h3('Program Studi'),width: 150, dataIndex: 'nmprodi', sortable: true }, { header: RH.h3('Pindah Ke PT'),width: 110, dataIndex: 'nmptitbpti', sortable: true }, { header: RH.h3('Tahun Akademik-Semester'),width: 200, dataIndex: 'kdthnakademik', sortable: true, renderer: function(value, p, r) {return r.data['kdthnakademik'] + ' - ' + r.data['nmjnssemester']} }, { header: RH.h3('Status'),width: 80, dataIndex: 'nmstsetuju', sortable: true }, RH.EditColumn(), /* RH.DeleteColumn(), */ RH.PrintColumn() ] ); // Selection Model UNTUK PAGING MANUAL var sm_srtpindahan = new Ext.grid.RowSelectionModel({ singleSelect: true }); // Grid View var gv_srtpindahan = new Ext.grid.GridView({emptyText: '< Belum ada Data >'}); /** THE GRID */ var gp_srtpindahan = new Ext.grid.EditorGridPanel({ ds: ds_srtpindahan, cm: cm_srtpindahan, singleSelect: true, //searchComp: sb_srtpindahan, allowAdd: true, //fnAdd: fnAddsrtpindahan, //pageSize: pageSize, //cellclick: onCellsrtpindahanClick sm: sm_srtpindahan, view: gv_srtpindahan, 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_srtpindahan], bbar: new Ext.PagingToolbar({ store: ds_srtpindahan, displayInfo: true, pageSize: pageSize, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { cellclick: onCellsrtpindahanClick } }); var fp_srtpindahan = new Ext.Panel({ title: 'Surat Pindahan 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(){ reloadGridSrtpindahan(); } }) ] },{ 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(){ reloadGridSrtpindahan(); }, }/* ,{ xtype: 'textfield', id: 'hidden.idsrtpindahmhs', hidden:true, } */) ] }] }] },{ region: 'center', layout:'form', autoScroll:true, items:[{ xtype: 'panel', layout:'fit', height:520, title:'Data Surat Pindahan', id:'fp.master', frame:true, items: [gp_srtpindahan], 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 != '') { fnAddsrtpindahan(); } } }] }], }], //gridPanel: gp_srtpindahan, }); SET_PAGE_CONTENT(fp_srtpindahan); /** FUNCTIONS */ function reloadGridSrtpindahan(){ //remove detail RH.removeDetail('fp.detil'); //reload master-grid ds_srtpindahan.reload({ params: { kdprodi: RH.getCompValue('cb.prodi-stru', true), kdstsemester: RH.getCompValue('cb.smt-stru', true) } }); } function onCellsrtpindahanClick(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 idsrtpindahmhs = record.data['idsrtpindahmhs']; //RH.removeDetail('fp.detil'); //RH.setCompValue('hidden.idsrtpindahmhs', idsrtpindahmhs); //var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditsrtpindahan(grid, record)}); RH.DeleteClick(e, function(){fnDeletesrtpindahan(grid, record)}); RH.PrintClick(e, function(){fnPrintsrtpindahan(grid, record)}); return true; } function reloadsrtpindahan(){ ds_srtpindahan.reload(); } function fnAddsrtpindahan(){ var combo_stsmt = Ext.getCmp('cb.smt-stru'); var combo_prodi = Ext.getCmp('cb.prodi-stru'); var grid = gp_srtpindahan; wform_srtpindahan(false, grid, combo_prodi, combo_stsmt, null, wAddEditStoresObj); } function fnPrintsrtpindahan(grid, record){ var nim = record.data['nim'] RH.ShowReport(BASE_URL + 'surat/surat_mutasi/get_surat_mutasi/' +nim); } function fnEditsrtpindahan(grid, record){ var combo_stsmt = Ext.getCmp('cb.smt-stru'); var combo_prodi = Ext.getCmp('cb.prodi-stru'); //wform_srtpindahan(true, grid, record); wform_srtpindahan(true, grid, combo_prodi, combo_stsmt, record, wAddEditStoresObj); } function fnDeletesrtpindahan(grid, record){ var url = BASE_URL + 'srtpindahan_controller/delete_srtpindahan'; var params =new Object({ idsrtpindahmhs : record.data['idsrtpindahmhs'] }); RH.deleteGridRecord(url, params, grid ); } } /** GRID FORM */ function wform_srtpindahan(isUpdate, grid, combo_prodi, combo_stsmt, record, wAddEditStoresObj){ var winTitle = (isUpdate)?'Surat Pindahan (Edit)':'Surat Pindahan (Entry)'; var ds_prodireg = wAddEditStoresObj.prodi; var ds_stsmt = wAddEditStoresObj.stsemester; var ds_stsetuju = wAddEditStoresObj.setuju; var ds_pimpinanobj = wAddEditStoresObj.pimpin; var ds_kopertis = wAddEditStoresObj.kopertis; var ds_stakreditasi = wAddEditStoresObj.stakreditasi; //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 srtpindahan_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.srtpindahan', buttonAlign: 'left', labelWidth: 250, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri //monitorValid: true, height: 450, width: 700, autoScroll: true, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'idsrtpindahmhs', hidden: true, xtype: 'textfield' }, { id: 'tf.frm.nosrtpindahmhs', fieldLabel: 'No.Surat', width: 250, allowBlank: false, xtype: 'textfield' }, { xtype: 'datefield', id: 'df.tglpermohonan', 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_pindahan',kdprodi);} //,kdstsemester }] }, { id: 'tf.frm.nmmhs', fieldLabel: 'Nama Mahasiswa', width: 250, allowBlank: false, disabled: true, xtype: 'textfield' }, { id: 'tf.frm.jenjangstudi', fieldLabel: 'Jenjang Studi', width: 250, hidden: true, 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 }, { id: 'tf.frm.perguruantinggi', fieldLabel: 'Perguruan Tinggi', width: 250, allowBlank: false, disabled: true,value: 'Universitas Langlangbuana' }, { xtype: 'combo', id: 'cb.frm.idstakreditasi', fieldLabel: 'Status Akreditasi', store: ds_stakreditasi, triggerAction: 'all', valueField: 'idstakreditasi', displayField: 'nmstakreditasi', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 250, editable: false }, { xtype: 'container', fieldLabel: 'Pindah Ke PT', layout: 'hbox', defaultType: 'textfield', defaults: { hideLabel: 'true' }, items: [ { id: 'tf.frm.kdptitbpti', width: 30, readOnly: true, hidden: true, }, { id: 'tf.frm.nmpt', width: 250, readOnly: true }, { xtype: 'button', id: 'bt.home-dos', iconCls: 'silk-find', margins: '0 0 0 6', width: 25, handler: function() { wLookup(lu_univ, 'Perguruan Tinggi','tf.frm.kdptitbpti','tf.frm.nmpt');} }] }, { xtype: 'combo', id: 'cb.frm.idkopertis', fieldLabel: 'Wilayah Kopertis', store: ds_kopertis, triggerAction: 'all', valueField: 'idkopertis', displayField: 'nmkopertis', 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, //disabled: true } ], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler:function() { fnSaveSrtpindahan(); } }, { text: 'Kembali', iconCls:'', handler:function() { wSrtpindahan.close(); } }] }); /** SET THE FORM UNTUK MEMASUKKAN NILAI PRODI DAN SEMESTER DI FORM */ setForm(); var wSrtpindahan = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [srtpindahan_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setsrtpindahan(isUpdate, record); wSrtpindahan.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 setsrtpindahan(isUpdate, record){ if(isUpdate){ if(record != null){ Ext.getCmp('tf.frm.nosrtpindahmhs').disable(); Ext.getCmp('btncari').disable(); Ext.getCmp('tf.frm.jenjangstudi').show(); Ext.getCmp('df.tglpersetujuan').enable(); //Ext.getCmp('cb.frm.idpimpinan').enable(); RH.setCompValue('idsrtpindahmhs', record.data['idsrtpindahmhs']); RH.setCompValue('tf.frm.nosrtpindahmhs', record.data['nosrtpindahmhs']); RH.setCompValue('df.tglpermohonan', record.data['tglpermohonan']); //RH.setCompValue('cb.frm.kdstsemester', record.data['kdstsemester']); RH.setCompValue('tf.frm.nim', record.data['nim']); RH.setCompValue('tf.frm.nmmhs', record.data['nmmhs']); //RH.setCompValue('tf.frm.programstudi', record.data['nmprodi']); RH.setCompValue('tf.frm.fakultas', record.data['nmfakultas']); RH.setCompValue('kode_fakultas', record.data['kdfakultas']); RH.setCompValue('tf.frm.jenjangstudi', record.data['nmdatajenjangstudi']); RH.setCompValue('tf.frm.kdptitbpti', record.data['kdptitbpti']); RH.setCompValue('tf.frm.nmpt', record.data['nmptitbpti']); RH.setCompValue('cb.frm.idstakreditasi', record.data['idstakreditasi']); RH.setCompValue('cb.frm.idkopertis', record.data['idkopertis']); 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 fnSaveSrtpindahan(){ var idForm = 'frm.srtpindahan'; var sUrl = BASE_URL +'srtpindahan_controller/insert_srtpindahan'; var sParams = getInsertSrtpindahanParams(); 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 +'srtpindahan_controller/update_srtpindahan'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wSrtpindahan, msgWait, msgSuccess, msgFail, msgInvalid); } function getInsertSrtpindahanParams(){ return new Object({ idsrtpindahmhs : RH.getCompValue('idsrtpindahmhs'), nosrtpindahmhs : RH.getCompValue('tf.frm.nosrtpindahmhs'), tglpermohonan : RH.getCompValue('df.tglpermohonan'), kdstsemester : RH.getCompValue('cb.frm.kdstsemester'), nim : RH.getCompValue('tf.frm.nim'), idstakreditasi : RH.getCompValue('cb.frm.idstakreditasi'), kdptitbpti : RH.getCompValue('tf.frm.kdptitbpti'), idkopertis : RH.getCompValue('cb.frm.idkopertis'), idstsetuju : RH.getCompValue('cb.frm.idstsetuju'), tglpersetujuan : RH.getCompValue('df.tglpersetujuan'), idpimpinan : RH.getCompValue('cb.frm.idpimpinan'), }); } }