Added Sender to Preordernotification

This commit is contained in:
Frank Schubert
2023-01-26 20:27:59 +01:00
parent fabb46851d
commit b8d7bd3956
3 changed files with 42 additions and 5 deletions

View File

@@ -31,7 +31,34 @@
<input type="hidden" name="id" value="<?=$notification->id?>" />
<input type="hidden" name="preordercampaign_id" value="<?=$campaign->id?>" />
<h4>Empfänger</h4>
<h4>Absender</h4>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="sender_name">Name *</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="sender_name" id="sender_name" value="<?=($notification->sender_name) ? $notification->sender_name : $campaign->network->owner->getCompanyOrName()?>">
<small>Wird beim Empfänger als Absender angezeigt</small>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="sender_email">Emailadresse *</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="sender_email" id="sender_email" value="<?=($notification->sender_email) ? $notification->sender_email : $campaign->network->owner->email?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="sender_replyto">Antworten an (Reply-To):</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="sender_replyto" id="sender_replyto" value="<?=$notification->sender_replyto?>">
</div>
</div>
<hr />
<h4 class="mt-4">Empfänger</h4>
<p>Die Aussendung wird an die Kontaktemailadresse aller Bestellungen versendet. Wählen Sie folgende Konditionen aus, um die Empfänger zu beschränken:</p>
<div class="form-group row">

View File

@@ -15,8 +15,12 @@ class Preordernotification extends mfBaseModel {
public function sendToPreorder(Preorder $preorder, $email_to) {
$subject = $this->subject;
$body = $this->body_html; // TODO: Variable replacement
$from = "office@xinon.at";
$from_name = "XINON Kundenservice";
$from = $this->sender_email;
$from_name = $this->sender_name;
$reply_to = null;
if($this->sender_replyto) {
$reply_to = $this->sender_replyto;
}
$to = $preorder->email;
if($email_to) {
@@ -46,7 +50,10 @@ class Preordernotification extends mfBaseModel {
$email->setHtmlBody($body);
$email->setFrom($from, $from_name);
$email->setTo($to);
$email->setHeader("X-".MFAPPNAME."-Pnid", $this->id);
if($reply_to) {
$email->setHeader("Reply-To", $reply_to);
}
$email->setHeader("X-".ucfirst(MFAPPNAME)."-Pnid", $this->id);
if(count($attachments)) {
foreach($attachments as $file) {
$email->addAttachment($file["path"], null, $file["filename"], $file['mimetype']);

View File

@@ -234,6 +234,9 @@ class PreordernotificationController extends mfBaseController {
//var_dump($filter);
$data = [];
$data['preordercampaign_id'] = $campaign_id;
$data['sender_email'] = $r->sender_email;
$data['sender_name'] = $r->sender_name;
$data['sender_replyto'] = $r->sender_replyto;
$data['subject'] = $r->subject;
$data['body_html'] = $r->body_html;
$data['note'] = $r->note;
@@ -371,7 +374,7 @@ class PreordernotificationController extends mfBaseController {
$this->redirect("Preordernotification", "edit", ['id' => $new_id]);
}
$notification->sendToPreorder($preorder, $r->testmail_to);
$this->layout()->setFlash("Testmail versendet", "success");
$this->layout()->setFlash("Test Email erfolgreich versendet", "success");
$this->redirect("Preordernotification", "edit", ['id' => $new_id]);
}