From 7671ccefcabe767fb7866d5c14900eea4ea5ea36 Mon Sep 17 00:00:00 2001
From: Damien <damien.burel@maarch.org>
Date: Tue, 2 Apr 2019 11:17:55 +0200
Subject: [PATCH] FIX Unlock signature book

---
 src/app/attachment/controllers/AttachmentController.php | 2 +-
 src/app/attachment/models/AttachmentModelAbstract.php   | 2 +-
 src/frontend/app/signature-book.component.ts            | 5 +++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/app/attachment/controllers/AttachmentController.php b/src/app/attachment/controllers/AttachmentController.php
index 42f0ce13c15..6791f09763e 100755
--- a/src/app/attachment/controllers/AttachmentController.php
+++ b/src/app/attachment/controllers/AttachmentController.php
@@ -477,7 +477,7 @@ class AttachmentController
         return ['encodedDocument' => $encodedDocument, 'fileName' => $fileName];
     }
 
-    public function generateAttachForMailing(array $aArgs)
+    public static function generateAttachForMailing(array $aArgs)
     {
         $attachments = AttachmentModel::getOnView([
             'select'    => ['*'],
diff --git a/src/app/attachment/models/AttachmentModelAbstract.php b/src/app/attachment/models/AttachmentModelAbstract.php
index aa24e5fdeaf..ecea1ccc8b5 100755
--- a/src/app/attachment/models/AttachmentModelAbstract.php
+++ b/src/app/attachment/models/AttachmentModelAbstract.php
@@ -95,7 +95,7 @@ abstract class AttachmentModelAbstract
                 'doc_date as update_date', 'validation_date as return_date', 'effective_date as real_return_date',
                 'u.firstname as firstname_updated', 'u.lastname as lastname_updated', 'relation', 'docserver_id', 'path',
                 'filename', 'fingerprint', 'filesize', 'label_status as status', 'attachment_type', 'dest_contact_id',
-                'dest_address_id', 'ut.firstname as firstname_typist', 'ut.lastname as lastname_typist'
+                'dest_address_id', 'ut.firstname as firstname_typist', 'ut.lastname as lastname_typist', 'in_signature_book', 'in_send_attach'
             ],
             'table'     => ['res_view_attachments', 'users ut', 'status', 'users u'],
             'left_join' => ['res_view_attachments.typist = ut.user_id', 'res_view_attachments.status = status.id', 'res_view_attachments.updated_by = u.user_id'],
diff --git a/src/frontend/app/signature-book.component.ts b/src/frontend/app/signature-book.component.ts
index 1d6d4327fff..bdc5166f9c0 100755
--- a/src/frontend/app/signature-book.component.ts
+++ b/src/frontend/app/signature-book.component.ts
@@ -205,7 +205,6 @@ export class SignatureBookComponent implements OnInit {
         }
 
         if (c > 0) { // This (if)line is added because of manage action behaviour (processAfterAction is called twice)
-            unlockDocument(this.resId);
             if (idToGo >= 0) {
                 $j("#send").removeAttr("disabled");
                 $j("#send").css("opacity", "1");
@@ -485,7 +484,9 @@ export class SignatureBookComponent implements OnInit {
         this.http.put('../../rest/resourcesList/users/' + this.userId + '/groups/' + this.groupId + '/baskets/' + this.basketId + '/unlock', { resources: [this.resId] })
             .subscribe((data: any) => {
                 window.location.href = 'index.php?page=view_baskets&module=basket&basketId='+this.basketId+'&userId='+this.userId+'&groupIdSer='+this.groupId+'&backToBasket=true';
-            }, (err: any) => { });
+            }, (err: any) => {
+                window.location.href = 'index.php?page=view_baskets&module=basket&basketId='+this.basketId+'&userId='+this.userId+'&groupIdSer='+this.groupId+'&backToBasket=true';
+            });
     }
 
     backToDetails() {
-- 
GitLab