mailer functions for shift delete,assign,remove

main
Felix Favre 10 years ago
parent 5b3e5750eb
commit 8f918422f4

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

Loading…
Cancel
Save