diff --git a/src/app/action/controllers/ActionMethodController.php b/src/app/action/controllers/ActionMethodController.php index 3321e1401efc9cb17fd678074fce5150cbb49800..bbfdaf74460270f77d7172311387d298704b1be1 100644 --- a/src/app/action/controllers/ActionMethodController.php +++ b/src/app/action/controllers/ActionMethodController.php @@ -57,7 +57,6 @@ class ActionMethodController 'sendShippingAction' => 'createMailevaShippings', 'sendSignatureBookAction' => 'sendSignatureBook', 'continueVisaCircuitAction' => 'continueVisaCircuit', - 'rejectVisaBackToPrevious' => 'rejectVisaBackToPrevious', 'redirectInitiatorEntityAction' => 'redirectInitiatorEntityAction', 'rejectVisaBackToPreviousAction' => 'rejectVisaBackToPrevious', 'resetVisaAction' => 'resetVisa', @@ -278,18 +277,18 @@ class ActionMethodController 'item_mode' => 'cc' ], 'where' => ['item_mode = ?', 'res_id = ?'], - 'data' => ['dest', $args['resId']] + 'data' => ['dest', $args['resId']] ]); $userInfo = UserModel::getById(['select' => ['user_id'], 'id' => $destUser[0]['item_id']]); ListInstanceModel::create([ - 'res_id' => $args['resId'], - 'sequence' => 0, - 'item_id' => $userInfo['user_id'], - 'item_type' => 'user_id', - 'item_mode' => 'dest', - 'added_by_user' => $GLOBALS['userId'], - 'viewed' => 0, - 'difflist_type' => 'entity_id' + 'res_id' => $args['resId'], + 'sequence' => 0, + 'item_id' => $userInfo['user_id'], + 'item_type' => 'user_id', + 'item_mode' => 'dest', + 'added_by_user' => $GLOBALS['userId'], + 'viewed' => 0, + 'difflist_type' => 'entity_id' ]); $destUser = $userInfo['user_id']; } else { @@ -324,16 +323,16 @@ class ActionMethodController } } - $resource = ResModel::getById(['select' => ['integrations'], 'resId' => $args['resId']]); + $resource = ResModel::getById(['select' => ['integrations'], 'resId' => $args['resId']]); $integrations = json_decode($resource['integrations'], true); if (!empty($integrations['inSignatureBook'])) { return true; } $attachments = AttachmentModel::get([ - 'select' => [1], - 'where' => ['res_id_master = ?', 'attachment_type in (?)', 'in_signature_book = ?', 'status not in (?)'], - 'data' => [$args['resId'], $signableAttachmentsTypes, true, ['OBS', 'DEL', 'FRZ']] + 'select' => [1], + 'where' => ['res_id_master = ?', 'attachment_type in (?)', 'in_signature_book = ?', 'status not in (?)'], + 'data' => [$args['resId'], $signableAttachmentsTypes, true, ['OBS', 'DEL', 'FRZ']] ]); if (empty($attachments)) { return ['errors' => ['No available attachments']]; @@ -389,12 +388,12 @@ class ActionMethodController $processingUserInfo = MaarchParapheurController::getUserById(['config' => $config, 'id' => $args['data']['processingUser']]); $sendedInfo = MaarchParapheurController::sendDatas([ - 'config' => $config, - 'resIdMaster' => $args['resId'], - 'processingUser' => $args['data']['processingUser'], - 'objectSent' => 'mail', - 'userId' => $GLOBALS['userId'], - 'note' => $args['note'] ?? null + 'config' => $config, + 'resIdMaster' => $args['resId'], + 'processingUser' => $args['data']['processingUser'], + 'objectSent' => 'mail', + 'userId' => $GLOBALS['userId'], + 'note' => $args['note'] ?? null ]); if (!empty($sendedInfo['error'])) { return ['errors' => [$sendedInfo['error']]]; @@ -407,9 +406,9 @@ class ActionMethodController if (!empty($attachmentToFreeze)) { ResModel::update([ - 'set' => ['external_signatory_book_id' => $attachmentToFreeze['letterbox_coll'][$args['resId']]], + 'set' => ['external_signatory_book_id' => $attachmentToFreeze['letterbox_coll'][$args['resId']]], 'where' => ['res_id = ?'], - 'data' => [$args['resId']] + 'data' => [$args['resId']] ]); } @@ -422,11 +421,11 @@ class ActionMethodController ValidatorModel::intVal($args, ['resId']); $listInstances = ListInstanceModel::get([ - 'select' => ['listinstance_id'], - 'where' => ['res_id = ?', 'difflist_type = ?', 'process_date is not null'], - 'data' => [$args['resId'], 'VISA_CIRCUIT'], - 'orderBy' => ['listinstance_id desc'], - 'limit' => 1 + 'select' => ['listinstance_id'], + 'where' => ['res_id = ?', 'difflist_type = ?', 'process_date is not null'], + 'data' => [$args['resId'], 'VISA_CIRCUIT'], + 'orderBy' => ['listinstance_id desc'], + 'limit' => 1 ]); if (empty($listInstances[0])) { @@ -444,17 +443,15 @@ class ActionMethodController 'orderBy' => ['listinstance_id'], 'limit' => 1 ]); - if (!empty($hasPrevious)) { + if (empty($hasPrevious)) { return ['errors' => ['Workflow not yet started']]; } } - $listInstances = $listInstances[0]; - ListInstanceModel::update([ 'set' => ['process_date' => null], 'where' => ['listinstance_id = ?'], - 'data' => [$listInstances['listinstance_id']] + 'data' => [$listInstances[0]['listinstance_id']] ]); return true; @@ -617,7 +614,7 @@ class ActionMethodController foreach ($args['data']['opinionCircuit'] as $key => $instance) { if (in_array($instance['item_type'], ['user_id', 'user'])) { $user = UserModel::getById(['id' => $instance['item_id'], 'select' => ['id', 'user_id']]); - $instance['item_id'] = $user['user_id'] ?? null; + $instance['item_id'] = $user['user_id'] ?? null; $instance['item_type'] = 'user_id'; if (empty($user)) { @@ -809,7 +806,7 @@ class ActionMethodController foreach ($args['data']['opinionWorkflow'] as $key => $instance) { if (in_array($instance['item_type'], ['user_id', 'user'])) { $user = UserModel::getById(['id' => $instance['item_id'], 'select' => ['id', 'user_id']]); - $instance['item_id'] = $user['user_id'] ?? null; + $instance['item_id'] = $user['user_id'] ?? null; $instance['item_type'] = 'user_id'; if (empty($user)) { diff --git a/src/app/resource/controllers/ResourceListController.php b/src/app/resource/controllers/ResourceListController.php index fca9109a5999b645d9480c8def91a6c4d3bf0c9e..6842d92494e27665d6279b1b1c445ab2b8cb4d7c 100644 --- a/src/app/resource/controllers/ResourceListController.php +++ b/src/app/resource/controllers/ResourceListController.php @@ -462,6 +462,9 @@ class ResourceListController $historic = empty($methodResponse['history']) ? '' : $methodResponse['history']; ActionMethodController::terminateAction(['id' => $aArgs['actionId'], 'resources' => $resourcesForAction, 'basketName' => $basket['basket_name'], 'note' => $body['note'], 'history' => $historic]); + if (!empty($methodResponses['errors'])) { + return $response->withStatus(403)->withJson($methodResponses); + } if (!empty($methodResponses)) { return $response->withJson($methodResponses); }