#51 fix problems with changing needed angeltypes in rooms

main
Philip Häusler 13 years ago
parent aac265ec7e
commit 505ad98e33

@ -67,21 +67,23 @@ function admin_rooms() {
else else
$ok = false; $ok = false;
foreach ($angeltypes as $angeltype_id => $angeltype) foreach ($angeltypes as $angeltype_id => $angeltype) {
if (isset ($_REQUEST['angeltype_count_' . $angeltype_id]) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['angeltype_count_' . $angeltype_id])) if (isset ($_REQUEST['angeltype_count_' . $angeltype_id]) && preg_match("/^[0-9]{1,4}$/", $_REQUEST['angeltype_count_' . $angeltype_id]))
$angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id]; $angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id];
else { else {
$ok = false; $ok = false;
$msg .= error(sprintf("Please enter needed angels for type %s.", $angeltype), true); $msg .= error(sprintf("Please enter needed angels for type %s.", $angeltype), true);
}
} }
if ($ok) { if ($ok) {
if(isset($id)) if(isset($id))
sql_query("UPDATE `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "' WHERE `RID`=" . sql_escape($id) . " LIMIT 1"); sql_query("UPDATE `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "' WHERE `RID`=" . sql_escape($id) . " LIMIT 1");
else else {
sql_query("INSERT INTO `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "'"); sql_query("INSERT INTO `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "'");
$id = sql_id(); $id = sql_id();
}
sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`=" . sql_escape($id)); sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`=" . sql_escape($id));
foreach ($angeltypes_count as $angeltype_id => $angeltype_count) foreach ($angeltypes_count as $angeltype_id => $angeltype_count)
sql_query("INSERT INTO `NeededAngelTypes` SET `room_id`=" . sql_escape($id) . ", `angel_type_id`=" . sql_escape($angeltype_id) . ", `count`=" . sql_escape($angeltype_count)); sql_query("INSERT INTO `NeededAngelTypes` SET `room_id`=" . sql_escape($id) . ", `angel_type_id`=" . sql_escape($angeltype_id) . ", `count`=" . sql_escape($angeltype_count));

@ -24,9 +24,9 @@ function user_shifts() {
redirect(page_link_to('user_shifts')); redirect(page_link_to('user_shifts'));
/* /*
if (sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift_id) . " LIMIT 1") > 0) { if (sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift_id) . " LIMIT 1") > 0) {
error("Du kannst nur Schichten bearbeiten, bei denen niemand eingetragen ist."); error("Du kannst nur Schichten bearbeiten, bei denen niemand eingetragen ist.");
redirect(page_link_to('user_shift')); redirect(page_link_to('user_shift'));
} }
*/ */
@ -49,13 +49,17 @@ function user_shifts() {
// Benötigte Engeltypen vom Raum // Benötigte Engeltypen vom Raum
$needed_angel_types_source = sql_select("SELECT `AngelTypes`.*, `NeededAngelTypes`.`count` FROM `AngelTypes` LEFT JOIN `NeededAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id` AND `NeededAngelTypes`.`room_id`=" . sql_escape($shift['RID']) . ") ORDER BY `AngelTypes`.`name`"); $needed_angel_types_source = sql_select("SELECT `AngelTypes`.*, `NeededAngelTypes`.`count` FROM `AngelTypes` LEFT JOIN `NeededAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id` AND `NeededAngelTypes`.`room_id`=" . sql_escape($shift['RID']) . ") ORDER BY `AngelTypes`.`name`");
foreach ($needed_angel_types_source as $type) foreach ($needed_angel_types_source as $type) {
$needed_angel_types[$type['id']] = $type['count'] != "" ? $type['count'] : "0"; if($type['count'] != "")
$needed_angel_types[$type['id']] =$type['count'];
}
// Benötigte Engeltypen von der Schicht // Benötigte Engeltypen von der Schicht
$needed_angel_types_source = sql_select("SELECT `AngelTypes`.*, `NeededAngelTypes`.`count` FROM `AngelTypes` LEFT JOIN `NeededAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id` AND `NeededAngelTypes`.`shift_id`=" . sql_escape($shift_id) . ") ORDER BY `AngelTypes`.`name`"); $needed_angel_types_source = sql_select("SELECT `AngelTypes`.*, `NeededAngelTypes`.`count` FROM `AngelTypes` LEFT JOIN `NeededAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id` AND `NeededAngelTypes`.`shift_id`=" . sql_escape($shift_id) . ") ORDER BY `AngelTypes`.`name`");
foreach ($needed_angel_types_source as $type) foreach ($needed_angel_types_source as $type){
$needed_angel_types[$type['id']] = $type['count'] != "" ? $type['count'] : "0"; if($type['count'] != "")
$needed_angel_types[$type['id']] =$type['count'];
}
$name = $shift['name']; $name = $shift['name'];
$rid = $shift['RID']; $rid = $shift['RID'];
@ -114,7 +118,7 @@ function user_shifts() {
} }
$room_select = html_select_key('rid', 'rid', $room_array, $rid); $room_select = html_select_key('rid', 'rid', $room_array, $rid);
$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 (
@ -123,7 +127,7 @@ function user_shifts() {
'value' => $needed_angel_types[$type['id']] 'value' => $needed_angel_types[$type['id']]
)); ));
} }
return template_render('../templates/user_shifts_edit.html', array ( return template_render('../templates/user_shifts_edit.html', array (
'msg' => $msg, 'msg' => $msg,
'name' => $name, 'name' => $name,

Loading…
Cancel
Save