From 69289f5005072c4b1bb439beb6831ef1f5c71ed0 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 26 Jan 2024 15:41:13 +0100 Subject: [PATCH 1/2] New hook to allow module show onlinepaymenturl --- htdocs/adherents/card.php | 8 ++++++++ htdocs/adherents/subscription.php | 8 ++++++++ htdocs/commande/card.php | 9 +++++++++ htdocs/compta/facture/card.php | 8 ++++++++ htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 9 ++++++++- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 9 ++++++++- htdocs/don/card.php | 8 ++++++++ 7 files changed, 57 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 1af279d33d4..7f41b76e564 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -2069,6 +2069,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Show online payment link $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox')); + $parameters = array(); + $reshook = $hookmanager->executeHooks('doShowOnlinePaymentUrl', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } else { + $useonlinepayment = $reshook; + } + if ($useonlinepayment) { print '
'; if (empty($amount)) { // Take the maximum amount among what the member is supposed to pay / has paid in the past diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 7c6647835d8..3d479cd23c6 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -825,6 +825,14 @@ if (($action != 'addsubscription' && $action != 'create_thirdparty')) { // Shon online payment link $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox')); + $parameters = array(); + $reshook = $hookmanager->executeHooks('doShowOnlinePaymentUrl', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + if (isset($hookmanager->resArray['showonlinepaymenturl'])) { + $useonlinepayment = $hookmanager->resArray['showonlinepaymenturl']; + } + } + if ($useonlinepayment) { print '
'; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index fc72d6a7f8a..cae96460a93 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -3090,6 +3090,15 @@ if ($action == 'create' && $usercancreate) { // Show online payment link $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox')); + + $parameters = array(); + $reshook = $hookmanager->executeHooks('doShowOnlinePaymentUrl', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + if (isset($hookmanager->resArray['showonlinepaymenturl'])) { + $useonlinepayment = $hookmanager->resArray['showonlinepaymenturl']; + } + } + if (getDolGlobalString('ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER')) { $useonlinepayment = 0; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 64d2f2637ae..55f4876fee2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5993,6 +5993,14 @@ if ($action == 'create') { // Show online payment link $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox')); + $parameters = array(); + $reshook = $hookmanager->executeHooks('doShowOnlinePaymentUrl', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + if (isset($hookmanager->resArray['showonlinepaymenturl'])) { + $useonlinepayment = $hookmanager->resArray['showonlinepaymenturl']; + } + } + if ($object->status != Facture::STATUS_DRAFT && $useonlinepayment) { print '
'."\n"; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 6c58f02900a..13df1c7b90c 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1111,7 +1111,7 @@ class pdf_crabe extends ModelePDFFactures protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlangsbis) { // phpcs:enable - global $conf, $mysoc; + global $conf, $mysoc, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1238,6 +1238,13 @@ class pdf_crabe extends ModelePDFFactures if (isModEnabled('paybox')) { $useonlinepayment++; } + $parameters = array(); + $reshook = $hookmanager->executeHooks('doShowOnlinePaymentUrl', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + if (isset($hookmanager->resArray['showonlinepaymenturl'])) { + $useonlinepayment += $hookmanager->resArray['showonlinepaymenturl']; + } + } } if ($object->statut != Facture::STATUS_DRAFT && $useonlinepayment) { diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 1d6b8104d87..1a3db19bab3 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1204,7 +1204,7 @@ class pdf_sponge extends ModelePDFFactures */ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlangsbis) { - global $conf, $mysoc; + global $conf, $mysoc, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1333,6 +1333,13 @@ class pdf_sponge extends ModelePDFFactures if (isModEnabled('paybox')) { $useonlinepayment++; } + $parameters = array(); + $reshook = $hookmanager->executeHooks('doShowOnlinePaymentUrl', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + if (isset($hookmanager->resArray['showonlinepaymenturl'])) { + $useonlinepayment += $hookmanager->resArray['showonlinepaymenturl']; + } + } } diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 44e5b207156..a9ffd884b5e 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -974,6 +974,14 @@ if (!empty($id) && $action != 'edit') { // Show online payment link $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox')); + $parameters = array(); + $reshook = $hookmanager->executeHooks('doShowOnlinePaymentUrl', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + if (isset($hookmanager->resArray['showonlinepaymenturl'])) { + $useonlinepayment += $hookmanager->resArray['showonlinepaymenturl']; + } + } + if ($useonlinepayment) { //$object->statut != Facture::STATUS_DRAFT && print '
'."\n"; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; From 47c98623f4a986923f93c1f00f781abcc3195e66 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 26 Jan 2024 15:58:22 +0100 Subject: [PATCH 2/2] fix php errors --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 1 + htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 13df1c7b90c..6ac14a96489 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1239,6 +1239,7 @@ class pdf_crabe extends ModelePDFFactures $useonlinepayment++; } $parameters = array(); + $action = ''; $reshook = $hookmanager->executeHooks('doShowOnlinePaymentUrl', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { if (isset($hookmanager->resArray['showonlinepaymenturl'])) { diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 1a3db19bab3..7f54da1fd99 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1334,6 +1334,7 @@ class pdf_sponge extends ModelePDFFactures $useonlinepayment++; } $parameters = array(); + $action = ''; $reshook = $hookmanager->executeHooks('doShowOnlinePaymentUrl', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { if (isset($hookmanager->resArray['showonlinepaymenturl'])) {