Skip to content
Snippets Groups Projects
Verified Commit f6bcf5e9 authored by Damien's avatar Damien
Browse files

FEAT #12346 TIME 1:00 signature book action

parent 6c837690
No related branches found
No related tags found
No related merge requests found
......@@ -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 (?)'],
......
......@@ -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];
}
}
}
......
......@@ -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);
......
......@@ -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'
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment