From 639f24a95b23707024c36cf8535e9b3f8210881e Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 5 Sep 2018 17:36:28 +0200 Subject: [PATCH 1/4] Add online payment link --- htdocs/don/card.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 5a9e439a9c7..d033f7b73c9 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -790,6 +790,16 @@ if (! empty($id) && $action != 'edit') // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('don')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + // Show online payment link + $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); + + if ($useonlinepayment) //$object->statut != Facture::STATUS_DRAFT && + { + print '
'."\n"; + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + print showOnlinePaymentUrl('donation', $object->ref).'
'; + } print '
'; From 6e209b550bdf0025fa76e3edb63627aaa9a7f0a3 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 5 Sep 2018 17:40:26 +0200 Subject: [PATCH 2/4] add payment link for donation --- htdocs/core/lib/payments.lib.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 98d9035112f..0f0cfc267d3 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -24,7 +24,8 @@ * @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; @@ -59,7 +60,8 @@ function payment_prepare_head(Paiement $object) { * @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; @@ -90,7 +92,7 @@ function payment_supplier_prepare_head(Paiement $object) { /** * Return array of valid payment mode * - * @param string $paymentmethod Filter on this payment method + * @param string $paymentmethod Filter on this payment method (''=none, 'paypal', ...) * @return array Array of valid payment method */ function getValidOnlinePaymentMethods($paymentmethod='') @@ -234,6 +236,24 @@ function getOnlinePaymentUrl($mode, $type, $ref='', $amount='9.99', $freetag='yo } } } + if ($type == 'donation') + { + $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=donation&ref='.($mode?'':''); + if ($mode == 1) $out.='donation_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."' + donation_ref)"; + if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); + $out.=($mode?'':''); + } + } + } // For multicompany if (! empty($out) && ! empty($conf->multicompany->enabled)) $out.="&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities From b630a9721516380b165b91616a45f99ddd983681 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 5 Sep 2018 17:41:37 +0200 Subject: [PATCH 3/4] add payment link on admin gateway --- htdocs/core/tpl/onlinepaymentlinks.tpl.php | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/onlinepaymentlinks.tpl.php b/htdocs/core/tpl/onlinepaymentlinks.tpl.php index a425055135f..a5c5ce7cf11 100644 --- a/htdocs/core/tpl/onlinepaymentlinks.tpl.php +++ b/htdocs/core/tpl/onlinepaymentlinks.tpl.php @@ -1,4 +1,4 @@ - * * This program is free software; you can redistribute it and/or modify @@ -118,6 +118,28 @@ if (! empty($conf->adherent->enabled)) } print '
'; } +if (! empty($conf->don->enabled)) +{ + print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnDonation",$servicename).':
'; + print ''.getOnlinePaymentUrl(1,'donation')."
\n"; + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) + { + $langs->load("members"); + print '
'; + print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Don")).': '; + print ''; + print ''; + if (GETPOST('generate_donation_ref')) + { + print '
-> '; + $url=getOnlinePaymentUrl(0,'donation',GETPOST('generate_donation_ref','alpha')); + print $url; + print "
\n"; + } + print '
'; + } + print '
'; +} if (! empty($conf->use_javascript_ajax)) { @@ -140,3 +162,4 @@ print info_admin($langs->trans("YouCanAddTagOnUrl")); print ''; + From 50e40669bf086a4bf00ccd321bf36a5d2f06c5e3 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 12 Sep 2018 17:24:11 +0200 Subject: [PATCH 4/4] use thirdparty --- htdocs/don/card.php | 103 +++++++++++++++++++++++++++++++++----------- 1 file changed, 77 insertions(+), 26 deletions(-) diff --git a/htdocs/don/card.php b/htdocs/don/card.php index d033f7b73c9..a8ad2008a93 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2015-2016 Alexandre Spangaro + * Copyright (C) 2018 Thibault FOUCART * * 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,23 +27,24 @@ */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (! empty($conf->projet->enabled)) +require_once DOL_DOCUMENT_ROOT . '/core/modules/dons/modules_don.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/donation.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmargin.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; +if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -$langs->load("companies"); -$langs->load("donations"); -$langs->load("bills"); +$langs->loadLangs(array("bills","companies","donations")); // File with generic data $id=GETPOST('rowid')?GETPOST('rowid','int'):GETPOST('id','int'); $action=GETPOST('action','alpha'); @@ -325,18 +327,54 @@ if ($action == 'create') print ''; print ''; - - // Date - print ''; - - // Amount - print "".''; - - print '\n"; + + // Ref + print ''; + + if (! empty($conf->societe->enabled)) { + // Thirdparty + print ''; + if ($soc->id > 0 && ! GETPOST('fac_rec','alpha')) + { + print ''; + } + else + { + print ''; + } + print '' . "\n"; + +} else { print "".''; print "".''; @@ -346,18 +384,31 @@ if ($action == 'create') // Zip / Town print ''; - // Country + // Country print ''; - print "".''; + print "".''; +} + + // Date + print ''; + + // Amount + print "".''; + + print '\n"; // Payment mode print "
'.$langs->trans("Date").''; - $form->select_date($donation_date?$donation_date:-1,'','','','',"add",1,1); - print '
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("PublicDonation").""; - print $form->selectyesno("public",isset($_POST["public"])?$_POST["public"]:1,1); - print "
' . $langs->trans('Ref') . '' . $langs->trans('Draft') . '
' . $langs->trans('Customer') . ''; + print $soc->getNomUrl(1); + print ''; + // Outstanding Bill + $outstandingBills = $soc->get_OutstandingBill(); + print ' (' . $langs->trans('CurrentOutstandingBill') . ': '; + print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency); + if ($soc->outstanding_limit != '') + { + if ($outstandingBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached")); + print ' / ' . price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency); + } + print ')'; + print ''; + print $form->select_company($soc->id, 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); + // Option to reload page to retrieve customer informations. Note, this clear other input + if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) + { + print ''; + } + print ' '.$langs->trans("AddThirdParty").''; + print '
'.$langs->trans("Company").'
'.$langs->trans("Lastname").'
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; - print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6); + print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6); print ' '; print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','state_id')); print '
'; print $form->select_country(GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
'.$langs->trans("EMail").'
'.$langs->trans("EMail").'
'.$langs->trans("Date").''; + $form->select_date($donation_date?$donation_date:-1,'','','','',"add",1,1); + print '
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("PublicDonation").""; + print $form->selectyesno("public",isset($_POST["public"])?$_POST["public"]:1,1); + print "
".$langs->trans("PaymentMode")."\n";