From bf1a8aedea619adc2e92a0a7e39a7c331112a94e Mon Sep 17 00:00:00 2001
From: Damien <damien.burel@maarch.org>
Date: Fri, 27 Nov 2020 16:29:26 +0100
Subject: [PATCH] FIX #12026 TIME 1:20 Send signature positions to MP

---
 .../controllers/MaarchParapheurController.php    | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php b/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php
index acfdb9718fb..f608a4bc70f 100755
--- a/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php
+++ b/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php
@@ -215,7 +215,21 @@ class MaarchParapheurController
         if ($aArgs['objectSent'] == 'attachment') {
             if (!empty($aArgs['steps'])) {
                 foreach ($aArgs['steps'] as $step) {
-                    $workflow[] = ['userId' => $step['externalId'], 'mode' => $step['action']];
+                    $signaturePositions = null;
+                    if (!empty($step['signaturePositions'])) {
+                        if (is_array($step['signaturePositions'])) {
+                            $valid = true;
+                            foreach ($step['signaturePositions'] as $keySP => $signaturePosition) {
+                                if (empty($signaturePosition['positionX']) || empty($signaturePosition['positionY']) || empty($signaturePosition['page'])) {
+                                    $valid = false;
+                                }
+                            }
+                            if ($valid) {
+                                $signaturePositions = $step['signaturePositions'];
+                            }
+                        }
+                    }
+                    $workflow[] = ['userId' => $step['externalId'], 'mode' => $step['action'], 'signaturePositions' => $signaturePositions];
                 }
             } else {
                 return ['error' => 'steps is empty'];
-- 
GitLab