Merged in release/3.8.1 (pull request #8677)

release/3.8.1
This commit is contained in:
Paula Quispe
2023-01-05 19:11:46 +00:00
23 changed files with 1138 additions and 131 deletions

View File

@@ -1377,8 +1377,16 @@ class PmDynaform
exit();
}
public function printEditSupervisor()
/**
* Print edit supervisor forms.
* @param array $param
*/
public function printEditSupervisor(array $param = [])
{
$navbar = '';
if (isset($param['DEL_INDEX'])) {
$navbar = self::navigationBarForStepsToRevise($this->fields["APP_UID"], $this->fields["CURRENT_DYNAFORM"], $param['DEL_INDEX']);
}
ob_clean();
$json = G::json_decode($this->record["DYN_CONTENT"]);
$this->jsonr($json);
@@ -1405,6 +1413,7 @@ class PmDynaform
" . $this->getTheStringVariableForGoogleMaps() . "
</script>
<script type=\"text/javascript\" src=\"/jscore/cases/core/pmDynaform.js\"></script>
{$navbar}
<div>
" . $this->getSessionMessageForSupervisor() . "
<div style=\"display: none;\">
@@ -2629,4 +2638,54 @@ class PmDynaform
}
};
}
/**
* Get html navigation bar for steps to revise.
* @param string $appUid
* @param string $uid
* @param int $delIndex
* @return string
*/
public static function navigationBarForStepsToRevise(string $appUid, string $uid, int $delIndex): string
{
$navbar = '';
$cases = new Cases();
$steps = $cases->getAllUrlStepsToRevise($appUid, $delIndex);
$n = count($steps);
foreach ($steps as $key => $step) {
if ($step['uid'] === $uid) {
$previousLabel = '';
$previousUrl = '';
$nextLabel = '';
$nextUrl = '';
if ($key - 1 >= 0) {
$previousLabel = G::LoadTranslation('ID_PREVIOUS');
$previousUrl = $steps[$key - 1]['url'];
}
if ($key + 1 < $n) {
$nextLabel = G::LoadTranslation('ID_NEXT');
$nextUrl = $steps[$key + 1]['url'];
}
if (empty($nextUrl)) {
$nextLabel = G::LoadTranslation('ID_FINISH');
$nextUrl = 'javascript:if(window.parent && window.parent.parent){window.parent.parent.postMessage("redirect=MyCases","*");}';
}
//this condition modify the next Url for submit action
if ($step['type'] === 'DYNAFORM') {
$nextUrl = 'javascript:document.querySelector(".pmdynaform-container .pmdynaform-form").submit();';
}
$navbar = "<div style='width:100%;padding:0px 10px 0px 10px;margin:15px 0px 0px 0px;'>" .
" <img src='/images/bulletButtonLeft.gif' style='float:left;'>&nbsp;" .
" <a href='{$previousUrl}' style='float:left;font-size:12px;line-height:1;margin:0px 0px 1px 5px;text-decoration:none;!important;'>" .
" {$previousLabel}" .
" </a>" .
" <img src='/images/bulletButton.gif' style='float:right;'>&nbsp;" .
" <a href='{$nextUrl}' style='float:right;font-size:12px;line-height:1;margin:0px 5px 1px 0px;text-decoration:none;!important;'>" .
" {$nextLabel}" .
" </a>" .
"</div>";
}
}
return $navbar;
}
}

View File

@@ -12,6 +12,7 @@ use ProcessMaker\Core\JobsManager;
use ProcessMaker\Core\System;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Task;
class WsBase
{
@@ -2989,15 +2990,31 @@ class WsBase
}
$tasUid = $aRow['TAS_UID'];
$derivation = new Derivation();
$userList = $derivation->getAllUsersFromAnyTask($tasUid, true);
$task = Task::where('TAS_UID', '=', $tasUid)->first();
$type = $task->TAS_ASSIGN_TYPE;
$variable = $task->TAS_GROUP_VARIABLE;
if ($type === 'SELF_SERVICE' && $variable !== '') {
$cases = new BmCases();
$usersToReasign = $cases->usersToReassign($sessionId, $tasUid, $caseId)['data'];
$userList = [];
foreach ($usersToReasign as $user){
$userList[] = $user['USR_UID'];
}
} else {
$derivation = new Derivation();
$userList = $derivation->getAllUsersFromAnyTask($tasUid, true);
}
if (!in_array($userIdTarget, $userList)) {
$result = new WsResponse(34, G::loadTranslation('ID_TARGET_USER_DOES_NOT_HAVE_RIGHTS'));
$g->sessionVarRestore();
return $result;
$bmCase = new BmCases();
if (!$bmCase->isSupervisor($userIdTarget, $rows['APP_NUMBER'])){
$result = new WsResponse(34, G::loadTranslation('ID_TARGET_USER_DOES_NOT_HAVE_RIGHTS'));
$g->sessionVarRestore();
return $result;
}
}
/**

View File

@@ -2419,6 +2419,12 @@ msgstr "Array of variables is empty"
msgid "Assign"
msgstr "Assign"
# TRANSLATION
# LABEL/ID_ASSIGN_CASE
#: LABEL/ID_ASSIGN_CASE
msgid "Assign Case"
msgstr "Assign Case"
# TRANSLATION
# LABEL/ID_ASSIGNED_FIEDS
#: LABEL/ID_ASSIGNED_FIEDS
@@ -2527,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
@@ -4019,6 +4031,12 @@ msgstr "The case {0}: {1} with {2}: {3} does not exist."
msgid "Case Description"
msgstr "Case Description"
# TRANSLATION
# LABEL/ID_CASE_DETAILS
#: LABEL/ID_CASE_DETAILS
msgid "Case Details"
msgstr "Case Details"
# TRANSLATION
# LABEL/ID_CASE_DOES_NOT_EXIST
#: LABEL/ID_CASE_DOES_NOT_EXIST
@@ -24011,6 +24029,12 @@ msgstr "Resume"
msgid "Return"
msgstr "Return"
# TRANSLATION
# LABEL/ID_REVIEW_CASE
#: LABEL/ID_REVIEW_CASE
msgid "Review Case"
msgstr "Review Case"
# TRANSLATION
# LABEL/ID_RIGHT
#: LABEL/ID_RIGHT

View File

@@ -57205,6 +57205,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_ARE_YOU_SURE_UNPAUSE_TASK','en','Are you sure want to unpause the task?','2021-01-26') ,
( 'LABEL','ID_ARRAY_VARIABLES_EMPTY','en','Array of variables is empty','2014-01-15') ,
( 'LABEL','ID_ASSIGN','en','Assign','2014-01-15') ,
( 'LABEL','ID_ASSIGN_CASE','en','Assign Case','2022-11-04') ,
( 'LABEL','ID_ASSIGNED_FIEDS','en','ASSIGNED FIELDS','2014-01-15') ,
( 'LABEL','ID_ASSIGNED_GROUPS','en','ASSIGNED GROUPS','2014-01-15') ,
( 'LABEL','ID_ASSIGNED_MEMBERS','en','MEMBERS','2014-01-15') ,
@@ -57225,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') ,
@@ -57403,6 +57405,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_CASEDEMO','en','Case Demo','2014-01-15') ,
( 'LABEL','ID_CASELIST_CAN_NOT_BE_IMPORTED_THE_PMTABLE_NOT_EXIST','en','Custom Case List {0} can not be imported because the PM Table does not exist in this Workspace.','2021-08-20') ,
( 'LABEL','ID_CASE_DELETE_SUCCESFULLY','en','The Case was deleted successfully.','2020-01-08') ,
( 'LABEL','ID_CASE_DETAILS','en','Case Details','2022-10-25') ,
( 'LABEL','ID_CASE_UID','en','Case Uid','2021-04-04') ,
( 'LABEL','ID_CASE_THREAD_TITLE','en','Case Thread Title','2021-08-27') ,
( 'LABEL','ID_CASE_THREAD_TITLE_NAME','en','Case Thread Title Name','2021-09-29') ,
@@ -60923,6 +60926,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_RESTORING_CASE','en','Restoring case','2015-09-15') ,
( 'LABEL','ID_RESULT','en','Result','2014-01-15') ,
( 'LABEL','ID_RESUME','en','Resume','2014-01-15') ,
( 'LABEL','ID_REVIEW_CASE','en','Review Case','2022-11-10') ,
( 'LABEL','ID_RETURN_ADVANCED_SEARCH','en','Return','2019-07-17') ,
( 'LABEL','ID_RIGHT','en','right','2014-09-18') ,
( 'LABEL','ID_RIGHT_MARGIN','en','Right Margin','2014-01-15') ,

View File

@@ -1,29 +1,7 @@
<?php
/**
* cases_SaveData.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
//validate the data post
use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\BusinessModel\Cases as BusinessModelCases;
$dynaForm = DynaformPeer::retrieveByPK($_GET["UID"]);
@@ -210,6 +188,21 @@ if (isset( $_FILES["form"]["name"] ) && count( $_FILES["form"]["name"] ) > 0) {
//Define the STEP_POSITION
$ex = isset($_GET['ex']) ? $_GET['ex'] : 0;
//go to the next step
$aNextStep = $oCase->getNextSupervisorStep( $_SESSION['PROCESS'], $_SESSION['STEP_POSITION'] );
G::header( 'Location: cases_StepToRevise?type=DYNAFORM&ex=' . $ex . '&PRO_UID=' . $_SESSION['PROCESS'] . '&DYN_UID=' . $aNextStep['UID'] . '&APP_UID=' . $_SESSION['APPLICATION'] . '&position=' . $aNextStep['POSITION'] . '&DEL_INDEX=' . $_SESSION['INDEX'] );
$nextSteps = $oCase->getNextSupervisorStep($_SESSION['PROCESS'], $_SESSION['STEP_POSITION']);
$url = '';
$steps = (new BusinessModelCases())->getAllUrlStepsToRevise($_SESSION['APPLICATION'], $_SESSION['INDEX']);
$n = count($steps);
foreach ($steps as $key => $step) {
if ($step['uid'] === $nextSteps['UID'] && $key + 1 < $n) {
$nextUrl = $steps[$key + 1]['url'];
$url = $nextUrl;
break;
}
}
if (empty($url)) {
die('<script type="text/javascript">'
. 'if(window.parent && window.parent.parent){window.parent.parent.postMessage("redirect=MyCases","*");}'
. '</script>');
}
G::header('Location:' . $url);
die();

View File

@@ -1,28 +1,4 @@
<?php
/**
* cases_Step.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
// die("first");
/* Permissions */
$filter = new InputFilter();
$_GET = $filter->xssFilterHard($_GET, "url");
@@ -151,7 +127,7 @@ if ($_GET['DYN_UID'] != '') {
$FieldsPmDynaform["CURRENT_DYNAFORM"] = $_GET['DYN_UID'];
$a = new PmDynaform($FieldsPmDynaform);
if ($a->isResponsive()) {
$a->printEditSupervisor();
$a->printEditSupervisor(['DEL_INDEX' => $_GET['DEL_INDEX']]);
} else {
$G_PUBLISH->AddContent('dynaform', 'xmlform', $_SESSION['PROCESS'] . '/' . $_GET['DYN_UID'], '', $Fields['APP_DATA'], 'cases_SaveDataSupervisor?UID=' . $_GET['DYN_UID'] . '&ex=' . $_GET['ex']);
}

View File

@@ -1,28 +1,4 @@
<?php
/**
* cases_Step.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
//die("second");
/* Permissions */
$filter = new InputFilter();
$_GET = $filter->xssFilterHard($_GET, "url");
@@ -119,13 +95,8 @@ if (! isset($_GET['INP_DOC_UID'])) {
$Fields['MESSAGE2'] = G::LoadTranslation('ID_PLEASE_SELECT_FILE');
$docName = $Fields['INP_DOC_TITLE'];
$oHeadPublisher->addScriptCode('var documentName=\'Reviewing Input Document<br>' . $docName . '\';');
// $G_PUBLISH->AddContent('xmlform', 'xmlform', $sXmlForm, '', $Fields, 'cases_SupervisorSaveDocument?UID=' .
//$_GET['INP_DOC_UID'] . '&APP_UID=' . $_GET['APP_UID'] . '&position=' . $_GET['position']);
$G_PUBLISH->AddContent('propeltable', 'cases/paged-table-inputDocumentsToRevise', 'cases/cases_ToReviseInputdocsList', $oCase->getInputDocumentsCriteria($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_GET['INP_DOC_UID']), array_merge(array('DOC_UID' => $_GET['INP_DOC_UID']
), $Fields));
//$aFields
// $G_PUBLISH->AddContent('propeltable', 'cases/paged-table-inputDocuments', 'cases/cases_InputdocsList',
//$oCase->getInputDocumentsCriteria($_SESSION['APPLICATION']));//$aFields
$G_PUBLISH->AddContent('view','cases/paged-table-inputDocumentsToReviseNavBar');
$G_PUBLISH->AddContent('propeltable', 'cases/paged-table-inputDocumentsToRevise', 'cases/cases_ToReviseInputdocsList', $oCase->getInputDocumentsCriteria($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_GET['INP_DOC_UID']), array_merge(['DOC_UID' => $_GET['INP_DOC_UID']], $Fields));
}
G::RenderPage('publish', 'blank');

View File

@@ -473,7 +473,7 @@ a:hover {
}
.card-body {
background-color: #5aa4c4;
background-color: #0099DC;
color: #fff;
-ms-flex: 1 1 auto;
flex: 1 1 auto;

244
workflow/engine/src/ProcessMaker/BusinessModel/Cases.php Normal file → Executable file
View File

@@ -53,9 +53,13 @@ use ProcessMaker\Model\AppNotes as Notes;
use ProcessMaker\Model\AppTimeoutAction;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Documents;
use ProcessMaker\Model\Groupwf;
use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\ListUnassigned;
use ProcessMaker\Model\Triggers;
use ProcessMaker\Model\ProcessUser;
use ProcessMaker\Model\StepSupervisor;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\User;
use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\Services\Api;
@@ -904,6 +908,26 @@ class Cases
return $permission;
}
/**
* Review if the user is supervisor
*
* @param string $usrUid
* @param int $caseNumber
*
* @return bool
*/
public function isSupervisor(string $usrUid, int $caseNumber)
{
$result = [];
$user = new BmUser();
if ($user->checkPermission($usrUid, 'PM_SUPERVISOR')) {
$processes = ProcessUser::getProcessesOfSupervisor($usrUid);
$query = Delegation::query()->select(['APP_NUMBER'])->case($caseNumber)->processInList($processes);
$result = $query->get()->values()->toArray();
}
return !empty($result);
}
/**
* Reassign Case
*
@@ -911,7 +935,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
*
@@ -939,11 +963,20 @@ 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
$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;
}
@@ -1120,13 +1153,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');
@@ -1139,19 +1174,33 @@ class Cases
$appDelegation = new AppDelegation();
$delegation = $appDelegation->load($appUid, $index);
if (empty($delegation['USR_UID'])) {
$case = new ClassesCases();
$case->loadCase($appUid);
$classesCase = new ClassesCases();
$case = $classesCase->loadCase($appUid);
//Review if the user can be claim the case
if (!$case->isSelfService($userUid, $delegation['TAS_UID'], $appUid)) {
$message = preg_replace("#<br\s*/?>#i", "", G::LoadTranslation("ID_NO_PERMISSION_NO_PARTICIPATED"));
throw new Exception($message);
if (!$classesCase->isSelfService($userUid, $delegation['TAS_UID'], $appUid)) {
if (!$this->isSupervisor($userUid, $case['APP_NUMBER'])){
$message = preg_replace("#<br\s*/?>#i", "", G::LoadTranslation("ID_NO_PERMISSION_NO_PARTICIPATED"));
throw new Exception($message);
}
}
$case->setCatchUser($appUid, $index, $userUid);
$classesCase->setCatchUser($appUid, $index, $userUid);
} 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));
}
/**
@@ -2741,6 +2790,70 @@ class Cases
}
}
/**
* Get Users to reassign
*
* @param string $userUid Unique id of User (User logged)
* @param string $taskUid Unique id of Task
* @param string $appUid Unique id of Application
*
* @return array Return Users to reassign
* @throws Exception
*/
public function usersToReassign(
$userUid,
$taskUid,
$appUid
) {
$task = Task::where('TAS_UID', '=', $taskUid)->first();
$type = $task->TAS_ASSIGN_TYPE;
$variable = $task->TAS_GROUP_VARIABLE;
$result = [];
if ($type === 'SELF_SERVICE' && $variable !== '') {
$variable = substr($variable, 2);
$fields = ModelApplication::where('APP_UID', '=', $appUid)->first();
$data = ClassesCases::unserializeData($fields->APP_DATA);
$row = [];
if (!empty($data[$variable])) {
foreach ($data[$variable] as $uid) {
$group = Groupwf::where('GRP_UID', '=', $uid)->first();
if (!empty($group)) {
$usersOfGroup = GroupUser::where('GRP_UID', '=', $uid)->get()->toArray();
foreach ($usersOfGroup as $data) {
$row[] = $data['USR_UID'];
}
} else {
$row[] = $uid;
}
}
}
$users = [];
foreach ($row as $data) {
$obj = User::where('USR_UID', '=', $data)->Active()->first();
if (!is_null($obj) && $obj->USR_USERNAME !== "") {
$users[] = $obj;
}
}
foreach ($users as $user) {
$result[] = [
"USR_UID" => $user->USR_UID,
"USR_USERNAME" => $user->USR_USERNAME,
"USR_FIRSTNAME" => $user->USR_FIRSTNAME,
"USR_LASTNAME"=> $user->USR_LASTNAME
];
}
} else {
$result = $this->getUsersToReassign($userUid, $taskUid)['data'];
}
return ['data' => $result];
}
/**
* Get Users to reassign
*
@@ -3944,6 +4057,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]) . '<br />' . 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
*
@@ -4300,4 +4454,68 @@ class Cases
// Return results
return $dynaForms;
}
/**
* Get objects that they have send it.
* @param string $appUid
* @param string $typeObject
* @return array
*/
public function getStepsToRevise(string $appUid, string $typeObject): array
{
$application = ModelApplication::where('APP_UID', '=', $appUid)
->first();
$result = StepSupervisor::where('PRO_UID', '=', $application['PRO_UID'])->
where('STEP_TYPE_OBJ', '=', $typeObject)->
orderBy('STEP_POSITION', 'ASC')->
get()->
toArray();
return $result;
}
/**
* Get all url steps to revise.
* @param string $appUid
* @param int $delIndex
* @return array
*/
public function getAllUrlStepsToRevise(string $appUid, int $delIndex): array
{
$result = [];
$dynaformStep = $this->getStepsToRevise($appUid, 'DYNAFORM');
$inputDocumentStep = $this->getStepsToRevise($appUid, 'INPUT_DOCUMENT');
$objects = array_merge($dynaformStep, $inputDocumentStep);
usort($objects, function ($a, $b) {
return $a['STEP_POSITION'] > $b['STEP_POSITION'];
});
$i = 0;
$endPoint = '';
$uidName = '';
foreach ($objects as $step) {
if ($step['STEP_TYPE_OBJ'] === 'DYNAFORM') {
$endPoint = 'cases_StepToRevise';
$uidName = 'DYN_UID';
}
if ($step['STEP_TYPE_OBJ'] === 'INPUT_DOCUMENT') {
$endPoint = 'cases_StepToReviseInputs';
$uidName = 'INP_DOC_UID';
}
$url = "{$endPoint}?"
. "type={$step['STEP_TYPE_OBJ']}&"
. "ex={$i}&"
. "PRO_UID={$step["PRO_UID"]}&"
. "{$uidName}={$step['STEP_UID_OBJ']}&"
. "APP_UID={$appUid}&"
. "position={$step['STEP_POSITION']}&"
. "DEL_INDEX={$delIndex}";
$result[] = [
'uid' => $step['STEP_UID_OBJ'],
'type' => $step['STEP_TYPE_OBJ'],
'url' => $url
];
$i++;
}
return $result;
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace ProcessMaker\Model;
use App\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class StepSupervisor extends Model
{
use HasFactory;
protected $table = 'STEP_SUPERVISOR';
protected $primaryKey = 'STEP_UID';
public $incrementing = false;
public $timestamps = false;
}

83
workflow/engine/src/ProcessMaker/Services/Api/Cases.php Normal file → Executable file
View File

@@ -1031,7 +1031,88 @@ 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());
}
}
/**
* Verify if current user is a supervisor
*
* @url GET /:appNumber/supervisor
*
* @param int $appNumber
*
* @return boolean
* @throws RestException
*
* @access protected
* @class AccessControl {@permission PM_CASES}
*/
public function isSupervisor(int $appNumber)
{
try {
$userUid = $this->getUserId();
$cases = new BmCases();
return $cases->isSupervisor($userUid, $appNumber);
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* Assign Case
*
* @url PUT /:appUid/:usrUid/assign
*
* @param string $appUid {@min 1}{@max 32}
* @param string $usrUid {@min 1}{@max 32}
* @param int $index {@from body}
* @param string $reason {@from body}
* @param bool $sendMail {@from body}
*
* @throws RestException
*
* @access protected
* @class AccessControl {@permission PM_CASES}
*/
public function doPutAssignCase($appUid, $usrUid, $index, $reason = '', $sendMail = false)
{
try {
$cases = new BmCases();
$cases->putClaimCase($appUid, $index, $usrUid, 'Assign', $reason);
/** Add the note */
if (!empty($reason)) {
$currentUserUid = $this->getUserId();
$cases->sendMail($appUid, $currentUserUid, $reason, $sendMail, $usrUid);
}
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* Get users to reassign or assign
*
* @url GET /:task_uid/:app_uid/userstoreassign
*
* @param string $task_uid
* @param string $app_uid
*
* @return array
* @throws RestException
*
* @access protected
* @class AccessControl {@permission PM_CASES}
*/
public function usersToReasign($task_uid, $app_uid)
{
try {
$usr_uid = $this->getUserId();
$cases = new BmCases();
return $cases->usersToReassign($usr_uid, $task_uid, $app_uid);
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}

View File

@@ -531,7 +531,8 @@ Ext.onReady(function(){
},
iconCls: 'ICON_STEPS',
toggleHandler: togglePreview,
disabled: true
disabled: true,
hidden: true
}, {
id: 'informationMenu',
text: _('ID_INFORMATION'),

View File

@@ -0,0 +1,11 @@
<?php
$navbar = PmDynaform::navigationBarForStepsToRevise($_GET['APP_UID'], $_GET['INP_DOC_UID'], $_GET['DEL_INDEX']);
echo '<div class="pagedTableDefault" style="border:none;margin:0px;padding:0px;margin-right:20px;margin-top:-3px;">'
. '<div class="headerContent" style="border:none;margin:0px;padding:0px;">'
. '<div class="tableOption" style="border:none;margin:0px;padding:0px;">'
. $navbar
. '</div>'
. '</div>'
. '</div>';