From 043a1203d41bf200f23b3b4d30cee5af5ccc4188 Mon Sep 17 00:00:00 2001 From: Philip Häusler Date: Mon, 26 Dec 2011 20:51:08 +0100 Subject: bugfixes with angeltype (TID removed) --- includes/pages/admin_rooms.php | 12 ++++++------ includes/pages/admin_shifts.php | 2 +- includes/pages/user_shifts.php | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'includes/pages') diff --git a/includes/pages/admin_rooms.php b/includes/pages/admin_rooms.php index a547e798..f4b6f8f9 100644 --- a/includes/pages/admin_rooms.php +++ b/includes/pages/admin_rooms.php @@ -63,13 +63,13 @@ function admin_rooms() { $room = sql_select("SELECT * FROM `Room` WHERE `RID`=" . sql_escape($rid) . " LIMIT 1"); if (count($room) > 0) { list ($room) = $room; - $room_angel_types = sql_select("SELECT * FROM `AngelTypes` LEFT OUTER JOIN `NeededAngelTypes` ON (`AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id` AND `NeededAngelTypes`.`room_id`=" . sql_escape($rid) . ") ORDER BY `AngelTypes`.`name`"); + $room_angel_types = sql_select("SELECT `AngelTypes`.*, `NeededAngelTypes`.`count` FROM `AngelTypes` LEFT OUTER JOIN `NeededAngelTypes` ON (`AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id` AND `NeededAngelTypes`.`room_id`=" . sql_escape($rid) . ") ORDER BY `AngelTypes`.`name`"); $angel_types = ""; foreach ($room_angel_types as $room_angel_type) { if ($room_angel_type['count'] == "") $room_angel_type['count'] = "0"; - $angel_types .= '' . $room_angel_type['name'] . ''; + $angel_types .= '' . $room_angel_type['name'] . ''; } $html .= template_render('../templates/admin_rooms_edit_form.html', array ( @@ -101,7 +101,7 @@ function admin_rooms() { $room = sql_select("SELECT * FROM `Room` WHERE `RID`=" . sql_escape($rid) . " LIMIT 1"); if (count($room) > 0) { list ($room) = $room; - $room_angel_types = sql_select("SELECT * FROM `AngelTypes` LEFT OUTER JOIN `NeededAngelTypes` ON (`AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id` AND `NeededAngelTypes`.`room_id`=" . sql_escape($rid) . ") ORDER BY `AngelTypes`.`name`"); + $room_angel_types = sql_select("SELECT `AngelTypes`.* FROM `AngelTypes` LEFT OUTER JOIN `NeededAngelTypes` ON (`AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id` AND `NeededAngelTypes`.`room_id`=" . sql_escape($rid) . ") ORDER BY `AngelTypes`.`name`"); $name = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}]{1,})/ui", '', strip_tags($_REQUEST['Name'])); $man = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}]{1,})/ui", '', strip_tags($_REQUEST['Man'])); @@ -111,11 +111,11 @@ function admin_rooms() { sql_query("UPDATE `Room` SET `Name`='" . sql_escape($name) . "', `Man`='" . sql_escape($man) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($show) . "', `Number`='" . sql_escape($number) . "' WHERE `RID`=" . sql_escape($rid) . " LIMIT 1"); sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`=" . sql_escape($rid)); foreach ($room_angel_types as $room_angel_type) { - if (isset ($_REQUEST['angel_type_' . $room_angel_type['TID']]) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['angel_type_' . $room_angel_type['TID']])) - $count = $_REQUEST['angel_type_' . $room_angel_type['TID']]; + if (isset ($_REQUEST['angel_type_' . $room_angel_type['id']]) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['angel_type_' . $room_angel_type['id']])) + $count = $_REQUEST['angel_type_' . $room_angel_type['id']]; else $count = "0"; - sql_query("INSERT INTO `NeededAngelTypes` SET `room_id`=" . sql_escape($rid) . ", `angel_type_id`=" . sql_escape($room_angel_type['TID']) . ", `count`=" . sql_escape($count)); + sql_query("INSERT INTO `NeededAngelTypes` SET `room_id`=" . sql_escape($rid) . ", `angel_type_id`=" . sql_escape($room_angel_type['id']) . ", `count`=" . sql_escape($count)); } header("Location: " . page_link_to("admin_rooms")); } else diff --git a/includes/pages/admin_shifts.php b/includes/pages/admin_shifts.php index c5dc28cd..7caba512 100644 --- a/includes/pages/admin_shifts.php +++ b/includes/pages/admin_shifts.php @@ -248,7 +248,7 @@ function admin_shifts() { $angel_types = ""; foreach ($types as $type) { $angel_types .= template_render('../templates/admin_shifts_angel_types.html', array ( - 'id' => $type['TID'], + 'id' => $type['id'], 'type' => $type['name'], 'value' => $needed_angel_types[$type['id']] )); diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index 49078c05..e0e8b1bc 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -36,10 +36,10 @@ function user_shifts() { $room_array[$room['RID']] = $room['Name']; // Engeltypen laden - $types = sql_select("SELECT * FROM `NeededAngelTypes` JOIN `AngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`) WHERE `shift_id`=" . sql_escape($shift_id) . " ORDER BY `AngelTypes`.`name`"); + $types = sql_select("SELECT `AngelTypes`.*, `NeededAngelTypes`.`count` FROM `NeededAngelTypes` JOIN `AngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`) WHERE `shift_id`=" . sql_escape($shift_id) . " ORDER BY `AngelTypes`.`name`"); $needed_angel_types = array (); foreach ($types as $type) - $needed_angel_types[$type['TID']] = $type['count']; + $needed_angel_types[$type['id']] = $type['count']; $name = $shift['name']; $rid = $shift['RID']; @@ -104,7 +104,7 @@ function user_shifts() { $angel_types = ""; foreach ($types as $type) { $angel_types .= template_render('../templates/admin_shifts_angel_types.html', array ( - 'id' => $type['TID'], + 'id' => $type['id'], 'type' => $type['name'], 'value' => $needed_angel_types[$type['id']] )); @@ -247,7 +247,7 @@ function user_shifts() { 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['TID']) . " ORDER BY `Nick`"); + $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 (in_array('user_shifts_admin', $privileges)) @@ -257,7 +257,7 @@ function user_shifts() { } if ($angeltype['count'] - count($entries) > 0) if (!$my_shift || in_array('user_shifts_admin', $privileges)) { - $entry_list[] = '' . ($angeltype['count'] - count($entries)) . ' Helfer' . ($angeltype['count'] - count($entries) != 1 ? '' : '') . ' gebraucht »'; + $entry_list[] = '' . ($angeltype['count'] - count($entries)) . ' Helfer' . ($angeltype['count'] - count($entries) != 1 ? '' : '') . ' gebraucht »'; $show_shift = true; } else $entry_list[] = ($angeltype['count'] - count($entries)) . ' Helfer gebraucht'; -- cgit v1.2.3-54-g00ecf