summaryrefslogtreecommitdiff
path: root/includes/view/User_view.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-01-21 13:58:53 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2017-01-21 13:58:53 +0100
commit9a3ad8883403949a59e8935497a548ec536f1d40 (patch)
treed3c27912c925e53bc240640ccc1133d8f87f1fd3 /includes/view/User_view.php
parentf7c09cb7ff84db1004a4fa83a70735475702023f (diff)
Changed from mysqli to PDO, some refactorings, faster sql queries
Diffstat (limited to 'includes/view/User_view.php')
-rw-r--r--includes/view/User_view.php21
1 files changed, 10 insertions, 11 deletions
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index ca32b80e..832569a6 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -282,26 +282,25 @@ function Users_table_header_link($column, $label, $order_by)
function User_shift_state_render($user)
{
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
- if ($upcoming_shifts === false) {
- return false;
- }
- if (count($upcoming_shifts) == 0) {
+ if (empty($upcoming_shifts)) {
return '<span class="text-success">' . _('Free') . '</span>';
}
- if ($upcoming_shifts[0]['start'] > time()) {
- if ($upcoming_shifts[0]['start'] - time() > 3600) {
- return '<span class="text-success moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _('Next shift %c') . '</span>';
+ $nextShift = array_shift($upcoming_shifts);
+
+ if ($nextShift['start'] > time()) {
+ if ($nextShift['start'] - time() > 3600) {
+ return '<span class="text-success moment-countdown" data-timestamp="' . $nextShift['start'] . '">' . _('Next shift %c') . '</span>';
}
- return '<span class="text-warning moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _('Next shift %c') . '</span>';
+ return '<span class="text-warning moment-countdown" data-timestamp="' . $nextShift['start'] . '">' . _('Next shift %c') . '</span>';
}
- $halfway = ($upcoming_shifts[0]['start'] + $upcoming_shifts[0]['end']) / 2;
+ $halfway = ($nextShift['start'] + $nextShift['end']) / 2;
if (time() < $halfway) {
- return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _('Shift starts %c') . '</span>';
+ return '<span class="text-danger moment-countdown" data-timestamp="' . $nextShift['start'] . '">' . _('Shift starts %c') . '</span>';
}
- return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['end'] . '">' . _('Shift ends %c') . '</span>';
+ return '<span class="text-danger moment-countdown" data-timestamp="' . $nextShift['end'] . '">' . _('Shift ends %c') . '</span>';
}
/**