From 82592662978903a50ad2b31669c0ed56e0fb9129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20H=C3=A4usler?= Date: Tue, 27 Dec 2011 15:42:13 +0100 Subject: [PATCH] #44 shiftplan --- includes/pages/admin_rooms.php | 2 +- includes/pages/user_shifts.php | 51 ++++++++++++++++------------------ includes/sys_template.php | 2 +- public/css/base.css | 11 ++++++-- templates/user_shifts.html | 8 ++---- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/includes/pages/admin_rooms.php b/includes/pages/admin_rooms.php index f4b6f8f9..f6e071c8 100644 --- a/includes/pages/admin_rooms.php +++ b/includes/pages/admin_rooms.php @@ -3,7 +3,7 @@ function admin_rooms() { global $user; $html = ""; - $rooms = sql_select("SELECT * FROM `Room` ORDER BY `Number`, `Name`"); + $rooms = sql_select("SELECT * FROM `Room` ORDER BY `Name`"); if (!isset ($_REQUEST["action"])) { $html .= "Hallo " . $user['Nick'] . ",
\nhier hast du die Möglichkeit, neue Räume für die Schichtpläne einzutragen " . diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index 3088e633..7cb28cfe 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -213,28 +213,33 @@ function user_shifts() { $shifts = sql_select("SELECT COUNT(*) AS `count` FROM `Shifts` ORDER BY `start`"); $days = array (); $rooms = array (); + if (!isset ($_SESSION['user_shifts'])) + $_SESSION['user_shifts'] = array (); + if ($shifts[0]["count"] > 0) { $days = sql_select("SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) FROM `Shifts`"); $days = array_map('array_pop', $days); - $day = $days[0]; + if (!isset ($_SESSION['user_shifts']['day'])) + $_SESSION['user_shifts']['day'] = $days[0]; if (isset ($_REQUEST['day'])) - $day = $_REQUEST['day']; + $_SESSION['user_shifts']['day'] = $_REQUEST['day']; $rooms = sql_select("SELECT * FROM `Room` WHERE `show`='Y' ORDER BY `Name`"); - $id = 0; + if (!isset ($_SESSION['user_shifts']['id'])) + $_SESSION['user_shifts']['id'] = 0; if (isset ($_REQUEST['room_id']) && preg_match("/^[0-9]*$/", $_REQUEST['room_id'])) - $id = $_REQUEST['room_id']; - $day_timestamp = DateTime :: createFromFormat("Y-m-d-Hi", $day . "-0000")->getTimestamp(); + $_SESSION['user_shifts']['id'] = $_REQUEST['room_id']; + $day_timestamp = DateTime :: createFromFormat("Y-m-d-Hi", $_SESSION['user_shifts']['day'] . "-0000")->getTimestamp(); - if ($id == 0) + if ($_SESSION['user_shifts']['id'] == 0) $shifts = sql_select("SELECT * FROM `Shifts` JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `start` > " . sql_escape(time()) . " ORDER BY `start`"); else - $shifts = sql_select("SELECT * FROM `Shifts` WHERE `RID`=" . sql_escape($id) . " AND `start` >= " . sql_escape($day_timestamp) . " AND `start` < " . sql_escape($day_timestamp +24 * 60 * 60) . " ORDER BY `start`"); + $shifts = sql_select("SELECT * FROM `Shifts` WHERE `RID`=" . sql_escape($_SESSION['user_shifts']['id']) . " AND `start` >= " . sql_escape($day_timestamp) . " AND `start` < " . sql_escape($day_timestamp +24 * 60 * 60) . " ORDER BY `start`"); $shifts_table = ""; $row_count = 0; foreach ($shifts as $shift) { - $shift_row = '' . date(($id == 0 ? "Y-m-d " : "") . "H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']) . ($id == 0 ? "
" . $shift['Name'] : "") . '' . $shift['name']; + $shift_row = '' . date(($_SESSION['user_shifts']['id'] == 0 ? "Y-m-d " : "") . "H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']) . ($_SESSION['user_shifts']['id'] == 0 ? "
" . $shift['Name'] : "") . '' . $shift['name']; if (in_array('admin_shifts', $privileges)) $shift_row .= ' [edit] [x]'; $shift_row .= '
'; @@ -266,42 +271,34 @@ function user_shifts() { $shift_row .= '
'; } } - if ($id != 0 || ($show_shift && $row_count++ < 15)) + if ($_SESSION['user_shifts']['id'] != 0 || ($show_shift && $row_count++ < 15)) $shifts_table .= $shift_row . ''; } } return template_render('../templates/user_shifts.html', array ( - 'room_select' => make_room_select($rooms, $id, $day), - 'day_select' => make_day_select($days, $day, $id), + 'room_select' => make_room_select($rooms, $_SESSION['user_shifts']['id'], $_SESSION['user_shifts']['day']), + 'day_select' => make_day_select($days, $_SESSION['user_shifts']['day'], $_SESSION['user_shifts']['id']), 'shifts_table' => $shifts_table )); } } function make_day_select($days, $day, $id) { + if ($id == 0) + return ""; $html = array (); - foreach ($days as $d) { - if ($day == $d && $id != 0) - $html[] = '' . $d . ''; - else - $html[] = '' . $d . ''; - } - return join(' | ', $html); + foreach ($days as $d) + $html[] = button(page_link_to('user_shifts') . '&day=' . $d, $d, $day == $d && $id != 0 ? 'on' : ''); + return buttons($html); } function make_room_select($rooms, $id, $day) { $html = array (); foreach ($rooms as $room) { - if ($room['RID'] == $id) - $html[] = '' . $room['Name'] . ''; - else - $html[] = '' . $room['Name'] . ''; + $html[] = button(page_link_to('user_shifts') . '&room_id=' . $room['RID'], $room['Name'], $room['RID'] == $id ? 'on' : ''); } - if ($id == 0) - $html[] = 'Nächste freie Schichten'; - else - $html[] = 'Nächste freie Schichten'; - return join(' | ', $html); + $html[] = button(page_link_to('user_shifts') . '&room_id=0', "Next free shifts.", $id == 0 ? 'on' : ''); + return buttons($html); } ?> diff --git a/includes/sys_template.php b/includes/sys_template.php index 9aed6d95..79e9fe77 100644 --- a/includes/sys_template.php +++ b/includes/sys_template.php @@ -147,7 +147,7 @@ function button($href, $label, $class = "") { * Rendert eine Toolbar mit Knöpfen */ function buttons($buttons = array ()) { - return '
' . join($buttons) . '
'; + return '
' . join(' ', $buttons) . '
'; } // Load and render template diff --git a/public/css/base.css b/public/css/base.css index b00ce3af..6fe914c4 100644 --- a/public/css/base.css +++ b/public/css/base.css @@ -276,19 +276,26 @@ tr:hover .hidden { } .toolbar { - margin: 5px 0 10px 0; + margin: 0 0 10px 0; } .button { background: #f0f0f0; border: 1px solid #888; border-radius: 4px; - margin-right: 5px; + line-height: 25px; padding: 2px 5px; text-decoration: none; + white-space: nowrap; +} + +.button.on { + color: #fff; + background: #444; } .button:hover { + color: #000; background: #fff; } diff --git a/templates/user_shifts.html b/templates/user_shifts.html index 85f38112..99d62ea0 100644 --- a/templates/user_shifts.html +++ b/templates/user_shifts.html @@ -1,9 +1,5 @@ -

- Raum: %room_select% -

-

- Tag: %day_select% -

+%room_select% +%day_select%