summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2016-12-28 14:53:35 +0100
committermsquare <msquare@notrademark.de>2016-12-28 14:53:35 +0100
commit4407604793e0a7b99122e306ae710304846cf3ea (patch)
tree248393d3b2d7271d823e8b4258b060e74ce05cc1
parent6c4bb0da3170ca365c6ef01991e26f26dd29fb30 (diff)
move data sorting to begin
-rw-r--r--includes/controller/rooms_controller.php6
-rw-r--r--includes/controller/users_controller.php25
-rw-r--r--includes/pages/user_shifts.php21
3 files changed, 28 insertions, 24 deletions
diff --git a/includes/controller/rooms_controller.php b/includes/controller/rooms_controller.php
index 24bf5220..a79034fb 100644
--- a/includes/controller/rooms_controller.php
+++ b/includes/controller/rooms_controller.php
@@ -43,13 +43,11 @@ function room_controller() {
$shiftsFilterRenderer = new ShiftsFilterRenderer($shiftsFilter);
$shiftsFilterRenderer->enableDaySelection($days);
- $shifts = Shifts_by_ShiftsFilter($shiftsFilter);
- $needed_angeltypes = NeededAngeltypes_by_ShiftsFilter($shiftsFilter);
- $shift_entries = ShiftEntries_by_ShiftsFilter($shiftsFilter);
+ $shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter);
return [
$room['Name'],
- Room_view($room, $shiftsFilterRenderer, new ShiftCalendarRenderer($shifts, $needed_angeltypes, $shift_entries, $shiftsFilter))
+ Room_view($room, $shiftsFilterRenderer, $shiftCalendarRenderer)
];
}
diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php
index 26ca8d00..ce7e95b2 100644
--- a/includes/controller/users_controller.php
+++ b/includes/controller/users_controller.php
@@ -1,4 +1,6 @@
<?php
+use Engelsystem\ShiftsFilter;
+use Engelsystem\ShiftCalendarRenderer;
/**
* Route user actions.
@@ -313,4 +315,27 @@ function load_user() {
return $user;
}
+function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter) {
+ $shifts = Shifts_by_ShiftsFilter($shiftsFilter);
+ $needed_angeltypes_source = NeededAngeltypes_by_ShiftsFilter($shiftsFilter);
+ $shift_entries_source = ShiftEntries_by_ShiftsFilter($shiftsFilter);
+
+ $needed_angeltypes = [];
+ $shift_entries = [];
+ foreach ($shifts as $shift) {
+ $needed_angeltypes[$shift['SID']] = [];
+ $shift_entries[$shift['SID']] = [];
+ }
+ foreach ($needed_angeltypes_source as $needed_angeltype) {
+ $needed_angeltypes[$needed_angeltype['SID']][] = $needed_angeltype;
+ }
+ foreach ($shift_entries_source as $shift_entry) {
+ $shift_entries[$shift_entry['SID']][] = $shift_entry;
+ }
+ unset($needed_angeltypes_source);
+ unset($shift_entries_source);
+
+ return new ShiftCalendarRenderer($shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
+}
+
?>
diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php
index da3c5463..3ea7309c 100644
--- a/includes/pages/user_shifts.php
+++ b/includes/pages/user_shifts.php
@@ -131,26 +131,7 @@ function view_user_shifts() {
update_ShiftsFilter($_SESSION['ShiftsFilter'], in_array('user_shifts_admin', $privileges), $days);
$shiftsFilter = $_SESSION['ShiftsFilter'];
- $shifts = Shifts_by_ShiftsFilter($shiftsFilter);
- $needed_angeltypes_source = NeededAngeltypes_by_ShiftsFilter($shiftsFilter);
- $shift_entries_source = ShiftEntries_by_ShiftsFilter($shiftsFilter);
-
- $needed_angeltypes = [];
- $shift_entries = [];
- foreach ($shifts as $shift) {
- $needed_angeltypes[$shift['SID']] = [];
- $shift_entries[$shift['SID']] = [];
- }
- foreach ($needed_angeltypes_source as $needed_angeltype) {
- $needed_angeltypes[$needed_angeltype['SID']][] = $needed_angeltype;
- }
- foreach ($shift_entries_source as $shift_entry) {
- $shift_entries[$shift_entry['SID']][] = $shift_entry;
- }
- unset($needed_angeltypes_source);
- unset($shift_entries_source);
-
- $shiftCalendarRenderer = new ShiftCalendarRenderer($shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
+ $shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter);
if ($user['api_key'] == "") {
User_reset_api_key($user, false);