function f_jadwalpmb_form(id_module,recordstat,ds) { var ds_thnakademik2 = store_thnakademik2(); var ds_status = store_status(); var ds_gelombangpmb = new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'pendaftaran/c_jadwalpmb/get_gelombangpmb', method: 'POST' }), totalProperty: 'results', root: 'data', autoLoad: true, fields: [{ name: 'idgelombangpmb', mapping: 'idgelombangpmb' },{ name: 'kdgelombangpmb', mapping: 'kdgelombangpmb' }, { name: 'nmgelombangpmb', mapping: 'nmgelombangpmb' }] }); var idgelombangpmb; var form_bp_general = new Ext.form.FormPanel({ border: false, id: 'form_bp_general', defaults: { labelWidth: 100, labelStyle: 'text-align: right;width:100;' }, buttonAlign: 'left', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 380, width: 640, layout: 'form', autoScroll: true, reader: new Ext.data.JsonReader ({ root: 'data', totalProperty: 'results', id: 'id', fields: [ { name: "idjadwalpmb", mapping: "idjadwalpmb" }, { name: "kdjadwalpmb", mapping: "kdjadwalpmb" }, { name: "nmjadwalpmb", mapping: "nmjadwalpmb" }, { name: "idstatus", mapping: "idstatus" }, { name: "nmstatus", mapping: "nmstatus" }, { name: "kdstsemester", mapping: "kdstsemester" }, { name: "nmthnakademik", mapping: "nmthnakademik" }, { name: "daritgl", mapping: "daritgl" }, { name: "sampaitgl", mapping: "sampaitgl" }, { name: "idgelombangpmb", mapping: "idgelombangpmb" }, { name: "nmgelombangpmb", mapping: "nmgelombangpmb" } ] }), items: [ { xtype: 'textfield', fieldLabel: '', width: 200, hidden:true, name: 'idjadwalpmb' },{ xtype: 'textfield', fieldLabel: 'Kode ', width: 200, name: 'kdjadwalpmb' },{ xtype: 'textfield', fieldLabel: 'Nama', width: 505, name: 'nmjadwalpmb' }, { xtype: 'htmleditor', fieldLabel: 'Deskripsi ', height:100, name: 'deskripsi', id: 'deskripsi' }, { xtype: 'combo', width: 150, height: 50, allowBlank: false, store: ds_thnakademik2, fieldLabel: 'Tahun Akademik - Semester', id: 'kdstsemester', triggerAction: 'all', editable: false, valueField: 'kdstsemester', displayField: 'nmthnakademik', forceSelection: true, submitValue: true, hiddenName: 'h_kdjnsjadwalpmb', listeners: {}, typeAhead: true, mode: 'local', emptyText:'Pilih...', selectOnFocus:true }, { xtype: 'combo', width: 125, height: 50, allowBlank: false, store: ds_status, fieldLabel: 'Status', id: 'idstatus', triggerAction: 'all', editable: false, valueField: 'idstatus', displayField: 'nmstatus', forceSelection: true, submitValue: true, hiddenName: 'h_status', listeners: {}, typeAhead: true, mode: 'local', emptyText:'Pilih...', selectOnFocus:true }, { xtype: 'datefield', fieldLabel: 'Dari Tanggal', id: 'daritgl', name: 'daritgl' }, { xtype: 'datefield', fieldLabel: 'Sampai Tanggal', id: 'sampaitgl', name: 'sampaitgl' },{ xtype:'compositefield', fieldLabel: 'Gelombang', items:[{ xtype: 'combo', width: 125, height: 50, allowBlank: false, store: ds_gelombangpmb, fieldLabel: 'Status', id: 'idgelombangpmb', triggerAction: 'all', editable: false, valueField: 'idgelombangpmb', displayField: 'nmgelombangpmb', forceSelection: true, submitValue: true, hiddenName: 'h_gelombangpmb', listeners: {}, typeAhead: true, mode: 'local', emptyText:'Pilih...', selectOnFocus:true },{ xtype:'checkbox', boxLabel: 'Semua Gelombang', name: 'cbxallgelombang', id: 'cbxallgelombang', listeners: { check : function(cb, value) { if(value){ Ext.getCmp('idgelombangpmb').allowBlank=true; Ext.getCmp('idgelombangpmb').disable(); Ext.getCmp('idgelombangpmb').setValue(); } else { Ext.getCmp('idgelombangpmb').allowBlank=false; Ext.getCmp('idgelombangpmb').enable(); if(id_module!=""){ Ext.getCmp('idgelombangpmb').setValue(idgelombangpmb); } else { Ext.getCmp('idgelombangpmb').setValue(); } Ext.getCmp('idgelombangpmb').focus(); } } } }] } ], buttons: [{ id:'btn_simpan', iconCls: 'silk-save', text: 'Simpan', handler: function() { var idstat = Ext.getCmp('idstatus').getValue(); Ext.Ajax.request({ url: BASE_URL + 'pendaftaran/c_jadwalpmb/cekaktifpmb', method: 'POST', success: function(response) { status = response.responseText; if (status == idstat && recordstat != '1'){ Ext.MessageBox.alert("Informasi", "Jadwal PMB Aktif Sudah Ada, Silahkan Tidak Aktifkan Terlebih Dahulu"); } else { if(id_module!=''){ ubah_grid('form_bp_general'); }else{ simpan_grid('form_bp_general'); } } } }); } }, { text: 'Kembali', handler: function() { win.close(); } } ], listeners:{ afterrender: module_afterrender } }); function module_afterrender(){ if(id_module!=""){ form_bp_general.getForm().load({ url: BASE_URL + 'pendaftaran/c_jadwalpmb/grid', params:{ id_module:id_module }, success: function(form, action){ idgelombangpmb = Ext.getCmp('idgelombangpmb').getValue(); if (!Ext.getCmp('idgelombangpmb').getValue()){ Ext.getCmp('cbxallgelombang').setValue(true); } else { Ext.getCmp('cbxallgelombang').setValue(false); } }, failure: function(form, action){ Ext.MessageBox.alert('Failure', 'Fail to get data'); }, waitMsg:'Loading..' }); } Ext.getCmp('daritgl').setValue(SYS_DATE); Ext.getCmp('sampaitgl').setValue(SYS_DATE); Ext.getCmp('cbxallgelombang').setValue(true); } var win = new Ext.Window({ title: 'Jadwal PMB', modal: true, items: [form_bp_general] }).show(); function simpan_grid(namaForm) { var form_nya = Ext.getCmp(namaForm); form_nya.getForm().submit({ url: BASE_URL + 'pendaftaran/c_jadwalpmb/save', method: 'POST', params:{ }, success: function() { Ext.MessageBox.alert("Informasi", "Simpan Data Berhasil"); ds.load(); form_bp_general.getForm().reset(); Ext.getCmp('form_bp_general').enable(); Ext.getCmp('btn_simpan').enable(); Ext.getCmp('cbxallgelombang').setValue(true); }, failure: function() { Ext.MessageBox.alert("Informasi", "Simpan Data Gagal"); } }); } function ubah_grid(namaForm) { var msgplus=''; var form_nya = Ext.getCmp(namaForm); Ext.MessageBox.show({ title: "Konfirmasi", width: 350, msg: msgplus +"
Anda Yakin Untuk Mengubah Data ini?
", buttons: Ext.MessageBox.YESNO, fn: function(btn) { if (btn == 'yes') { form_nya.getForm().submit({ url: BASE_URL + 'pendaftaran/c_jadwalpmb/update', params:{ // mslider:Ext.getCmp('slideratas').getValue(), // pengguna:USERNAME }, method: 'POST', success: function() { Ext.MessageBox.alert("Informasi", "Ubah Data Berhasil"); ds.load(); form_bp_general.getForm().reset(); Ext.getCmp('form_bp_general').enable(); Ext.getCmp('btn_simpan').enable(); win.close(); }, failure: function() { Ext.MessageBox.alert("Informasi", "Ubah Data Gagal"); } }); } } }); } }