From 0d08c371fece2ca756c4b521918f44201f15ca68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luciana=20Nu=C3=B1ez?= Date: Thu, 8 Dec 2022 10:36:44 -0400 Subject: [PATCH] PMCORE-4087 --- .../assets/js/home/modal/ModalAssignCase.vue | 2 +- .../js/home/modal/ModalReassignCase.vue | 2 +- .../translations/english/processmaker.en.po | 6 +++ workflow/engine/data/mysql/insert.sql | 1 + .../src/ProcessMaker/BusinessModel/Cases.php | 46 +++++++++++++++++-- .../src/ProcessMaker/Services/Api/Cases.php | 2 +- 6 files changed, 52 insertions(+), 7 deletions(-) diff --git a/resources/assets/js/home/modal/ModalAssignCase.vue b/resources/assets/js/home/modal/ModalAssignCase.vue index 0cdd309ab..e83518ae3 100755 --- a/resources/assets/js/home/modal/ModalAssignCase.vue +++ b/resources/assets/js/home/modal/ModalAssignCase.vue @@ -146,7 +146,7 @@ export default { let that = this; this.data.userSelected = this.userSelected; this.data.reasonAssign = this.reasonAssign; - this.notifyUser = this.notifyUser; + this.data.notifyUser = this.notifyUser; api.cases.assignCase(this.data).then((response) => { if (response.statusText == "OK" || response.status === 200) { that.$refs["modal-assign-case"].hide(); diff --git a/resources/assets/js/home/modal/ModalReassignCase.vue b/resources/assets/js/home/modal/ModalReassignCase.vue index a92778ad7..e475e6a49 100755 --- a/resources/assets/js/home/modal/ModalReassignCase.vue +++ b/resources/assets/js/home/modal/ModalReassignCase.vue @@ -150,7 +150,7 @@ export default { let that = this; this.data.userSelected = this.userSelected; this.data.reasonReassign = this.reasonReassign; - this.notifyUser = this.notifyUser; + this.data.notifyUser = this.notifyUser; if (!this.data.FLAG){ api.cases.reassingCase(this.data).then((response) => { if (response.statusText == "OK" || response.status === 200) { diff --git a/workflow/engine/content/translations/english/processmaker.en.po b/workflow/engine/content/translations/english/processmaker.en.po index 4e62b8735..67001106b 100755 --- a/workflow/engine/content/translations/english/processmaker.en.po +++ b/workflow/engine/content/translations/english/processmaker.en.po @@ -2533,6 +2533,12 @@ msgstr "Assign group to" msgid "Assign Manager To Department" msgstr "Assign Manager To Department" +# TRANSLATION +# LABEL/ID_ASSIGN_NOTIFICATION +#: LABEL/ID_ASSIGN_NOTIFICATION +msgid "You were assigned to case #{0}." +msgstr "You were assigned to case #{0}." + # TRANSLATION # LABEL/ID_ASSIGN_ROLE #: LABEL/ID_ASSIGN_ROLE diff --git a/workflow/engine/data/mysql/insert.sql b/workflow/engine/data/mysql/insert.sql index 8da14ffab..d867fc689 100755 --- a/workflow/engine/data/mysql/insert.sql +++ b/workflow/engine/data/mysql/insert.sql @@ -57226,6 +57226,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_ASSIGN_GROUP_TASK','en','Assign Group Task','2015-02-20') , ( 'LABEL','ID_ASSIGN_GROUP_TO','en','Assign group to','2014-01-15') , ( 'LABEL','ID_ASSIGN_MANAGER_TO_DEPARTAMENT','en','Assign Manager To Department','2014-10-21') , +( 'LABEL','ID_ASSIGN_NOTIFICATION','en','You were assigned to case #{0}.','2022-12-08') , ( 'LABEL','ID_ASSIGN_ROLE','en','Assign user','2014-01-15') , ( 'LABEL','ID_ASSIGN_RULES','en','Error: There is a problem with the next tasks of this process. One of them has manual assignment. Manual assignment shouldn''t be used with sub-processes','2015-02-24') , ( 'LABEL','ID_ASSIGN_SCREEN','en','Assign Screen','2014-01-15') , diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php index 23428442c..d1e192bf4 100755 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php @@ -962,10 +962,7 @@ class Cases /** 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); + $this->sendMail($appUid, $usrUid, $reason, $sendMail, $userTarget); } // Log @@ -4059,6 +4056,47 @@ class Cases return $result; } + /** + * Send mail to notify and Add a case note + * + * @param string $appUid + * @param string $userUid + * @param string $note + * @param bool $sendMail + * @param string $toUser + * + */ + public function sendMail($appUid, $userUid, $note, $sendMail = false, $toUser = '') + { + + $appNumber = ModelApplication::getCaseNumber($appUid); + + // Register the note + $attributes = [ + "APP_UID" => $appUid, + "APP_NUMBER" => $appNumber, + "USR_UID" => $userUid, + "NOTE_DATE" => date("Y-m-d H:i:s"), + "NOTE_CONTENT" => $note, + "NOTE_TYPE" => "USER", + "NOTE_AVAILABILITY" => "PUBLIC", + "NOTE_RECIPIENTS" => "" + ]; + $newNote = Notes::create($attributes); + + // Send the email + if ($sendMail) { + // Get the FK + $noteId = $newNote->NOTE_ID; + + $note = G::LoadTranslation('ID_ASSIGN_NOTIFICATION', [$appNumber]) . '
' . G::LoadTranslation('ID_REASON') . ': ' . stripslashes($note); + + // Send the notification + $appNote = new AppNotes(); + $appNote->sendNoteNotification($appUid, $userUid, $note, $toUser, '', 0, $noteId); + } + } + /** * Upload file related to the case notes * diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Cases.php b/workflow/engine/src/ProcessMaker/Services/Api/Cases.php index 806f84580..836be841f 100755 --- a/workflow/engine/src/ProcessMaker/Services/Api/Cases.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Cases.php @@ -1086,7 +1086,7 @@ class Cases extends Api /** Add the note */ if (!empty($reason)) { $currentUserUid = $this->getUserId(); - $cases->addNote($appUid, $currentUserUid, $reason, $sendMail); + $cases->sendMail($appUid, $currentUserUid, $reason, $sendMail, $usrUid); } } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());