function f_tambahkatalog_form(id_module,ds) { var form_bp_general = new Ext.form.FormPanel({ border: false, id: 'form_bp_general', labelAlign: 'left', buttonAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 350, width: 700, layout: 'form', reader: new Ext.data.JsonReader ({ root: 'data', totalProperty: 'results', id: 'id', fields: [ { name: "id_katalog", mapping: "id_katalog" },{ name: "kd_katalog", mapping: "kd_katalog" },{ name: "nama_pengarang", mapping: "nama_pengarang" },{ name: "nama_kategori", mapping: "nama_kategori" },{ name: "isbn", mapping: "isbn" },{ name: "judul_buku", mapping: "judul_buku" },{ name: "deskripsi", mapping: "deskripsi" },{ name: "tgl_terbit", mapping: "tgl_terbit" },{ name: "thn_terbit", mapping: "thn_terbit" } ] }), items: [{ xtype:'fieldset', title: '', width: 650, items :[ { xtype: 'textfield', fieldLabel: '', width: 100, name: 'id_katalog', hidden:true, }, { xtype: 'textfield', fieldLabel: 'Kode Katalog', width: 100, name: 'kd_katalog' }, { xtype: 'compositefield', name: 'comp_pengarang', fieldLabel: 'Pengarang', //labelStyle: 'width:160px', id: 'comp_pengarang', items: [{ xtype: 'textfield', id: 'id_pengarang', name: 'nama_pengarang', readOnly:true, width: 200, emptyText:'Pilih...', listeners: { 'render': function(c) { c.getEl().on('keypress', function(e) { // if (e.getKey() == 13) Ext.getCmp('btn_simpan_product').focus(); }, c); } } }, { xtype: 'button', text: ' ... ', id: 'btn_data_pengarang', width: 3, handler: function() { find_x("Data Pengarang", 11); } }] }, { xtype: 'compositefield', name: 'comp_kategori', fieldLabel: 'Kategori', //labelStyle: 'width:160px', id: 'comp_kategori', items: [{ xtype: 'textfield', id: 'id_kategori', name: 'nama_kategori', readOnly:true, width: 200, emptyText:'Pilih...', listeners: { 'render': function(c) { c.getEl().on('keypress', function(e) { // if (e.getKey() == 13) Ext.getCmp('btn_simpan_product').focus(); }, c); } } }, { xtype: 'button', text: ' ... ', id: 'btn_data_kategori', width: 3, handler: function() { find_x("Data Kategori", 12); } }] }, { xtype: 'textfield', fieldLabel: 'No.Buku', width: 100, name: 'isbn' }, { xtype: 'textfield', fieldLabel: 'Judul Buku', width: 200, name: 'judul_buku' }, { xtype: 'textarea', fieldLabel: 'Deskripsi', height:50, width: 515, name: 'deskripsi', id: 'deskripsi' }, { xtype: 'datefield', fieldLabel: 'Tanggal Terbit', id: 'tglterbit', name: 'tgl_terbit' }, { xtype: 'textfield', fieldLabel: 'Tahun Terbit', width: 50, name: 'thn_terbit' }, { xtype: 'textfield', fieldLabel: '', width: 200, id: 'jampublish', name: 'jampublish', hidden:true }] }], buttons: [{ id:'btn_simpan', text: 'Simpan', iconCls: 'silk-save', handler: function() { 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 + 'e_katalog/c_katalog/grid', params:{ id_module:id_module }, success: function(form, action){ }, failure: function(form, action){ Ext.MessageBox.alert('Failure', 'Fail to get data'); }, waitMsg:'Loading..' }); } } var win = new Ext.Window({ title: 'Tambah Kategori', modal: true, items: [form_bp_general] }).show(); function simpan_grid(namaForm) { var form_nya = Ext.getCmp(namaForm); form_nya.getForm().submit({ url: BASE_URL + 'e_katalog/c_katalog/save', method: 'POST', params:{ // matas:Ext.getCmp('menuatas').getValue(), // mbawah:Ext.getCmp('menubawah').getValue(), // mkanan:Ext.getCmp('menukanan').getValue(), // mkiri:Ext.getCmp('menukiri').getValue() }, 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('btn_hapus').disable(); // Ext.getCmp('btn_ubah').disable(); }, failure: function() { Ext.MessageBox.alert("Informasi", "Simpan Data Gagal"); } }); } function ubah_grid(namaForm) { // var msgplus; // if(kodex!=Ext.getCmp('kode').getValue()){ // msgplus='
Semua field dapat berubah terkecuali field "KODE"!?
'; // }else{ 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 + 'e_katalog/c_katalog/update', params:{ // matas:Ext.getCmp('menuatas').getValue(), // mbawah:Ext.getCmp('menubawah').getValue(), // mkanan:Ext.getCmp('menukanan').getValue(), // mkiri:Ext.getCmp('menukiri').getValue() }, 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(); }, failure: function() { Ext.MessageBox.alert("Informasi", "Ubah Data Gagal"); } }); } } }); } }