function setting_kuisioner(){ var ds_stsmt = store_stsmt(); var ds_kuisioner = new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url : BASE_URL + 'kuisioner_controller/get_kuisioner', method: 'POST' }), totalProperty: 'results', root: 'data', autoLoad: true, fields: [{ name: 'kdstsemester', mapping: 'kdstsemester' },{ name: 'id_question', mapping: 'id_question' },{ name: 'question', mapping: 'question' },{ name: 'nmlengkap', mapping: 'nmlengkap' },{ name: 'userid', mapping: 'userid' }] }); 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; } }); var arr_cari = [['question', 'Pertanyaan'],['userid', 'User']]; var ds_cari = new Ext.data.ArrayStore({ fields: ['id', 'nama'], data : arr_cari }); var row_gridnya = new Ext.grid.RowSelectionModel({ singleSelect: true }); var vw_grid_nya = new Ext.grid.GridView({ emptyText: '< Belum ada Data >' }); var grid_nya = new Ext.grid.EditorGridPanel({ id: 'gp.kuisioner', store: ds_kuisioner, sm: row_gridnya, view: vw_grid_nya, tbar: [{ xtype: 'tbtext', style: 'marginLeft: 10px', text: 'Search :' },{ xtype: 'combo', id: 'cb.search', width: 150, store: ds_cari, valueField: 'id', displayField: 'nama', editable: false, triggerAction: 'all', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', disabled: true, listeners: { select: function() { var cbsearchh = Ext.getCmp('cb.search').getValue(); if(cbsearchh != ''){ Ext.getCmp('cek').enable(); Ext.getCmp('btn_cari').enable(); Ext.getCmp('cek').focus(); } return; } } },{ xtype: 'textfield', style: 'marginLeft: 7px', id: 'cek', width: 185, disabled: true, /* validator: function(){ var cek = Ext.getCmp('cek').getValue(); if(cek == ''){ fnSearchgrid(); } return; } */ },{ text: 'Cari', id:'btn_cari', iconCls: 'silk-find', style: 'marginLeft: 7px', disabled: true, handler: function() { var btncari = Ext.getCmp('cek').getValue(); if(btncari != ''){ fnSearchgrid(); }else{ Ext.MessageBox.alert('Message', 'Tidak ada data yang di cari'); } return; } }], //plugins: editor,//cari_data, autoScroll: true, columnLines: true, height: 480, forceFit: true, loadMask: true, frame: true, clicksToEdit: 1, columns: [new Ext.grid.RowNumberer(), { header: '', width: 60, dataIndex: 'id_question', sortable: true, hidden: true }, { header: 'Pertanyaan', width: 600, dataIndex: 'question', sortable: true, }, { header: 'User', width: 100, dataIndex: 'nmlengkap', sortable: true, align: 'left', } ,{ xtype: 'actioncolumn', width: 45, header: 'Hapus', align:'center', items: [{ getClass: function(v, meta, record) { meta.attr = "style='cursor:pointer;'"; }, icon : 'application/framework/img/rh_delete.gif', tooltip: 'Hapus record', handler: function(grid, rowIndex) { fnHapusData(rowIndex); } }] }], listeners: { //rowclick: Addrecord } }); var form_bp_general = new Ext.form.FormPanel({ id: 'form_bp_general', title: 'Setting Kuisioner', iconCls:'silk-user', width: 900, Height: 1000, layout: 'column', frame: true, autoScroll: true, //defaults: { labelWidth: 150, labelAlign: 'right', width: 910, }, items: [{ xtype: 'container', style: 'padding: 5px; margin: -8px 0 -10px 0', columnWidth: 1, layout: 'fit', items: [{ xtype: 'fieldset', //title: 'Daftar Pertanyaan', layout: 'form', height: 505, //boxMaxHeight:325, items: [{ xtype: 'panel', layout:'form', columnWidth: 0.99, id:'fp.master', items: [grid_nya], tbar: [ { xtype: 'tbtext', text: '
Tahun Akademik - Semester :
' }, { xtype: 'combo', id: 'cb.kdstsemester', store: ds_stsmt, triggerAction: 'all', valueField: 'kdstsemester', displayField: 'nmsmt', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 150, editable: false, allowBlank: false, listeners: { select: function() { var isi = Ext.getCmp('cb.kdstsemester').getValue(); if (isi){ Ext.getCmp('btn_add').enable(); Ext.getCmp('cb.search').enable(); Ext.getCmp('bt_cpdata').enable(); //Ext.getCmp('btn_settingakun').enable(); //Ext.getCmp("df.blnawal").setValue(RH.getRecordFieldValue(ds_tahunakun, 'tglawal', 'tahun', isi)); //Ext.getCmp("df.blnakhir").setValue(RH.getRecordFieldValue(ds_tahunakun, 'tglakhir', 'tahun', isi)); ds_kuisioner.setBaseParam('kdstsemester', isi); Ext.getCmp('gp.kuisioner').store.reload(); } else { Ext.getCmp('btn_add').disable(); Ext.getCmp('cb.search').disable(); Ext.getCmp('bt_cpdata').disable(); } } } },'-', { text: 'Tambah', id: 'btn_add', iconCls: 'silk-add', disabled: true, handler: function() { var cbkdsmt= Ext.getCmp("cb.kdstsemester").getValue(); if(cbkdsmt != "" ){ tambah_kuisioner(); Ext.getCmp("cb.kdstsemester_form").setValue(cbkdsmt); } } } ,{ text: 'Salin Setting Kuisioner', id: 'bt_cpdata', iconCls: 'silk-page-copy', disabled: true, style: 'marginLeft: 10px', handler: function(){ var cbkdsmt= Ext.getCmp("cb.kdstsemester").getValue(); if(cbkdsmt){ fncopydata(); } return; } } ] }] }] }], listeners: { //afterrender: mulai } }); SET_PAGE_CONTENT(form_bp_general); function fnSearchgrid(){ var idcombo, nmcombo; idcombo= Ext.getCmp('cb.search').getValue(); nmcombo= Ext.getCmp('cek').getValue(); ds_kuisioner.setBaseParam('key', '1'); ds_kuisioner.setBaseParam('id', idcombo); ds_kuisioner.setBaseParam('name', nmcombo); ds_kuisioner.load(); } function fnHapusData(record){ var record = ds_kuisioner.getAt(record); Ext.Msg.show({ title: 'Konfirmasi', msg: 'Hapus data yang dipilih..?', buttons: Ext.Msg.YESNO, icon: Ext.MessageBox.QUESTION, fn: function (response) { if ('yes' !== response) { return; } Ext.Ajax.request({ url: BASE_URL + 'kuisioner_controller/delete_data', params: { id_question : record.data['id_question'], }, success: function(response){ Ext.MessageBox.alert('Informasi', 'Hapus Data Berhasil'); Ext.getCmp('gp.kuisioner').store.reload(); //fTotal(); }, failure: function() { //Ext.Msg.alert("Informasi", "Ubah Data Gagal"); } }); } }); } function tambah_kuisioner(){ var form_copy = new Ext.form.FormPanel({ xtype:'form', id: 'frm.kuisioner', labelWidth: 120, labelAlign: 'right', //bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 180, width: 500, layout: 'form', frame: true, items: [{ xtype: 'fieldset', layout:'form', height: 130, frame:true, items: [{ xtype: 'combo', id: 'cb.kdstsemester_form', store: ds_stsmt, triggerAction: 'all', fieldLabel: 'T.A - Semester', valueField: 'kdstsemester', displayField: 'nmsmt', forceSelection: true, submitValue: true, mode: 'local', width: 200, editable: false, allowBlank: false, readOnly: true },{ xtype: 'textarea', id: 'ta.frm.question', fieldLabel: 'Pertanyaan', width: 300, }] },{ xtype: 'button', text: 'Simpan', id: 'bt.cpy', iconCls:'silk-save', style: 'margin: -5px 0 0 10px', width: 72, handler: function(){ fnSave(); } },{ xtype: 'button', text: 'Kembali', id: 'bt.kemb', iconCls:'silk-arrow-undo', style: 'marginLeft: 90px; marginTop: -22px; marginBottom: 15px', width: 72, handler: function(){ win_salin_dta.close(); } }] }); function fnSave(){ var form = RH.getForm('frm.kuisioner'); if(form.isValid()){ form.submit({ url: BASE_URL +'kuisioner_controller/insert_question', method: 'POST', params: { kdstsemester : RH.getCompValue('cb.kdstsemester_form'), question : RH.getCompValue('ta.frm.question'), userid : USERID, }, waitMsg: 'Tunggu, sedang proses menyimpan...', success: function(response) { var jsonData = Ext.decode(response.responseText); Ext.Msg.alert("Info", "Simpan Data Berhasil"); ds_kuisioner.reload(); win_salin_dta.close(); }, failure: function(result){ Ext.MessageBox.alert("Info", "Simpan Data Gagal"); win_salin_dta.close(); } }); } } var win_salin_dta = new Ext.Window({ title: 'Form Kuisioner', modal: true, closable: false, items: [form_copy] }).show(); } function fncopydata(){ var form_salin = new Ext.form.FormPanel({ xtype:'form', id: 'frm.salin', defaults: {labelWidth: 220, labelAlign: 'right'}, //bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 250, width: 500, layout: 'form', frame: true, border: true, items: [{ xtype: 'fieldset', layout:'form', height: 80, frame:true, items: [{ xtype: 'combo', id: 'cb.tahunlama', fieldLabel: 'Tahun Akademik - Semester Asal', store: ds_stsmt, triggerAction: 'all', valueField: 'kdstsemester', displayField: 'nmsmt', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 170, editable: false, //readOnly: true, style: 'opacitty: 0.6', },{ xtype: 'combo', id: 'cb.tahunbaru', fieldLabel: 'Tahun Akademik - Semester Tujuan', store: ds_stsmt, triggerAction: 'all', valueField: 'kdstsemester', displayField: 'nmsmt', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 170, editable: false, }] },{ xtype: 'fieldset', title: 'Informasi :', layout:'form', style: 'font-size: 12px', items: [{ xtype: 'tbtext', text: '1. Tahun Akademik - Semester Asal akan menyalin dan menimpa (replace) Tahun Akademik - Semester Tujuan', },{ xtype: 'tbtext', text: '2. Tahun Akademik - Semester Asal tidak boleh sama dengan Tahun Akademik - Semester Tujuan', }] }], bbar:[{ xtype: 'button', text: 'Salin', id: 'bt.cpy', iconCls:'silk-page-copy', width: 72, handler: function(){ copydata(); } },{ xtype: 'button', text: 'Kembali', id: 'bt.kemb', iconCls:'silk-arrow-undo', width: 72, handler: function(){ win_copy.close(); } }] }); function copydata(){ var cektalama = Ext.getCmp("cb.tahunlama").getValue(); var cektabaru = Ext.getCmp("cb.tahunbaru").getValue(); if (!cektalama || !cektabaru) { Ext.Msg.alert("Informasi", "Lengkapi"); } else { if (cektalama == cektabaru){ Ext.Msg.alert("Informasi", "Tahun Akademik - Semester tidak boleh sama"); } else { Ext.Msg.show({ title: 'Konfirmasi', msg: 'Salin Data..?', buttons: Ext.Msg.YESNO, icon: Ext.MessageBox.QUESTION, fn: function (response) { if ('yes' !== response) { return; } Ext.Ajax.request({ url: BASE_URL + 'kuisioner_controller/copy_data', params: { tahun_lama : Ext.getCmp('cb.tahunlama').getValue(), tahun_baru : Ext.getCmp('cb.tahunbaru').getValue() }, success: function(response){ Ext.MessageBox.alert('Informasi', 'Salin Berhasil..'); Ext.getCmp('gp.kuisioner').store.reload(); win_copy.close(); }, failure: function() { Ext.Msg.alert("Informasi", "Copy Data Gagal"); } }); } }); } } } var win_copy = new Ext.Window({ title: 'Salin Setting Kuisioner', modal: true, closable: false, items: [form_salin] }).show(); } }