Skip to content
Snippets Groups Projects
Commit 007377f9 authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FIX #12026 TIME 4:00 fix do not send signed document to Maarch Parapheur

parent 8fcc9328
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ use Configuration\models\ConfigurationModel; ...@@ -22,6 +22,7 @@ use Configuration\models\ConfigurationModel;
use Contact\controllers\ContactController; use Contact\controllers\ContactController;
use Contact\models\ContactModel; use Contact\models\ContactModel;
use Convert\controllers\ConvertPdfController; use Convert\controllers\ConvertPdfController;
use Convert\models\AdrModel;
use CustomField\models\CustomFieldModel; use CustomField\models\CustomFieldModel;
use Docserver\models\DocserverModel; use Docserver\models\DocserverModel;
use Docserver\models\DocserverTypeModel; use Docserver\models\DocserverTypeModel;
...@@ -446,7 +447,7 @@ class PreProcessActionController ...@@ -446,7 +447,7 @@ class PreProcessActionController
'status', 'typist', 'docserver_id', 'path', 'filename', 'creation_date', 'status', 'typist', 'docserver_id', 'path', 'filename', 'creation_date',
'validation_date', 'relation', 'origin_id' 'validation_date', 'relation', 'origin_id'
], ],
'where' => ["res_id_master = ?", "attachment_type not in (?)", "status not in ('DEL', 'OBS', 'FRZ', 'TMP')", "in_signature_book = 'true'"], 'where' => ["res_id_master = ?", "attachment_type not in (?)", "status not in ('DEL', 'OBS', 'FRZ', 'TMP', 'SIGN')", "in_signature_book = 'true'"],
'data' => [$resId, ['signed_response']] 'data' => [$resId, ['signed_response']]
]); ]);
...@@ -455,6 +456,12 @@ class PreProcessActionController ...@@ -455,6 +456,12 @@ class PreProcessActionController
'where' => ['integrations->>\'inSignatureBook\' = \'true\'', 'external_id->>\'signatureBookId\' is null', 'res_id = ?'], 'where' => ['integrations->>\'inSignatureBook\' = \'true\'', 'external_id->>\'signatureBookId\' is null', 'res_id = ?'],
'data' => [$resId] 'data' => [$resId]
]); ]);
$mainDocumentSigned = AdrModel::getConvertedDocumentById([
'select' => [1],
'resId' => $resId,
'collId' => 'letterbox_coll',
'type' => 'SIGN'
]);
$attachmentTypes = AttachmentTypeModel::get(['select' => ['type_id', 'signable']]); $attachmentTypes = AttachmentTypeModel::get(['select' => ['type_id', 'signable']]);
$attachmentTypes = array_column($attachmentTypes, 'signable', 'type_id'); $attachmentTypes = array_column($attachmentTypes, 'signable', 'type_id');
...@@ -503,7 +510,9 @@ class PreProcessActionController ...@@ -503,7 +510,9 @@ class PreProcessActionController
$additionalsInfos['noAttachment'][] = ['alt_identifier' => $noAttachmentsResource['alt_identifier'], 'res_id' => $resId, 'reason' => 'fileDoesNotExists']; $additionalsInfos['noAttachment'][] = ['alt_identifier' => $noAttachmentsResource['alt_identifier'], 'res_id' => $resId, 'reason' => 'fileDoesNotExists'];
break; break;
} }
$availableResources[] = ['resId' => $resId, 'subject' => $integratedResource[0]['subject'], 'chrono' => $integratedResource[0]['alt_identifier'], 'mainDocument' => true]; if (empty($mainDocumentSigned)) {
$availableResources[] = ['resId' => $resId, 'subject' => $integratedResource[0]['subject'], 'chrono' => $integratedResource[0]['alt_identifier'], 'mainDocument' => true];
}
} }
if (!$hasSignableAttachment && empty($integratedResource)) { if (!$hasSignableAttachment && empty($integratedResource)) {
$additionalsInfos['noAttachment'][] = ['alt_identifier' => $noAttachmentsResource['alt_identifier'], 'res_id' => $resId, 'reason' => 'noSignableAttachmentInSignatoryBook']; $additionalsInfos['noAttachment'][] = ['alt_identifier' => $noAttachmentsResource['alt_identifier'], 'res_id' => $resId, 'reason' => 'noSignableAttachmentInSignatoryBook'];
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</div> </div>
<div class="col-md-12" style="text-align: right;"> <div class="col-md-12" style="text-align: right;">
<button mat-button *ngIf="additionalsInfos.attachments.length === 1" color="primary" type="button" <button mat-button *ngIf="additionalsInfos.attachments.length === 1" color="primary" type="button"
[matMenuTriggerFor]="menu" [disabled]="!isValidParaph()">Gérer les positions de signature...</button> [matMenuTriggerFor]="menu" [disabled]="!isValidParaph()">{{'lang.manageSignaturesPositions' | translate}}</button>
<mat-menu #menu="matMenu" class="docToSignTemplateMenu"> <mat-menu #menu="matMenu" class="docToSignTemplateMenu">
<button mat-menu-item *ngFor="let resource of resourcesToSign" (click)="openSignaturePosition(resource)" <button mat-menu-item *ngFor="let resource of resourcesToSign" (click)="openSignaturePosition(resource)"
style="font-size:12px;"> style="font-size:12px;">
...@@ -38,4 +38,4 @@ ...@@ -38,4 +38,4 @@
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -51,7 +51,7 @@ export class MaarchParaphComponent implements OnInit { ...@@ -51,7 +51,7 @@ export class MaarchParaphComponent implements OnInit {
} }
isValidParaph() { isValidParaph() {
if (this.additionalsInfos.attachments.length === 0 || this.appVisaWorkflow.getWorkflow().length === 0 || this.appVisaWorkflow.checkExternalSignatoryBook().length > 0) { if (this.additionalsInfos.attachments.length === 0 || this.appVisaWorkflow.getWorkflow().length === 0 || this.appVisaWorkflow.checkExternalSignatoryBook().length > 0 || this.resourcesToSign.length === 0) {
return false; return false;
} else { } else {
return true; return true;
......
...@@ -44,6 +44,8 @@ export class SendExternalSignatoryBookActionComponent implements OnInit { ...@@ -44,6 +44,8 @@ export class SendExternalSignatoryBookActionComponent implements OnInit {
errors: any; errors: any;
mainDocumentSigned: boolean = false;
@ViewChild('noteEditor', { static: true }) noteEditor: NoteEditorComponent; @ViewChild('noteEditor', { static: true }) noteEditor: NoteEditorComponent;
@ViewChild('xParaph', { static: false }) xParaph: XParaphComponent; @ViewChild('xParaph', { static: false }) xParaph: XParaphComponent;
...@@ -63,7 +65,18 @@ export class SendExternalSignatoryBookActionComponent implements OnInit { ...@@ -63,7 +65,18 @@ export class SendExternalSignatoryBookActionComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.loading = true; this.loading = true;
if (this.data.resource.integrations['inSignatureBook']) { if (this.data.resource.integrations['inSignatureBook']) {
this.toggleDocToSign(true, this.data.resource, true); this.http.get(`../rest/resources/${this.data.resource.resId}/versionsInformations`).pipe(
tap((data: any) => {
this.mainDocumentSigned = data.SIGN.length !== 0;
if (!this.mainDocumentSigned) {
this.toggleDocToSign(true, this.data.resource, true);
}
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
} }
this.checkExternalSignatureBook(); this.checkExternalSignatureBook();
} }
...@@ -78,7 +91,7 @@ export class SendExternalSignatoryBookActionComponent implements OnInit { ...@@ -78,7 +91,7 @@ export class SendExternalSignatoryBookActionComponent implements OnInit {
checkExternalSignatureBook() { checkExternalSignatureBook() {
this.loading = true; this.loading = true;
return new Promise((resolve, reject) => { return new Promise((resolve) => {
this.http.post(`../rest/resourcesList/users/${this.data.userId}/groups/${this.data.groupId}/baskets/${this.data.basketId}/checkExternalSignatoryBook`, { resources: this.data.resIds }).pipe( this.http.post(`../rest/resourcesList/users/${this.data.userId}/groups/${this.data.groupId}/baskets/${this.data.basketId}/checkExternalSignatoryBook`, { resources: this.data.resIds }).pipe(
tap((data: any) => { tap((data: any) => {
this.additionalsInfos = data.additionalsInfos; this.additionalsInfos = data.additionalsInfos;
...@@ -143,7 +156,10 @@ export class SendExternalSignatoryBookActionComponent implements OnInit { ...@@ -143,7 +156,10 @@ export class SendExternalSignatoryBookActionComponent implements OnInit {
this.http.put(`../rest/resourcesList/integrations`, { resources: this.data.resIds, integrations: { [integrationId]: !this.data.resource.integrations[integrationId] } }).pipe( this.http.put(`../rest/resourcesList/integrations`, { resources: this.data.resIds, integrations: { [integrationId]: !this.data.resource.integrations[integrationId] } }).pipe(
tap(async () => { tap(async () => {
this.data.resource.integrations[integrationId] = !this.data.resource.integrations[integrationId]; this.data.resource.integrations[integrationId] = !this.data.resource.integrations[integrationId];
this.toggleDocToSign(this.data.resource.integrations[integrationId], this.data.resource, true);
if (!this.mainDocumentSigned) {
this.toggleDocToSign(this.data.resource.integrations[integrationId], this.data.resource, true);
}
await this.checkExternalSignatureBook(); await this.checkExternalSignatureBook();
this.changeDetectorRef.detectChanges(); this.changeDetectorRef.detectChanges();
}), }),
......
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