From 25ec7eed6d651ca3f2121e85ae36ede7cfa62bb1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Apr 2013 16:14:28 +0200 Subject: [PATCH] New: Can send email to warn when payment for subscription is payed. --- htdocs/adherents/admin/public.php | 78 +++++++++++++++++++++--------- htdocs/langs/en_US/members.lang | 1 + htdocs/langs/fr_FR/members.lang | 2 +- htdocs/public/paybox/paymentko.php | 26 ++++++++++ htdocs/public/paybox/paymentok.php | 50 +++++++++++++++++++ htdocs/public/paypal/paymentko.php | 25 ++++++++++ htdocs/public/paypal/paymentok.php | 45 +++++++++++++---- 7 files changed, 193 insertions(+), 34 deletions(-) diff --git a/htdocs/adherents/admin/public.php b/htdocs/adherents/admin/public.php index daa5c76554f..1bb11d41c40 100755 --- a/htdocs/adherents/admin/public.php +++ b/htdocs/adherents/admin/public.php @@ -48,11 +48,13 @@ if ($action == 'update') $amount=GETPOST('MEMBER_NEWFORM_AMOUNT'); $editamount=GETPOST('MEMBER_NEWFORM_EDITAMOUNT'); $payonline=GETPOST('MEMBER_NEWFORM_PAYONLINE'); + $email=GETPOST('MEMBER_PAYONLINE_SENDEMAIL'); $res=dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC",$public,'chaine',0,'',$conf->entity); $res=dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT",$amount,'chaine',0,'',$conf->entity); $res=dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT",$editamount,'chaine',0,'',$conf->entity); $res=dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE",$payonline,'chaine',0,'',$conf->entity); + $res=dolibarr_set_const($db, "MEMBER_PAYONLINE_SENDEMAIL",$email,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; @@ -90,22 +92,39 @@ if ($conf->use_javascript_ajax) { print "\n".''."\n"; } @@ -119,7 +138,7 @@ print ''; print ''; print ''; -print ''; +print ''; print "\n"; $var=true; @@ -128,14 +147,14 @@ $var=! $var; print ''; print '\n"; // Type /*$var=! $var; print ''; -print '\n"; */ // Amount $var=! $var; print ''; -print '\n"; // Can edit $var=! $var; print ''; -print '\n"; +if (! empty($conf->paybox->enabled) || ! empty($conf->paypal->enabled)) +{ + // Jump to an online payment page + $var=! $var; + print '\n"; +} + if (! empty($conf->paybox->enabled) || ! empty($conf->paypal->enabled)) { // Jump to an online payment page $var=! $var; - print '\n"; } diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index e1eda16c790..35848399e79 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -202,3 +202,4 @@ MembersStatisticsByProperties=Members statistics by characteristics MembersByNature=Members by nature VATToUseForSubscriptions=VAT rate to use for subscriptions NoVatOnSubscription=No TVA for subscriptions +MEMBER_PAYONLINE_SENDEMAIL=Email to warn when Dolibarr receive a confirmation of a validated payment for subscription diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index 9a047a30ae6..5cd7890df1e 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -207,4 +207,4 @@ MembersStatisticsByProperties=Statistiques des adhérents par caractéristiques MembersByNature=Adhérents par nature VATToUseForSubscriptions=Taux de TVA pour les adhésions NoVatOnSubscription=Pas de TVA sur les adhésions - +MEMBER_PAYONLINE_SENDEMAIL=Email à avertir en cas de retour de paiement validé pour une cotisation diff --git a/htdocs/public/paybox/paymentko.php b/htdocs/public/paybox/paymentko.php index 5afeab8d639..4db0684005b 100644 --- a/htdocs/public/paybox/paymentko.php +++ b/htdocs/public/paybox/paymentko.php @@ -62,6 +62,32 @@ $tracepost = ""; foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paybox'); + +// Send an email +if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=',$fulltag)) +{ + $sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile( + 'New subscription payed', + $sendto, + $from, + 'New subscription payed '.$fulltag + ); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR); + } +} + + llxHeaderPayBox($langs->trans("PaymentForm")); diff --git a/htdocs/public/paybox/paymentok.php b/htdocs/public/paybox/paymentok.php index 5553956ce82..ebd3c834d09 100644 --- a/htdocs/public/paybox/paymentok.php +++ b/htdocs/public/paybox/paymentok.php @@ -41,6 +41,15 @@ $langs->load("companies"); $langs->load("paybox"); $langs->load("paypal"); +/*$source=GETPOST('source'); +$ref=GETPOST('ref'); +$PAYBOXTOKEN=GETPOST('TOKEN'); +if (empty($PAYBOXTOKEN)) $PAYBOXTOKEN=GETPOST('token'); +$PAYBOXPAYERID=GETPOST('PAYERID'); +if (empty($PAYBOXPAYERID)) $PAYBOXPAYERID=GETPOST('PayerID'); +*/ +$PAYBOXFULLTAG=GETPOST('FULLTAG'); +if (empty($PAYBOXFULLTAG)) $PAYBOXFULLTAG=GETPOST('fulltag'); /* @@ -68,6 +77,47 @@ llxHeaderPayBox($langs->trans("PaymentForm")); print ''."\n"; print '
'."\n"; +// Get on url call +/* +$token = $PAYBOXTOKEN; +*/ +$fulltag = $PAYBOXFULLTAG; +/*$payerID = $PAYBOXPAYERID; +// Set by newpayment.php +$paymentType = $_SESSION['PaymentType']; +$currencyCodeType = $_SESSION['currencyCodeType']; +$FinalPaymentAmt = $_SESSION["Payment_Amount"]; +// From env +$ipaddress = $_SESSION['ipaddress']; + +dol_syslog("Call newpaymentok with token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag); +*/ + +// Send an email +if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=',$fulltag)) +{ + $sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile( + 'New subscription payed', + $sendto, + $from, + 'New subscription payed '.$fulltag + ); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR); + } +} + + print $langs->trans("YourPaymentHasBeenRecorded")."
\n"; if (! empty($conf->global->PAYBOX_MESSAGE_OK)) print $conf->global->PAYBOX_MESSAGE_OK; diff --git a/htdocs/public/paypal/paymentko.php b/htdocs/public/paypal/paymentko.php index 13c4718c361..c6fe53ac7b0 100755 --- a/htdocs/public/paypal/paymentko.php +++ b/htdocs/public/paypal/paymentko.php @@ -71,6 +71,31 @@ foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paypal'); +// Send an email +if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=',$fulltag)) +{ + $sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile( + 'New subscription payed', + $sendto, + $from, + 'New subscription payed '.$fulltag + ); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR); + } +} + + llxHeaderPaypal($langs->trans("PaymentForm")); diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php index 45cd6f46014..ca11bcb5422 100755 --- a/htdocs/public/paypal/paymentok.php +++ b/htdocs/public/paypal/paymentok.php @@ -81,6 +81,15 @@ if (empty($PAYPAL_API_SIGNATURE)) return -1; } +$source=GETPOST('source'); +$ref=GETPOST('ref'); +$PAYPALTOKEN=GETPOST('TOKEN'); +if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); +$PAYPALPAYERID=GETPOST('PAYERID'); +if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); +$PAYPALFULLTAG=GETPOST('FULLTAG'); +if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag'); + /* * Actions @@ -105,15 +114,6 @@ llxHeaderPaypal($langs->trans("PaymentForm")); print ''."\n"; print '
'."\n"; -$source=GETPOST('source'); -$ref=GETPOST('ref'); -$PAYPALTOKEN=GETPOST('TOKEN'); -if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); -$PAYPALPAYERID=GETPOST('PAYERID'); -if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); -$PAYPALFULLTAG=GETPOST('FULLTAG'); -if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag'); - if ($PAYPALTOKEN) { // Get on url call @@ -129,6 +129,33 @@ if ($PAYPALTOKEN) dol_syslog("Call newpaymentok with token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag); + + // Send an email + if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=',$fulltag)) + { + $sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile( + 'New subscription payed', + $sendto, + $from, + 'New subscription payed '.$fulltag + ); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR); + } + } + + + // Validate record if (! empty($paymentType)) { dol_syslog("We call GetExpressCheckoutDetails");
'.$langs->trans("Parameter").''.$langs->trans("Value").''.$langs->trans("Value").'
'; print $langs->trans("EnablePublicSubscriptionForm"); -print ''; +print ''; print $form->selectyesno("MEMBER_ENABLE_PUBLIC",(! empty($conf->global->MEMBER_ENABLE_PUBLIC)?$conf->global->MEMBER_ENABLE_PUBLIC:0),1); print "
'; +print '
'; print $langs->trans("EnablePublicSubscriptionForm"); print ''; print $form->selectyesno("forcedate",$conf->global->MEMBER_NEWFORM_FORCETYPE,1); @@ -144,32 +163,43 @@ print "
'; +print '
'; print $langs->trans("DefaultAmount"); -print ''; +print ''; print '';; print "
'; +print '
'; print $langs->trans("CanEditAmount"); -print ''; +print ''; print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT",(! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)?$conf->global->MEMBER_NEWFORM_EDITAMOUNT:0),1); print "
'; + print $langs->trans("MEMBER_NEWFORM_PAYONLINE"); + print ''; + $listofval=array(); + if (! empty($conf->paybox->enabled)) $listofval['paybox']='Paybox'; + if (! empty($conf->paypal->enabled)) $listofval['paypal']='PayPal'; + print $form->selectarray("MEMBER_NEWFORM_PAYONLINE",$listofval,(! empty($conf->global->MEMBER_NEWFORM_PAYONLINE)?$conf->global->MEMBER_NEWFORM_PAYONLINE:''),1); + print "
'; - print $langs->trans("MEMBER_NEWFORM_PAYONLINE"); - print ''; - $listofval=array(); - if (! empty($conf->paybox->enabled)) $listofval['paybox']='Paybox'; - if (! empty($conf->paypal->enabled)) $listofval['paypal']='PayPal'; - print $form->selectarray("MEMBER_NEWFORM_PAYONLINE",$listofval,(! empty($conf->global->MEMBER_NEWFORM_PAYONLINE)?$conf->global->MEMBER_NEWFORM_PAYONLINE:''),1); + print '
'; + print $langs->trans("MEMBER_PAYONLINE_SENDEMAIL"); + print ''; + print '';; print "