From 8f033e159cc9d7277834fff39d5fbcb48b31a4f5 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Wed, 13 Nov 2024 18:25:12 +0100 Subject: [PATCH] added testmode for MaintenanceNotification --- .../MaintenanceNotification.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/application/MaintenanceNotification/MaintenanceNotification.php b/application/MaintenanceNotification/MaintenanceNotification.php index 03a0ca9eb..440928349 100644 --- a/application/MaintenanceNotification/MaintenanceNotification.php +++ b/application/MaintenanceNotification/MaintenanceNotification.php @@ -7,7 +7,7 @@ class MaintenanceNotification extends mfBaseModel { private $creator; - public function sendToRecipients() { + public function sendToRecipients($test_to_email = false) { $emails = $this->getRecipients(); if(!$emails) return true; @@ -25,9 +25,11 @@ class MaintenanceNotification extends mfBaseModel { $from = "office@xinon.at"; $from_name = "XINON"; - foreach($emails as $email) { $to = $email; + if($test_to_email) { + $to = $test_to_email; + } // check for NotificationLog $mnlog = MaintenanceNotificationLog::getFirst(["maintenancenotification_id" => $this->id, "email" => $to]); @@ -45,6 +47,10 @@ class MaintenanceNotification extends mfBaseModel { $email->send(); $this->log->info(__METHOD__.": Sending MaintenanceNotification to $to"); + if($test_to_email) { + return true; + } + $mnlog = MaintenanceNotificationLog::create([ "maintenancenotification_id" => $this->id, "email" => $to, @@ -54,6 +60,19 @@ class MaintenanceNotification extends mfBaseModel { $mnlog->save(); } + // send to xinon + $to = "wartungsverteiler.team@xinon.at"; + $body .= "\n\nPLZ Liste:\n\n"; + $body .= implode("\n", $this->getProperty("plzs")); + $email = new Emailnotification(); + $email->setSubject($subject); + $email->setHtmlBody($body); + $email->setFrom($from, $from_name); + $email->setTo($to); + $email->setHeader("X-".ucfirst(MFAPPNAME)."-mnid", $this->id); + $email->send(); + $this->log->info(__METHOD__.": Sending MaintenanceNotification to $to"); + return true; }