From b04dfcadc77d26e8863413dc4af7d05b6c98cfbe Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 4 May 2021 21:55:19 +0200 Subject: [PATCH] Add function to get html online payment link --- htdocs/core/lib/payments.lib.php | 39 ++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 494a92d33e3..90fba70464c 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -3,6 +3,7 @@ * Copyright (C) 2013 Marcos García * Copyright (C) 2018 Frédéric France * Copyright (C) 2020 Abbes Bahfir + * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,8 +27,7 @@ * @param Paiement $object Current payment object * @return array Tabs for the payment section */ -function payment_prepare_head(Paiement $object) -{ +function payment_prepare_head(Paiement $object) { global $langs, $conf; $h = 0; @@ -61,8 +61,7 @@ function payment_prepare_head(Paiement $object) * @param int $id ID of bank line * @return array Tabs for the Bankline section */ -function bankline_prepare_head($id) -{ +function bankline_prepare_head($id) { global $langs, $conf; $h = 0; @@ -96,8 +95,7 @@ function bankline_prepare_head($id) * @param Paiement $object Current payment object * @return array Tabs for the payment section */ -function payment_supplier_prepare_head(Paiement $object) -{ +function payment_supplier_prepare_head(Paiement $object) { global $langs, $conf; $h = 0; @@ -130,8 +128,7 @@ function payment_supplier_prepare_head(Paiement $object) * @param string $paymentmethod Filter on this payment method (''=none, 'paypal', ...) * @return array Array of valid payment method */ -function getValidOnlinePaymentMethods($paymentmethod = '') -{ +function getValidOnlinePaymentMethods($paymentmethod = '') { global $conf, $langs; $validpaymentmethod = array(); @@ -155,14 +152,13 @@ function getValidOnlinePaymentMethods($paymentmethod = '') } /** - * Return string with full Url + * Return string with full online payment Url * * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) * @param string $ref Ref of object * @return string Url string */ -function showOnlinePaymentUrl($type, $ref) -{ +function showOnlinePaymentUrl($type, $ref) { global $langs; // Load translation files required by the page @@ -178,6 +174,21 @@ function showOnlinePaymentUrl($type, $ref) return $out; } +/** + * Return string with HTML link for online payment + * + * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) + * @param string $ref Ref of object + * @param string $label Text or HTML tag to display, if empty it display the URL + * @return string Url string + */ +function getHtmlOnlinePaymentLink($type, $ref, $label='') { + $url = getOnlinePaymentUrl(0, $type, $ref); + $label = $label ? $label : $url; + return''.$label.''; +} + + /** * Return string with full Url * @@ -189,8 +200,7 @@ function showOnlinePaymentUrl($type, $ref) * @param string $localorexternal 0=Url for browser, 1=Url for external access * @return string Url string */ -function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_tag', $localorexternal = 0) -{ +function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_tag', $localorexternal = 0) { global $conf, $dolibarr_main_url_root; $ref = str_replace(' ', '', $ref); @@ -355,8 +365,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag * @param Object $object Object related to payment * @return void */ -function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $suffix = '', $object = null) -{ +function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $suffix = '', $object = null) { global $conf; // Juridical status