var newButton; var editButton; var deleteButton; var importButton; var exportButton; var dataButton; var store; var expander; var cmodel; var chkSelModel; var infoGrid; var viewport; var rowsSelected; var importOption; var externalOption; var externalPermissions; var currentSelectedRow = -1; Ext.onReady(function(){ ///Keyboard Events new Ext.KeyMap(document, { key: Ext.EventObject.F5, fn: function(keycode, e) { if (! e.ctrlKey) { if (Ext.isIE) { e.browserEvent.keyCode = 8; } e.stopEvent(); document.location = document.location; } else{ Ext.Msg.alert( _('ID_REFRESH_LABEL') , _('ID_REFRESH_MESSAGE') ); } } }); Ext.QuickTips.init(); pageSize = parseInt(CONFIG.pageSize); if (PRO_UID == false) { var newMenuOptions = new Array(); newMenuOptions.push({ text: _('ID_NEW_PMTABLE'), handler: newPMTable }); newMenuOptions.push({ text: _('ID_NEW_REPORT_TABLE'), handler: NewReportTable }); newButton = new Ext.Action({ id: 'newButton', text: _('ID_NEW'), icon: '/images/add-table.png', menu: newMenuOptions }); } var flagProcessmap = (typeof('flagProcessmap') != 'undefined') ? flagProcessmap : 0; /*if (PRO_UID !== false) { newMenuOptions.push({ text: _('ID_NEW_REPORT_TABLE_OLD'), handler: NewReportTableOld }); }*/ if (PRO_UID !== false) { newButton = new Ext.Action({ id: 'newButton', text: _('ID_NEW'), icon: '/images/add-table.png', handler: NewReportTable }); } editButton = new Ext.Action({ id: 'editButton', text: _('ID_EDIT'), icon: '/images/edit-table.png', handler: EditPMTable, disabled: true }); deleteButton = new Ext.Action({ id: 'deleteButton', text: _('ID_DELETE'), icon: '/images/delete-table.png', handler: DeletePMTable, disabled: true }); importButton = new Ext.Action({ id: 'importButton', text: _('ID_IMPORT'), iconCls: 'silk-add', icon: '/images/import.gif', handler: ImportPMTable }); exportButton = new Ext.Action({ id: 'exportButton', text: _('ID_EXPORT'), iconCls: 'silk-add', icon: '/images/export.png', handler: ExportPMTable, disabled: true }); dataButton = new Ext.Action({ id: 'dataButton', text: ' ' + _('ID_DATA'), iconCls: 'silk-add', icon: '/images/database-start.png', handler: PMTableData, disabled: true }); searchButton = new Ext.Action({ id: 'searchButton', text: _('ID_SEARCH'), handler: DoSearch }); var contextMenuItems = new Array(); contextMenuItems.push(editButton); contextMenuItems.push(deleteButton); contextMenuItems.push('-'); contextMenuItems.push(dataButton); contextMenuItems.push(exportButton); if (_PLUGIN_SIMPLEREPORTS !== false) { externalOption = new Ext.Action({ text:'', iconCls: 'x-btn-text button_menu_ext ss_sprite ss_report_picture', handler: function() { updateTag('plugin@simplereport'); }, disabled: false }); externalPermissions = new Ext.Action({ text: _('ID_PERMISSIONS'), iconCls: 'x-btn-text button_menu_ext ss_sprite ss_key_add', handler: function() { updateTagPermissions('plugin@simplereport'); }, disabled: false }); contextMenuItems.push('-'); contextMenuItems.push(externalOption); contextMenuItems.push(externalPermissions); } contextMenu = new Ext.menu.Menu({ items: contextMenuItems }); searchText = new Ext.form.TextField ({ id: 'searchTxt', ctCls:'pm_search_text_field', allowBlank: true, width: 150, emptyText: _('ID_EMPTY_SEARCH'), listeners: { specialkey: function(f,e){ if (e.getKey() == e.ENTER) { DoSearch(); } }, focus: function(f,e) { var row = infoGrid.getSelectionModel().getSelected(); infoGrid.getSelectionModel().deselectRow(infoGrid.getStore().indexOf(row)); } } }); clearTextButton = new Ext.Action({ id: 'clearTextButton', text: 'X', ctCls:'pm_search_x_button', handler: GridByDefault }); storePageSize = new Ext.data.SimpleStore({ fields: ['size'], data: [['20'],['30'],['40'],['50'],['100']], autoLoad: true }); comboPageSize = new Ext.form.ComboBox({ id: 'comboPageSize', typeAhead : false, mode : 'local', triggerAction : 'all', store: storePageSize, valueField: 'size', displayField: 'size', width: 50, editable: false, listeners:{ select: function(c,d,i){ UpdatePageConfig(d.data['size']); bbarpaging.pageSize = parseInt(d.data['size']); bbarpaging.moveFirst(); } } }); comboPageSize.setValue(pageSize); store = new Ext.data.GroupingStore( { autoLoad: false, remoteSort: true, proxy : new Ext.data.HttpProxy({ url: 'pmTablesProxy/getList' + (PRO_UID? '?pro_uid='+PRO_UID: '') }), reader : new Ext.data.JsonReader( { root: 'rows', totalProperty: 'count', fields : [ {name : 'ADD_TAB_UID'}, {name : 'ADD_TAB_NAME'}, {name : 'ADD_TAB_DESCRIPTION'}, {name : 'PRO_TITLE'}, {name : 'TYPE'}, {name : 'ADD_TAB_TYPE'}, {name : 'ADD_TAB_TAG'}, {name : 'PRO_UID'}, {name : "DBS_UID"}, {name : 'NUM_ROWS'} ] }), listeners: { load: function(a,b){ if (currentSelectedRow != -1) { Ext.getCmp('infoGrid').getSelectionModel().selectRow(currentSelectedRow); Ext.getCmp('infoGrid').fireEvent('rowclick', Ext.getCmp('infoGrid'), currentSelectedRow) } } } }); chkSelModel = new Ext.grid.CheckboxSelectionModel({ listeners:{ selectionchange: function(sm){ if (sm.last !== false) { var count_rows = sm.getCount(); //var isReport = sm.getSelected().get('PRO_UID') != ''; currentSelectedRow = sm.last; switch(count_rows){ case 0: editButton.disable(); deleteButton.disable(); exportButton.disable(); dataButton.disable(); break; case 1: editButton.enable(); deleteButton.enable(); exportButton.enable(); dataButton.enable(); break; default: editButton.disable(); deleteButton.enable(); exportButton.enable(); dataButton.disable(); break; } } } } }); cmodelColumns = new Array(); cmodelColumns.push(chkSelModel); cmodelColumns.push({id:'ADD_TAB_UID', dataIndex: 'ADD_TAB_UID', hidden:true, hideable:false}); cmodelColumns.push({dataIndex: 'ADD_TAB_TAG', hidden:true, hideable:false}); cmodelColumns.push({header: _('ID_NAME'), dataIndex: 'ADD_TAB_NAME', width: 300, align:'left', renderer: function(v,p,r){ return r.get('TYPE') == 'CLASSIC'? v + ' ('+ _('ID_OLD_VERSION') +')' : v; }}); cmodelColumns.push({header: _('ID_DESCRIPTION'), dataIndex: 'ADD_TAB_DESCRIPTION', sortable:false, width: 400, hidden:false, align:'left', renderer: function(v,p,r){ if (r.get('ADD_TAB_TAG')) { tag = r.get('ADD_TAB_TAG').replace('plugin@', ''); tag = tag.charAt(0).toUpperCase() + tag.slice(1); switch(tag.toLowerCase()){ case 'simplereport': tag = _('ID_SIMPLE_REPORT'); break; } } v = Ext.util.Format.htmlEncode(v); return r.get("ADD_TAB_TAG") ? "" + tag + ": "+ v : v; }}); cmodelColumns.push({header: _('ID_TABLE_TYPE'), dataIndex: 'PRO_UID', width: 120, align:'left', renderer: function(v,p,r){ color = r.get('PRO_UID') ? 'blue' : 'green'; value = r.get('PRO_UID') ? _('ID_REPORT_TABLE') : _('ID_PMTABLE'); return ''+value+' '; }}); cmodelColumns.push({dataIndex: "DBS_UID", hidden: true, hideable: false}); cmodelColumns.push({header: _('ID_RECORDS'), dataIndex: 'NUM_ROWS', width: 90, align:'left'}); if (PRO_UID === false) { cmodelColumns.push({header: _('ID_PROCESS'), dataIndex: 'PRO_TITLE', width: 180, align:'left'}); } cmodelColumns.push({header: _('ID_TYPE'), dataIndex: 'ADD_TAB_TYPE', width: 400, hidden:true, align:'left'}); cmodel = new Ext.grid.ColumnModel({ defaults: { width: 50, sortable: true }, columns: cmodelColumns }); bbarpaging = new Ext.PagingToolbar({ id: 'bbarpaging', pageSize: pageSize, store: store, displayInfo: true, displayMsg: (PRO_UID? _('ID_GRID_PAGE_DISPLAYING_REPORTABLES_MESSAGE') : _('ID_GRID_PAGE_DISPLAYING_PMTABLES_MESSAGE')) + '    ', emptyMsg: _('ID_GRID_PAGE_NO_PMTABLES_MESSAGE'), items: ['-',_('ID_PAGE_SIZE')+':',comboPageSize] }); infoGrid = new Ext.grid.GridPanel({ region: 'center', layout: 'fit', id: 'infoGrid', height:100, autoWidth : true, title : (PRO_UID? _('ID_REPORT_TABLES') : _('ID_PMTABLE')), stateful : true, stateId : 'gridList', enableColumnResize: true, enableHdMenu: true, frame:false, columnLines: false, viewConfig: { forceFit:true }, store: store, loadMask: true, cm: cmodel, sm: chkSelModel, tbar: [ newButton, editButton, deleteButton,'-', dataButton,'-' , importButton, exportButton, '->', searchText, clearTextButton, searchButton], bbar: bbarpaging, listeners: { rowdblclick: EditPMTable, render: function(){ this.loadMask = new Ext.LoadMask(this.body, {msg: _('ID_LOADING_GRID')}); } }, view: new Ext.grid.GroupingView({ forceFit:true, groupTextTpl: '{text}' }) }); infoGrid.on('rowcontextmenu', function (grid, rowIndex, evt) { var sm = grid.getSelectionModel(); sm.selectRow(rowIndex, sm.isSelected(rowIndex)); var rowsSelected = Ext.getCmp('infoGrid').getSelectionModel().getSelections(); if (externalOption) { tag = rowsSelected[0].get('ADD_TAB_TAG'); if (tag) { text = _('ID_CONVERT_NATIVE_REP_TABLE'); externalPermissions.setDisabled(false); } else { text = _('ID_CONVERT_SIMPLE_REPORT'); externalPermissions.setDisabled(true); } externalOption.setText(text); if (rowsSelected[0].get('PRO_UID')) { externalOption.setDisabled(false); } else { externalOption.setDisabled(true); } externalOption.setHidden((rowsSelected[0].get("TYPE") != "CLASSIC" && rowsSelected[0].get("DBS_UID") == "workflow")? false : true); } },this); infoGrid.on('contextmenu', function(evt){evt.preventDefault();}, this); infoGrid.addListener('rowcontextmenu',onMessageContextMenu, this); viewport = new Ext.Viewport({ layout: 'fit', autoScroll: false, items: [infoGrid] }); infoGrid.store.load(); }); //Funtion Handles Context Menu Opening onMessageContextMenu = function (grid, rowIndex, e) { e.stopEvent(); var coords = e.getXY(); contextMenu.showAt([coords[0], coords[1]]); }; /////JS FUNCTIONS //Capitalize String Function capitalize = function(s){ s = s.toLowerCase(); return s.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } ); }; //Do Nothing Function DoNothing = function(){}; //Load New PM Table Forms NewReportTable = function() { if(PRO_UID !== false) { location.href = 'pmTables/edit?PRO_UID='+PRO_UID+'&tableType=report&flagProcessmap='+flagProcessmap; } else { location.href = 'pmTables/edit?tableType=report&flagProcessmap='+flagProcessmap; } }; NewReportTableOld = function(){ //location.href = 'reportTables/edit?PRO_UID='+PRO_UID+'&tableType=report'; //parent.reportTables2(); //parent.Pm.data.render.buildingBlocks.injector('reportTables2'); location.href = 'reportTables/reportTables_Edit?PRO_UID='+PRO_UID; }; newPMTable = function(){ location.href = 'pmTables/edit?tableType=table'; }; EditPMTable = function(){ var row = Ext.getCmp('infoGrid').getSelectionModel().getSelected(); if (row.data.TYPE != 'CLASSIC') { tableType = row.data.PRO_UID ? 'report' : 'table'; proParam = PRO_UID !== false ? '&PRO_UID='+PRO_UID : ''; location.href = 'pmTables/edit?id='+row.data.ADD_TAB_UID+'&flagProcessmap='+flagProcessmap+'&tableType=' + tableType + proParam; } else { //edit old report table location.href = 'reportTables/reportTables_Edit?REP_TAB_UID='+row.data.ADD_TAB_UID } }; //Confirm PM Table Deletion Tasks DeletePMTable = function() { var rows = Ext.getCmp('infoGrid').getSelectionModel().getSelections(); var selections = new Array(); for(var i=0; i' + _('ID_IMPORTING_ERROR') + '' + result.message, items: [], buttons: [{ text: 'Close', handler: function(){ win.hide(); } }] }); win.show(this); } w.close(); infoGrid.store.reload(); }, failure: function(o, resp){ w.close(); infoGrid.store.reload(); var result = Ext.util.JSON.decode(resp.response.responseText); if (result.errorType == 'warning') { PMExt.warning(_('ID_WARNING'), result.message.replace(/\n/g,'
')); } else { if(result.fromAdmin) { /* from admin tab */ if(result.validationType == 1) { Ext.MessageBox.confirm('Confirmation', result.message.replace(/\n/g,'
'), function(btn, text){ if (btn == 'yes'){ Ext.Ajax.request({ url: 'pmTablesProxy/import', params: { 'form[FROM_CONFIRM]':'overWrite', 'form[TYPE_TABLE]':(PRO_UID? 'designer' : 'admin'), 'form[OVERWRITE]':true }, success: function(resp){ var result = Ext.util.JSON.decode(resp.responseText); if (result.success) { PMExt.notify(_('ID_IMPORT_RESULT'), result.message); Ext.getCmp('infoGrid').getStore().reload(); } else { if(result.validationType == 2) { PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,'
')); } } }, failure: function(obj, resp){ var result = Ext.util.JSON.decode(resp.responseText); if(result.validationType == 2) { PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,'
')); } } }); } else { Ext.Ajax.request({ url: 'pmTablesProxy/import', params: { 'form[FROM_CONFIRM]':'clear', 'form[TYPE_TABLE]':(PRO_UID? 'designer' : 'admin') }, success: function(resp) { var result = Ext.util.JSON.decode(resp.responseText); PMExt.notify(_('ID_IMPORT_RESULT'), result.message); Ext.getCmp('infoGrid').getStore().reload(); } }); } Ext.getCmp('infoGrid').getStore().reload(); }); return false; } else { PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,'
')); } } else { /* from designer tab */ if(result.validationType == 1) { Ext.MessageBox.confirm('Confirmation', result.message.replace(/\n/g,'
'), function(btn, text){ if (btn == 'yes'){ Ext.Ajax.request({ url: 'pmTablesProxy/import', params: { 'form[FROM_CONFIRM]':'2', 'form[TYPE_TABLE]':(PRO_UID? 'designer' : 'admin'), 'form[OVERWRITE]':true }, success: function(resp){ var result = Ext.util.JSON.decode(resp.responseText); if (result.success) { PMExt.notify(_('ID_IMPORT_RESULT'), result.message); Ext.getCmp('infoGrid').getStore().reload(); } else { if(result.validationType == 2) { Ext.MessageBox.confirm('Confirmation', result.message.replace(/\n/g,'
'), function(btn, text){ if (btn == 'yes'){ Ext.Ajax.request({ url: 'pmTablesProxy/import', params: { 'form[FROM_CONFIRM]':'overWrite', 'form[TYPE_TABLE]':(PRO_UID? 'designer' : 'admin'), 'form[OVERWRITE]':true }, success: function(resp){ var result = Ext.util.JSON.decode(resp.responseText); if (result.success) { PMExt.notify(_('ID_IMPORT_RESULT'), result.message); Ext.getCmp('infoGrid').getStore().reload(); } else { PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,'
')); } }, failure: function(obj, resp){ PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,'
')); } }); Ext.getCmp('infoGrid').getStore().reload(); } }); return false; } else { PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,'
')); } } }, failure: function(obj, resp){ var result = Ext.util.JSON.decode(resp.responseText); if(result.validationType == 2) { PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,'
')); } } }); Ext.getCmp('infoGrid').getStore().reload(); } else { Ext.Ajax.request({ url: 'pmTablesProxy/import', params: { 'form[FROM_CONFIRM]':'2', 'form[TYPE_TABLE]':(PRO_UID? 'designer' : 'admin'), 'form[PRO_UID_HELP]':PRO_UID }, success: function(resp) { var result = Ext.util.JSON.decode(resp.responseText); if(result.validationType == 2) { /*add code if related process*/ Ext.MessageBox.confirm('Confirmation', result.message.replace(/\n/g,'
'), function(btn, text){ if (btn == 'yes'){ Ext.Ajax.request({ url: 'pmTablesProxy/import', params: { 'form[FROM_CONFIRM]':'overWrite', 'form[TYPE_TABLE]':(PRO_UID? 'designer' : 'admin'), 'form[PRO_UID_HELP]':PRO_UID }, success: function(resp){ var result = Ext.util.JSON.decode(resp.responseText); if (result.success) { PMExt.notify(_('ID_IMPORT_RESULT'), result.message); Ext.getCmp('infoGrid').getStore().reload(); } else { PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,'
')); } }, failure: function(obj, resp){ PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,'
')); } }); Ext.getCmp('infoGrid').getStore().reload(); } }); return false; } else { var result = Ext.util.JSON.decode(resp.responseText); if (result.success) { PMExt.notify(_('ID_IMPORT_RESULT'), result.message); Ext.getCmp('infoGrid').getStore().reload(); } else { PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,'
')); } } //PMExt.notify(_('ID_IMPORT_RESULT'), result.message); }, failure: function(obj, resp){ var result = Ext.util.JSON.decode(resp.responseText); PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,'
')); } }); } Ext.getCmp('infoGrid').getStore().reload(); }); return false; } if(result.validationType == 2) { Ext.MessageBox.confirm('Confirmation', result.message.replace(/\n/g,'
'), function(btn, text){ if (btn == 'yes'){ Ext.Ajax.request({ url: 'pmTablesProxy/import', params: { 'form[FROM_CONFIRM]':'overWrite', 'form[TYPE_TABLE]':(PRO_UID? 'designer' : 'admin'), 'form[OVERWRITE]':true, 'form[PRO_UID_HELP]':PRO_UID }, success: function(resp){ var result = Ext.util.JSON.decode(resp.responseText); if (result.success) { PMExt.notify(_('ID_IMPORT_RESULT'), result.message); Ext.getCmp('infoGrid').getStore().reload(); } else { PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,'
')); } }, failure: function(obj, resp){ PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,'
')); } }); Ext.getCmp('infoGrid').getStore().reload(); } }); return false; } else { PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,'
')); } } } } }); } } }/*,{ text: 'Reset', handler: function(){ uploader = Ext.getCmp('uploader'); uploader.getForm().reset(); } }*/,{ id: 'importPMTableButtonCancel', text: TRANSLATIONS.ID_CANCEL, handler: function(){ w.close(); } }] }) ] }); w.show(); } //Load Export PM Tables Form ExportPMTable = function(){ var rows = Ext.getCmp('infoGrid').getSelectionModel().getSelections(); var toExportRows = new Array(); for(var i=0; i