Skip to content

Commit

Permalink
FIX Sending email from attendee list
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed May 11, 2023
1 parent f88f5cd commit 2f6b95c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
38 changes: 23 additions & 15 deletions htdocs/core/actions_massactions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@
$oneemailperrecipient = (GETPOST('oneemailperrecipient', 'int') ? 1 : 0);

if (!$error) {
$thirdparty = new Societe($db);

$objecttmp = new $objectclass($db);

// Define object $thirdparty (Societe or User, Adherent, ConferenceOrBoothAttendee...)
$thirdparty = new Societe($db);
if ($objecttmp->element == 'expensereport') {
$thirdparty = new User($db);
}
Expand All @@ -100,28 +101,33 @@
if ($objecttmp->element == 'holiday') {
$thirdparty = new User($db);
}
if ($objecttmp->element == 'conferenceorboothattendee') {
$thirdparty = new ConferenceOrBoothAttendee($db);
}

foreach ($toselect as $toselectid) {
$objecttmp = new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use
$result = $objecttmp->fetch($toselectid);
if ($result > 0) {
$listofobjectid[$toselectid] = $toselectid;

$thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
$tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
if ($objecttmp->element == 'societe') {
$thirdpartyid = $objecttmp->id;
$tmpobjectid = $objecttmp->id;
}
if ($objecttmp->element == 'expensereport') {
$thirdpartyid = $objecttmp->fk_user_author;
$tmpobjectid = $objecttmp->fk_user_author;
}
if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
$thirdpartyid = $objecttmp->fk_member;
$tmpobjectid = $objecttmp->fk_member;
}
if ($objecttmp->element == 'holiday') {
$thirdpartyid = $objecttmp->fk_user;
$tmpobjectid = $objecttmp->fk_user;
}
if (empty($thirdpartyid)) {
$thirdpartyid = 0;
if ($objecttmp->element == 'conferenceorboothattendee') {
$tmpobjectid = $objecttmp->id;
}
if (empty($tmpobjectid)) {
$tmpobjectid = 0;
}

if ($objectclass == 'Facture') {
Expand All @@ -142,8 +148,8 @@
}
}

$listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
$listofobjectref[$thirdpartyid][$toselectid] = $objecttmp;
$listofobjectthirdparties[$tmpobjectid] = $tmpobjectid;
$listofobjectref[$tmpobjectid][$toselectid] = $objecttmp;
}
}
}
Expand Down Expand Up @@ -175,7 +181,7 @@
$massaction = 'presend';
}

// Loop on each recipient/thirdparty
// Loop on each recipient (may be a thirdparty but also a user, a conferenceorboothattendee, ...)
if (!$error) {
foreach ($listofobjectthirdparties as $thirdpartyid) {
$result = $thirdparty->fetch($thirdpartyid);
Expand All @@ -187,7 +193,7 @@
$sendto = '';
$sendtocc = '';
$sendtobcc = '';
$sendtoid = array();
//$sendtoid = array();

// Define $sendto
$tmparray = array();
Expand All @@ -202,7 +208,7 @@
$tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>';
} elseif ($val && method_exists($thirdparty, 'contact_get_property')) { // Id of contact
$tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
$sendtoid[] = $val;
//$sendtoid[] = $val;
}
}
}
Expand Down Expand Up @@ -302,6 +308,8 @@
if (count($emails_to_sends) > 0) {
$sendto = implode(',', $emails_to_sends);
}
} elseif ($objectobj->element == 'conferenceorboothattendee') {
$sendto = $objectobj->email;
} else {
$objectobj->fetch_thirdparty();
$sendto = $objectobj->thirdparty->email;
Expand Down
4 changes: 4 additions & 0 deletions htdocs/core/class/html.formmail.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,10 @@ public function get_form($addfileaction = 'addfile', $removefileaction = 'remove
$helpforsubstitution .= $langs->trans('AvailableVariables').' :<br>'."\n";
}
foreach ($this->substit as $key => $val) {
// Do not show deprecated variables into the tooltip help of substitution variables
if (in_array($key, array('__NEWREF__', '__REFCLIENT__', '__REFSUPPLIER__', '__SUPPLIER_ORDER_DATE_DELIVERY__', '__SUPPLIER_ORDER_DELAY_DELIVERY__'))) {
continue;
}
$helpforsubstitution .= $key.' -> '.$langs->trans(dol_string_nohtmltag(dolGetFirstLineOfText($val))).'<br>';
}
if (!empty($this->withsubstit)) { // Unset or set ->withsubstit=0 to disable this.
Expand Down
7 changes: 6 additions & 1 deletion htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -7747,7 +7747,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%M") : '');
$substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%S") : '');

// For backward compatibility
// For backward compatibility (deprecated)
$substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null));
$substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null);
$substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs) : '');
Expand Down Expand Up @@ -7841,6 +7841,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__CANDIDATE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : '';
$substitutionarray['__CANDIDATE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : '';
}
if (is_object($object) && $object->element == 'conferenceorboothattendee') {
$substitutionarray['__ATTENDEE_FULLNAME__'] = $object->getFullName($outputlangs);
$substitutionarray['__ATTENDEE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : '';
$substitutionarray['__ATTENDEE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : '';
}

if (is_object($object->project)) {
$substitutionarray['__PROJECT_ID__'] = (is_object($object->project) ? $object->project->id : '');
Expand Down

0 comments on commit 2f6b95c

Please sign in to comment.