diff --git a/workflow/engine/classes/model/AdditionalTables.php b/workflow/engine/classes/model/AdditionalTables.php index 5916c021c..7ed97b058 100644 --- a/workflow/engine/classes/model/AdditionalTables.php +++ b/workflow/engine/classes/model/AdditionalTables.php @@ -860,6 +860,13 @@ public function loadByName($name) { } return implode('', $aAux); } + + function deleteMultiple($arrUID){ + $arrUIDs = explode(",",$arrUID); + foreach ($arrUIDs as $UID){ + $this->deleteAll($UID); + } + } function deleteAll($sUID) { try { @@ -1168,7 +1175,7 @@ var additionalTablesDataDelete = function(sUID, sKeys) { throw($oError); } } - + function deleteDataInTable($sUID, $aKeys) { try { $aData = $this->load($sUID, true); diff --git a/workflow/engine/methods/additionalTables/additionalTablesAjax.php b/workflow/engine/methods/additionalTables/additionalTablesAjax.php index cccad793d..c951ae715 100644 --- a/workflow/engine/methods/additionalTables/additionalTablesAjax.php +++ b/workflow/engine/methods/additionalTables/additionalTablesAjax.php @@ -91,6 +91,7 @@ if(isset($_POST['action'])) { $EXPORT_TRACEBACK = Array(); + $c = 0; foreach ($tables as $uid) { $aTable = new additionalTables(); @@ -112,6 +113,8 @@ if(isset($_POST['action'])) { 'num_regs' => sizeof($rows), 'schema' => in_array($uid, $schema)? 'yes': 'no', 'data' => in_array($uid, $data)? 'yes': 'no' +// 'schema' => ($schema[$c]=='Export')? 'yes': 'no', +// 'data' => ($data[$c]=='Export')? 'yes': 'no' )); } diff --git a/workflow/engine/methods/additionalTables/additionalTablesDelete.php b/workflow/engine/methods/additionalTables/additionalTablesDelete.php index 8c3233d32..4775a0c3c 100644 --- a/workflow/engine/methods/additionalTables/additionalTablesDelete.php +++ b/workflow/engine/methods/additionalTables/additionalTablesDelete.php @@ -39,6 +39,6 @@ if ($_GET['sUID'] == '') { require_once 'classes/model/AdditionalTables.php'; $oAdditionalTables = new AdditionalTables(); -$oAdditionalTables->deleteAll($_GET['sUID']); +$oAdditionalTables->deleteMultiple($_GET['sUID']); G::Header('Location: additionalTablesList'); \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/additionalTablesToExport.php b/workflow/engine/methods/additionalTables/additionalTablesToExport.php new file mode 100644 index 000000000..f80d78a34 --- /dev/null +++ b/workflow/engine/methods/additionalTables/additionalTablesToExport.php @@ -0,0 +1,46 @@ +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +global $RBAC; +$RBAC->requirePermissions('PM_SETUP_ADVANCE'); +$G_PUBLISH = new Publisher; + +$oHeadPublisher =& headPublisher::getSingleton(); + +//$oHeadPublisher->usingExtJs('ux/Ext.ux.fileUploadField'); +$oHeadPublisher->addExtJsScript('additionalTables/additionalTablesExport', false); //adding a javascript file .js +$oHeadPublisher->addContent('additionalTables/additionalTablesExport'); //adding a html file .html. + +$labels = G::getTranslations(Array('ID_EXPORT','ID_IMPORT','ID_EDIT','ID_DELETE', 'ID_DATA', + 'ID_NEW_ADD_TABLE','ID_DESCRIPTION','ID_NAME','ID_CONFIRM','ID_ADDITIONAL_TABLES','ID_SELECT_FIRST_PM_TABLE_ROW', + 'ID_CONFIRM_DELETE_PM_TABLE', 'ID_CANCEL','ID_CLOSE','ID_ACTION_EXPORT','ID_ACTION_IGNORE','ID_TITLE_EXPORT_RESULT','ID_TITLE_EXPORT_TOOL')); + +$toSend = Array(); +$toSend['UID_LIST'] = $_GET["sUID"]; + +$oHeadPublisher->assign('TRANSLATIONS', $labels); +$oHeadPublisher->assign('EXPORT_TABLES', $toSend); +G::RenderPage('publish', 'extJs'); +?> \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/data_additionalTablesExport.php b/workflow/engine/methods/additionalTables/data_additionalTablesExport.php new file mode 100644 index 000000000..0027b8a2b --- /dev/null +++ b/workflow/engine/methods/additionalTables/data_additionalTablesExport.php @@ -0,0 +1,54 @@ +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +require_once 'classes/model/AdditionalTables.php'; + +$oCriteria = new Criteria('workflow'); +$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_UID); +$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_NAME); +$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_DESCRIPTION); +$oCriteria->addSelectColumn("'".G::LoadTranslation('ID_ACTION_EXPORT')."' as 'CH_SCHEMA'"); +$oCriteria->addSelectColumn("'".G::LoadTranslation('ID_ACTION_EXPORT')."' as 'CH_DATA'"); + +$uids = explode(',',$_GET['aUID']); + +foreach ($uids as $UID){ + if (!isset($CC)){ + $CC = $oCriteria->getNewCriterion(AdditionalTablesPeer::ADD_TAB_UID, $UID ,Criteria::EQUAL); + }else{ + $CC->addOr($oCriteria->getNewCriterion(AdditionalTablesPeer::ADD_TAB_UID, $UID ,Criteria::EQUAL)); + } +} +$oCriteria->add($CC); +$oCriteria->addAnd($oCriteria->getNewCriterion(AdditionalTablesPeer::ADD_TAB_UID, '', Criteria::NOT_EQUAL)); + +$oDataset = AdditionalTablesPeer::doSelectRS ( $oCriteria ); +$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC ); + +$addTables = Array(); +while( $oDataset->next() ) { + $addTables[] = $oDataset->getRow(); +} +echo G::json_encode($addTables); \ No newline at end of file diff --git a/workflow/engine/templates/additionalTables/additionalTablesData.js b/workflow/engine/templates/additionalTables/additionalTablesData.js index fbca327d8..768595126 100644 --- a/workflow/engine/templates/additionalTables/additionalTablesData.js +++ b/workflow/engine/templates/additionalTables/additionalTablesData.js @@ -32,6 +32,7 @@ var expander; var cmodel; var infoGrid; var viewport; +var smodel; var FIELD_CM; var FIELD_DS @@ -51,14 +52,16 @@ Ext.onReady(function(){ text: TRANSLATIONS.ID_EDIT, iconCls: 'button_menu_ext ss_sprite ss_pencil', //icon: '/images/addc.png', - handler: EditPMTableRow + handler: EditPMTableRow, + disabled: true }); deleteButton = new Ext.Action({ text: TRANSLATIONS.ID_DELETE, iconCls: 'button_menu_ext ss_sprite ss_delete', //icon: '/images/addc.png', - handler: DeletePMTableRow + handler: DeletePMTableRow, + disabled: true }); importButton = new Ext.Action({ @@ -89,6 +92,30 @@ Ext.onReady(function(){ xColumns.unshift(idField); + smodel = new Ext.grid.CheckboxSelectionModel({ + listeners:{ + selectionchange: function(sm){ + var count_rows = sm.getCount(); + switch(count_rows){ + case 0: + editButton.disable(); + deleteButton.disable(); + break; + case 1: + editButton.enable(); + deleteButton.enable(); + break; + default: + editButton.disable(); + deleteButton.disable(); + break; + } + } + } + }); + + xColumns.unshift(smodel); + store = new Ext.data.GroupingStore( { proxy : new Ext.data.HttpProxy({ url: 'data_additionalTablesData?sUID=' + TABLES.UID @@ -98,15 +125,14 @@ Ext.onReady(function(){ fields : xFields }) }); - - cmodel = new Ext.grid.ColumnModel({ - defaults: { - width: 50, - sortable: true - }, - columns: xColumns - }); + cmodel = new Ext.grid.ColumnModel({ + defaults: { + width: 50, + sortable: true + }, + columns: xColumns + }); infoGrid = new Ext.grid.GridPanel({ @@ -123,23 +149,19 @@ Ext.onReady(function(){ enableColumnResize: true, enableHdMenu: true, frame:false, - plugins: expander, - cls : 'grid_with_checkbox', + //plugins: expander, + //cls : 'grid_with_checkbox', + iconCls:'icon-grid', columnLines: false, viewConfig: { forceFit:true }, store: store, cm: cmodel, + sm: smodel, tbar:[newButton,'-',editButton, deleteButton,'-',importButton,{xtype: 'tbfill' }, backButton], listeners: { - rowdblclick: EditPMTableRow, - rowclick: DoNothing, - render: function(){ - infoGrid.getSelectionModel().on('rowselect', function(){ - var rowSelected = infoGrid.getSelectionModel().getSelected(); - }); - } + rowdblclick: EditPMTableRow }, view: new Ext.grid.GroupingView({ forceFit:true, @@ -178,47 +200,21 @@ NewPMTableRow = function(){ //Load PM Table Edition Row Form EditPMTableRow = function(){ - iGrid = Ext.getCmp('infoGrid'); - var rowSelected = iGrid.getSelectionModel().getSelected(); - if( rowSelected ) { - location.href = 'additionalTablesDataEdit?sUID='+TABLES.UID+'&'+TABLES.PKF+'='+rowSelected.data[TABLES.PKF]; - } else { - Ext.Msg.show({ - title:'', - msg: TRANSLATIONS.ID_SELECT_FIRST_ROW, - buttons: Ext.Msg.INFO, - fn: DoNothing, - animEl: 'elId', - icon: Ext.MessageBox.INFO, - buttons: Ext.MessageBox.OK - }); - } + iGrid = Ext.getCmp('infoGrid'); + rowsSelected = iGrid.getSelectionModel().getSelections(); + location.href = 'additionalTablesDataEdit?sUID='+TABLES.UID+'&'+TABLES.PKF+'='+RetrieveRowsID(rowsSelected); } //Confirm PM Table Row Deletion Tasks DeletePMTableRow = function(){ iGrid = Ext.getCmp('infoGrid'); - var rowSelected = iGrid.getSelectionModel().getSelected(); - if( rowSelected ) { - confirmMsg = TRANSLATIONS.ID_MSG_CONFIRM_DELETE_ROW; - //confirmMsg = confirmMsg.replace('{0}',rowSelected.data.ADD_TAB_NAME); - Ext.Msg.confirm(TRANSLATIONS.ID_CONFIRM, confirmMsg, - function(btn, text){ - if (btn=="yes"){ - location.href = 'additionalTablesDataDelete?sUID='+TABLES.UID+'&'+TABLES.PKF+'='+rowSelected.data[TABLES.PKF]; - } - }); - } else { - Ext.Msg.show({ - title:'', - msg: TRANSLATIONS.ID_SELECT_FIRST_ROW, - buttons: Ext.Msg.INFO, - fn: DoNothing, - animEl: 'elId', - icon: Ext.MessageBox.INFO, - buttons: Ext.MessageBox.OK - }); - } + rowsSelected = iGrid.getSelectionModel().getSelections(); + Ext.Msg.confirm(TRANSLATIONS.ID_CONFIRM, TRANSLATIONS.ID_MSG_CONFIRM_DELETE_ROW, + function(btn, text){ + if (btn=="yes"){ + location.href = 'additionalTablesDataDelete?sUID='+TABLES.UID+'&'+TABLES.PKF+'='+RetrieveRowsID(rowsSelected); + } + }); } //Load Import PM Table From CSV Source @@ -229,4 +225,13 @@ ImportPMTableCSV = function(){ //Load PM Table List BackPMList = function(){ location.href = 'additionalTablesList'; +} + +//Gets UIDs from a array of rows +RetrieveRowsID = function(rows){ + var arrAux = new Array(); + for(var c=0; c +
+ diff --git a/workflow/engine/templates/additionalTables/additionalTablesExport.js b/workflow/engine/templates/additionalTables/additionalTablesExport.js new file mode 100644 index 000000000..51e760ff8 --- /dev/null +++ b/workflow/engine/templates/additionalTables/additionalTablesExport.js @@ -0,0 +1,195 @@ + +/* + * @author: Qennix + * Jan 13th, 2011 + */ + +//Keyboard Events +new Ext.KeyMap(document, { + key: Ext.EventObject.F5, + fn: function(keycode, e) { + if (! e.ctrlKey) { + if (Ext.isIE) { + // IE6 doesn't allow cancellation of the F5 key, so trick it into + // thinking some other key was pressed (backspace in this case) + e.browserEvent.keyCode = 8; + } + e.stopEvent(); + document.location = document.location; + }else{ + Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5'); + } + } +}); + +var store; +var cmodel; +var smodel; +var infoGrid; +var viewport + +var cancelButton; +var exportButton; + +var w; + +Ext.onReady(function(){ + Ext.QuickTips.init(); + + var reader = new Ext.data.ArrayReader({}, [{name: 'action'}]); + + var comboStore = new Ext.data.Store({ + reader: reader, + data: Ext.grid.dummyData + }); + + exportButton = new Ext.Action({ + text: TRANSLATIONS.ID_EXPORT, + iconCls: 'silk-add', + icon: '/images/export.png', + handler: ExportPMTables + }); + + cancelButton = new Ext.Action({ + text: TRANSLATIONS.ID_CANCEL, + iconCls: 'silk-add', + icon: '/images/cases-selfservice.png', + handler: CancelExport + }); + + store = new Ext.data.GroupingStore( { + proxy : new Ext.data.HttpProxy({ + url: 'data_additionalTablesExport?aUID='+EXPORT_TABLES.UID_LIST + }), + reader : new Ext.data.JsonReader( { + root: '', + fields : [ + {name : 'ADD_TAB_UID'}, + {name : 'ADD_TAB_NAME'}, + {name : 'ADD_TAB_DESCRIPTION'}, + {name : 'CH_SCHEMA'}, + {name : 'CH_DATA'} + ] + }) + }); + + var action_edit = new Ext.form.ComboBox({ + typeAhead: true, + triggerAction: 'all', + mode: 'local', + store: comboStore, + displayField: 'action', + valueField: 'action' + }); + + cmodel = new Ext.grid.ColumnModel({ + defaults: { + width: 10, + sortable: true + }, + columns: [ + new Ext.grid.RowNumberer(), + //smodel, + {id:'ADD_TAB_UID', dataIndex: 'ADD_TAB_UID', hidden:true, hideable:false}, + {header: TRANSLATIONS.ID_NAME, dataIndex: 'ADD_TAB_NAME', width: 20, align:'left'}, + {header: TRANSLATIONS.ID_DESCRIPTION, dataIndex: 'ADD_TAB_DESCRIPTION', width: 50, hidden:false, align:'left'},//, + {header: 'SCHEMA', dataIndex: 'CH_SCHEMA', hidden: false, width: 20, editor: action_edit, align: 'center'}, + {header: 'DATA', dataIndex: 'CH_DATA', hidden: false, width: 20, editor: action_edit, align: 'center'} + ] + }); + + infoGrid = new Ext.grid.EditorGridPanel({ + store: store, + cm: cmodel, + width: 600, + height: 300, + title: TRANSLATIONS.ID_ADDITIONAL_TABLES + ': ' +TRANSLATIONS.ID_TITLE_EXPORT_TOOL, + frame: true, + clicksToEdit: 1, + iconCls:'icon-grid', + id: 'infoGrid', + + sm: new Ext.grid.RowSelectionModel({singleSelect: false}), + tbar:[exportButton, {xtype: 'tbfill'} ,cancelButton],//'-', editButton, deleteButton,'-', dataButton,{xtype: 'tbfill'} , importButton, exportButton], + view: new Ext.grid.GroupingView({ + forceFit:true, + groupTextTpl: '{text}' + }) + }); + + infoGrid.store.load({params: {"function":"additionalTablesExport"}}); + + viewport = new Ext.Viewport({ + layout: 'fit', + autoScroll: false, + items: [ + infoGrid + ] + }); + +}); + +//Cancels Export View +CancelExport = function(){ + location.href = 'additionalTablesList'; +} + +//Export Schema/Data from PM Tables +ExportPMTables = function(){ + iGrid = Ext.getCmp('infoGrid'); + var storeExport = iGrid.getStore(); + var UIDs = new Array(); + var SCHs = new Array(); + var DATs = new Array(); + for (var r=0; rUID: {ADD_TAB_UID}


' - ) + smodel = new Ext.grid.CheckboxSelectionModel({ + listeners:{ + selectionchange: function(sm){ + var count_rows = sm.getCount(); + 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; + } + } + } }); cmodel = new Ext.grid.ColumnModel({ @@ -106,7 +135,7 @@ Ext.onReady(function(){ sortable: true }, columns: [ - expander, + smodel, {id:'ADD_TAB_UID', dataIndex: 'ADD_TAB_UID', hidden:true, hideable:false}, {header: TRANSLATIONS.ID_NAME, dataIndex: 'ADD_TAB_NAME', width: 20, align:'left'}, {header: TRANSLATIONS.ID_DESCRIPTION, dataIndex: 'ADD_TAB_DESCRIPTION', width: 50, hidden:false, align:'left'} @@ -127,23 +156,19 @@ Ext.onReady(function(){ enableColumnResize: true, enableHdMenu: true, frame:false, - plugins: expander, - cls : 'grid_with_checkbox', + //plugins: expander, + iconCls:'icon-grid', + //cls : 'grid_with_checkbox', columnLines: false, viewConfig: { forceFit:true }, store: store, cm: cmodel, + sm: smodel, tbar:[newButton,'-', editButton, deleteButton,'-', dataButton,{xtype: 'tbfill'} , importButton, exportButton], listeners: { rowdblclick: PMTableData, - rowclick: DoNothing, - render: function(){ - infoGrid.getSelectionModel().on('rowselect', function(){ - var rowSelected = infoGrid.getSelectionModel().getSelected(); - }); - } }, view: new Ext.grid.GroupingView({ forceFit:true, @@ -180,47 +205,21 @@ NewPMTable = function(){ //Load PM Table Edition Forms EditPMTable = function(){ - iGrid = Ext.getCmp('infoGrid'); - var rowSelected = iGrid.getSelectionModel().getSelected(); - if( rowSelected ) { - location.href = 'additionalTablesEdit?sUID='+rowSelected.data.ADD_TAB_UID+'&rand='+Math.random(); - } else { - Ext.Msg.show({ - title:'', - msg: TRANSLATIONS.ID_SELECT_FIRST_PM_TABLE_ROW, - buttons: Ext.Msg.INFO, - fn: DoNothing, - animEl: 'elId', - icon: Ext.MessageBox.INFO, - buttons: Ext.MessageBox.OK - }); - } + iGrid = Ext.getCmp('infoGrid'); + rowsSelected = iGrid.getSelectionModel().getSelections(); + location.href = 'additionalTablesEdit?sUID='+RetrieveRowsID(rowsSelected)+'&rand='+Math.random(); } //Confirm PM Table Deletion Tasks DeletePMTable = function(){ iGrid = Ext.getCmp('infoGrid'); - var rowSelected = iGrid.getSelectionModel().getSelected(); - if( rowSelected ) { - confirmMsg = TRANSLATIONS.ID_CONFIRM_DELETE_PM_TABLE; - confirmMsg = confirmMsg.replace('{0}',rowSelected.data.ADD_TAB_NAME); - Ext.Msg.confirm(TRANSLATIONS.ID_CONFIRM, confirmMsg, + rowsSelected = iGrid.getSelectionModel().getSelections(); + Ext.Msg.confirm(TRANSLATIONS.ID_CONFIRM, TRANSLATIONS.ID_CONFIRM_DELETE_PM_TABLE, function(btn, text){ if (btn=="yes"){ - location.href = 'additionalTablesDelete?sUID='+rowSelected.data.ADD_TAB_UID+'&rand='+Math.random(); + location.href = 'additionalTablesDelete?sUID='+RetrieveRowsID(rowsSelected)+'&rand='+Math.random(); } - }); - } else { - Ext.Msg.show({ - title:'', - msg: TRANSLATIONS.ID_SELECT_FIRST_PM_TABLE_ROW, - buttons: Ext.Msg.INFO, - fn: DoNothing, - animEl: 'elId', - icon: Ext.MessageBox.INFO, - buttons: Ext.MessageBox.OK - }); - } + }); } //Load Import PM Table Form @@ -230,24 +229,23 @@ ImportPMTable = function(){ //Load Export PM Tables Form ExportPMTable = function(){ - location.href = 'additionalTablesToExport'; + iGrid = Ext.getCmp('infoGrid'); + rowsSelected = iGrid.getSelectionModel().getSelections(); + location.href = 'additionalTablesToExport?sUID='+RetrieveRowsID(rowsSelected)+'&rand='+Math.random(); } //Load PM TAble Data PMTableData = function(){ iGrid = Ext.getCmp('infoGrid'); - var rowSelected = iGrid.getSelectionModel().getSelected(); - if( rowSelected ) { - location.href = 'additionalTablesData?sUID='+rowSelected.data.ADD_TAB_UID+'&rand='+Math.random(); - } else { - Ext.Msg.show({ - title:'', - msg: TRANSLATIONS.ID_SELECT_FIRST_PM_TABLE_ROW, - buttons: Ext.Msg.INFO, - fn: DoNothing, - animEl: 'elId', - icon: Ext.MessageBox.INFO, - buttons: Ext.MessageBox.OK - }); - } + rowsSelected = iGrid.getSelectionModel().getSelections(); + location.href = 'additionalTablesData?sUID='+RetrieveRowsID(rowsSelected)+'&rand='+Math.random(); +} + +//Gets UIDs from a array of rows +RetrieveRowsID = function(rows){ + var arrAux = new Array(); + for(var c=0; c - - - - <en>Processmaker Tables export</en> - - + @@ -13,7 +8,7 @@ File size - + Sumary \ No newline at end of file