diff --git a/workflow/engine/classes/model/ListInbox.php b/workflow/engine/classes/model/ListInbox.php index c97fa5fc6..47362ea9f 100644 --- a/workflow/engine/classes/model/ListInbox.php +++ b/workflow/engine/classes/model/ListInbox.php @@ -1,6 +1,7 @@ additionalClassName; + } + + /** + * Set the value of $additionalClassName. + * + * @param string $v new value + * @return void + */ + public function setAdditionalClassName($v) + { + $this->additionalClassName = $v; + } + + /** + * Get the $userDisplayFormat value. + * + * @return string + */ + public function getUserDisplayFormat() + { + return $this->userDisplayFormat; + } + + /** + * Set the value of $userDisplayFormat. + * + * @param string $v new value + * @return void + */ + public function setUserDisplayFormat($v) + { + $this->userDisplayFormat = $v; + } /** * Create List Inbox Table * * @param type $data * @return type - * + * @throws Exception */ public function create($data, $isSelfService = false) { @@ -115,7 +159,7 @@ class ListInbox extends BaseListInbox * * @param type $data * @return type - * @throws type + * @throws Exception */ public function update($data, $isSelfService = false) { @@ -209,7 +253,7 @@ class ListInbox extends BaseListInbox * * @param type $seqName * @return type - * @throws type + * @throws Exception * */ public function remove($app_uid, $del_index) @@ -233,7 +277,7 @@ class ListInbox extends BaseListInbox * * @param type $seqName * @return type - * @throws type + * @throws Exception * */ public function removeAll($app_uid) @@ -478,8 +522,14 @@ class ListInbox extends BaseListInbox $criteria->add(ListInboxPeer::APP_UID, $search, Criteria::EQUAL); } else { //If we have additional tables configured in the custom cases list, prepare the variables for search - $casesList = new \ProcessMaker\BusinessModel\Cases(); - $casesList->getSearchCriteriaListCases($criteria, __CLASS__ . 'Peer', $search, $this->additionalClassName, $additionalColumns); + $casesList = new BmCases(); + $casesList->getSearchCriteriaListCases( + $criteria, + __CLASS__ . 'Peer', + $search, + $this->getAdditionalClassName(), + $additionalColumns + ); } } @@ -515,7 +565,7 @@ class ListInbox extends BaseListInbox * This function get the information in the corresponding cases list * @param string $usr_uid, must be show cases related to this user * @param array $filters for apply in the result - * @param null $callbackRecord + * @param callable $callbackRecord * @return array $data * @throws PropelException */ @@ -524,7 +574,7 @@ class ListInbox extends BaseListInbox $pmTable = new PmTable(); $list = isset($filters['action']) ? $filters['action'] : ""; $criteria = $pmTable->addPMFieldsToList($list); - $this->additionalClassName = $pmTable->tableClassName; + $this->setAdditionalClassName($pmTable->tableClassName); $additionalColumns = $criteria->getSelectColumns(); $filters['usr_uid'] = $usr_uid; @@ -556,14 +606,16 @@ class ListInbox extends BaseListInbox self::loadFilters($criteria, $filters, $additionalColumns); //We will be defined the sort - $casesList = new \ProcessMaker\BusinessModel\Cases(); + $casesList = new BmCases(); + $sort = $casesList->getSortColumn( __CLASS__ . 'Peer', BasePeer::TYPE_FIELDNAME, empty($filters['sort']) ? "APP_UPDATE_DATE" : $filters['sort'], "APP_UPDATE_DATE", - $this->additionalClassName, - $additionalColumns + $this->getAdditionalClassName(), + $additionalColumns, + $this->getUserDisplayFormat() ); $dir = isset($filters['dir']) ? $filters['dir'] : "ASC"; @@ -571,10 +623,20 @@ class ListInbox extends BaseListInbox $limit = isset($filters['limit']) ? $filters['limit'] : "25"; $paged = isset($filters['paged']) ? $filters['paged'] : 1; - if ($dir == "DESC") { - $criteria->addDescendingOrderByColumn($sort); + if (is_array($sort) && count($sort) > 0) { + foreach ($sort as $key) { + if ($dir == 'DESC') { + $criteria->addDescendingOrderByColumn($key); + } else { + $criteria->addAscendingOrderByColumn($key); + } + } } else { - $criteria->addAscendingOrderByColumn($sort); + if ($dir == 'DESC') { + $criteria->addDescendingOrderByColumn($sort); + } else { + $criteria->addAscendingOrderByColumn($sort); + } } if ($paged == 1) { diff --git a/workflow/engine/classes/model/ListParticipatedLast.php b/workflow/engine/classes/model/ListParticipatedLast.php index 56962c98e..81d3ed331 100644 --- a/workflow/engine/classes/model/ListParticipatedLast.php +++ b/workflow/engine/classes/model/ListParticipatedLast.php @@ -1,7 +1,7 @@ additionalClassName; + } + + /** + * Set the value of $additionalClassName. + * + * @param string $v new value + * @return void + */ + public function setAdditionalClassName($v) + { + $this->additionalClassName = $v; + } + + /** + * Get the $userDisplayFormat value. + * + * @return string + */ + public function getUserDisplayFormat() + { + return $this->userDisplayFormat; + } + + /** + * Set the value of $userDisplayFormat. + * + * @param string $v new value + * @return void + */ + public function setUserDisplayFormat($v) + { + $this->userDisplayFormat = $v; + } /** * Create List Participated History Table. @@ -22,6 +65,7 @@ class ListParticipatedLast extends BaseListParticipatedLast * @param type $data * * @return type + * @throws Exception */ public function create($data) { @@ -142,7 +186,7 @@ class ListParticipatedLast extends BaseListParticipatedLast * * @return type * - * @throws type + * @throws Exception */ public function update($data) { @@ -180,11 +224,12 @@ class ListParticipatedLast extends BaseListParticipatedLast /** * Refresh List Participated Last. * - * @param type $seqName + * @param array $data + * @param boolean $isSelfService * * @return type * - * @throws type + * @throws Exception */ public function refresh($data, $isSelfService = false) { @@ -235,11 +280,13 @@ class ListParticipatedLast extends BaseListParticipatedLast /** * Remove List Participated History. * - * @param type $seqName + * @param string $app_uid + * @param string $usr_uid + * @param integer $del_index * * @return type * - * @throws type + * @throws Exception */ public function remove($app_uid, $usr_uid, $del_index) { @@ -319,8 +366,14 @@ class ListParticipatedLast extends BaseListParticipatedLast $criteria->add(ListParticipatedLastPeer::APP_UID, $search, Criteria::EQUAL); } else { //If we have additional tables configured in the custom cases list, prepare the variables for search - $casesList = new \ProcessMaker\BusinessModel\Cases(); - $casesList->getSearchCriteriaListCases($criteria, __CLASS__ . 'Peer', $search, $this->additionalClassName, $additionalColumns); + $casesList = new BmCases(); + $casesList->getSearchCriteriaListCases( + $criteria, + __CLASS__ . 'Peer', + $search, + $this->getAdditionalClassName(), + $additionalColumns + ); } } @@ -352,7 +405,7 @@ class ListParticipatedLast extends BaseListParticipatedLast * This function get the information in the corresponding cases list * @param string $usr_uid, must be show cases related to this user * @param array $filters for apply in the result - * @param null $callbackRecord + * @param callable $callbackRecord * @param string $appUid related to the specific case * @return array $data * @throws PropelException @@ -361,7 +414,7 @@ class ListParticipatedLast extends BaseListParticipatedLast { $pmTable = new PmTable(); $criteria = $pmTable->addPMFieldsToList('sent'); - $this->additionalClassName = $pmTable->tableClassName; + $this->setAdditionalClassName($pmTable->tableClassName); $additionalColumns = $criteria->getSelectColumns(); $criteria->addSelectColumn(ListParticipatedLastPeer::APP_UID); @@ -397,14 +450,15 @@ class ListParticipatedLast extends BaseListParticipatedLast self::loadFilters($criteria, $filters, $additionalColumns); //We will be defined the sort - $casesList = new \ProcessMaker\BusinessModel\Cases(); + $casesList = new BmCases(); $sort = $casesList->getSortColumn( __CLASS__ . 'Peer', BasePeer::TYPE_FIELDNAME, empty($filters['sort']) ? "DEL_DELEGATE_DATE" : $filters['sort'], "DEL_DELEGATE_DATE", - $this->additionalClassName, - $additionalColumns + $this->getAdditionalClassName(), + $additionalColumns, + $this->getUserDisplayFormat() ); $dir = isset($filters['dir']) ? $filters['dir'] : 'ASC'; @@ -412,10 +466,20 @@ class ListParticipatedLast extends BaseListParticipatedLast $limit = isset($filters['limit']) ? $filters['limit'] : '25'; $paged = isset($filters['paged']) ? $filters['paged'] : 1; - if ($dir == 'DESC') { - $criteria->addDescendingOrderByColumn($sort); + if (is_array($sort) && count($sort) > 0) { + foreach ($sort as $key) { + if ($dir == 'DESC') { + $criteria->addDescendingOrderByColumn($key); + } else { + $criteria->addAscendingOrderByColumn($key); + } + } } else { - $criteria->addAscendingOrderByColumn($sort); + if ($dir == 'DESC') { + $criteria->addDescendingOrderByColumn($sort); + } else { + $criteria->addAscendingOrderByColumn($sort); + } } if ($paged == 1) { diff --git a/workflow/engine/classes/model/ListPaused.php b/workflow/engine/classes/model/ListPaused.php index 1b885020d..edaf5336c 100644 --- a/workflow/engine/classes/model/ListPaused.php +++ b/workflow/engine/classes/model/ListPaused.php @@ -1,7 +1,7 @@ additionalClassName; + } + + /** + * Set the value of $additionalClassName. + * + * @param string $v new value + * @return void + */ + public function setAdditionalClassName($v) + { + $this->additionalClassName = $v; + } + + /** + * Get the $userDisplayFormat value. + * + * @return string + */ + public function getUserDisplayFormat() + { + return $this->userDisplayFormat; + } + + /** + * Set the value of $userDisplayFormat. + * + * @param string $v new value + * @return void + */ + public function setUserDisplayFormat($v) + { + $this->userDisplayFormat = $v; + } /** * Create List Paused Table * * @param type $data * @return type - * + * @throws Exception */ public function create($data) { @@ -153,7 +196,7 @@ class ListPaused extends BaseListPaused * * @param type $data * @return type - * @throws type + * @throws Exception */ public function update($data) { @@ -187,9 +230,12 @@ class ListPaused extends BaseListPaused /** * Remove List Paused * - * @param type $seqName + * @param string $app_uid + * @param integer $del_index + * @param array $data_inbox + * * @return type - * @throws type + * @throws Exception * */ public function remove($app_uid, $del_index, $data_inbox) @@ -246,8 +292,14 @@ class ListPaused extends BaseListPaused $criteria->add(ListPausedPeer::APP_UID, $search, Criteria::EQUAL); } else { //If we have additional tables configured in the custom cases list, prepare the variables for search - $casesList = new \ProcessMaker\BusinessModel\Cases(); - $casesList->getSearchCriteriaListCases($criteria, __CLASS__ . 'Peer', $search, $this->additionalClassName, $additionalColumns); + $casesList = new BmCases(); + $casesList->getSearchCriteriaListCases( + $criteria, + __CLASS__ . 'Peer', + $search, + $this->getAdditionalClassName(), + $additionalColumns + ); } } @@ -270,7 +322,7 @@ class ListPaused extends BaseListPaused * This function get the information in the corresponding cases list * @param string $usr_uid, must be show cases related to this user * @param array $filters for apply in the result - * @param null $callbackRecord + * @param callable $callbackRecord * @return array $data * @throws PropelException */ @@ -279,7 +331,7 @@ class ListPaused extends BaseListPaused $resp = array(); $pmTable = new PmTable(); $criteria = $pmTable->addPMFieldsToList('paused'); - $this->additionalClassName = $pmTable->tableClassName; + $this->setAdditionalClassName($pmTable->tableClassName); $additionalColumns = $criteria->getSelectColumns(); $criteria->addSelectColumn(ListPausedPeer::APP_UID); @@ -308,14 +360,15 @@ class ListPaused extends BaseListPaused self::loadFilters($criteria, $filters, $additionalColumns); //We will be defined the sort - $casesList = new \ProcessMaker\BusinessModel\Cases(); + $casesList = new BmCases(); $sort = $casesList->getSortColumn( __CLASS__ . 'Peer', BasePeer::TYPE_FIELDNAME, empty($filters['sort']) ? "APP_PAUSED_DATE" : $filters['sort'], "APP_PAUSED_DATE", - $this->additionalClassName, - $additionalColumns + $this->getAdditionalClassName(), + $additionalColumns, + $this->getUserDisplayFormat() ); $dir = isset($filters['dir']) ? $filters['dir'] : "ASC"; @@ -323,10 +376,20 @@ class ListPaused extends BaseListPaused $limit = isset($filters['limit']) ? $filters['limit'] : "25"; $paged = isset($filters['paged']) ? $filters['paged'] : 1; - if ($dir == "DESC") { - $criteria->addDescendingOrderByColumn($sort); + if (is_array($sort) && count($sort) > 0) { + foreach ($sort as $key) { + if ($dir == 'DESC') { + $criteria->addDescendingOrderByColumn($key); + } else { + $criteria->addAscendingOrderByColumn($key); + } + } } else { - $criteria->addAscendingOrderByColumn($sort); + if ($dir == 'DESC') { + $criteria->addDescendingOrderByColumn($sort); + } else { + $criteria->addAscendingOrderByColumn($sort); + } } if ($paged == 1) { diff --git a/workflow/engine/methods/cases/proxyNewCasesList.php b/workflow/engine/methods/cases/proxyNewCasesList.php index ae559eceb..113c95d73 100644 --- a/workflow/engine/methods/cases/proxyNewCasesList.php +++ b/workflow/engine/methods/cases/proxyNewCasesList.php @@ -90,8 +90,11 @@ try { $filters['limit'] = (int)$filters['limit']; $filters['limit'] = abs($filters['limit']); + $conf = new Configurations(); + $formats = $conf->getFormats(); + $list->setUserDisplayFormat($formats['format']); + if ($filters['limit'] == 0) { - $conf = new Configurations(); $generalConfCasesList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', ''); if (isset($generalConfCasesList['casesListRowNumber'])) { $filters['limit'] = (int)$generalConfCasesList['casesListRowNumber']; @@ -101,10 +104,11 @@ try { } else { $filters['limit'] = (int)$filters['limit']; } - + switch ($filters['sort']) { case 'APP_CURRENT_USER': - $filters['sort'] = 'DEL_CURRENT_USR_LASTNAME'; + //This value is format according to the userDisplayFormat, for this reason we will sent the UID + $filters['sort'] = 'USR_UID'; break; case 'DEL_TASK_DUE_DATE': $filters['sort'] = 'DEL_DUE_DATE'; @@ -113,7 +117,8 @@ try { $filters['sort'] = 'DEL_DELEGATE_DATE'; break; case 'APP_DEL_PREVIOUS_USER': - $filters['sort'] = 'DEL_DUE_DATE'; + //This value is format according to the userDisplayFormat, for this reason we will sent the UID + $filters['sort'] = 'DEL_PREVIOUS_USR_UID'; break; case 'DEL_CURRENT_TAS_TITLE': $filters['sort'] = 'APP_TAS_TITLE'; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php index 0b712db70..3beb9067b 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php @@ -3539,13 +3539,15 @@ class Cases * This function get the table.column by order by the result * We can include the additional table related to the custom cases list * - * @param string $listPeer , name of the list class - * @param string $field , name of the fieldName - * @param string $sort , name of column by sort - * @param string $defaultSort , name of column by sort default - * @param string $additionalClassName , name of the className of pmTable - * @param array $additionalColumns , columns related to the custom cases list with the format TABLE_NAME.COLUMN_NAME - * @return string $tableName + * @param string $listPeer, name of the list class + * @param string $field, name of the fieldName + * @param string $sort, name of column by sort + * @param string $defaultSort, name of column by sort default + * @param string $additionalClassName, name of the className of pmTable + * @param array $additionalColumns, columns related to the custom cases list with the format TABLE_NAME.COLUMN_NAME + * @param string $userDisplayFormat, user information display format + * + * @return string|array could be an string $tableName, could be an array $columnSort */ public function getSortColumn( $listPeer, @@ -3553,7 +3555,8 @@ class Cases $sort, $defaultSort, $additionalClassName = '', - $additionalColumns = array() + $additionalColumns = array(), + $userDisplayFormat = '' ) { $columnSort = $defaultSort; $tableName = ''; @@ -3561,7 +3564,16 @@ class Cases //We will check if the column by sort is a LIST table $columnsList = $listPeer::getFieldNames($field); if (in_array($sort, $columnsList)) { - $columnSort = $listPeer::TABLE_NAME . '.' . $sort; + switch ($sort) { + case 'DEL_PREVIOUS_USR_UID': + $columnSort = $this->buildOrderFieldFormatted($columnsList, $userDisplayFormat, 'DEL_PREVIOUS_'); + break; + case 'USR_UID': + $columnSort = $this->buildOrderFieldFormatted($columnsList, $userDisplayFormat, 'DEL_CURRENT_'); + break; + default: + $columnSort = $listPeer::TABLE_NAME . '.' . $sort; + } } else { //We will sort by CUSTOM CASE LIST table if (count($additionalColumns) > 0) { @@ -3580,7 +3592,63 @@ class Cases } /** - * This function verify if the user is a supervisor + * When we order columns related to the user information we need to use the userDisplayFormat + * + * @param array $columnsList, the list of columns in the table + * @param string $format, the user display format + * @param string $prefix, the initial name of the columns related to the USR_FIRSTNAME USR_LASTNAME USR_USERNAME + * + * @return array $columnSort, columns by apply the sql command ORDER BY + */ + public function buildOrderFieldFormatted($columnsList, $format, $prefix = 'DEL_PREVIOUS_') + { + $columnSort = []; + + if (in_array($prefix . 'USR_FIRSTNAME', $columnsList) && + in_array($prefix . 'USR_LASTNAME', $columnsList) && + in_array($prefix . 'USR_USERNAME', $columnsList) + ) { + switch ($format) { + case '@firstName @lastName': + array_push($columnSort, $prefix . 'USR_FIRSTNAME'); + array_push($columnSort, $prefix . 'USR_LASTNAME'); + break; + case '@firstName @lastName (@userName)': + array_push($columnSort, $prefix . 'USR_FIRSTNAME'); + array_push($columnSort, $prefix . 'USR_LASTNAME'); + array_push($columnSort, $prefix . 'USR_USERNAME'); + break; + case '@userName': + array_push($columnSort, $prefix . 'USR_USERNAME'); + break; + case '@userName (@firstName @lastName)': + array_push($columnSort, $prefix . 'USR_USERNAME'); + array_push($columnSort, $prefix . 'USR_FIRSTNAME'); + array_push($columnSort, $prefix . 'USR_LASTNAME'); + break; + case '@lastName, @firstName': + array_push($columnSort, $prefix . 'USR_LASTNAME'); + array_push($columnSort, $prefix . 'USR_FIRSTNAME'); + break; + case '@lastName @firstName': + array_push($columnSort, $prefix . 'USR_LASTNAME'); + array_push($columnSort, $prefix . 'USR_FIRSTNAME'); + break; + case '@lastName, @firstName (@userName)': + array_push($columnSort, $prefix . 'USR_LASTNAME'); + array_push($columnSort, $prefix . 'USR_FIRSTNAME'); + array_push($columnSort, $prefix . 'USR_USERNAME'); + break; + default: + array_push($columnSort, $prefix . 'USR_USERNAME'); + break; + } + } + + return $columnSort; + } + + /** This function verify if the user is a supervisor * If we send the formUid we will to review if has the object form assigned * * @param string $usrUid, Uid related to the user