Fix getting the wrong step in the participated list.

This commit is contained in:
Alexandre Rosenfeld
2011-03-01 14:11:51 +00:00
parent 136678aab2
commit 64d1965902
2 changed files with 30 additions and 2 deletions

View File

@@ -203,8 +203,8 @@ class AppCacheView extends BaseAppCacheView {
*/
function getSentListCriteria ($userUid) {
$Criteria = $this->addPMFieldsToCriteria('sent');
$Criteria->addAsColumn( 'DEL_INDEX', 'MAX(' . AppDelegationPeer::DEL_INDEX . ')' );
$Criteria->addJoin ( AppCacheViewPeer::APP_UID , AppDelegationPeer::APP_UID, Criteria::LEFT_JOIN);
//$Criteria->addAsColumn( 'MAX_DEL_INDEX', 'MAX(' . AppDelegationPeer::DEL_INDEX . ')' );
//$Criteria->addJoin ( AppCacheViewPeer::APP_UID , AppDelegationPeer::APP_UID, Criteria::LEFT_JOIN);
$Criteria->add (AppCacheViewPeer::USR_UID, $userUid);

View File

@@ -288,6 +288,7 @@
$Criteria->setOffset( $start );
/*
// this is the optimal way or query to render the cases search list
// fixing the bug related to the wrong data displayed in the list
if ( $action == 'search' ) {
@@ -305,6 +306,7 @@
$params = array ( $maxDelIndexList );
}
*/
//execute the query
$oDataset = AppCacheViewPeer::doSelectRS($Criteria);
@@ -326,6 +328,32 @@
if( isset($aRow['DEL_PRIORITY']) ){
$aRow['DEL_PRIORITY'] = G::LoadTranslation("ID_PRIORITY_{$aPriorities[$aRow['DEL_PRIORITY']]}");
}
/* For participated cases, we want the last step in the case, not only
* the last step this user participated. To do that we get every case
* information again for the last step. (This could be solved by a subquery,
* but Propel might not support it and subqueries can be slower for larger
* datasets).
*/
if ($action == 'sent') {
$maxCriteria = new Criteria('workflow');
$maxCriteria->add(AppCacheViewPeer::APP_UID, $aRow['APP_UID'], Criteria::EQUAL);
$maxCriteria->addDescendingOrderByColumn(AppCacheViewPeer::DEL_INDEX);
$maxCriteria->setLimit(1);
$maxDataset = AppCacheViewPeer::doSelectRS( $maxCriteria );
$maxDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$maxDataset->next();
$newData = $maxDataset->getRow();
foreach ($aRow as $col => $value) {
if (array_key_exists($col, $newData))
$aRow[$col] = $newData[$col];
}
$maxDataset->close();
}
$rows[] = $aRow;
$oDataset->next();
}