From 440f6b9d944f529ae4072d11a0613afe1ebb0c04 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Tue, 5 Nov 2019 15:39:17 +0100
Subject: [PATCH] FEAT #11691 TIME 0:05 refactoring attachments

---
 modules/visa/class/class_modules_tools_Abstract.php | 2 +-
 modules/visa/js/functions.js                        | 6 ++----
 modules/visa/sign_file.php                          | 3 +--
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/modules/visa/class/class_modules_tools_Abstract.php b/modules/visa/class/class_modules_tools_Abstract.php
index 96fa00f5080..b4ed9ad244c 100755
--- a/modules/visa/class/class_modules_tools_Abstract.php
+++ b/modules/visa/class/class_modules_tools_Abstract.php
@@ -846,7 +846,7 @@ abstract class visa_Abstract extends Database
             if ($pdf_exist == false) {
                 $collIdConv = ($from_res_attachment) ? 'attachments_coll' : 'letterbox_coll';
                 
-                $viewLinkHtml = '<a id="gen_'.$idFile.'" style="cursor:pointer;" title="'._GENERATE_PDF .'" target="_blank" onclick="generatePdf(\''.$idFile.'\',\''.$collIdConv.'\',\'false\')">'
+                $viewLinkHtml = '<a id="gen_'.$idFile.'" style="cursor:pointer;" title="'._GENERATE_PDF .'" target="_blank" onclick="generatePdf(\''.$idFile.'\',\''.$collIdConv.'\')">'
                     .'<i id="spinner_'.$idFile.'" class="fa fa-sync-alt fa-2x" title="'._GENERATE_PDF.'"></i>'
                     .'</a>';
             } else {
diff --git a/modules/visa/js/functions.js b/modules/visa/js/functions.js
index 1999dd07191..1ce45cc7305 100755
--- a/modules/visa/js/functions.js
+++ b/modules/visa/js/functions.js
@@ -391,7 +391,7 @@ function selectAllPrintFolder() {
     }
 }
 
-function generatePdf(resId, collId, isVersion) {
+function generatePdf(resId, collId) {
     $j("#spinner_"+resId).addClass( "fa-spin" );
     $j.ajax({
         url: '?display=true&module=visa&page=generatePdf',
@@ -399,9 +399,7 @@ function generatePdf(resId, collId, isVersion) {
         dataType : 'json',
         data: {
             res_id : resId,
-            coll_id : collId,
-            is_version : isVersion,
-
+            coll_id : collId
         },
         success: function(result) {
             if (result.status == "0") {
diff --git a/modules/visa/sign_file.php b/modules/visa/sign_file.php
index fe2c66aa885..de3eb82f579 100755
--- a/modules/visa/sign_file.php
+++ b/modules/visa/sign_file.php
@@ -82,12 +82,11 @@ if (!empty($_REQUEST['id']) && !empty($_REQUEST['collId'])) {
             $db->query("update res_letterbox SET departure_date = ? where res_id = ?", array($date,$line->res_id_master));
         }
 
-        $isVersion = false;
         $attachResId = $line->res_id;
         
         $convertedAttachment =  \Convert\controllers\ConvertPdfController::getConvertedPdfById(['select' => ['docserver_id', 'path', 'filename'], 'resId' => $attachResId, 'collId' => 'attachments_coll']);
         if (!empty($convertedAttachment['errors'])) {
-            echo "{\"status\":1, \"error\" : \""._ATTACH_PDF_NOT_FOUND . ": {$attachResId}, version : {$isVersion}\"}";
+            echo "{\"status\":1, \"error\" : \""._ATTACH_PDF_NOT_FOUND . ": {$attachResId}, version : false\"}";
             exit;
         }
 
-- 
GitLab