function pSyaratsidang(NM_KLP){ var ds_stsemester = store_stsmt(); var ds_prodireg = store_prodireg(); 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; } }); var fields_syaratsidang = RH.storeFields('kdstsemester','nmthnakademik','kdprodi','nmprodi','idklppengguna', 'kdsyaratsidang','nmsyaratsidang','deskripsi','nmklppengguna'); var pageSize = 18; var ds_syaratsidang = RH.JsonStore({ url : BASE_URL + 'syaratsidang_controller/get_syaratsidang', fields : fields_syaratsidang, limit: pageSize, params: [ {key:'kdstsemester', id:'cb.frm.kdstsemester'}, {key:'kdprodi', id:'cb.frm.kdprodi'} ], enableSearch: true, }); //SEARCH COMPONENT var sb_syaratsidang = RH.searchComp({ id : 'sb_syaratsidang', fields : ['kdsyaratsidang:Kode','nmsyaratsidang:Nama'], selected : 'kdsyaratsidang', store : ds_syaratsidang }); // COLUMN MODEL var cm_syaratsidang = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdsyaratsidang', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmsyaratsidang', 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_syaratsidang = new Ext.grid.RowSelectionModel({ singleSelect: true }); // Grid View var gv_syaratsidang = new Ext.grid.GridView({emptyText: '< Belum ada Data >'}); /** THE GRID */ var gp_syaratsidang = new Ext.grid.EditorGridPanel({ //PAKE EditorGridPanel ds: ds_syaratsidang, cm: cm_syaratsidang, sm: sm_syaratsidang, view: gv_syaratsidang, 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() { fnAddsyaratsidang(); } },{ xtype:'button', text: 'Salin Syarat Sidang dari Tahun Akademik - Semester Sebelumnya', id:'bcopy', iconCls: 'silk-page-copy', handler:function(){ var combo_stsmt = Ext.getCmp('cb.frm.kdstsemester'); var combo_prodi = Ext.getCmp('cb.frm.kdprodi'); if (combo_stsmt.getValue() && combo_prodi.getValue()) { if (gp_syaratsidang.getStore().getCount() > 0) { RH.warning('Data sudah ada. Hapus terlebih dahulu'); } else { wFormCopySyaratSidang(combo_stsmt, combo_prodi, gp_syaratsidang); } } else { RH.warning('Pilih ' + combo_stsmt.fieldLabel + ' dan ' + combo_prodi.fieldLabel); } } },'->',sb_syaratsidang], bbar: new Ext.PagingToolbar({ store: ds_syaratsidang, displayInfo: true, pageSize: pageSize, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { cellclick: onCellsyaratsidang } }); var fp_syaratsidang = new Ext.Panel({ xtype: 'panel', title: 'Syarat Sidang', 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.kdprodi', label: 'Program Studi', width: 400, data: ds_prodireg, key: 'kdprodi', display: 'lnmprodi', fnSelect: function(combo, record){ reloadData(Ext.getCmp('cb.frm.kdstsemester').getValue(), record.data.kdprodi); } }) ] },{ 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){ reloadData(record.data.kdstsemester, Ext.getCmp('cb.frm.kdprodi').getValue()); } }) ] }] }] },{ region: 'center', layout:'form', autoScroll:true, items:[{ xtype: 'panel', layout:'fit', height:400, frame:true, items: [gp_syaratsidang], }], }] }); SET_PAGE_CONTENT(fp_syaratsidang); /** FUNCTIONS */ function reloadData(kdstsemester, kdprodi) { if (kdstsemester && kdprodi) { ds_syaratsidang.reload({ params: { kdstsemester: kdstsemester, kdprodi : kdprodi, } }); } } function onCellsyaratsidang(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditsyaratsidang(grid, record)}); RH.DeleteClick(e, function(){fnDeletesyaratsidang(grid, record)}); } function fnAddsyaratsidang(){ var grid = gp_syaratsidang; var cbstsemester = Ext.getCmp('cb.frm.kdstsemester'); var cbprodi = Ext.getCmp('cb.frm.kdprodi'); var level_member = L_MEMBER; if (cbstsemester.getValue() && cbprodi.getValue()) { wEntrysyaratsidang(false, grid, null, cbstsemester, cbprodi, level_member); } else { RH.warning('Pilih ' + cbstsemester.fieldLabel + ' dan ' + cbprodi.fieldLabel); } } function fnEditsyaratsidang(grid, record){ var cbstsemester = Ext.getCmp('cb.frm.kdstsemester'); var cbprodi = Ext.getCmp('cb.frm.kdprodi'); var level_member = L_MEMBER; if (cbstsemester.getValue() && cbprodi.getValue()) { wEntrysyaratsidang(true, grid, record, cbstsemester, cbprodi, level_member); } else { RH.warning('Pilih ' + cbstsemester.fieldLabel + ' dan ' + cbprodi.fieldLabel); } } function fnDeletesyaratsidang(grid, record){ var url = BASE_URL + 'syaratsidang_controller/delete_syaratsidang'; var params = new Object({ kdstsemester : record.data['kdstsemester'], kdprodi : record.data['kdprodi'], kdsyaratsidang : record.data['kdsyaratsidang'] }); RH.deleteGridRecord(url, params, grid ); } } function wEntrysyaratsidang(isUpdate, grid, record, cbstsemester, cbprodi, level_member){ var winTitle = (isUpdate)?'Syarat Sidang (Edit)':'Syarat Sidang (Entry)'; var vkdstsemester, vkdprodi; /** FORM ENTRY/EDIT */ var hidden_klppengguna; if (level_member== 2){ hidden_klppengguna = false; }else{ hidden_klppengguna = true; } 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 syaratsidang_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.syaratsidang', buttonAlign: 'left', labelWidth: 200, labelAlign: 'right', bodyStyle: 'padding:10px 5px 5px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 280, width: 600, layout: 'form', frame: false, items: [ { xtype: 'textfield', id: 'tf.frm.nmthnakademik', disabled: true, fieldLabel: 'Tahun Akademik - Semester', width: 150, allowBlank: false, },{ xtype: 'textfield', id: 'tf.frm.nmprodi', disabled: true, fieldLabel: 'Program Studi', width: 350, allowBlank: false, },{ xtype: 'textfield', id: 'tf.frm.kdsyaratsidang', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ xtype: 'textfield', id: 'tf.frm.nmsyaratsidang', fieldLabel: 'Nama', width: 350, 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: 350, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveSyaratSidang(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wSyaratSidang.close(); } }] }); var wSyaratSidang = new Ext.Window({ title: winTitle, resizable:false, modal: true, closable:false, items: [syaratsidang_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setSyaratSidangForm(isUpdate, record); wSyaratSidang.show(); /** FORM FUNCTIONS */ function setSyaratSidangForm(isUpdate, record){ if(isUpdate){ if(record != null){ vkdstsemester = record.data['kdstsemester']; vkdprodi = record.data['kdprodi']; RH.setCompValue('tf.frm.nmthnakademik', record.data['nmthnakademik']); RH.setCompValue('tf.frm.nmprodi', record.data['nmprodi']); RH.setCompValue('tf.frm.kdsyaratsidang', record.data['kdsyaratsidang']); RH.setCompValue('tf.frm.nmsyaratsidang', record.data['nmsyaratsidang']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); RH.setCompValue('kelompok_pengguna', record.data['idklppengguna']); return; } } else { vkdstsemester = cbstsemester.getValue(); vkdprodi = cbprodi.getValue(); RH.setCompValue('tf.frm.nmthnakademik', cbstsemester.getRawValue()); RH.setCompValue('tf.frm.nmprodi', cbprodi.getRawValue()); } } function fnSaveSyaratSidang(){ var idForm = 'frm.syaratsidang'; var sUrl = BASE_URL +'syaratsidang_controller/insert_syaratsidang'; var sParams = new Object({ kdstsemester : vkdstsemester, kdprodi : vkdprodi, kdsyaratsidang : RH.getCompValue('tf.frm.kdsyaratsidang'), nmsyaratsidang : RH.getCompValue('tf.frm.nmsyaratsidang'), 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 +'syaratsidang_controller/update_syaratsidang'; sParams.kdsyaratsidangold = record.data['kdsyaratsidang']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wSyaratSidang, msgWait, msgSuccess, msgFail, msgInvalid); } } //============================================== function wFormCopySyaratSidang(combo_stsmt, combo_prodi, masterGrid){ var ds_stsmt = combo_stsmt.getStore(); var kdstsemesterc = combo_stsmt.getValue(); var nmthnakademikc = combo_stsmt.getRawValue(); var kdprodic = combo_prodi.getValue(); var nmprodic = combo_prodi.getRawValue(); var copy_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.copy', buttonAlign: 'left', labelWidth: 215, labelAlign: 'right', bodyStyle: 'padding:10px 5px 5px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 130, layout: 'form', frame: false, items: [{ xtype: 'textfield', value: nmprodic, id: 'tf.nmprodi-copy', disabled: true, fieldLabel: 'Program Studi', width: 350, allowBlank: false, },{ xtype: 'textfield', value: nmthnakademikc, 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:'silk-arrow-undo', handler: function() { wCopySyaratSidang.close(); } }] }); var wCopySyaratSidang = new Ext.Window({ title: 'Salin Syarat Sidang dari Tahun Akademik - Semester Sebelumnya', modal: true, closable:false, resizable:false, items: [copy_form] }).show(); /** 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 +'syaratsidang_controller/copy_syaratsidang'; var sParams = new Object({ kdprodi : kdprodic, smtbaru : kdstsemesterc, 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, wCopySyaratSidang, msgWait, msgSuccess, msgFail, msgInvalid); } }