From b3df2288456eb47e108230fcb486bcf47a5c34f5 Mon Sep 17 00:00:00 2001 From: Philip Häusler Date: Wed, 12 Dec 2012 22:56:51 +0100 Subject: #77 bugblue-one-day-calendar-layout-patch --- includes/pages/user_shifts.php | 141 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 140 insertions(+), 1 deletion(-) (limited to 'includes/pages/user_shifts.php') diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index 785fc8ab..9a48c4e7 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -325,7 +325,146 @@ function view_user_shifts() { $shifts_table = ""; $row_count = 0; - foreach ($shifts as $shift) { + //qqqq + /* + [0] => Array + ( + [SID] => 1 + [start] => 1355958000 + [end] => 1355961600 + [RID] => 1 + [name] => + [URL] => + [PSID] => + [room_name] => test1 + ) + */ + if(count($_SESSION['user_shifts']['days'])==1) { + $myrooms=$rooms; + foreach($myrooms as $k => $v) { + if(array_search($v["id"],$_SESSION['user_shifts']['rooms'])===FALSE) + unset($myrooms[$k]); + } + $first=date("U",strtotime($_SESSION['user_shifts']['days'][0]." 00:00:00")); + $last=date("U",strtotime($_SESSION['user_shifts']['days'][0]." 23:59:59")); + $maxshow=24*4; + $block=array(); + foreach($myrooms as $room) { + $rid=$room["id"]; + foreach($shifts as $shift) { + if($shift["RID"]==$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_table=""; + foreach($myrooms as $room) { + $rid=$room["id"]; + $colspan=1; + foreach($block[$rid] as $max) if($max>$colspan) $colspan=$max; + for($i=0;$i<$maxshow;$i++) + $todo[$rid][$i]=$colspan; + $shifts_table.="\n"; + } + $shifts_table.=""; + for($i=0;$i<24*4;$i++) { + $thistime=$first+($i*15*60); + if($thistime%(60*60)==0) { + $shifts_table.=""; + } else { + $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; + // qqqqqq + $is_free = false; + $shifts_row=""; + if (in_array('admin_shifts', $privileges)) + $shifts_row .= ' [edit][x]'; + $shifts_row.= '
'; + $shift_has_special_needs = 0 < sql_num_query("SELECT `id` FROM `NeededAngelTypes` WHERE `shift_id` = " . $shift['SID']); + $query = "SELECT * + FROM `NeededAngelTypes` + JOIN `AngelTypes` + ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`) + WHERE "; + if ($shift_has_special_needs) + $query .= "`shift_id` = " . sql_escape($shift['SID']); + else + $query .= "`room_id` = " . sql_escape($shift['RID']); + $query .= " AND `count` > 0 + AND `angel_type_id` IN (" . implode(',', $_SESSION['user_shifts']['types']) . ") + ORDER BY `AngelTypes`.`name`"; + $angeltypes = sql_select($query); + + if (count($angeltypes) > 0) { + $my_shift = sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift['SID']) . " AND `UID`=" . sql_escape($user['UID']) . " LIMIT 1") > 0; + foreach ($angeltypes as $angeltype) { + $entries = sql_select("SELECT * FROM `ShiftEntry` JOIN `User` ON (`ShiftEntry`.`UID` = `User`.`UID`) WHERE `SID`=" . sql_escape($shift['SID']) . " AND `TID`=" . sql_escape($angeltype['id']) . " ORDER BY `Nick`"); + $entry_list = array (); + foreach ($entries as $entry) { + if($entry['Gekommen']==1) + $style="font-weight:bold;"; + else + $style="font-weight:normal;"; + if (in_array('user_shifts_admin', $privileges)) + $entry_list[] = "" . '' . $entry['Nick'] . ' [x]'; + else + $entry_list[] = "" . $entry['Nick']." 0) { + if ((time() < $shift['end'] && !$my_shift) || in_array('user_shifts_admin', $privileges)) { + $entry_list[] = '' . ($angeltype['count'] - count($entries)) . ' Helfer' . ($angeltype['count'] - count($entries) != 1 ? '' : '') . ' gebraucht »'; + } else { + $entry_list[] = ($angeltype['count'] - count($entries)) . ' Helfer gebraucht'; + } + $is_free = true; + } + + $shifts_row .= '' . $angeltype['name'] . ': '; + $shifts_row .= join(", ", $entry_list); + $shifts_row .= '
'; + } + if (in_array('user_shifts_admin', $privileges)) { + $shifts_row .= 'Weitere Helfer eintragen »'; + } + } + $color=""; + if($is_free) { + $color="style=\"background: #F6CECE\";"; + } else { + $color="style=\"background: #BCF5A9\";"; + } + $shifts_table.="
"; + for($j=0;$j<$blocks;$j++) { + $todo[$rid][$i+$j]--; + } + } + } + } + while($todo[$rid][$i]) { + $shifts_table.=''; + $todo[$rid][$i]--; + } + } + $shifts_table.="\n"; + } + $shifts_table.="
-".$room['name']."
".date("H:i",$thistime)."
"; + if (($is_free && in_array(0, $_SESSION['user_shifts']['filled'])) || (!$is_free && in_array(1, $_SESSION['user_shifts']['filled']))) { + $shifts_table.=$shifts_row; + } + $shifts_table.="
"; + // qqq + } else foreach ($shifts as $shift) { $info = array (); if (count($_SESSION['user_shifts']['days']) > 1) $info[] = date("Y-m-d", $shift['start']); -- cgit v1.2.3-54-g00ecf