diff --git a/src/app/action/controllers/ActionMethodController.php b/src/app/action/controllers/ActionMethodController.php index 1c6d2221ee0c852a05fa582f75d05f82b2b270df..fe92c1cf3f1e952a168dbd9540c1afb067cb1871 100644 --- a/src/app/action/controllers/ActionMethodController.php +++ b/src/app/action/controllers/ActionMethodController.php @@ -324,6 +324,12 @@ class ActionMethodController } } + $resource = ResModel::getById(['select' => ['integrations'], 'id' => $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 (?)'], diff --git a/src/app/action/controllers/PreProcessActionController.php b/src/app/action/controllers/PreProcessActionController.php index 5504987924d59cb847ab3bde9273573e4405314d..03db6175f5ecb27df5ce750fa14a84fab9f37320 100755 --- a/src/app/action/controllers/PreProcessActionController.php +++ b/src/app/action/controllers/PreProcessActionController.php @@ -936,21 +936,26 @@ class PreProcessActionController $resourcesInformations = []; foreach ($body['resources'] as $resId) { - $resource = ResModel::getById(['resId' => $resId, 'select' => ['alt_identifier']]); + $resource = ResModel::getById(['resId' => $resId, 'select' => ['alt_identifier', 'integrations']]); if (empty($resource['alt_identifier'])) { $resource['alt_identifier'] = _UNDEFINED; } - $attachments = AttachmentModel::get([ - 'select' => [1], - 'where' => ['res_id_master = ?', 'attachment_type in (?)', 'in_signature_book = ?', 'status not in (?)'], - 'data' => [$resId, $signableAttachmentsTypes, true, ['OBS', 'DEL', 'FRZ']] - ]); - - if (empty($attachments)) { - $resourcesInformations['noAttachment'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId, 'reason' => 'noAttachmentInSignatoryBook']; + $integrations = json_decode($resource['integrations'], true); + if (!empty($integrations['inSignatureBook'])) { + $resourcesInformations['success'][] = ['res_id' => $resId]; } else { - $resourcesInformations['attachments'][] = ['res_id' => $resId]; + $attachments = AttachmentModel::get([ + 'select' => [1], + 'where' => ['res_id_master = ?', 'attachment_type in (?)', 'in_signature_book = ?', 'status not in (?)'], + 'data' => [$resId, $signableAttachmentsTypes, true, ['OBS', 'DEL', 'FRZ']] + ]); + + if (empty($attachments)) { + $resourcesInformations['error'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId, 'reason' => 'noAttachmentInSignatoryBook']; + } else { + $resourcesInformations['success'][] = ['res_id' => $resId]; + } } } diff --git a/src/app/resource/controllers/IndexingController.php b/src/app/resource/controllers/IndexingController.php index f45ba7b30a0a7fca282a7bfd6dee0cc729d08641..5a39996a909f6cb094b293470ebb5a885b09aba0 100755 --- a/src/app/resource/controllers/IndexingController.php +++ b/src/app/resource/controllers/IndexingController.php @@ -99,12 +99,15 @@ class IndexingController if (!empty($method)) { $methodResponse = ActionMethodController::$method(['resId' => $body['resource'], 'data' => $body['data'], 'note' => $body['note']]); } + if (!empty($methodResponse['errors'])) { + return $response->withStatus(400)->withJson(['errors' => $methodResponse['errors'][0]]); + } $historic = empty($methodResponse['history']) ? '' : $methodResponse['history']; ActionMethodController::terminateAction(['id' => $args['actionId'], 'resources' => [$body['resource']], 'note' => $body['note'], 'history' => $historic]); - if (!empty($methodResponses['data']) || !empty($methodResponses['errors'])) { - return $response->withJson($methodResponses); + if (!empty($methodResponse['data'])) { + return $response->withJson($methodResponse['data']); } return $response->withStatus(204); diff --git a/src/app/resource/controllers/StoreController.php b/src/app/resource/controllers/StoreController.php index fe34e32989adc5fadcb67356505d17fe29a2489a..e833b7b1ca4ab603707464c6e5206430047bcadf 100755 --- a/src/app/resource/controllers/StoreController.php +++ b/src/app/resource/controllers/StoreController.php @@ -172,6 +172,12 @@ class StoreController $externalId = json_encode($args['externalId']); } + $integrations = ['inSignatureBook' => false, 'inShipping' => false]; + if (!empty($args['integrations'])) { + $integrations['inSignatureBook'] = !empty($integrations['inSignatureBook']); + $integrations['inShipping'] = !empty($integrations['inShipping']); + } + if (!empty($args['customFields'])) { foreach ($args['customFields'] as $key => $value) { $customField = CustomFieldModel::getById(['id' => $key, 'select' => ['type']]); @@ -204,6 +210,7 @@ class StoreController 'barcode' => $args['barcode'] ?? null, 'origin' => $args['origin'] ?? null, 'custom_fields' => !empty($args['customFields']) ? json_encode($args['customFields']) : null, + 'integrations' => json_encode($integrations), 'linked_resources' => !empty($args['linkedResources']) ? json_encode($args['linkedResources']) : '[]', 'external_id' => $externalId, 'creation_date' => 'CURRENT_TIMESTAMP' diff --git a/src/frontend/app/actions/visa-send-signature-book-action/send-signature-book-action.component.ts b/src/frontend/app/actions/visa-send-signature-book-action/send-signature-book-action.component.ts index 40f4cfa1f0696c1787fdf82d4e86150eeb4c77f1..6b1f7e9004d5bc286663ef6b35caadb2ba128815 100644 --- a/src/frontend/app/actions/visa-send-signature-book-action/send-signature-book-action.component.ts +++ b/src/frontend/app/actions/visa-send-signature-book-action/send-signature-book-action.component.ts @@ -57,8 +57,8 @@ export class SendSignatureBookActionComponent implements AfterViewInit { return new Promise((resolve, reject) => { this.http.post('../../rest/resourcesList/users/' + this.data.userId + '/groups/' + this.data.groupId + '/baskets/' + this.data.basketId + '/actions/' + this.data.action.id + '/checkSignatureBook', { resources: this.data.resIds }) .subscribe((data: any) => { - if (!this.functions.empty(data.resourcesInformations.noAttachment)) { - this.resourcesError = data.resourcesInformations.noAttachment; + if (!this.functions.empty(data.resourcesInformations.error)) { + this.resourcesError = data.resourcesInformations.error; } this.noResourceToProcess = this.data.resIds.length === this.resourcesError.length; resolve(true);