You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.8 KiB
PHTML

<?php
8 years ago
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"]);
8 years ago
8 years ago
$noticable_changes = false;
8 years ago
8 years ago
$message = _("A Shift you are registered on has changed:");
$message .= "\n";
8 years ago
8 years ago
if ($old_shift["name"] != $new_shift["name"]) {
$message .= sprintf(_("* Shift type changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n";
$noticable_changes = true;
}
8 years ago
8 years ago
if ($old_shift["title"] != $new_shift["title"]) {
$message .= sprintf(_("* Shift title changed from %s to %s"), $old_shift["title"], $new_shift["title"]) . "\n";
$noticable_changes = true;
}
8 years ago
8 years ago
if ($old_shift["start"] != $new_shift["start"]) {
8 years ago
$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";
8 years ago
$noticable_changes = true;
}
8 years ago
8 years ago
if ($old_shift["end"] != $new_shift["end"]) {
8 years ago
$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";
8 years ago
$noticable_changes = true;
}
8 years ago
8 years ago
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;
}
8 years ago
if (!$noticable_changes) {
8 years ago
// There are no changes worth sending an E-Mail
8 years ago
return;
8 years ago
}
8 years ago
8 years ago
$message .= "\n";
$message .= _("The updated Shift:") . "\n";
8 years ago
8 years ago
$message .= $new_shift["name"] . "\n";
$message .= $new_shift["title"] . "\n";
$message .= date("Y-m-d H:i", $new_shift["start"]) . " - " . date("H:i", $new_shift["end"]) . "\n";
$message .= $new_room["Name"] . "\n";
8 years ago
8 years ago
foreach ($users as $user) {
if ($user["email_shiftinfo"]) {
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift has changed"), $message, true);
}
}
}
8 years ago
function mail_shift_delete($shift)
{
$users = ShiftEntries_by_shift($shift["SID"]);
$room = Room($shift["RID"]);
8 years ago
8 years ago
$message = _("A Shift you are registered on was deleted:") . "\n";
8 years ago
8 years ago
$message .= $shift["name"] . "\n";
$message .= $shift["title"] . "\n";
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
$message .= $room["Name"] . "\n";
8 years ago
8 years ago
foreach ($users as $user) {
if ($user["email_shiftinfo"]) {
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift was deleted"), $message, true);
}
}
}
8 years ago
function mail_shift_assign($user, $shift)
{
if ($user["email_shiftinfo"]) {
$room = Room($shift["RID"]);
8 years ago
8 years ago
$message = _("You have been assigned to a Shift:") . "\n";
$message .= $shift["name"] . "\n";
$message .= $shift["title"] . "\n";
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
$message .= $room["Name"] . "\n";
8 years ago
8 years ago
engelsystem_email_to_user($user, '[engelsystem] ' . _("Assigned to Shift"), $message, true);
}
}
8 years ago
function mail_shift_removed($user, $shift)
{
if ($user["email_shiftinfo"]) {
$room = Room($shift["RID"]);
8 years ago
8 years ago
$message = _("You have been removed from a Shift:") . "\n";
$message .= $shift["name"] . "\n";
$message .= $shift["title"] . "\n";
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
$message .= $room["Name"] . "\n";
8 years ago
8 years ago
engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true);
}
}