diff --git a/src/app/action/controllers/PreProcessActionController.php b/src/app/action/controllers/PreProcessActionController.php index d68599e74a765f5db58e5322d8a4d964f63ab080..31851fd86b423c72dd0cd3e14883a4f6b90fc460 100755 --- a/src/app/action/controllers/PreProcessActionController.php +++ b/src/app/action/controllers/PreProcessActionController.php @@ -1235,67 +1235,6 @@ class PreProcessActionController return $response->withJson(['resourcesInformations' => $resourcesInformation]); } - public function checkValidateParallelOpinionDiffusion(Request $request, Response $response, array $args) - { - $body = $request->getParsedBody(); - - if (!Validator::arrayType()->notEmpty()->validate($body['resources'])) { - return $response->withStatus(400)->withJson(['errors' => 'Body resources is empty or not an array']); - } - - $errors = ResourceListController::listControl(['groupId' => $args['groupId'], 'userId' => $args['userId'], 'basketId' => $args['basketId'], 'currentUserId' => $GLOBALS['id']]); - if (!empty($errors['errors'])) { - return $response->withStatus($errors['code'])->withJson(['errors' => $errors['errors']]); - } - - $body['resources'] = array_slice($body['resources'], 0, 500); - if (!ResController::hasRightByResId(['resId' => $body['resources'], 'userId' => $GLOBALS['id']])) { - return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); - } - - $resourcesInformation = []; - foreach ($body['resources'] as $resId) { - $resource = ResModel::getById(['resId' => $resId, 'select' => ['alt_identifier', 'opinion_limit_date']]); - - if (empty($resource['alt_identifier'])) { - $resource['alt_identifier'] = _UNDEFINED; - } - - if (empty($resource['opinion_limit_date'])) { - return $response->withStatus(400)->withJson(['errors' => 'No opinion limit date for resource ' . $resource['alt_identifier']]); - } - - $opinionNote = NoteModel::get([ - 'where' => ['identifier = ?', "note_text ilike '[" . _TO_AVIS . "]%'"], - 'data' => [$resId] - ]); - - if (empty($opinionNote)) { - return $response->withStatus(400)->withJson(['errors' => 'No opinion note for resource ' . $resource['alt_identifier']]); - } - - $isSignatory = ListInstanceModel::get([ - 'select' => [1], - 'where' => ['res_id = ?', 'difflist_type = ?', 'process_date is null', 'item_mode in (?)'], - 'data' => [$resId, 'entity_id', ['avis', 'avis_copy', 'avis_info']], - 'orderBy' => ['listinstance_id'], - 'limit' => 1 - ]); - if (empty($isSignatory[0])) { - $hasCircuit = ListInstanceModel::get(['select' => [1], 'where' => ['res_id = ?', 'difflist_type = ?'], 'data' => [$resId, 'entity_id']]); - if (!empty($hasCircuit)) { - $resourcesInformation['error'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId, 'reason' => 'endedCircuit']; - } else { - $resourcesInformation['error'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId, 'reason' => 'noCircuitAvailable']; - } - } else { - $resourcesInformation['success'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId]; - } - } - - return $response->withJson(['resourcesInformations' => $resourcesInformation]); - } - public function isDestinationChanging(Request $request, Response $response, array $args) { if (!ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) {