bugfixes with angeltype (TID removed)
This commit is contained in:
parent
80f355a94f
commit
043a1203d4
|
@ -63,13 +63,13 @@ function admin_rooms() {
|
||||||
$room = sql_select("SELECT * FROM `Room` WHERE `RID`=" . sql_escape($rid) . " LIMIT 1");
|
$room = sql_select("SELECT * FROM `Room` WHERE `RID`=" . sql_escape($rid) . " LIMIT 1");
|
||||||
if (count($room) > 0) {
|
if (count($room) > 0) {
|
||||||
list ($room) = $room;
|
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 = "";
|
$angel_types = "";
|
||||||
foreach ($room_angel_types as $room_angel_type) {
|
foreach ($room_angel_types as $room_angel_type) {
|
||||||
if ($room_angel_type['count'] == "")
|
if ($room_angel_type['count'] == "")
|
||||||
$room_angel_type['count'] = "0";
|
$room_angel_type['count'] = "0";
|
||||||
$angel_types .= '<tr><td>' . $room_angel_type['name'] . '</td><td><input type="text" name="angel_type_' . $room_angel_type['TID'] . '" value="' . $room_angel_type['count'] . '" /></td></tr>';
|
$angel_types .= '<tr><td>' . $room_angel_type['name'] . '</td><td><input type="text" name="angel_type_' . $room_angel_type['id'] . '" value="' . $room_angel_type['count'] . '" /></td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= template_render('../templates/admin_rooms_edit_form.html', array (
|
$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");
|
$room = sql_select("SELECT * FROM `Room` WHERE `RID`=" . sql_escape($rid) . " LIMIT 1");
|
||||||
if (count($room) > 0) {
|
if (count($room) > 0) {
|
||||||
list ($room) = $room;
|
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']));
|
$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']));
|
$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("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));
|
sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`=" . sql_escape($rid));
|
||||||
foreach ($room_angel_types as $room_angel_type) {
|
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']]))
|
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['TID']];
|
$count = $_REQUEST['angel_type_' . $room_angel_type['id']];
|
||||||
else
|
else
|
||||||
$count = "0";
|
$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"));
|
header("Location: " . page_link_to("admin_rooms"));
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -248,7 +248,7 @@ function admin_shifts() {
|
||||||
$angel_types = "";
|
$angel_types = "";
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
$angel_types .= template_render('../templates/admin_shifts_angel_types.html', array (
|
$angel_types .= template_render('../templates/admin_shifts_angel_types.html', array (
|
||||||
'id' => $type['TID'],
|
'id' => $type['id'],
|
||||||
'type' => $type['name'],
|
'type' => $type['name'],
|
||||||
'value' => $needed_angel_types[$type['id']]
|
'value' => $needed_angel_types[$type['id']]
|
||||||
));
|
));
|
||||||
|
|
|
@ -36,10 +36,10 @@ function user_shifts() {
|
||||||
$room_array[$room['RID']] = $room['Name'];
|
$room_array[$room['RID']] = $room['Name'];
|
||||||
|
|
||||||
// Engeltypen laden
|
// 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 ();
|
$needed_angel_types = array ();
|
||||||
foreach ($types as $type)
|
foreach ($types as $type)
|
||||||
$needed_angel_types[$type['TID']] = $type['count'];
|
$needed_angel_types[$type['id']] = $type['count'];
|
||||||
|
|
||||||
$name = $shift['name'];
|
$name = $shift['name'];
|
||||||
$rid = $shift['RID'];
|
$rid = $shift['RID'];
|
||||||
|
@ -104,7 +104,7 @@ function user_shifts() {
|
||||||
$angel_types = "";
|
$angel_types = "";
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
$angel_types .= template_render('../templates/admin_shifts_angel_types.html', array (
|
$angel_types .= template_render('../templates/admin_shifts_angel_types.html', array (
|
||||||
'id' => $type['TID'],
|
'id' => $type['id'],
|
||||||
'type' => $type['name'],
|
'type' => $type['name'],
|
||||||
'value' => $needed_angel_types[$type['id']]
|
'value' => $needed_angel_types[$type['id']]
|
||||||
));
|
));
|
||||||
|
@ -247,7 +247,7 @@ function user_shifts() {
|
||||||
if (count($angeltypes) > 0) {
|
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;
|
$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) {
|
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 ();
|
$entry_list = array ();
|
||||||
foreach ($entries as $entry) {
|
foreach ($entries as $entry) {
|
||||||
if (in_array('user_shifts_admin', $privileges))
|
if (in_array('user_shifts_admin', $privileges))
|
||||||
|
@ -257,7 +257,7 @@ function user_shifts() {
|
||||||
}
|
}
|
||||||
if ($angeltype['count'] - count($entries) > 0)
|
if ($angeltype['count'] - count($entries) > 0)
|
||||||
if (!$my_shift || in_array('user_shifts_admin', $privileges)) {
|
if (!$my_shift || in_array('user_shifts_admin', $privileges)) {
|
||||||
$entry_list[] = '<a href="' . page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['TID'] . '">' . ($angeltype['count'] - count($entries)) . ' Helfer' . ($angeltype['count'] - count($entries) != 1 ? '' : '') . ' gebraucht »</a>';
|
$entry_list[] = '<a href="' . page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'] . '">' . ($angeltype['count'] - count($entries)) . ' Helfer' . ($angeltype['count'] - count($entries) != 1 ? '' : '') . ' gebraucht »</a>';
|
||||||
$show_shift = true;
|
$show_shift = true;
|
||||||
} else
|
} else
|
||||||
$entry_list[] = ($angeltype['count'] - count($entries)) . ' Helfer gebraucht';
|
$entry_list[] = ($angeltype['count'] - count($entries)) . ' Helfer gebraucht';
|
||||||
|
|
Loading…
Reference in New Issue