diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 78969a8df14..7279d5b055a 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1743,14 +1743,19 @@ else // Show links to link elements /*$linktoelem = $form->showLinkToObjectBlock($object,array('order')); if ($linktoelem) print ($somethingshown?'':'
').$linktoelem; - - // Link for paypal payment - /* - if (! empty($conf->paypal->enabled) && $object->statut != 0) { - include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php'; - print showPaypalPaymentUrl('invoice', $object->ref); - } */ + + // Shon online payment link + $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); + + if ($useonlinepayment) + { + print '
'; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + print showOnlinePaymentUrl('membersubscription', $object->ref); + } + print '
'; // List of actions on element diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 8002b33b1f6..bddb8efb50b 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -789,14 +789,10 @@ if ($rowid > 0) if ($object->statut > 0) print '"; else print ''; - print "
\n"; - print '
'; - print '
'; } } - /* * List of subscriptions */ @@ -882,24 +878,21 @@ if ($rowid > 0) { dol_print_error($db); } - - - // Link for paypal payment - if (! empty($conf->paypal->enabled)) - { - include_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; - print showPaypalPaymentUrl('membersubscription',$object->ref); - } - - // Link for stripe payment - if (! empty($conf->stripe->enabled)) - { - include_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; - print showStripePaymentUrl('membersubscription',$object->ref); - } - } + + // Shon online payment link + $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); + + if ($useonlinepayment) + { + print '
'; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + print showOnlinePaymentUrl('membersubscription', $object->ref); + } + + /* * Add new subscription form */ diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 3faa45d7d84..2689a1d93be 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -402,14 +402,8 @@ if ($rowid && $action != 'edit') // Show links to link elements /*$linktoelem = $form->showLinkToObjectBlock($object,array('order')); if ($linktoelem) print ($somethingshown?'':'
').$linktoelem; - - // Link for paypal payment - /* - if (! empty($conf->paypal->enabled) && $object->statut != 0) { - include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php'; - print showPaypalPaymentUrl('invoice', $object->ref); - } */ + print '
'; // List of actions on element diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 248bc31737d..e40070adbbc 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4307,16 +4307,15 @@ else if ($id > 0 || ! empty($ref)) $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - // Link for paypal payment - if (! empty($conf->paypal->enabled) && $object->statut != 0) { - include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php'; - print showPaypalPaymentUrl('invoice', $object->ref); - } - // Link for stripe payment - if (! empty($conf->stripe->enabled) && $object->statut != 0) { - include_once DOL_DOCUMENT_ROOT . '/stripe/lib/stripe.lib.php'; - print showStripePaymentUrl('invoice', $object->ref); + // Show online payment link + $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); + + if ($object->statut != 0 && $useonlinepayment) + { + print '
'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + print showOnlinePaymentUrl('invoice', $object->ref); } print '
'; diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php index 043778d92c3..44d5ec2ced5 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php @@ -44,7 +44,7 @@ foreach($linkedObjectBlock as $key => $objectlink) trans("RepeatableInvoice"); ?> getNomUrl(1); ?> - date,'day'); ?> + date_when,'day'); ?> rights->facture->lire) { $total = $total + $objectlink->total_ht; diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 630011ab3e0..49a1e909d91 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -88,6 +88,134 @@ function payment_supplier_prepare_head(Paiement $object) { } +/** + * Return string with full 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) +{ + global $conf, $langs; + + $langs->load("PAYMENT"); + $langs->load("paybox"); + $servicename='Online'; + + $out.=img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'
'; + $url=getOnlinePaymentUrl(0,$type,$ref); + $out.=''; + $out.=ajax_autoselect("onlinepaymenturl", 0); + return $out; +} + + +/** + * Return string with full Url + * + * @param int $mode 0=True url, 1=Url formated with colors + * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) + * @param string $ref Ref of object + * @param int $amount Amount + * @param string $freetag Free tag + * @return string Url string + */ +function getOnlinePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_free_tag') +{ + global $conf; + + $ref=str_replace(' ','',$ref); + + if ($type == 'free') + { + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?amount='.($mode?'':'').$amount.($mode?'':'').'&tag='.($mode?'':'').$freetag.($mode?'':''); + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + else $out.='&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + } + } + if ($type == 'order') + { + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=order&ref='.($mode?'':''); + if ($mode == 1) $out.='order_ref'; + if ($mode == 0) $out.=urlencode($ref); + $out.=($mode?'':''); + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + else + { + $out.='&securekey='.($mode?'':''); + if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)"; + if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); + $out.=($mode?'':''); + } + } + } + if ($type == 'invoice') + { + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'':''); + if ($mode == 1) $out.='invoice_ref'; + if ($mode == 0) $out.=urlencode($ref); + $out.=($mode?'':''); + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + else + { + $out.='&securekey='.($mode?'':''); + if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; + if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); + $out.=($mode?'':''); + } + } + } + if ($type == 'contractline') + { + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'':''); + if ($mode == 1) $out.='contractline_ref'; + if ($mode == 0) $out.=urlencode($ref); + $out.=($mode?'':''); + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + else + { + $out.='&securekey='.($mode?'':''); + if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; + if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); + $out.=($mode?'':''); + } + } + } + if ($type == 'membersubscription') + { + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'':''); + if ($mode == 1) $out.='member_ref'; + if ($mode == 0) $out.=urlencode($ref); + $out.=($mode?'':''); + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + { + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + else + { + $out.='&securekey='.($mode?'':''); + if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)"; + if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); + $out.=($mode?'':''); + } + } + } + + // For multicompany + $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities + + return $out; +} + + /** * Show footer of company in HTML pages