Fix default message with online payment link must be hidden when no

online payment mode exists.
This commit is contained in:
Laurent Destailleur 2018-06-27 11:34:40 +02:00
parent a076d4b461
commit 9eaca045e4
5 changed files with 46 additions and 7 deletions

View File

@ -917,7 +917,7 @@ class FormMail extends Form
}
// Complete substitution array with the url to make online payment
$paymenturl='';
$paymenturl=''; $validpaymentmethod=array();
if (empty($this->substit['__REF__']))
{
$paymenturl='';
@ -926,16 +926,27 @@ class FormMail extends Form
{
// Set the online payment url link into __ONLINE_PAYMENT_URL__ key
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
$langs->load('paypal');
$langs->loadLangs(array('paypal','other'));
$typeforonlinepayment='free';
if ($this->param["models"]=='order' || $this->param["models"]=='order_send') $typeforonlinepayment='order'; // TODO use detection on something else than template
if ($this->param["models"]=='invoice' || $this->param["models"]=='facture_send') $typeforonlinepayment='invoice'; // TODO use detection on something else than template
if ($this->param["models"]=='member') $typeforonlinepayment='member'; // TODO use detection on something else than template
$url=getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']);
$paymenturl=$url;
$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
}
var_dump($validpaymentmethod);
if (count($validpaymentmethod) > 0)
{
$this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']=($paymenturl?$langs->trans("PredefinedMailContentLink", $paymenturl):'');
$this->substit['__ONLINE_PAYMENT_URL__']=$paymenturl;
}
else
{
$this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']='';
$this->substit['__ONLINE_PAYMENT_URL__']='';
}
$this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']=($paymenturl?$langs->trans("PredefinedMailContentLink", $paymenturl):'');
$this->substit['__ONLINE_PAYMENT_URL__']=$paymenturl;
//Add lines substitution key from each line
$lines = '';

View File

@ -87,6 +87,32 @@ function payment_supplier_prepare_head(Paiement $object) {
return $head;
}
/**
* Return array of valid payment mode
*
* @param string $paymentmethod Filter on this payment method
* @return array Array of valid payment method
*/
function getValidOnlinePaymentMethods($paymentmethod='')
{
global $conf;
$validpaymentmethod=array();
if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->paypal->enabled))
{
$validpaymentmethod['paypal']='valid';
}
if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->paybox->enabled))
{
$validpaymentmethod['paybox']='valid';
}
if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled))
{
$validpaymentmethod['stripe']='valid';
}
return $validpaymentmethod;
}
/**
* Return string with full Url

View File

@ -80,8 +80,8 @@ LinkedObject=Linked object
NbOfActiveNotifications=Number of notifications (nb of recipient emails)
PredefinedMailTest=__(Hello)__\nThis is a test mail sent to __EMAIL__.\nThe two lines are separated by a carriage return.\n\n__USER_SIGNATURE__
PredefinedMailTestHtml=__(Hello)__\nThis is a <b>test</b> mail (the word test must be in bold).<br>The two lines are separated by a carriage return.<br><br>__USER_SIGNATURE__
PredefinedMailContentSendInvoice=__(Hello)__\n\nYou will find here the invoice __REF__\n\nThis is the link to make your online payment if this invoice is not already payed:\n__ONLINE_PAYMENT_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__
PredefinedMailContentSendInvoiceReminder=__(Hello)__\n\nWe would like to warn you that the invoice __REF__ seems to not be payed. So this is the invoice in attachment again, as a reminder.\n\nThis is the link to make your online payment:\n__ONLINE_PAYMENT_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__
PredefinedMailContentSendInvoice=__(Hello)__\n\nYou will find here the invoice __REF__\n\n__ONLINE_PAYMENT_TEXT_AND_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__
PredefinedMailContentSendInvoiceReminder=__(Hello)__\n\nWe would like to warn you that the invoice __REF__ seems to not be payed. So this is the invoice in attachment again, as a reminder.\n\n__ONLINE_PAYMENT_TEXT_AND_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__
PredefinedMailContentSendProposal=__(Hello)__\n\nYou will find here the commercial proposal __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__
PredefinedMailContentSendSupplierProposal=__(Hello)__\n\nYou will find here the price request __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__
PredefinedMailContentSendOrder=__(Hello)__\n\nYou will find here the order __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__
@ -91,6 +91,7 @@ PredefinedMailContentSendShipping=__(Hello)__\n\nYou will find here the shipping
PredefinedMailContentSendFichInter=__(Hello)__\n\nYou will find here the intervention __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__
PredefinedMailContentThirdparty=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__
PredefinedMailContentUser=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__
PredefinedMailContentLink=You can click on the link below to make your payment if it is not already done.<br><br>%s<br><br>
DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available.
ChooseYourDemoProfil=Choose the demo profile that best suits your needs...
ChooseYourDemoProfilMore=...or build your own profile<br>(manual module selection)

View File

@ -14,7 +14,6 @@ PaypalModeOnlyPaypal=PayPal only
ONLINE_PAYMENT_CSS_URL=Optionnal URL of CSS style sheet on online payment page
ThisIsTransactionId=This is id of transaction: <b>%s</b>
PAYPAL_ADD_PAYMENT_URL=Add the url of Paypal payment when you send a document by mail
PredefinedMailContentLink=You can click on the link below to make your payment if it is not already done.<br><br>%s<br><br>
YouAreCurrentlyInSandboxMode=You are currently in the %s "sandbox" mode
NewOnlinePaymentReceived=New online payment received
NewOnlinePaymentFailed=New online payment tried but failed

View File

@ -208,6 +208,8 @@ if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stri
$validpaymentmethod['stripe']='valid';
}
// TODO Replace previous set of $validpaymentmethod with this line:
//$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
// Check security token