function upload_files(){ var ds_status = store_status(); var fields_uploadfiles = RH.storeFields('kodeuploadfile','juduluploadfile','deskripsi' ,'fileupload','idstatus','nmstatus', 'userid','nmlengkap','tglupload','tgluploadrender','jamupload', 'useridupdate','nmlengkapupdate','tglupdaterender','jamupdate'); var pageSize = 20; var ds_uploadfiles = RH.JsonStore({ url : BASE_URL + 'upload_files/get_uploadfiles', fields : fields_uploadfiles, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_uploadfiles = RH.searchComp({ id : 'sb_uploadfiles', fields : ['juduluploadfile:Judul', 'fileupload:File', 'nmstatus:Status', 'nmlengkap:User Input', 'tglupload:Tanggal Upload'], selected : 'nip', store : ds_uploadfiles }); var cm_uploadfiles = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: 'Kode',width: 100, dataIndex: 'kodeuploadfile', sortable: true }, { header: 'Judul',width: 250, dataIndex: 'juduluploadfile', sortable: true }, { header: 'File',width: 150, dataIndex: 'fileupload', sortable: true }, { header: 'Status',width: 100, dataIndex: 'nmstatus', sortable: true }, { header: 'User Input',width: 150, dataIndex: 'nmlengkap', sortable: true }, { header: 'Tanggal Upload',width: 100, dataIndex: 'tgluploadrender', sortable: true }, { header: 'Jam Upload',width: 100, dataIndex: 'jamupload', sortable: true }, { header: 'User Update',width: 150, dataIndex: 'nmlengkapupdate', sortable: true }, { header: 'Tanggal Update',width: 100, dataIndex: 'tglupdaterender', sortable: true }, { header: 'Jam Update',width: 100, dataIndex: 'jamupdate', sortable: true },{ xtype: 'actioncolumn', width: 50, header: 'Edit', align:'center', items: [{ getClass: function(v, meta, record) { meta.attr = "style='cursor:pointer;'"; }, icon : BASE_PATH + 'resources/img/icons/fam/application_edit.png', tooltip: 'Edit', handler: function(grid, rowIndex) { var record = grid.store.getAt(rowIndex); fnEdituploadfiles(grid, record); } }] },{ xtype: 'actioncolumn', width: 50, header: 'Delete', align:'center', items: [{ getClass: function(v, meta, record) { meta.attr = "style='cursor:pointer;'"; }, icon : BASE_PATH + '/resources/img/icons/fam/delete.gif', tooltip: 'Delete', handler: function(grid, rowIndex) { var record = grid.store.getAt(rowIndex); fnDeleteuploadfiles(grid, record) } }] }] ); /** THE GRID */ var gp_uploadfiles = RH.GridPanel_T1({ ds: ds_uploadfiles, cm: cm_uploadfiles, singleSelect: true, searchComp: sb_uploadfiles, allowAdd: true, fnAdd: fnAdduploadfiles, pageSize: pageSize, cellclick: onCelluploadfilesClick }); var fp_uploadfiles = RH.GPContainer1({ title: 'Upload File', iconCls:'silk-page-copy', gridPanel: gp_uploadfiles, }); get_content(fp_uploadfiles); /** FUNCTIONS */ function onCelluploadfilesClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record } function reloaduploadfiles(){ ds_uploadfiles.reload(); } function fnAdduploadfiles(){ var grid = gp_uploadfiles; wform_uploadfiles(false, grid, null, ds_status); } //function fnPrintuploadfiles(grid, record){ // // var nim = record.data['nim'] // RH.ShowReport(BASE_URL + 'surat/surat_observasi/get_surat_observasi/' // +nim); // // } function fnEdituploadfiles(grid, record){ wform_uploadfiles(true, grid, record, ds_status); } function fnDeleteuploadfiles(grid, record){ var url = BASE_URL + 'upload_files/delete_uploadfile'; var params = new Object({ kodeuploadfile : record.data['kodeuploadfile'], fileupload : record.data['fileupload'] }); RH.deleteGridRecord(url, params, grid ); } function wform_uploadfiles(isUpdate, grid, record, ds_status){ var winTitle = (isUpdate) ? 'Upload File (Edit)':'Upload File (Entry)'; var interval; var uploadfiles_form = new Ext.form.FormPanel({ id: 'frm_uploadfiles', buttonAlign: 'left', labelWidth: 100, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 350, width: 700, autoScroll: true, layout: 'form', fileUpload: true, frame: true, defaultType:'textfield', items: [{ id: 'tf_kodeuploadfile', fieldLabel: 'Kode', width: 100, allowBlank: false, }, { id: 'tf_juduluploadfile', fieldLabel: 'Judul', width: 250, allowBlank: false, }, { xtype: 'htmleditor', id: 'hm_deskripsi', fieldLabel: 'Deskripsi', height: 100, allowBlank: true, }, { xtype: 'fileuploadfield', id: 'fu_fileupload', name: 'fu_fileupload', emptyText: 'Cari File (Maksimal 5 MB)...', fieldLabel: 'File', allowBlank:false, buttonText: '', anchor: '70%', buttonCfg: { iconCls: 'silk-page-copy' }, listeners: { valid: function() { } } }, { xtype: 'combo', width: 125, height: 50, allowBlank: false, store: ds_status, fieldLabel: 'Status', id: 'cb_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 }, { id: 'tf_nmlengkap', value: USERNAME, fieldLabel: 'User Input', width: 100, disabled: true, allowBlank: false, }, { xtype: 'datefield', fieldLabel: 'Tgl Upload ', id: 'df_tglupload', name: 'df_tglupload', allowBlank: false, format: 'd/m/Y', disabled: true, value: new Date(), width: 100 }, { xtype: 'textfield', id: 'tf_jamupload', name: 'tf_jamupload', fieldLabel: 'Jam Upload', disabled: true, allowBlank: false, width: 100 }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveuploadfiles(); } }, { text: 'Kembali', iconCls:'', handler: function() { wuploadfiles.close(); } }] }); var wuploadfiles = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [uploadfiles_form] }); setuploadfiles(isUpdate, record); wuploadfiles.show(); function setuploadfiles(isUpdate, record){ if(isUpdate){ clearInterval(interval); Ext.getCmp('tf_kodeuploadfile').disable(); Ext.getCmp('fu_fileupload').disable(); if(record != null){ RH.setCompValue('tf_kodeuploadfile', record.data['kodeuploadfile']); RH.setCompValue('tf_juduluploadfile', record.data['juduluploadfile']); RH.setCompValue('hm_deskripsi', record.data['deskripsi']); RH.setCompValue('fu_fileupload', record.data['fileupload']); RH.setCompValue('tf_nmlengkap', record.data['nmlengkap']); RH.setCompValue('df_tglupload', record.data['tglupload']); RH.setCompValue('tf_jamupload', record.data['jamupload']); RH.setCompValue('cb_idstatus', record.data['idstatus']); return; } } else { setTime(); } } function setTime(){ interval = setInterval(function() { var d=new Date(); var t=d.toLocaleTimeString('en-US', { hour12: false }); if(Ext.getCmp('tf_jamupload')) RH.setCompValue('tf_jamupload',t); }, 1000); } function fnSaveuploadfiles(){ var fForm = Ext.getCmp('frm_uploadfiles'); var sUrl = BASE_URL +'upload_files/insert_uploadfile'; if(isUpdate){ sUrl = BASE_URL +'upload_files/update_uploadfile'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } if(fForm.getForm().isValid()){ fForm.getForm().submit({ url: sUrl, params: { kodeuploadfile: Ext.getCmp('tf_kodeuploadfile').getValue(), fileupload: Ext.getCmp('fu_fileupload').getValue(), userid: USERID }, method: 'POST', waitMsg: 'Tunggu, sedang proses menyimpan...', success: function(fForm, o) { if(isUpdate){ Ext.MessageBox.alert("Informasi", "Ubah Data Berhasil"); grid.getStore().reload(); wuploadfiles.close(); } else { if (o.result.success == 'true') { Ext.MessageBox.alert('Informasi', 'Upload File ' + o.result.filename + ' Berhasil'); grid.getStore().reload(); wuploadfiles.close(); } else if (o.result.success == 'false-up') { Ext.MessageBox.alert('Informasi', 'Upload File ' + o.result.filename + ' Berhasil'); } else if (o.result.success == 'false-size') { Ext.MessageBox.alert('Informasi', '