Merge branch 'fronkdev' of code.fronk.at:fronk/thetool into fronkdev

This commit is contained in:
Frank Schubert
2026-01-14 14:08:13 +01:00
2 changed files with 10 additions and 4 deletions
@@ -147,7 +147,7 @@ class ADBHausnummerModel {
$sql .= " WHERE $where"; $sql .= " WHERE $where";
if (!empty($filter['home_oaid_rimo_id'])) { if (!empty($filter['home_oaid_rimo_id']) && !$join_tables) {
$sql .= " GROUP BY Hausnummer.id"; $sql .= " GROUP BY Hausnummer.id";
} }
@@ -56,6 +56,9 @@ function sendPreorderEmail($mailtemplate, $preordercampaign, $preorder, $email_t
} }
} }
$email_to = trim($preorder->email);
if(!$email_to) return false;
$subject = $mailtemplate->getVariableReplacedSubject($replacers); $subject = $mailtemplate->getVariableReplacedSubject($replacers);
$body = '<html lang="de"><head><meta charset="utf-8" /></head><body>'; $body = '<html lang="de"><head><meta charset="utf-8" /></head><body>';
$body .= $mailtemplate->renderBody($replacers); $body .= $mailtemplate->renderBody($replacers);
@@ -71,7 +74,7 @@ function sendPreorderEmail($mailtemplate, $preordercampaign, $preorder, $email_t
$email->setBody($body); $email->setBody($body);
} }
$email->setFrom($preordercampaign->from_email, $preordercampaign->from_email_name); $email->setFrom($preordercampaign->from_email, $preordercampaign->from_email_name);
$email->setTo($preorder->email); $email->setTo($email_to);
$email->setHeader("X-".ucfirst(MFAPPNAME)."-pid", $preorder->id); $email->setHeader("X-".ucfirst(MFAPPNAME)."-pid", $preorder->id);
$email->setHeader("X-".ucfirst(MFAPPNAME)."-ps", '300-custom'); $email->setHeader("X-".ucfirst(MFAPPNAME)."-ps", '300-custom');
// add attachments // add attachments
@@ -81,12 +84,15 @@ function sendPreorderEmail($mailtemplate, $preordercampaign, $preorder, $email_t
logMessage("Adding attachment: " . $file->filename); logMessage("Adding attachment: " . $file->filename);
$email->addAttachment($file->file->getFullPath(), null, $file->filename, $file->file->mimetype ?: null); $email->addAttachment($file->file->getFullPath(), null, $file->filename, $file->file->mimetype ?: null);
} }
$email->send(); if(!$email->send()) {
logMessage("Error sending email for Preorder ID {$preorder->id}");
return false;
}
logMessage("Email sent successfully for Preorder ID: $preorder->id, Campaign: $preordercampaign->name, Type: $email_type"); logMessage("Email sent successfully for Preorder ID: $preorder->id, Campaign: $preordercampaign->name, Type: $email_type");
$psn_log = PreorderStatusnotificationLog::create([ $psn_log = PreorderStatusnotificationLog::create([
"preorder_id" => $preorder->id, "preorder_id" => $preorder->id,
"email_type" => $email_type, "email_type" => $email_type,
"email" => $preorder->email, "email" => $email_to,
]); ]);
$psn_log->save(); $psn_log->save();
} catch (Exception $e) { } catch (Exception $e) {