diff --git a/workflow/engine/classes/model/AdditionalTables.php b/workflow/engine/classes/model/AdditionalTables.php index c89223865..a3d291596 100755 --- a/workflow/engine/classes/model/AdditionalTables.php +++ b/workflow/engine/classes/model/AdditionalTables.php @@ -343,7 +343,7 @@ class AdditionalTables extends BaseAdditionalTables } } - public function getAllData($sUID, $start = null, $limit = null, $keyOrderUppercase = true) + public function getAllData($sUID, $start = null, $limit = null, $keyOrderUppercase = true, $filter = '') { $addTab = new AdditionalTables(); $aData = $addTab->load($sUID, true); @@ -370,15 +370,43 @@ class AdditionalTables extends BaseAdditionalTables if ($keyOrderUppercase == true) { foreach ($aData['FIELDS'] as $aField) { eval('$oCriteria->addSelectColumn(' . $sClassPeerName . '::' . $aField['FLD_NAME'] . ');'); - if ($aField['FLD_KEY'] == '1') { + /*if ($aField['FLD_KEY'] == '1') { eval('$oCriteria->addAscendingOrderByColumn('. $sClassPeerName . '::' . $aField['FLD_NAME'] . ');'); - } + }*/ } } $oCriteriaCount = clone $oCriteria; //$count = $sClassPeerName::doCount($oCriteria); eval('$count = ' . $sClassPeerName . '::doCount($oCriteria);'); + if ($filter != '' && is_string($filter)) { + eval('$fieldsTable = ' . $sClassPeerName . '::getFieldNames(BasePeer::TYPE_FIELDNAME);'); + $countField = count($fieldsTable); + $stringOr = '$oCriteria->add('; + $cont = 1; + foreach ($fieldsTable as $value) { + if ($cont == $countField) { + $stringOr .= '$oCriteria->getNewCriterion(' . $sClassPeerName . '::' . strtoupper($value) . ', "%' . $filter . '%", Criteria::LIKE)'; + } else { + $stringOr .= '$oCriteria->getNewCriterion(' . $sClassPeerName . '::' . strtoupper($value) . ', "%' . $filter . '%", Criteria::LIKE)->addOr('; + } + $cont++; + } + for ($c = 1; $c < $countField; $c ++) { + $stringOr .= ')'; + } + $stringOr .= ');'; + eval($stringOr); + } + + if (isset($_POST['sort'])) { + if ($_POST['dir'] == 'ASC') { + eval('$oCriteria->addAscendingOrderByColumn(' . $sClassPeerName . '::' . $_POST['sort'] . ');'); + } else { + eval('$oCriteria->addDescendingOrderByColumn(' . $sClassPeerName . '::' . $_POST['sort'] . ');'); + } + } + if (isset($limit)) { $oCriteria->setLimit($limit); } diff --git a/workflow/engine/controllers/pmTablesProxy.php b/workflow/engine/controllers/pmTablesProxy.php index 147c7af76..fccfdf689 100755 --- a/workflow/engine/controllers/pmTablesProxy.php +++ b/workflow/engine/controllers/pmTablesProxy.php @@ -416,10 +416,16 @@ class pmTablesProxy extends HttpProxyController $limit_size = isset( $config['pageSize'] ) ? $config['pageSize'] : 20; $start = isset( $httpData->start ) ? $httpData->start : 0; $limit = isset( $httpData->limit ) ? $httpData->limit : $limit_size; + $filter = isset( $httpData->textFilter ) ? $httpData->textFilter : ''; $additionalTables = new AdditionalTables(); $table = $additionalTables->load( $httpData->id, true ); - $result = $additionalTables->getAllData( $httpData->id, $start, $limit ); + + if ($filter != '') { + $result = $additionalTables::getAllData( $httpData->id, $start, $limit, true, $filter); + } else { + $result = $additionalTables->getAllData( $httpData->id, $start, $limit ); + } $primaryKeys = $additionalTables->getPrimaryKeys(); diff --git a/workflow/engine/templates/pmTables/data.js b/workflow/engine/templates/pmTables/data.js index 5e7bd4763..82a0b529b 100755 --- a/workflow/engine/templates/pmTables/data.js +++ b/workflow/engine/templates/pmTables/data.js @@ -71,9 +71,39 @@ Ext.onReady(function(){ handler : BackPMList }); + searchButton = new Ext.Action({ + text: _('ID_SEARCH'), + handler: DoSearch + }); + contextMenu = new Ext.menu.Menu({ items : [ editButton, deleteButton ] }); + + searchText = new Ext.form.TextField ({ + id: 'searchTxt', + ctCls:'pm_search_text_field', + allowBlank: true, + width: 150, + emptyText: _('ID_ENTER_SEARCH_TERM'), + 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({ + text: 'X', + ctCls:'pm_search_x_button', + handler: GridByDefault + }); //This loop loads columns and fields to store and column model _columns = new Array(); @@ -295,6 +325,7 @@ Ext.onReady(function(){ }) store = new Ext.data.Store({ + remoteSort: true, proxy : proxy, reader : reader, writer : writer, // <-- plug a DataWriter into the store just as you would a Reader @@ -352,11 +383,19 @@ Ext.onReady(function(){ deleteButton, '-', importButton, - exportButton + exportButton, + '->', + searchText, + clearTextButton, + searchButton ]; } else - tbar = [genDataReportButton]; + tbar = [genDataReportButton, + '->', + searchText, + clearTextButton, + searchButton]; infoGridConfig = { region: 'center', @@ -423,6 +462,18 @@ onMessageContextMenu = function (grid, rowIndex, e) { /////JS FUNCTIONS +//Do Search Function + +DoSearch = function(){ + infoGrid.store.load({params: {textFilter: searchText.getValue()}}); +}; + +//Load Grid By Default +GridByDefault = function(){ + searchText.reset(); + infoGrid.store.load(); +}; + //Capitalize String Function capitalize = function(s){ s = s.toLowerCase();