From db966495b1b9f28a6e7c1710ec18e793106ebe86 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Mon, 29 Aug 2022 15:57:13 +0200 Subject: [PATCH 1/2] fix #21941 call_trigger better fix #21941 : trigger nearest the code that justify its execution --- htdocs/core/ajax/onlineSign.php | 9 +++++++++ htdocs/public/onlinesign/newonlinesign.php | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index 67c3c989a3a..3ec4cfa0f20 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -212,6 +212,15 @@ if ($action == "importSignature") { $db->commit(); $response = "success"; setEventMessages("PropalSigned", null, 'warnings'); + if (method_exists($object, 'call_trigger')) { + //customer is not a user !?! so could we use same user as validation ? + $user = new User($db); + $user->fetch($object->user_valid_id); + $result = $object->call_trigger('PROPAL_CLOSE_SIGNED', $user); + if ($result < 0) { + $error++; + } + } } else { $db->rollback(); $error++; diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index a3ad1eaf645..1d90339a0ac 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -168,6 +168,15 @@ if ($action == 'confirm_refusepropal' && $confirm == 'yes') { $message = 'refused'; setEventMessages("PropalRefused", null, 'warnings'); + if (method_exists($object, 'call_trigger')) { + //customer is not a user !?! so could we use same user as validation ? + $user = new User($db); + $user->fetch($object->user_valid_id); + $result = $object->call_trigger('PROPAL_CLOSE_REFUSED', $user); + if ($result < 0) { + $error++; + } + } } else { $db->rollback(); } @@ -459,6 +468,7 @@ if ($action == "dosign" && empty($cancel)) { print '
'; if ($message == 'refused') { print ''.$langs->trans("PropalRefused").''; + } else { print ''.$langs->trans("PropalAlreadyRefused").''; } From 8e06c988878aa83d10f8f1ad0b47f7afa3cedffc Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 3 Sep 2022 12:02:29 +0000 Subject: [PATCH 2/2] Fixing style errors. --- htdocs/public/onlinesign/newonlinesign.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index 1d90339a0ac..e379853ed91 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -468,7 +468,6 @@ if ($action == "dosign" && empty($cancel)) { print '
'; if ($message == 'refused') { print ''.$langs->trans("PropalRefused").''; - } else { print ''.$langs->trans("PropalAlreadyRefused").''; }