Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // BEFORE WE CAN SAVE THIS CHANGE, WE MUST CONFIRM WE CAN ACTUALLY DO THIS SAFELY
- $errors = array();
- // 1. We have no planned rota shifts (shouldn't happen if they're leaving right?)
- $planned_shifts = Database::getRepository("Staff:ModelRotaEntry")
- ->countAfterDateForStaffMember($staff, $perform_changes_at);
- if($planned_shifts > 0)
- $errors[] = "User has planned rota shifts after leaving date.";
- // 2. We have no worked rota shifts (would not get paid!)
- $worked_shifts = Database::getRepository("Reports:ModelDailyReportRotaEntry")
- ->countAfterDateForStaffMember($staff, $perform_changes_at);
- if($worked_shifts > 0)
- $errors[] = "User has worked rota shifts after leaving date.";
- // 3. We have no planned holiday (would be processed)
- $planned_holiday = Database::getRepository("Staff:ModelHoliday")
- ->countAfterDateForStaffMember($staff, $perform_changes_at);
- if($planned_holiday > 0)
- $errors[] = "User has planned rota shifts after leaving date.";
- // 4. We have no upcoming scheduled updates (these could reactivate the user)
- $scheduled_updates = Database::getRepository("Staff:ModelScheduledUpdate")
- ->countAfterDateForStaffMember($staff, $perform_changes_at);
- if($scheduled_updates > 0)
- $errors[] = "User has scheduled updates after leaving date.";
- if(count($errors)) {
- $error_msg = "<strong>Unable to mark as left</strong><br/>" . join($errors, "<br/>");
- return Request::setResponseCode("error", $error_msg);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement