function pSyaratwisuda(NM_KLP){ var ds_stsemester = store_stsmt(); var wAddEditStoresObj = new Object({ stsemester: ds_stsemester }); var fields_syaratwisuda = RH.storeFields('kdstsemester','nmklppengguna','idklppengguna','nmthnakademik','kdsyaratwisuda','nmsyaratwisuda','deskripsi'); var pageSize = 18; var ds_syaratwisuda = RH.JsonStore({ url : BASE_URL + 'syaratwisuda_controller/get_syaratwisuda', fields : fields_syaratwisuda, limit: pageSize, params: [ {key:'kdstsemester', id:'cb.frm.kdstsemester'} ], enableSearch: true, }); Ext.Ajax.request({ url:BASE_URL + 'c_tools/get_user', method:'POST', success: function(response){ var r = Ext.decode(response.responseText); USERID = r.userid; USERNAME = r.username; L_MEMBER = r.level_member; NM_KLP = r.nm_klp; ID_KLP = r.id_klp; } }); //SEARCH COMPONENT var sb_syaratwisuda = RH.searchComp({ id : 'sb_syaratwisuda', fields : ['kdsyaratwisuda:Kode','nmsyaratwisuda:Nama'], selected : 'kdsyaratwisuda', store : ds_syaratwisuda }); // COLUMN MODEL var cm_syaratwisuda = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdsyaratwisuda', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmsyaratwisuda', sortable: true }, { header: RH.h3('Deskripsi'), width: 300, dataIndex: 'deskripsi', sortable: true }, { header: RH.h3('ID KLP Pengguna'), width: 200, dataIndex: 'idklppengguna', hidden: true }, { header: RH.h3('Kel. Pengguna'), width: 200, dataIndex: 'nmklppengguna', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); // Selection Model var sm_syaratwisuda = new Ext.grid.RowSelectionModel({ singleSelect: true }); // Grid View var gv_syaratwisuda = new Ext.grid.GridView({emptyText: '< Belum ada Data >'}); /** THE GRID */ var gp_syaratwisuda = new Ext.grid.EditorGridPanel({ //PAKE EditorGridPanel ds: ds_syaratwisuda, cm: cm_syaratwisuda, sm: sm_syaratwisuda, view: gv_syaratwisuda, 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:[{ text: 'Tambah', id: 'tb.add', iconCls: 'silk-add', handler: function() { fnAddsyaratwisuda(); } },{ xtype:'button', text: 'Salin Syarat Wisuda dari Tahun Akademik - Semester Sebelumnya', id:'bcopy', iconCls: 'silk-page-copy', handler:function(){ var combo_stsmt = Ext.getCmp('cb.frm.kdstsemester'); if (gp_syaratwisuda.getStore().getCount() > 0) { RH.warning('Data sudah ada. Hapus terlebih dahulu'); } else { wFormCopySyaratWisuda(combo_stsmt, gp_syaratwisuda); } } },'->',sb_syaratwisuda], bbar: new Ext.PagingToolbar({ store: ds_syaratwisuda, displayInfo: true, pageSize: pageSize, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { cellclick: onCellsyaratwisuda } }); var fp_syaratwisuda = new Ext.Panel({ xtype: 'panel', title: 'Syarat Wisuda', iconCls:'silk-house', 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:170, labelAlign:'right', items: [ RH.ActionCombo({ id: 'cb.frm.kdstsemester', label: 'Tahun Akademik - Semester', width: 150, data: ds_stsemester, key: 'kdstsemester', display: 'nmsmt', fnSelect: function(combo, record){ ds_syaratwisuda.reload({ params: { kdstsemester: record.data.kdstsemester, } }); } }) ] }] }] },{ region: 'center', layout:'form', autoScroll:true, items:[{ xtype: 'panel', layout:'fit', height:400, frame:true, items: [gp_syaratwisuda], }], }] }); SET_PAGE_CONTENT(fp_syaratwisuda); /** FUNCTIONS */ function onCellsyaratwisuda(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditsyaratwisuda(grid, record)}); RH.DeleteClick(e, function(){fnDeletesyaratwisuda(grid, record)}); } function fnAddsyaratwisuda(){ var grid = gp_syaratwisuda; var level_member = L_MEMBER; var cbstsemester = Ext.getCmp('cb.frm.kdstsemester'); wEntrysyaratwisuda(false, grid, null, cbstsemester,level_member); } function fnEditsyaratwisuda(grid, record){ var cbstsemester = Ext.getCmp('cb.frm.kdstsemester'); var level_member = L_MEMBER; wEntrysyaratwisuda(true, grid, record, cbstsemester,level_member); } function fnDeletesyaratwisuda(grid, record){ var url = BASE_URL + 'syaratwisuda_controller/delete_syaratwisuda'; var params = new Object({ kdstsemester : record.data['kdstsemester'], kdsyaratwisuda : record.data['kdsyaratwisuda'] }); RH.deleteGridRecord(url, params, grid ); } } function wEntrysyaratwisuda(isUpdate, grid, record, cbstsemester, level_member){ var winTitle = (isUpdate)?'Syarat Wisuda (Edit)':'Syarat Wisuda (Entry)'; var vkdstsemester; /** FORM ENTRY/EDIT */ var ds_otoritas= new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'c_utility/g_JKP', method: 'POST' }), params: { start: 0, limit: 5 }, root: 'data', totalProperty: 'results', autoLoad: true, fields: [{ name: "idklppengguna", mapping: "idklppengguna" }, { name: "nmklppengguna", mapping: "nmklppengguna" }] }); var hidden_klppengguna; if (level_member== 2){ hidden_klppengguna = false; }else{ hidden_klppengguna = true; } var syaratwisuda_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.syaratwisuda', buttonAlign: 'left', labelWidth: 170, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 210, width: 500, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'tf.frm.nmthnakademik', disabled: true, fieldLabel: 'Tahun Akademik - Semester', width: 150, allowBlank: false, },{ id: 'tf.frm.kdsyaratwisuda', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmsyaratwisuda', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ xtype: 'combo', width: 125, //height: 50, allowBlank: true, hidden: hidden_klppengguna, store: ds_otoritas, fieldLabel: 'Kelompok Pengguna', //labelStyle: 'width:100px', id: 'kelompok_pengguna', triggerAction: 'all', editable: false, valueField: 'idklppengguna', displayField: 'nmklppengguna', forceSelection: true, submitValue: true, hiddenName: 'h_klppengguna', listeners: {}, typeAhead: true, mode: 'local', emptyText: 'Pilih...', selectOnFocus: true },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveSyaratWisuda(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wSyaratWisuda.close(); } }] }); var wSyaratWisuda = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [syaratwisuda_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setSyaratWisudaForm(isUpdate, record); wSyaratWisuda.show(); /** FORM FUNCTIONS */ function setSyaratWisudaForm(isUpdate, record){ if(isUpdate){ if(record != null){ vkdstsemester = record.data['kdstsemester']; RH.setCompValue('tf.frm.nmthnakademik', record.data['nmthnakademik']); RH.setCompValue('tf.frm.kdsyaratwisuda', record.data['kdsyaratwisuda']); RH.setCompValue('tf.frm.nmsyaratwisuda', record.data['nmsyaratwisuda']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); RH.setCompValue('kelompok_pengguna', record.data['kelompok_pengguna']); return; } } else { vkdstsemester = cbstsemester.getValue(); RH.setCompValue('tf.frm.nmthnakademik', cbstsemester.getRawValue()); } } function fnSaveSyaratWisuda(){ var idForm = 'frm.syaratwisuda'; var sUrl = BASE_URL +'syaratwisuda_controller/insert_syaratwisuda'; var sParams = new Object({ kdstsemester : vkdstsemester, kdsyaratwisuda : RH.getCompValue('tf.frm.kdsyaratwisuda'), nmsyaratwisuda : RH.getCompValue('tf.frm.nmsyaratwisuda'), deskripsi : RH.getCompValue('ta.frm.deskripsi'), idklppengguna : (RH.getCompValue('kelompok_pengguna')) ? RH.getCompValue('kelompok_pengguna'):level_member, }); 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 +'syaratwisuda_controller/update_syaratwisuda'; sParams.kdsyaratwisudaold = record.data['kdsyaratwisuda']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wSyaratWisuda, msgWait, msgSuccess, msgFail, msgInvalid); } } //============================================== function wFormCopySyaratWisuda(combo_stsmt, masterGrid){ var ds_stsmt = combo_stsmt.getStore(); var copy_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.copy', buttonAlign: 'left', labelWidth: 215, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 120, width: 545, layout: 'form', frame: false, items: [{ xtype: 'textfield', id: 'tf.smtbaru-copy', disabled: true, fieldLabel: 'Tahun Akademik - Semester (Baru)', width: 150, allowBlank: false, },{ xtype: 'combo', id: 'cb.smtlama-copy', fieldLabel: 'Tahun Akademik - Semester (Lama)', store: ds_stsmt, triggerAction: 'all', valueField: 'kdstsemester', displayField: 'nmsmt', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width:150, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveCopy(); } }, { text: 'Kembali', iconCls:'', handler: function() { wCopySyaratWisuda.close(); } }] }); /**SET THE FORM */ setForm(); var wCopySyaratWisuda = new Ext.Window({ title: 'Salin Syarat Wisuda dari Tahun Akademik - Semester Sebelumnya', modal: true, closable:false, items: [copy_form] }).show(); /** FUNCTIONS */ function setForm(){ Ext.getCmp('tf.smtbaru-copy').disable(); RH.setCompValue('tf.smtbaru-copy', combo_stsmt.getRawValue()); } /** SAVE COPY FUNCTIONS */ function fnSaveCopy(){ var smtlama = RH.getCompValue('cb.smtlama-copy',true); if(smtlama == '') { RH.warning('Tahun Akademik - Semester (Lama) harus diisi'); return; }; var idForm = 'frm.copy'; var sUrl = BASE_URL +'syaratwisuda_controller/copy_syaratwisuda'; var sParams = new Object({ smtbaru : combo_stsmt.getValue(), smtlama : smtlama }); var grid = masterGrid; var msgWait = 'Tunggu, sedang proses menyimpan...'; var msgSuccess = 'Salin data berhasil'; var msgFail = 'Salin data gagal'; var msgInvalid = 'Data belum valid (data primer belum terisi)!'; //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wCopySyaratWisuda, msgWait, msgSuccess, msgFail, msgInvalid); } }