diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index d415e5f5..e5fd27ef 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -1,5 +1,6 @@ Array ( [SID] => 1 [start] => 1355958000 [end] => 1355961600 [RID] => 1 [name] => [URL] => [PSID] => [room_name] => test1 [has_special_needs] => 1 [is_full] => 0 ) - */ - $first = 15 * 60 * floor($shiftsFilter->getStartTime() / (15 * 60)); - $maxshow = ceil(($shiftsFilter->getEndTime() - $first) / (60 * 15)); - $block = []; - $todo = []; - $myrooms = $rooms; - - // delete un-selected rooms from array - foreach ($myrooms as $k => $v) { - if (array_search($v["id"], $shiftsFilter->getRooms()) === false) { - unset($myrooms[$k]); - } - // initialize $block array - $block[$v["id"]] = array_fill(0, $maxshow, 0); - } - - // calculate number of parallel shifts in each timeslot for each room - foreach ($shifts as $k => $shift) { - $rid = $shift["RID"]; - $blocks = ($shift["end"] - $shift["start"]) / (15 * 60); - $firstblock = floor(($shift["start"] - $first) / (15 * 60)); - for ($i = $firstblock; $i < $blocks + $firstblock && $i < $maxshow; $i ++) { - $block[$rid][$i] ++; - } - $shifts[$k]['own'] = in_array($shift['SID'], array_keys($ownshifts)); - } - - $shifts_table = '
- | '; - foreach ($myrooms as $key => $room) { - $rid = $room["id"]; - if (array_sum($block[$rid]) == 0) { - // do not display columns without entries - unset($block[$rid]); - unset($myrooms[$key]); - continue; - } - $colspan = call_user_func_array('max', $block[$rid]); - if ($colspan == 0) { - $colspan = 1; - } - $todo[$rid] = array_fill(0, $maxshow, $colspan); - $shifts_table .= "1) ? ' colspan="' . $colspan . '"' : '') . ">" . Room_name_render([ - 'RID' => $room['id'], - 'Name' => $room['name'] - ]) . " | \n"; - } - unset($block, $blocks, $firstblock, $colspan, $key, $room); - - $shifts_table .= "||
---|---|---|---|
"; - $shifts_table .= date('Y-m-dH:i', $thistime); - } elseif ($thistime % (60 * 60) == 0) { - $shifts_table .= " | |||
"; - $shifts_table .= date("H:i", $thistime); - } else { - $shifts_table .= " | |||
"; - } - $shifts_table .= " | "; - foreach ($myrooms as $room) { - $rid = $room["id"]; - foreach ($shifts as $shift) { - if ($shift["RID"] == $rid) { - if (floor($shift["start"] / (15 * 60)) == $thistime / (15 * 60)) { - $blocks = ($shift["end"] - $shift["start"]) / (15 * 60); - if ($blocks < 1) { - $blocks = 1; - } - - $collides = in_array($shift['SID'], array_keys($ownshifts)); - if (! $collides) { - foreach ($ownshifts as $ownshift) { - if ($ownshift['start'] >= $shift['start'] && $ownshift['start'] < $shift['end'] || $ownshift['end'] > $shift['start'] && $ownshift['end'] <= $shift['end'] || $ownshift['start'] < $shift['start'] && $ownshift['end'] > $shift['end']) { - $collides = true; - break; - } - } - } - - $is_free = false; - $shifts_row = ''; - if (in_array('admin_shifts', $privileges)) { - $shifts_row .= ''; - $shifts_table .= $shifts_row; - $shifts_table .= " | "; - // also output that shift on ical export - $ical_shifts[] = $shift; - for ($j = 0; $j < $blocks && $i + $j < $maxshow; $j ++) { - $todo[$rid][$i + $j] --; - } - } - } - } - // fill up row with empty- while ($todo[$rid][$i] -- > 0) { - $shifts_table .= ' | '; - } - } - $shifts_table .= " |
' . sprintf(_("Export of shown shifts. iCal format or JSON format available (please keep secret, otherwise reset the api key)."), page_link_to_absolute('ical') . '&key=' . $user['api_key'], page_link_to_absolute('shifts_json_export') . '&key=' . $user['api_key'], page_link_to('user_myshifts') . '&reset') . '
', 'filter' => _("Filter") ])