From 930d64b9976f32bfb848e5cadffaa45c58af14d1 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Wed, 9 Oct 2019 11:28:25 +0100
Subject: [PATCH] FIX connection with iParapheur

---
 modules/visa/class/IParapheurController.php | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/modules/visa/class/IParapheurController.php b/modules/visa/class/IParapheurController.php
index e7dca200734..a0a08e40459 100755
--- a/modules/visa/class/IParapheurController.php
+++ b/modules/visa/class/IParapheurController.php
@@ -121,12 +121,15 @@ class IParapheurController
             $b64Attachment          = base64_encode(file_get_contents($attachmentFilePath));
             $b64AnnexesLetterbox    = base64_encode(file_get_contents($annexes['letterbox']['filePath']));
 
-            $annexesXmlPostString   = '<ns:DocAnnexe> 
-                                    <ns:nom>Fichier original</ns:nom> 
-                                    <ns:fichier xm:contentType="application/pdf">' . $b64AnnexesLetterbox . '</ns:fichier> 
-                                    <ns:mimetype>application/pdf</ns:mimetype> 
+            $annexLetterboxMimeType = mime_content_type($annexes['letterbox']['filePath']);
+            if ($annexLetterboxMimeType) {
+                $annexesXmlPostString = '<ns:DocAnnexe>
+                                    <ns:nom>Fichier original</ns:nom>
+                                    <ns:fichier xm:contentType="' . $annexLetterboxMimeType . '">' . $b64AnnexesLetterbox . '</ns:fichier>
+                                    <ns:mimetype>' . $annexLetterboxMimeType . '</ns:mimetype>
                                     <ns:encoding>utf-8</ns:encoding>
                                 </ns:DocAnnexe>';
+            }
             if (!empty($annexes['attachments'])) {
                 for ($j = 0; $j < count($annexes['attachments']); $j++) {
                     $b64AnnexesAttachment = base64_encode(file_get_contents($annexes['attachments'][$j]['filePath']));
-- 
GitLab