engelsystem/includes/mailer/shifts_mailer.php

98 lines
3.0 KiB
PHP
Raw Normal View History

2014-12-07 18:01:45 +01:00
<?php
function mail_shift_change($old_shift, $new_shift) {
$users = ShiftEntries_by_shift($old_shift["SID"]);
$old_room = Room($old_shift["RID"]);
$new_room = Room($new_shift["RID"]);
$noticable_changes = false;
$message = _("A Shift you are registered on has changed:");
$message .="\n";
if($old_shift["name"] != $new_shift["name"]) {
$message .= sprintf(_("* Shift Name changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n";
$noticable_changes = true;
}
if($old_shift["start"] != $new_shift["start"]) {
$message .= sprintf(_("* Shift Start changed from %s to %s"),date("y-m-d H:i", $old_shift["start"]), date("y-m-d H:i", $new_shift["start"])) . "\n";
$noticable_changes = true;
}
if($old_shift["end"] != $new_shift["end"]) {
$message .= sprintf(_("* Shift End changed from %s to %s"),date("y-m-d H:i", $old_shift["end"]), date("y-m-d H:i", $new_shift["end"])) . "\n";
$noticable_changes = true;
}
if($old_shift["RID"] != $new_shift["RID"]) {
$message .= sprintf(_("* Shift Location changed from %s to %s"), $old_room["Name"], $new_room["Name"]) . "\n";
$noticable_changes = true;
}
if (!$noticable_changes) {
//There are no changes worth sending an E-Mail
return;
}
$message .= "\n";
$message .= _("The updated Shift:") . "\n";
$message .= $new_shift["name"] . "\n";
$message .= date("y-m-d H:i", $new_shift["start"]) . " - " . date("H:i", $new_shift["end"]) . "\n";
$message .= $new_room["Name"] . "\n";
2014-12-07 18:01:45 +01:00
foreach ($users as $user) {
if ($user["email_shiftinfo"]) {
engelsystem_email_to_user($user, _("[Angelsystem] Your Shift has changed"), $message);
}
}
}
2014-12-07 18:01:45 +01:00
function mail_shift_delete($shift) {
2014-12-07 18:01:45 +01:00
$users = ShiftEntries_by_shift($shift["SID"]);
$room = Room($shift["RID"]);
2014-12-07 18:01:45 +01:00
$message = _("A Shift you are registered on was deleted:") . "\n";
2014-12-07 18:01:45 +01:00
$message .= $shift["name"] . "\n";
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
$message .= $room["Name"] . "\n";
foreach ($users as $user) {
if ($user["email_shiftinfo"]) {
engelsystem_email_to_user($user, _("[Angelsystem] Your Shift was deleted"), $message);
}
}
}
2014-12-07 18:01:45 +01:00
function mail_shift_assign($user, $shift) {
if ($user["email_shiftinfo"]) {
$room = Room($shift["RID"]);
2014-12-07 18:01:45 +01:00
2014-12-07 19:48:54 +01:00
$message = _("You have been assigned to a Shift:") . "\n";
$message .= $shift["name"] . "\n";
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
$message .= $room["Name"] . "\n";
2014-12-07 18:01:45 +01:00
engelsystem_email_to_user($user, _("[Angelsystem] Assigned to Shift"), $message);
}
}
2014-12-07 18:01:45 +01:00
function mail_shift_removed($user, $shift) {
if ($user["email_shiftinfo"]) {
$room = Room($shift["RID"]);
2014-12-07 18:01:45 +01:00
2014-12-07 19:48:54 +01:00
$message = _("You have been removed from a Shift:") . "\n";
$message .= $shift["name"] . "\n";
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
$message .= $room["Name"] . "\n";
2014-12-07 18:01:45 +01:00
engelsystem_email_to_user($user, _("[Angelsystem] Assigned to Shift"), $message);
2014-12-07 18:01:45 +01:00
}
}
?>