function f_tambahmateri_form(id_module,ds) { var hapusfilex = 0; var userid = USERID; var pengajar = USERNAME; var ds_sesi = store_sesi(); var ds_stpublish = store_stpublish(); var form_bp_general = new Ext.form.FormPanel({ border: false, fileUpload: true, 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: 500, width: 690, layout: 'form', autoScroll: true, reader: new Ext.data.JsonReader ({ root: 'data', totalProperty: 'results', id: 'id', fields: [{ name: "idmateri", mapping: "idmateri" }, { name: "idmk", mapping: "idmk" }, { name: "nmmk", mapping: "nmmk" }, { name: "idsesi", mapping: "idsesi" }, { name: "nmsesi", mapping: "nmsesi" }, { name: "userid", mapping: "userid" }, { name: "pengguna", mapping: "pengguna" }, { name: "subjek", mapping: "subjek" }, { name: "deskripsi", mapping: "deskripsi" }, { name: "tujuan", mapping: "tujuan" }, { name: "catatan", mapping: "catatan" }, { name: "idstpublish", mapping: "idstpublish" }, { name: "nmstpublish", mapping: "nmstpublish" }, { name: "tglpublish", mapping: "tglpublish" }, { name: "jampublish", mapping: "jampublish" }, { name: "file", mapping: "file" }, { name: "file-path", mapping: "file-path" }, { name: "tipe", mapping: "tipe" }, { name: "download", mapping: "download" }] }), items: [{ xtype:'fieldset', title: '', width: 650, items :[ { xtype: 'textfield', fieldLabel: '', width: 200, name: 'idmateri', hidden:true, }, { xtype: 'textfield', fieldLabel: '', width: 200, hidden:true, readOnly:true, name: 'userid', value:userid }, { xtype: 'textfield', fieldLabel: 'Dosen Pengajar', width: 200, readOnly:true, name: 'pengguna', value:pengajar }, { xtype: 'compositefield', name: 'comp_matakuliah', fieldLabel: 'Mata Kuliah', //labelStyle: 'width:160px', id: 'comp_matakuliah', items: [{ xtype: 'textfield', id: 'idmk', name: 'idmk', hidden:true, readOnly:true, width: 200, emptyText:'Pilih...' }, { xtype: 'textfield', id: 'nmmk', name: 'nmmk', 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_matakuliah', width: 3, handler: function() { find_x("Data Mata Kuliah", 10); } }] }, { xtype: 'textarea', fieldLabel: 'Subjek/Judul', height:50, width: 515, name: 'subjek', id: 'subjek' }, { xtype: 'textarea', fieldLabel: 'Deskripsi ', height:50, width: 515, name: 'deskripsi', id: 'deskripsi' }, { xtype: 'textarea', fieldLabel: 'Tujuan ', height:50, width: 515, name: 'tujuan', id: 'tujuan' }, { xtype: 'textarea', fieldLabel: 'Catatan ', height:50, width: 515, name: 'catatan', id: 'catatan' }, { xtype: 'combo', width: 125, height: 50, allowBlank: false, store: ds_sesi, fieldLabel: 'Sesi', id: 'idsesi', triggerAction: 'all', editable: false, valueField: 'idsesi', displayField: 'nmsesi', forceSelection: true, submitValue: true, hiddenName: 'h_sesi', listeners: {}, typeAhead: true, mode: 'local', emptyText:'Pilih...', selectOnFocus:true }, { xtype: 'fileuploadfield', id: 'file-path', emptyText: 'Select an file', fieldLabel: 'File Materi', name: 'file-path', buttonText: '', anchor: '90%', buttonCfg: { iconCls: 'silk-page-copy' }, allowBlank: false, listeners: { valid: function() { hapusfilex = 1; } } }, { xtype: 'combo', width: 125, height: 50, allowBlank: false, store: ds_stpublish, fieldLabel: 'Status Publish', id: 'idstpublish', triggerAction: 'all', editable: false, valueField: 'idstpublish', displayField: 'nmstpublish', forceSelection: true, submitValue: true, hiddenName: 'h_status', listeners: {}, typeAhead: true, mode: 'local', emptyText:'Pilih...', selectOnFocus:true }, { xtype: 'datefield', fieldLabel: 'Tanggal Publish', id: 'tglpublish', name: 'tglpublish' }, { xtype: 'textfield', fieldLabel: 'Jam Publish', width: 200, id: 'jampublish', name: 'jampublish' }] }], buttons: [{ id:'btn_simpan', iconCls: 'silk-save', text: 'Simpan', 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(){ Ext.getCmp('jampublish').setValue(""); if(id_module!=""){ form_bp_general.getForm().load({ url: BASE_URL + 'e_learning/c_tambahmateri/grid', params:{ id_module:id_module }, success: function(form, action){ }, failure: function(form, action){ Ext.MessageBox.alert('Failure', 'Fail to get data'); }, waitMsg:'Loading..' }); Ext.getCmp("file-path").disable(); Ext.getCmp('tglpublish').disable(); Ext.getCmp('jampublish').disable(); } else if(id_module==''){ Ext.getCmp('tglpublish').setValue(SYS_DATE); setInterval(function() { var d = new Date(); var t = d.toLocaleTimeString(); if (Ext.getCmp('jampublish')) Ext.getCmp('jampublish').setValue(t); }, 1000); } } var win = new Ext.Window({ title: 'Upload Materi', modal: true, items: [form_bp_general] }).show(); function simpan_grid(namaForm) { var xls = Right(Ext.getCmp('file-path').getValue(),3); var xls2 = Right(Ext.getCmp('file-path').getValue(),4); var form_nya = Ext.getCmp(namaForm); if (xls=="doc" || xls=="pdf" || xls=="PDF" || xls=="ppt" || xls=="xls" || xls=="rar" || xls=="zip" || xls2=="docx" || xls2=="pptx" || xls2=="xlsx") { form_nya.getForm().submit({ url: BASE_URL + 'e_learning/c_tambahmateri/upload', method: 'POST', params:{ }, success: function(form_bp_general, o) { if (o.result.success == 'true') { Ext.MessageBox.alert('Informasi', 'Upload Data Berhasil'); ds.load(); win.close(); } else if (o.result.success == 'false') { Ext.MessageBox.alert('Informasi', '