Attach invoice on email subscription confirmation
This commit is contained in:
parent
e5bb6030eb
commit
0b316c3980
@ -1350,6 +1350,8 @@ class Adherent extends CommonObject
|
|||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
|
$this->invoice = null; // This will contains invoice if an invoice is created
|
||||||
|
|
||||||
// Insert into bank account directlty (if option choosed for) + link to llx_subscription if option is 'bankdirect'
|
// Insert into bank account directlty (if option choosed for) + link to llx_subscription if option is 'bankdirect'
|
||||||
if ($option == 'bankdirect' && $accountid)
|
if ($option == 'bankdirect' && $accountid)
|
||||||
{
|
{
|
||||||
@ -1489,6 +1491,10 @@ class Adherent extends CommonObject
|
|||||||
$this->errors=$invoice->errors;
|
$this->errors=$invoice->errors;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->invoice = $invoice;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
@ -1524,6 +1530,11 @@ class Adherent extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
// TODO Link invoice with subscription ?
|
||||||
|
}
|
||||||
|
|
||||||
// Add payment onto invoice
|
// Add payment onto invoice
|
||||||
if (! $error && $option == 'bankviainvoice' && $accountid)
|
if (! $error && $option == 'bankviainvoice' && $accountid)
|
||||||
{
|
{
|
||||||
@ -1584,6 +1595,7 @@ class Adherent extends CommonObject
|
|||||||
// Set invoice as paid
|
// Set invoice as paid
|
||||||
$invoice->set_paid($user);
|
$invoice->set_paid($user);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
@ -1604,7 +1616,6 @@ class Adherent extends CommonObject
|
|||||||
$invoice->generateDocument($invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$invoice->generateDocument($invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($error)
|
if ($error)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -322,11 +322,15 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
|
|||||||
$error++;
|
$error++;
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If an invoice was created, it is into $object->invoice
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$db->commit();
|
// $db->commit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -334,6 +338,11 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
|
|||||||
$action = 'addsubscription';
|
$action = 'addsubscription';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
setEventMessages("SubscriptionRecorded", null, 'mesgs');
|
||||||
|
}
|
||||||
|
|
||||||
// Send email
|
// Send email
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
@ -343,12 +352,36 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
|
|||||||
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
|
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
|
||||||
$texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
|
$texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
|
||||||
|
|
||||||
$result=$object->send_an_email($texttosend,$subjecttosend,array(),array(),array(),"","",0,-1);
|
// Attach a file ?
|
||||||
|
$file='';
|
||||||
|
$listofpaths=array();
|
||||||
|
$listofnames=array();
|
||||||
|
$listofmimes=array();
|
||||||
|
if (is_object($object->invoice))
|
||||||
|
{
|
||||||
|
$invoicediroutput = $conf->facture->dir_output;
|
||||||
|
$fileparams = dol_most_recent_file($invoicediroutput . '/' . $object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+');
|
||||||
|
$file = $fileparams['fullname'];
|
||||||
|
|
||||||
|
$listofpaths=array($file);
|
||||||
|
$listofnames=array(basename($file));
|
||||||
|
$listofmimes=array(dol_mimetype($file));
|
||||||
|
}
|
||||||
|
|
||||||
|
$result=$object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofnames, $listofmimes, "", "", 0, -1);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$errmsg=$object->error;
|
$errmsg=$object->error;
|
||||||
setEventMessages($errmsg, null, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -998,7 +1031,7 @@ if ($rowid > 0)
|
|||||||
$helpcontent.='<b>'.$langs->trans("MailText").'</b>:<br>';
|
$helpcontent.='<b>'.$langs->trans("MailText").'</b>:<br>';
|
||||||
$helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
|
$helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
|
||||||
|
|
||||||
print $form->textwithpicto($tmp,$helpcontent,1,'help');
|
print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend');
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '</tbody>';
|
print '</tbody>';
|
||||||
|
|||||||
@ -148,16 +148,19 @@ class FormMail extends Form
|
|||||||
* Add a file into the list of attached files (stored in SECTION array)
|
* Add a file into the list of attached files (stored in SECTION array)
|
||||||
*
|
*
|
||||||
* @param string $path Full absolute path on filesystem of file, including file name
|
* @param string $path Full absolute path on filesystem of file, including file name
|
||||||
* @param string $file Only filename
|
* @param string $file Only filename (can be basename($path))
|
||||||
* @param string $type Mime type
|
* @param string $type Mime type (can be dol_mimetype($file))
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function add_attached_files($path,$file,$type)
|
function add_attached_files($path, $file='', $type='')
|
||||||
{
|
{
|
||||||
$listofpaths=array();
|
$listofpaths=array();
|
||||||
$listofnames=array();
|
$listofnames=array();
|
||||||
$listofmimes=array();
|
$listofmimes=array();
|
||||||
|
|
||||||
|
if (empty($file)) $file=basename($path);
|
||||||
|
if (empty($type)) $type=dol_mimetype($file);
|
||||||
|
|
||||||
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
|
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
|
||||||
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
|
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
|
||||||
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
|
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
|
||||||
|
|||||||
@ -177,3 +177,6 @@ NoVatOnSubscription=No TVA for subscriptions
|
|||||||
MEMBER_PAYONLINE_SENDEMAIL=Email to use for email warning when Dolibarr receive a confirmation of a validated payment for a subscription (Example: paymentdone@example.com)
|
MEMBER_PAYONLINE_SENDEMAIL=Email to use for email warning when Dolibarr receive a confirmation of a validated payment for a subscription (Example: paymentdone@example.com)
|
||||||
ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS=Product used for subscription line into invoice: %s
|
ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS=Product used for subscription line into invoice: %s
|
||||||
NameOrCompany=Name or company
|
NameOrCompany=Name or company
|
||||||
|
SubscriptionRecorded=Subscription recorded
|
||||||
|
NoEmailSentToMember=No email sent to member
|
||||||
|
EmailSentToMember=Email sent to member at %s
|
||||||
@ -374,6 +374,8 @@ if ($ispaymentok)
|
|||||||
if ($option == 'bankdirect') $postactionmessages[] = 'Bank record created';
|
if ($option == 'bankdirect') $postactionmessages[] = 'Bank record created';
|
||||||
if ($option == 'invoiceonly') $postactionmessages[] = 'Invoice recorded';
|
if ($option == 'invoiceonly') $postactionmessages[] = 'Invoice recorded';
|
||||||
$ispostactionok = 1;
|
$ispostactionok = 1;
|
||||||
|
|
||||||
|
// If an invoice was created, it is into $object->invoice
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,13 +397,34 @@ if ($ispaymentok)
|
|||||||
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
|
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
|
||||||
$texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
|
$texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
|
||||||
|
|
||||||
$result=$object->send_an_email($texttosend,$subjecttosend,array(),array(),array(),"","",0,-1);
|
// Attach a file ?
|
||||||
|
$file='';
|
||||||
|
$listofpaths=array();
|
||||||
|
$listofnames=array();
|
||||||
|
$listofmimes=array();
|
||||||
|
if (is_object($object->invoice))
|
||||||
|
{
|
||||||
|
$invoicediroutput = $conf->facture->dir_output;
|
||||||
|
$fileparams = dol_most_recent_file($invoicediroutput . '/' . $object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+');
|
||||||
|
$file = $fileparams['fullname'];
|
||||||
|
|
||||||
|
$listofpaths=array($file);
|
||||||
|
$listofnames=array(basename($file));
|
||||||
|
$listofmimes=array(dol_mimetype($file));
|
||||||
|
}
|
||||||
|
|
||||||
|
$result=$object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofnames, $listofmimes, "", "", 0, -1);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$errmsg=$object->error;
|
$errmsg=$object->error;
|
||||||
$postactionmessages[] = $errmsg;
|
$postactionmessages[] = $errmsg;
|
||||||
$ispostactionok = -1;
|
$ispostactionok = -1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($file) $postactionmessages[] = 'Email sent to member (with invoice document attached)';
|
||||||
|
else $postactionmessages[] = 'Email sent to member (without any attached document)';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -601,7 +624,7 @@ if ($ispaymentok)
|
|||||||
$content="";
|
$content="";
|
||||||
if (in_array('MEM', array_keys($tmptag)))
|
if (in_array('MEM', array_keys($tmptag)))
|
||||||
{
|
{
|
||||||
$url=$urlwithroot."/adherents/card_subscriptions.php?rowid=".$tmptag['MEM'];
|
$url=$urlwithroot."/adherents/subscription.php?rowid=".$tmptag['MEM'];
|
||||||
$content.='<strong>'.$companylangs->trans("PaymentSubscription")."</strong><br><br>\n";
|
$content.='<strong>'.$companylangs->trans("PaymentSubscription")."</strong><br><br>\n";
|
||||||
$content.=$companylangs->trans("MemberId").': <strong>'.$tmptag['MEM']."</strong><br>\n";
|
$content.=$companylangs->trans("MemberId").': <strong>'.$tmptag['MEM']."</strong><br>\n";
|
||||||
$content.=$companylangs->trans("Link").': <a href="'.$url.'">'.$url.'</a>'."<br>\n";
|
$content.=$companylangs->trans("Link").': <a href="'.$url.'">'.$url.'</a>'."<br>\n";
|
||||||
|
|||||||
@ -212,7 +212,7 @@ if ($PAYPALTOKEN)
|
|||||||
if (! empty($tmptag['MEM']))
|
if (! empty($tmptag['MEM']))
|
||||||
{
|
{
|
||||||
$langs->load("members");
|
$langs->load("members");
|
||||||
$url=$urlwithroot."/adherents/card_subscriptions.php?rowid=".$tmptag['MEM'];
|
$url=$urlwithroot."/adherents/subscriptions/card.php?rowid=".$tmptag['MEM'];
|
||||||
$content.=$langs->trans("PaymentSubscription")."<br>\n";
|
$content.=$langs->trans("PaymentSubscription")."<br>\n";
|
||||||
$content.=$langs->trans("MemberId").': '.$tmptag['MEM']."<br>\n";
|
$content.=$langs->trans("MemberId").': '.$tmptag['MEM']."<br>\n";
|
||||||
$content.=$langs->trans("Link").': <a href="'.$url.'">'.$url.'</a>'."<br>\n";
|
$content.=$langs->trans("Link").': <a href="'.$url.'">'.$url.'</a>'."<br>\n";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user