PMCORE-3018

This commit is contained in:
Paula Quispe
2021-05-12 18:59:01 -04:00
parent 9e57f97b34
commit 87138811a2
4 changed files with 370 additions and 360 deletions

View File

@@ -4262,8 +4262,14 @@ msgstr "The Case {APP_NUMBER} was unpaused successfully!"
# TRANSLATION # TRANSLATION
# LABEL/ID_CASE_USER_INVALID_CANCEL_CASE # LABEL/ID_CASE_USER_INVALID_CANCEL_CASE
#: LABEL/ID_CASE_USER_INVALID_CANCEL_CASE #: LABEL/ID_CASE_USER_INVALID_CANCEL_CASE
msgid "The user with \"{0}\" is invalid to cancel the Case." msgid "The user with \"{0}\" is invalid to cancel the case."
msgstr "The user with \"{0}\" is invalid to cancel the Case." msgstr "The user with \"{0}\" is invalid to cancel the case."
# TRANSLATION
# LABEL/ID_CASE_USER_INVALID_CLAIM_CASE
#: LABEL/ID_CASE_USER_INVALID_CLAIM_CASE
msgid "The user with \"{0}\" is invalid to claim the case."
msgstr "The user with \"{0}\" is invalid to claim the case."
# TRANSLATION # TRANSLATION
# LABEL/ID_CASE_USER_INVALID_PAUSED_CASE # LABEL/ID_CASE_USER_INVALID_PAUSED_CASE
@@ -4274,8 +4280,8 @@ msgstr "The user with \"{0}\" is invalid to pause the case."
# TRANSLATION # TRANSLATION
# LABEL/ID_CASE_USER_INVALID_UNPAUSE_CASE # LABEL/ID_CASE_USER_INVALID_UNPAUSE_CASE
#: LABEL/ID_CASE_USER_INVALID_UNPAUSE_CASE #: LABEL/ID_CASE_USER_INVALID_UNPAUSE_CASE
msgid "The user with \"{0}\" is invalid to Unpause the Case." msgid "The user with \"{0}\" is invalid to Unpause the case."
msgstr "The user with \"{0}\" is invalid to Unpause the Case." msgstr "The user with \"{0}\" is invalid to Unpause the case."
# TRANSLATION # TRANSLATION
# LABEL/ID_CASE_USER_NOT_HAVE_PERMISSION # LABEL/ID_CASE_USER_NOT_HAVE_PERMISSION

View File

@@ -57521,9 +57521,10 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_CASE_TRACKER_OBJECT_DOES_NOT_EXIST','en','The case tracker object with {0}: {1} does not exist.','2014-05-20') , ( 'LABEL','ID_CASE_TRACKER_OBJECT_DOES_NOT_EXIST','en','The case tracker object with {0}: {1} does not exist.','2014-05-20') ,
( 'LABEL','ID_CASE_UNARHIVE','en','Case Unarhive','2015-09-15') , ( 'LABEL','ID_CASE_UNARHIVE','en','Case Unarhive','2015-09-15') ,
( 'LABEL','ID_CASE_UNPAUSED_SUCCESSFULLY','en','The Case {APP_NUMBER} was unpaused successfully!','2014-01-15') , ( 'LABEL','ID_CASE_UNPAUSED_SUCCESSFULLY','en','The Case {APP_NUMBER} was unpaused successfully!','2014-01-15') ,
( 'LABEL','ID_CASE_USER_INVALID_CANCEL_CASE','en','The user with "{0}" is invalid to cancel the Case.','2015-08-24') , ( 'LABEL','ID_CASE_USER_INVALID_CANCEL_CASE','en','The user with "{0}" is invalid to cancel the case.','2015-08-24') ,
( 'LABEL','ID_CASE_USER_INVALID_CLAIM_CASE','en','The user with "{0}" is invalid to claim the case.','2021-05-212') ,
( 'LABEL','ID_CASE_USER_INVALID_PAUSED_CASE','en','The user with "{0}" is invalid to pause the case.','2015-08-14') , ( 'LABEL','ID_CASE_USER_INVALID_PAUSED_CASE','en','The user with "{0}" is invalid to pause the case.','2015-08-14') ,
( 'LABEL','ID_CASE_USER_INVALID_UNPAUSE_CASE','en','The user with "{0}" is invalid to Unpause the Case.','2015-08-14') , ( 'LABEL','ID_CASE_USER_INVALID_UNPAUSE_CASE','en','The user with "{0}" is invalid to Unpause the case.','2015-08-14') ,
( 'LABEL','ID_CASE_USER_NOT_HAVE_PERMISSION','en','The user with "{0}" did not have permission to perform this action.','2015-09-01') , ( 'LABEL','ID_CASE_USER_NOT_HAVE_PERMISSION','en','The user with "{0}" did not have permission to perform this action.','2015-09-01') ,
( 'LABEL','ID_CASE_VARIABLE_ALREADY_EXISTS','en','The Variable with {0}: "{1}" already exists in Case','2016-02-23') , ( 'LABEL','ID_CASE_VARIABLE_ALREADY_EXISTS','en','The Variable with {0}: "{1}" already exists in Case','2016-02-23') ,
( 'LABEL','ID_CASE_VARIABLE_DOES_NOT_EXIST','en','The Variable with {0}: "{1}" does not exist in Case','2016-02-23') , ( 'LABEL','ID_CASE_VARIABLE_DOES_NOT_EXIST','en','The Variable with {0}: "{1}" does not exist in Case','2016-02-23') ,

View File

@@ -39,6 +39,7 @@ use InputDocument;
use InvalidIndexSearchTextException; use InvalidIndexSearchTextException;
use PmDynaform; use PmDynaform;
use PmTable; use PmTable;
use ProcessMaker\BusinessModel\Cases as BmCases;
use ProcessMaker\BusinessModel\ProcessSupervisor as BmProcessSupervisor; use ProcessMaker\BusinessModel\ProcessSupervisor as BmProcessSupervisor;
use ProcessMaker\BusinessModel\Task as BmTask; use ProcessMaker\BusinessModel\Task as BmTask;
use ProcessMaker\BusinessModel\User as BmUser; use ProcessMaker\BusinessModel\User as BmUser;
@@ -912,12 +913,12 @@ class Cases
* @access public * @access public
* @param string $appUid, Uid for case * @param string $appUid, Uid for case
* @param string $usrUid, Uid for user * @param string $usrUid, Uid for user
* @param bool|string $delIndex * @param interger $delIndex
* *
* @return void * @return void
* @throws Exception * @throws Exception
*/ */
public function putCancelCase($appUid, $usrUid, $delIndex = false) public function putCancelCase($appUid, $usrUid, $delIndex = null, $reason = '', $sendMail = false)
{ {
Validator::isString($appUid, '$app_uid'); Validator::isString($appUid, '$app_uid');
Validator::appUid($appUid, '$app_uid'); Validator::appUid($appUid, '$app_uid');
@@ -929,7 +930,7 @@ class Cases
$supervisor = new BmProcessSupervisor(); $supervisor = new BmProcessSupervisor();
$isSupervisor = $supervisor->isUserProcessSupervisor($fields['PRO_UID'], $usrUid); $isSupervisor = $supervisor->isUserProcessSupervisor($fields['PRO_UID'], $usrUid);
if ($delIndex === false) { if (is_null($delIndex)) {
$u = new ModelUsers(); $u = new ModelUsers();
$usrId = $u->load($usrUid)['USR_ID']; $usrId = $u->load($usrUid)['USR_ID'];
@@ -956,6 +957,13 @@ class Cases
if ($result->status_code !== 0) { if ($result->status_code !== 0) {
throw new Exception($result->message); throw new Exception($result->message);
} }
/** Add the note */
if (!empty($reason)) {
$noteContent = $reason;
// Define the Case for register a case note
$cases = new BmCases();
$response = $cases->addNote($appUid, $usrUid, $noteContent, $sendMail);
}
} }
/** /**
@@ -1076,6 +1084,39 @@ class Cases
$case->unpauseCase($app_uid, $del_index, $usr_uid); $case->unpauseCase($app_uid, $del_index, $usr_uid);
} }
/**
* Put claim case
*
* @param string $appUid
* @param integer $index
* @param string $userUid
*
* @return void
* @throws Exception
*
* @access public
*/
public function putClaimCase($appUid, $index, $userUid)
{
// Validate the parameters
Validator::isString($appUid, '$appUid');
Validator::isString($userUid, '$userUid');
Validator::isInteger($index, '$index');
Validator::appUid($appUid, '$appUid');
Validator::usrUid($userUid, '$userUid');
// Review if the user can claim the case
$appDelegation = new AppDelegation();
$delegation = $appDelegation->load($appUid, $index);
if (empty($delegation['USR_UID'])) {
$case = new ClassesCases();
$case->loadCase($appUid);
$case->setCatchUser($appUid, $index, $userUid);
} else {
throw new Exception(G::LoadTranslation("ID_CASE_USER_INVALID_CLAIM_CASE", [$userUid]));
}
}
/** /**
* Put execute trigger case * Put execute trigger case
* *
@@ -1977,98 +2018,89 @@ class Cases
/** /**
* Get Case Notes * Get Case Notes
* *
* @access public * @param string $appUid
* @param string $app_uid , Uid for case * @param string $usrUid
* @param array $parameters
* *
* @return array * @return array
* @throws Exception * @throws \PropelException
* @access public
*/ */
public function getCaseNotes($app_uid, $usr_uid, $data_get) public function getCaseNotes($appUid, $usrUid, $parameters = [])
{ {
Validator::isString($app_uid, '$app_uid'); // Validate parameters
Validator::appUid($app_uid, '$app_uid'); Validator::isString($appUid, '$app_uid');
Validator::isString($usr_uid, '$usr_uid'); Validator::appUid($appUid, '$app_uid');
Validator::usrUid($usr_uid, '$usr_uid'); Validator::isString($usrUid, '$usr_uid');
Validator::isArray($data_get, '$data_get'); Validator::usrUid($usrUid, '$usr_uid');
Validator::isArray($parameters, '$parameters');
Validator::isArray($data_get, '$data_get'); Validator::isArray($parameters, '$parameters');
$start = isset($data_get["start"]) ? $data_get["start"] : "0"; $start = isset($parameters["start"]) ? $parameters["start"] : "0";
$limit = isset($data_get["limit"]) ? $data_get["limit"] : ""; $limit = isset($parameters["limit"]) ? $parameters["limit"] : "";
$sort = isset($data_get["sort"]) ? $data_get["sort"] : "APP_NOTES.NOTE_DATE"; $sort = isset($parameters["sort"]) ? $parameters["sort"] : "NOTE_DATE";
$dir = isset($data_get["dir"]) ? $data_get["dir"] : "DESC"; $dir = isset($parameters["dir"]) ? $parameters["dir"] : "DESC";
$user = isset($data_get["user"]) ? $data_get["user"] : ""; $user = isset($parameters["user"]) ? $parameters["user"] : "";
$dateFrom = (!empty($data_get["dateFrom"])) ? substr($data_get["dateFrom"], 0, 10) : ""; $dateFrom = (!empty($parameters["dateFrom"])) ? substr($parameters["dateFrom"], 0, 10) : "";
$dateTo = (!empty($data_get["dateTo"])) ? substr($data_get["dateTo"], 0, 10) : ""; $dateTo = (!empty($parameters["dateTo"])) ? substr($parameters["dateTo"], 0, 10) : "";
$search = isset($data_get["search"]) ? $data_get["search"] : ""; $search = isset($parameters["search"]) ? $parameters["search"] : "";
$paged = isset($data_get["paged"]) ? $data_get["paged"] : true; $paged = isset($parameters["paged"]) ? $parameters["paged"] : true;
$files = isset($parameters["files"]) ? $parameters["files"] : false;
$case = new ClassesCases(); if (!empty($user)) {
$caseLoad = $case->loadCase($app_uid);
$pro_uid = $caseLoad['PRO_UID'];
$tas_uid = AppDelegation::getCurrentTask($app_uid);
$respView = $case->getAllObjectsFrom($pro_uid, $app_uid, $tas_uid, $usr_uid, 'VIEW');
$respBlock = $case->getAllObjectsFrom($pro_uid, $app_uid, $tas_uid, $usr_uid, 'BLOCK');
if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) {
throw (new Exception(G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS")));
}
if ($sort != 'APP_NOTE.NOTE_DATE') {
$sort = G::toUpper($sort);
$columnsAppCacheView = AppNotesPeer::getFieldNames(BasePeer::TYPE_FIELDNAME);
if (!(in_array($sort, $columnsAppCacheView))) {
$sort = 'APP_NOTES.NOTE_DATE';
} else {
$sort = 'APP_NOTES.' . $sort;
}
}
if ((int)$start == 1 || (int)$start == 0) {
$start = 0;
}
$dir = G::toUpper($dir);
if (!($dir == 'DESC' || $dir == 'ASC')) {
$dir = 'DESC';
}
if ($user != '') {
Validator::usrUid($user, '$usr_uid'); Validator::usrUid($user, '$usr_uid');
} }
if ($dateFrom != '') { if (!empty($dateFrom)) {
Validator::isDate($dateFrom, 'Y-m-d', '$date_from'); Validator::isDate($dateFrom, 'Y-m-d', '$date_from');
} }
if ($dateTo != '') { if (!empty($dateTo)) {
Validator::isDate($dateTo, 'Y-m-d', '$date_to'); Validator::isDate($dateTo, 'Y-m-d', '$date_to');
} }
// Review the process permissions
$appNote = new \AppNotes(); $case = new ClassesCases();
$note_data = $appNote->getNotesList($app_uid, $user, $start, $limit, $sort, $dir, $dateFrom, $dateTo, $search); $caseLoad = $case->loadCase($appUid);
$response = array(); $proUid = $caseLoad['PRO_UID'];
if ($paged === true) { $tasUid = AppDelegation::getCurrentTask($appUid);
$response['total'] = $note_data['array']['totalCount']; $respView = $case->getAllObjectsFrom($proUid, $appUid, $tasUid, $usrUid, 'VIEW');
$response['start'] = $start; $respBlock = $case->getAllObjectsFrom($proUid, $appUid, $tasUid, $usrUid, 'BLOCK');
$response['limit'] = $limit; if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) {
$response['sort'] = $sort; throw new Exception(G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS"));
$response['dir'] = $dir; }
$response['usr_uid'] = $user; // Get the notes
$response['date_to'] = $dateTo; $appNote = new Notes();
$response['date_from'] = $dateFrom; $notes = $appNote->getNotes($appUid, $start, $limit, $dir);
$response['search'] = $search; $notes = AppNotes::applyHtmlentitiesInNotes($notes);
$response['data'] = array(); // Add a the notes the files related
$con = 0; $documents = new Documents();
foreach ($note_data['array']['notes'] as $value) { $iterator = 0;
$response['data'][$con]['app_uid'] = $value['APP_UID']; $data = [];
$response['data'][$con]['usr_uid'] = $value['USR_UID']; foreach ($notes['notes'] as $value) {
$response['data'][$con]['note_date'] = $value['NOTE_DATE']; $data[$iterator] = array_change_key_case($value, CASE_LOWER);
$response['data'][$con]['note_content'] = $value['NOTE_CONTENT']; $data[$iterator]['note_date'] = UtilDateTime::convertUtcToTimeZone($value['NOTE_DATE']);
$con++; if ($files) {
$data[$iterator]['attachments'] = $documents->getFiles($value['NOTE_ID']);
} }
$iterator++;
}
// If is paged will add the filters used
$filters = [];
if ($paged) {
$total = $appNote->getTotal($appUid);
$filters['total'] = $total;
$filters['start'] = $start;
$filters['limit'] = $limit;
$filters['sort'] = $sort;
$filters['dir'] = $dir;
$filters['usr_uid'] = $user;
$filters['date_to'] = $dateTo;
$filters['date_from'] = $dateFrom;
$filters['search'] = $search;
}
// Prepare the response
$response = [];
if ($paged) {
$response = $filters;
$response['data'] = $data;
} else { } else {
$con = 0; $response = $data;
foreach ($note_data['array']['notes'] as $value) {
$response[$con]['app_uid'] = $value['APP_UID'];
$response[$con]['usr_uid'] = $value['USR_UID'];
$response[$con]['note_date'] = $value['NOTE_DATE'];
$response[$con]['note_content'] = $value['NOTE_CONTENT'];
$con++;
}
} }
return $response; return $response;
@@ -2078,40 +2110,37 @@ class Cases
* Save new case note * Save new case note
* *
* @access public * @access public
* @param string $app_uid , Uid for case * @param string $appUid, Uid for case
* @param array $app_data , Data for case variables * @param string $usrUid, Uid for user
* @param string $noteContent
* @param boolean $sendMail
* *
* @return void * @return void
* @throws Exception * @throws Exception
*/ */
public function saveCaseNote($app_uid, $usr_uid, $note_content, $send_mail = false) public function saveCaseNote($appUid, $usrUid, $noteContent, $sendMail = false)
{ {
Validator::isString($app_uid, '$app_uid'); Validator::isString($appUid, '$app_uid');
Validator::appUid($app_uid, '$app_uid'); Validator::appUid($appUid, '$app_uid');
Validator::isString($usrUid, '$usr_uid');
Validator::isString($usr_uid, '$usr_uid'); Validator::usrUid($usrUid, '$usr_uid');
Validator::usrUid($usr_uid, '$usr_uid'); Validator::isString($noteContent, '$note_content');
if (strlen($noteContent) > 500) {
Validator::isString($note_content, '$note_content'); throw (new Exception(G::LoadTranslation("ID_INVALID_MAX_PERMITTED", [$noteContent, '500'])));
if (strlen($note_content) > 500) {
throw (new Exception(G::LoadTranslation("ID_INVALID_MAX_PERMITTED", array($note_content, '500'))));
} }
Validator::isBoolean($sendMail, '$send_mail');
Validator::isBoolean($send_mail, '$send_mail'); // Review the process permissions
$case = new ClassesCases(); $case = new ClassesCases();
$caseLoad = $case->loadCase($app_uid); $caseLoad = $case->loadCase($appUid);
$pro_uid = $caseLoad['PRO_UID']; $proUid = $caseLoad['PRO_UID'];
$tas_uid = AppDelegation::getCurrentTask($app_uid); $tasUid = AppDelegation::getCurrentTask($appUid);
$respView = $case->getAllObjectsFrom($pro_uid, $app_uid, $tas_uid, $usr_uid, 'VIEW'); $respView = $case->getAllObjectsFrom($proUid, $appUid, $tasUid, $usrUid, 'VIEW');
$respBlock = $case->getAllObjectsFrom($pro_uid, $app_uid, $tas_uid, $usr_uid, 'BLOCK'); $respBlock = $case->getAllObjectsFrom($proUid, $appUid, $tasUid, $usrUid, 'BLOCK');
if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) { if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) {
throw (new Exception(G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS"))); throw (new Exception(G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS")));
} }
// Save the notes
$note_content = addslashes($note_content); $response = $this->addNote($appUid, $usrUid, $noteContent, intval($sendMail));
// Define the Case for register a case note
$response = $this->addNote($app_uid, $usr_uid, $note_content, intval($send_mail));
} }
/** /**
@@ -3988,7 +4017,7 @@ class Cases
} }
} }
//rules validation // Rules validation
foreach ($files as $key => $value) { foreach ($files as $key => $value) {
$entry = [ $entry = [
"filename" => $value['name'], "filename" => $value['name'],

File diff suppressed because it is too large Load Diff