summaryrefslogtreecommitdiff
path: root/includes/controller/public_dashboard_controller.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/controller/public_dashboard_controller.php')
-rw-r--r--includes/controller/public_dashboard_controller.php47
1 files changed, 26 insertions, 21 deletions
diff --git a/includes/controller/public_dashboard_controller.php b/includes/controller/public_dashboard_controller.php
index 7d652a64..23d5a4d6 100644
--- a/includes/controller/public_dashboard_controller.php
+++ b/includes/controller/public_dashboard_controller.php
@@ -2,25 +2,27 @@
/**
* Loads all data for the public dashboard
+ *
+ * @return array
*/
function public_dashboard_controller()
{
$stats = [
'needed-3-hours' => stats_angels_needed_three_hours(),
- 'needed-night' => stats_angels_needed_for_nightshifts(),
+ 'needed-night' => stats_angels_needed_for_nightshifts(),
'angels-working' => stats_currently_working(),
- 'hours-to-work' => stats_hours_to_work()
+ 'hours-to-work' => stats_hours_to_work()
];
-
+
$free_shifts_source = Shifts_free(time(), time() + 12 * 60 * 60);
$free_shifts = [];
foreach ($free_shifts_source as $shift) {
$free_shift = public_dashboard_controller_free_shift($shift);
- if(count($free_shift['needed_angels']) > 0) {
+ if (count($free_shift['needed_angels']) > 0) {
$free_shifts[] = $free_shift;
}
}
-
+
return [
_('Public Dashboard'),
public_dashboard_view($stats, $free_shifts)
@@ -30,41 +32,43 @@ function public_dashboard_controller()
/**
* Gathers information for free shifts to display.
*
- * @param array $shift
+ * @param array $shift
+ * @return array
*/
function public_dashboard_controller_free_shift($shift)
{
$shifttype = ShiftType($shift['shifttype_id']);
$room = Room($shift['RID']);
-
+
$free_shift = [
- 'SID' => $shift['SID'],
- 'style' => 'default',
- 'start' => date('H:i', $shift['start']),
- 'end' => date('H:i', $shift['end']),
- 'duration' => round(($shift['end'] - $shift['start']) / 3600),
+ 'SID' => $shift['SID'],
+ 'style' => 'default',
+ 'start' => date('H:i', $shift['start']),
+ 'end' => date('H:i', $shift['end']),
+ 'duration' => round(($shift['end'] - $shift['start']) / 3600),
'shifttype_name' => $shifttype['name'],
- 'title' => $shift['title'],
- 'room_name' => $room['Name'],
- 'needed_angels' => []
+ 'title' => $shift['title'],
+ 'room_name' => $room['Name'],
+ 'needed_angels' => []
];
-
+
if (time() + 3 * 60 * 60 > $shift['start']) {
$free_shift['style'] = 'warning';
}
if (time() > $shift['start']) {
$free_shift['style'] = 'danger';
}
-
+
$free_shift['needed_angels'] = public_dashboard_needed_angels($shift['NeedAngels']);
-
+
return $free_shift;
}
/**
* Gathers information for needed angels on dashboard
*
- * @param array $needed_angels
+ * @param array $needed_angels
+ * @return array
*/
function public_dashboard_needed_angels($needed_angels)
{
@@ -75,7 +79,7 @@ function public_dashboard_needed_angels($needed_angels)
$angeltype = AngelType($needed_angel['TID']);
if ($angeltype['show_on_dashboard']) {
$result[] = [
- 'need' => $need,
+ 'need' => $need,
'angeltype_name' => $angeltype['name']
];
}
@@ -86,9 +90,10 @@ function public_dashboard_needed_angels($needed_angels)
/**
* Returns url to public dashboard
+ *
+ * @return string
*/
function public_dashboard_link()
{
return page_link_to('public-dashboard');
}
-?> \ No newline at end of file