added testmode for MaintenanceNotification
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user