From 3f88a7d75d58a0f112d8b9971c5eb5a94642cd38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luciana=20Nu=C3=B1ez?= Date: Wed, 7 Dec 2022 11:48:46 -0400 Subject: [PATCH] PMCORE-4088 --- .../src/ProcessMaker/BusinessModel/Cases.php | 31 +++++++++++++++++-- .../src/ProcessMaker/Services/Api/Cases.php | 4 +-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php index 9cf14b4f8..23428442c 100755 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php @@ -934,7 +934,7 @@ class Cases * @param string $usrUid Unique id of User * @param int $delIndex * @param string $userSource Unique id of User Source - * @param string $userTarget $userUidTarget id of User Target + * @param string $userTarget id of User Target * @param string $reason * @param boolean $sendMail * @@ -967,6 +967,18 @@ class Cases $cases = new BmCases(); $response = $cases->addNote($appUid, $usrUid, $noteContent, $sendMail); } + + // Log + $message = 'Reassign case'; + $context = $data = [ + "appUid" => $appUid, + "usrUidSupervisor" => $usrUid, + "userSource" => $userSource, + "userTarget" => $userTarget, + "reason" => $reason, + "delIndex" => $delIndex + ]; + Log::channel(':ReassignCase')->info($message, Bootstrap::context($context)); } catch (Exception $e) { throw $e; } @@ -1143,13 +1155,15 @@ class Cases * @param string $appUid * @param integer $index * @param string $userUid + * @param string $action + * @param string $reason * * @return void * @throws Exception * * @access public */ - public function putClaimCase($appUid, $index, $userUid) + public function putClaimCase($appUid, $index, $userUid, $action, $reason = '') { // Validate the parameters Validator::isString($appUid, '$appUid'); @@ -1176,6 +1190,19 @@ class Cases } else { throw new Exception(G::LoadTranslation("ID_CASE_USER_INVALID_CLAIM_CASE", [$userUid])); } + + $usrUidSupervisor = (Server::getUserId() === $userUid) ? '' : Server::getUserId(); + + // Log + $message = $action . ' case'; + $context = $data = [ + "appUid" => $appUid, + "usrUidSupervisor" => $usrUidSupervisor, + "userTarget" => $userUid, + "reason" => $reason, + "delIndex" => $index + ]; + Log::channel(':' . $action . 'Case')->info($message, Bootstrap::context($context)); } /** diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Cases.php b/workflow/engine/src/ProcessMaker/Services/Api/Cases.php index 7785394a0..806f84580 100755 --- a/workflow/engine/src/ProcessMaker/Services/Api/Cases.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Cases.php @@ -1031,7 +1031,7 @@ class Cases extends Api try { $userUid = $this->getUserId(); $cases = new BmCases(); - $cases->putClaimCase($appUid, $index, $userUid); + $cases->putClaimCase($appUid, $index, $userUid, 'Claim'); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -1081,7 +1081,7 @@ class Cases extends Api { try { $cases = new BmCases(); - $cases->putClaimCase($appUid, $index, $usrUid); + $cases->putClaimCase($appUid, $index, $usrUid, 'Assign', $reason); /** Add the note */ if (!empty($reason)) {