diff options
author | Philip Häusler <msquare@notrademark.de> | 2011-12-27 15:42:13 +0100 |
---|---|---|
committer | Philip Häusler <msquare@notrademark.de> | 2011-12-27 15:42:13 +0100 |
commit | 82592662978903a50ad2b31669c0ed56e0fb9129 (patch) | |
tree | cb86dd59fb9cc0bfba6589307158e33548417a4c /includes | |
parent | e0ffeb100568890ac32717d8ddf98d6d501655fc (diff) |
#44 shiftplan
Diffstat (limited to 'includes')
-rw-r--r-- | includes/pages/admin_rooms.php | 2 | ||||
-rw-r--r-- | includes/pages/user_shifts.php | 51 | ||||
-rw-r--r-- | includes/sys_template.php | 2 |
3 files changed, 26 insertions, 29 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'] . ",<br />\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 = '<tr><td>' . date(($id == 0 ? "Y-m-d " : "") . "H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']) . ($id == 0 ? "<br />" . $shift['Name'] : "") . '</td><td>' . $shift['name']; + $shift_row = '<tr><td>' . date(($_SESSION['user_shifts']['id'] == 0 ? "Y-m-d " : "") . "H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']) . ($_SESSION['user_shifts']['id'] == 0 ? "<br />" . $shift['Name'] : "") . '</td><td>' . $shift['name']; if (in_array('admin_shifts', $privileges)) $shift_row .= ' <a href="?p=user_shifts&edit_shift=' . $shift['SID'] . '">[edit]</a> <a href="?p=user_shifts&delete_shift=' . $shift['SID'] . '">[x]</a>'; $shift_row .= '<br />'; @@ -266,42 +271,34 @@ function user_shifts() { $shift_row .= '<br />'; } } - if ($id != 0 || ($show_shift && $row_count++ < 15)) + if ($_SESSION['user_shifts']['id'] != 0 || ($show_shift && $row_count++ < 15)) $shifts_table .= $shift_row . '</td></tr>'; } } 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[] = '<b>' . $d . '</b>'; - else - $html[] = '<a href="' . page_link_to('user_shifts') . '&day=' . $d . '&room_id=' . $id . '">' . $d . '</a>'; - } - 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[] = '<b>' . $room['Name'] . '</b>'; - else - $html[] = '<a href="' . page_link_to('user_shifts') . '&room_id=' . $room['RID'] . '&day=' . $day . '">' . $room['Name'] . '</a>'; + $html[] = button(page_link_to('user_shifts') . '&room_id=' . $room['RID'], $room['Name'], $room['RID'] == $id ? 'on' : ''); } - if ($id == 0) - $html[] = '<b>Nächste freie Schichten</b>'; - else - $html[] = '<a href="' . page_link_to('user_shifts') . '&room_id=0">Nächste freie Schichten</a>'; - 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 '<div class="toolbar">' . join($buttons) . '</div>'; + return '<div class="toolbar">' . join(' ', $buttons) . '</div>'; } // Load and render template |