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"]);
|
2014-12-07 20:29:01 +01:00
|
|
|
|
2014-12-07 19:43:48 +01:00
|
|
|
$noticable_changes = false;
|
2014-12-07 20:29:01 +01:00
|
|
|
|
2014-12-07 19:43:48 +01:00
|
|
|
$message = _("A Shift you are registered on has changed:");
|
2014-12-07 20:29:01 +01:00
|
|
|
$message .= "\n";
|
|
|
|
|
|
|
|
if ($old_shift["name"] != $new_shift["name"]) {
|
2014-12-22 20:06:37 +01:00
|
|
|
$message .= sprintf(_("* Shift type changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n";
|
|
|
|
$noticable_changes = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($old_shift["title"] != $new_shift["title"]) {
|
|
|
|
$message .= sprintf(_("* Shift title changed from %s to %s"), $old_shift["title"], $new_shift["title"]) . "\n";
|
2014-12-07 19:43:48 +01:00
|
|
|
$noticable_changes = true;
|
|
|
|
}
|
2014-12-07 20:29:01 +01:00
|
|
|
|
|
|
|
if ($old_shift["start"] != $new_shift["start"]) {
|
2015-08-26 15:00:10 +02:00
|
|
|
$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";
|
2014-12-07 19:43:48 +01:00
|
|
|
$noticable_changes = true;
|
|
|
|
}
|
2014-12-07 20:29:01 +01:00
|
|
|
|
|
|
|
if ($old_shift["end"] != $new_shift["end"]) {
|
2015-08-26 15:00:10 +02:00
|
|
|
$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";
|
2014-12-07 19:43:48 +01:00
|
|
|
$noticable_changes = true;
|
|
|
|
}
|
2014-12-07 20:29:01 +01:00
|
|
|
|
|
|
|
if ($old_shift["RID"] != $new_shift["RID"]) {
|
2014-12-07 19:43:48 +01:00
|
|
|
$message .= sprintf(_("* Shift Location changed from %s to %s"), $old_room["Name"], $new_room["Name"]) . "\n";
|
|
|
|
$noticable_changes = true;
|
|
|
|
}
|
2014-12-07 20:29:01 +01:00
|
|
|
|
|
|
|
if (! $noticable_changes) {
|
|
|
|
// There are no changes worth sending an E-Mail
|
2014-12-07 19:43:48 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-12-07 20:29:01 +01:00
|
|
|
|
2014-12-07 19:43:48 +01:00
|
|
|
$message .= "\n";
|
|
|
|
$message .= _("The updated Shift:") . "\n";
|
2014-12-07 20:29:01 +01:00
|
|
|
|
2014-12-07 19:43:48 +01:00
|
|
|
$message .= $new_shift["name"] . "\n";
|
2014-12-22 20:06:37 +01:00
|
|
|
$message .= $new_shift["title"] . "\n";
|
2015-08-26 15:00:10 +02:00
|
|
|
$message .= date("Y-m-d H:i", $new_shift["start"]) . " - " . date("H:i", $new_shift["end"]) . "\n";
|
2014-12-07 19:43:48 +01:00
|
|
|
$message .= $new_room["Name"] . "\n";
|
2014-12-07 20:29:01 +01:00
|
|
|
|
2016-09-29 09:50:31 +02:00
|
|
|
foreach ($users as $user) {
|
|
|
|
if ($user["email_shiftinfo"]) {
|
2014-12-07 20:42:54 +01:00
|
|
|
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift has changed"), $message, true);
|
2016-09-29 09:50:31 +02:00
|
|
|
}
|
|
|
|
}
|
2014-12-07 19:43:48 +01:00
|
|
|
}
|
2014-12-07 18:01:45 +01:00
|
|
|
|
2014-12-07 19:43:48 +01:00
|
|
|
function mail_shift_delete($shift) {
|
|
|
|
$users = ShiftEntries_by_shift($shift["SID"]);
|
|
|
|
$room = Room($shift["RID"]);
|
2014-12-07 20:29:01 +01:00
|
|
|
|
2014-12-07 19:43:48 +01:00
|
|
|
$message = _("A Shift you are registered on was deleted:") . "\n";
|
2014-12-07 20:29:01 +01:00
|
|
|
|
2014-12-07 19:43:48 +01:00
|
|
|
$message .= $shift["name"] . "\n";
|
2016-08-21 18:00:24 +02:00
|
|
|
$message .= $shift["title"] . "\n";
|
2015-08-26 15:00:10 +02:00
|
|
|
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
2014-12-07 19:43:48 +01:00
|
|
|
$message .= $room["Name"] . "\n";
|
2014-12-07 20:29:01 +01:00
|
|
|
|
2016-09-29 09:50:31 +02:00
|
|
|
foreach ($users as $user) {
|
|
|
|
if ($user["email_shiftinfo"]) {
|
2014-12-07 20:42:54 +01:00
|
|
|
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift was deleted"), $message, true);
|
2016-09-29 09:50:31 +02:00
|
|
|
}
|
|
|
|
}
|
2014-12-07 19:43:48 +01:00
|
|
|
}
|
2014-12-07 18:01:45 +01:00
|
|
|
|
2014-12-07 19:43:48 +01:00
|
|
|
function mail_shift_assign($user, $shift) {
|
|
|
|
if ($user["email_shiftinfo"]) {
|
|
|
|
$room = Room($shift["RID"]);
|
2014-12-07 20:29:01 +01:00
|
|
|
|
2014-12-07 19:48:54 +01:00
|
|
|
$message = _("You have been assigned to a Shift:") . "\n";
|
2014-12-07 19:43:48 +01:00
|
|
|
$message .= $shift["name"] . "\n";
|
2014-12-22 20:06:37 +01:00
|
|
|
$message .= $shift["title"] . "\n";
|
2015-08-26 15:00:10 +02:00
|
|
|
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
2014-12-07 19:43:48 +01:00
|
|
|
$message .= $room["Name"] . "\n";
|
2014-12-07 20:29:01 +01:00
|
|
|
|
2014-12-07 20:42:54 +01:00
|
|
|
engelsystem_email_to_user($user, '[engelsystem] ' . _("Assigned to Shift"), $message, true);
|
2014-12-07 19:43:48 +01:00
|
|
|
}
|
|
|
|
}
|
2014-12-07 18:01:45 +01:00
|
|
|
|
2014-12-07 19:43:48 +01:00
|
|
|
function mail_shift_removed($user, $shift) {
|
|
|
|
if ($user["email_shiftinfo"]) {
|
|
|
|
$room = Room($shift["RID"]);
|
2014-12-07 20:29:01 +01:00
|
|
|
|
2014-12-07 19:48:54 +01:00
|
|
|
$message = _("You have been removed from a Shift:") . "\n";
|
2014-12-07 19:43:48 +01:00
|
|
|
$message .= $shift["name"] . "\n";
|
2014-12-22 20:06:37 +01:00
|
|
|
$message .= $shift["title"] . "\n";
|
2015-08-26 15:00:10 +02:00
|
|
|
$message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
2014-12-07 19:43:48 +01:00
|
|
|
$message .= $room["Name"] . "\n";
|
2014-12-07 20:29:01 +01:00
|
|
|
|
2014-12-07 20:42:54 +01:00
|
|
|
engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true);
|
2014-12-07 18:01:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|