FIX sending email on payment of registration of event

This commit is contained in:
Laurent Destailleur 2022-05-03 20:07:21 +02:00
parent 5bb2772968
commit 207373d37d
3 changed files with 20 additions and 12 deletions

View File

@ -220,7 +220,7 @@ if ($action == 'edit') {
foreach ($arrayofparameters as $constname => $val) {
if ($val['enabled']==1) {
$setupnotempty++;
print '<tr class="oddeven"><td>aa';
print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
$tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';

View File

@ -1257,9 +1257,9 @@ class FormMail extends Form
* @param string $type_template Get message for model/type=$type_template, type='all' also included.
* @param User $user Get template public or limited to this user
* @param Translate $outputlangs Output lang object
* @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found)
* @param int $id Id of template to get, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found)
* @param int $active 1=Only active template, 0=Only disabled, -1=All
* @param string $label Label of template
* @param string $label Label of template to get
* @return ModelMail|integer One instance of ModelMail or -1 if error
*/
public function getEMailTemplate($dbs, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '')

View File

@ -1271,17 +1271,21 @@ if ($ispaymentok) {
// Get email content from template
$arraydefaultmessage = null;
$labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT;
$idoftemplatetouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; // Email to send for Event organization registration
if (!empty($labeltouse)) {
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, '');
if (!empty($idoftemplatetouse)) {
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1, '');
}
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
} else {
$subject = '['.$object->ref.' - '.$outputlangs->trans("NewRegistration").']';
$msg = $outputlangs->trans("OrganizationEventPaymentOfRegistrationWasReceived");
}
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
@ -1300,7 +1304,7 @@ if ($ispaymentok) {
if ($result) {
dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment');
} else {
dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment');
dol_syslog("Failed to send EMail to ".$sendto.' - '.$mailfile->error, LOG_ERR, 0, '_payment');
}
}
}
@ -1456,14 +1460,18 @@ if ($ispaymentok) {
// Get email content from template
$arraydefaultmessage = null;
$labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT;
if (!empty($labeltouse)) {
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, '');
$idoftemplatetouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH; // Email sent after registration for a Booth
if (!empty($idoftemplatetouse)) {
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1, '');
}
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
} else {
$subject = '['.$booth->ref.' - '.$outputlangs->trans("NewRegistration").']';
$msg = $outputlangs->trans("OrganizationEventPaymentOfBoothWasReceived");
}
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty);