Merged in bugfix/HOR-3521-A (pull request #6117)

HOR-3521

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Paula Quispe
2017-10-25 19:00:09 +00:00
committed by Julio Cesar Laura Avendaño
5 changed files with 323 additions and 61 deletions

View File

@@ -1,6 +1,7 @@
<?php
require_once 'classes/model/om/BaseListInbox.php';
use ProcessMaker\BusinessModel\Cases as BmCases;
/**
* Skeleton subclass for representing a row from the 'LIST_INBOX' table.
@@ -13,17 +14,60 @@ require_once 'classes/model/om/BaseListInbox.php';
*
* @package classes.model
*/
// @codingStandardsIgnoreStart
class ListInbox extends BaseListInbox
{
private $additionalClassName = '';
private $userDisplayFormat = '';
/**
* Get the $additionalClassName value.
*
* @return string
*/
public function getAdditionalClassName()
{
return $this->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,11 +623,21 @@ class ListInbox extends BaseListInbox
$limit = isset($filters['limit']) ? $filters['limit'] : "25";
$paged = isset($filters['paged']) ? $filters['paged'] : 1;
if ($dir == "DESC") {
if (is_array($sort) && count($sort) > 0) {
foreach ($sort as $key) {
if ($dir == 'DESC') {
$criteria->addDescendingOrderByColumn($key);
} else {
$criteria->addAscendingOrderByColumn($key);
}
}
} else {
if ($dir == 'DESC') {
$criteria->addDescendingOrderByColumn($sort);
} else {
$criteria->addAscendingOrderByColumn($sort);
}
}
if ($paged == 1) {
$criteria->setLimit($limit);

View File

@@ -1,7 +1,7 @@
<?php
// @codingStandardsIgnoreStart
require_once 'classes/model/om/BaseListParticipatedLast.php';
use ProcessMaker\BusinessModel\Cases as BmCases;
/**
* Skeleton subclass for representing a row from the 'LIST_PARTICIPATED_LAST' table.
@@ -15,6 +15,49 @@ require_once 'classes/model/om/BaseListParticipatedLast.php';
class ListParticipatedLast extends BaseListParticipatedLast
{
private $additionalClassName = '';
private $userDisplayFormat = '';
/**
* Get the $additionalClassName value.
*
* @return string
*/
public function getAdditionalClassName()
{
return $this->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,11 +466,21 @@ class ListParticipatedLast extends BaseListParticipatedLast
$limit = isset($filters['limit']) ? $filters['limit'] : '25';
$paged = isset($filters['paged']) ? $filters['paged'] : 1;
if (is_array($sort) && count($sort) > 0) {
foreach ($sort as $key) {
if ($dir == 'DESC') {
$criteria->addDescendingOrderByColumn($key);
} else {
$criteria->addAscendingOrderByColumn($key);
}
}
} else {
if ($dir == 'DESC') {
$criteria->addDescendingOrderByColumn($sort);
} else {
$criteria->addAscendingOrderByColumn($sort);
}
}
if ($paged == 1) {
$criteria->setLimit($limit);

View File

@@ -1,7 +1,7 @@
<?php
require_once 'classes/model/om/BaseListPaused.php';
use ProcessMaker\BusinessModel\Cases as BmCases;
/**
* Skeleton subclass for representing a row from the 'LIST_PAUSED' table.
@@ -14,17 +14,60 @@ require_once 'classes/model/om/BaseListPaused.php';
*
* @package classes.model
*/
// @codingStandardsIgnoreStart
class ListPaused extends BaseListPaused
{
private $additionalClassName = '';
private $userDisplayFormat = '';
/**
* Get the $additionalClassName value.
*
* @return string
*/
public function getAdditionalClassName()
{
return $this->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,11 +376,21 @@ class ListPaused extends BaseListPaused
$limit = isset($filters['limit']) ? $filters['limit'] : "25";
$paged = isset($filters['paged']) ? $filters['paged'] : 1;
if ($dir == "DESC") {
if (is_array($sort) && count($sort) > 0) {
foreach ($sort as $key) {
if ($dir == 'DESC') {
$criteria->addDescendingOrderByColumn($key);
} else {
$criteria->addAscendingOrderByColumn($key);
}
}
} else {
if ($dir == 'DESC') {
$criteria->addDescendingOrderByColumn($sort);
} else {
$criteria->addAscendingOrderByColumn($sort);
}
}
if ($paged == 1) {
$criteria->setLimit($limit);

View File

@@ -90,8 +90,11 @@ try {
$filters['limit'] = (int)$filters['limit'];
$filters['limit'] = abs($filters['limit']);
if ($filters['limit'] == 0) {
$conf = new Configurations();
$formats = $conf->getFormats();
$list->setUserDisplayFormat($formats['format']);
if ($filters['limit'] == 0) {
$generalConfCasesList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', '');
if (isset($generalConfCasesList['casesListRowNumber'])) {
$filters['limit'] = (int)$generalConfCasesList['casesListRowNumber'];
@@ -104,7 +107,8 @@ try {
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';

View File

@@ -3545,7 +3545,9 @@ class Cases
* @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 $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)) {
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