New: Can send email to warn when payment for subscription is payed.

This commit is contained in:
Laurent Destailleur 2013-04-06 16:14:28 +02:00
parent f22b1d3678
commit 25ec7eed6d
7 changed files with 193 additions and 34 deletions

View File

@ -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".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () {
function initemail()
{
if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\')
{
jQuery("#tremail").hide();
}
else
{
jQuery("#tremail").show();
}
}
function initfields()
{
if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\')
if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\')
{
jQuery(".drag").hide();
jQuery("#tramount").hide();
jQuery("#tredit").hide();
jQuery("#trpayment").hide();
jQuery("#tremail").hide();
}
if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\')
{
jQuery(".drag").show();
}
}
initfields();
jQuery("#MEMBER_ENABLE_PUBLIC").change(function() {
initfields();
});
})';
jQuery("#tramount").show();
jQuery("#tredit").show();
jQuery("#trpayment").show();
if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide();
else jQuery("#tremail").show();
}
}
initfields();
jQuery("#MEMBER_ENABLE_PUBLIC").change(function() { initfields(); });
jQuery("#MEMBER_NEWFORM_PAYONLINE").change(function() { initemail(); });
})';
print '</script>'."\n";
}
@ -119,7 +138,7 @@ print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
print '<td align="right">'.$langs->trans("Value").'</td>';
print "</tr>\n";
$var=true;
@ -128,14 +147,14 @@ $var=! $var;
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("EnablePublicSubscriptionForm");
print '</td><td width="60" align="right">';
print '</td><td align="right">';
print $form->selectyesno("MEMBER_ENABLE_PUBLIC",(! empty($conf->global->MEMBER_ENABLE_PUBLIC)?$conf->global->MEMBER_ENABLE_PUBLIC:0),1);
print "</td></tr>\n";
// Type
/*$var=! $var;
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr '.$bcdd[$var].'><td>';
print '<tr '.$bc[$var].' class="drag"><td>';
print $langs->trans("EnablePublicSubscriptionForm");
print '</td><td width="60" align="center">';
print $form->selectyesno("forcedate",$conf->global->MEMBER_NEWFORM_FORCETYPE,1);
@ -144,32 +163,43 @@ print "</td></tr>\n"; */
// Amount
$var=! $var;
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr '.$bcdd[$var].'><td>';
print '<tr '.$bc[$var].' id="tramount"><td>';
print $langs->trans("DefaultAmount");
print '</td><td width="60" align="right">';
print '</td><td align="right">';
print '<input type="text" id="MEMBER_NEWFORM_AMOUNT" name="MEMBER_NEWFORM_AMOUNT" size="5" value="'.(! empty($conf->global->MEMBER_NEWFORM_AMOUNT)?$conf->global->MEMBER_NEWFORM_AMOUNT:'').'">';;
print "</td></tr>\n";
// Can edit
$var=! $var;
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr '.$bcdd[$var].'><td>';
print '<tr '.$bc[$var].' id="tredit"><td>';
print $langs->trans("CanEditAmount");
print '</td><td width="60" align="right">';
print '</td><td align="right">';
print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT",(! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)?$conf->global->MEMBER_NEWFORM_EDITAMOUNT:0),1);
print "</td></tr>\n";
if (! empty($conf->paybox->enabled) || ! empty($conf->paypal->enabled))
{
// Jump to an online payment page
$var=! $var;
print '<tr '.$bc[$var].' id="trpayment"><td>';
print $langs->trans("MEMBER_NEWFORM_PAYONLINE");
print '</td><td align="right">';
$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 "</td></tr>\n";
}
if (! empty($conf->paybox->enabled) || ! empty($conf->paypal->enabled))
{
// Jump to an online payment page
$var=! $var;
print '<tr '.$bcdd[$var].'><td>';
print $langs->trans("MEMBER_NEWFORM_PAYONLINE");
print '</td><td width="60" align="right">';
$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 '<tr '.$bc[$var].' id="tremail"><td>';
print $langs->trans("MEMBER_PAYONLINE_SENDEMAIL");
print '</td><td align="right">';
print '<input type="text" id="MEMBER_PAYONLINE_SENDEMAIL" name="MEMBER_PAYONLINE_SENDEMAIL" size="24" value="'.(! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL)?$conf->global->MEMBER_PAYONLINE_SENDEMAIL:'').'">';;
print "</td></tr>\n";
}

View File

@ -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

View File

@ -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

View File

@ -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"));

View File

@ -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 '<span id="dolpaymentspan"></span>'."\n";
print '<div id="dolpaymentdiv" align="center">'."\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")."<br>\n";
if (! empty($conf->global->PAYBOX_MESSAGE_OK)) print $conf->global->PAYBOX_MESSAGE_OK;

View File

@ -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"));

View File

@ -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 '<span id="dolpaymentspan"></span>'."\n";
print '<div id="dolpaymentdiv" align="center">'."\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");