begin form validation

main
Philip Häusler 13 years ago
parent e665d1701f
commit 82522881d4

@ -6,31 +6,37 @@ function admin_shifts() {
$msg = ""; $msg = "";
$ok = true; $ok = true;
// Name/Bezeichnung der Schicht, darf nicht leer sein $name = "";
if (isset ($_REQUEST['name']) && strlen($_REQUEST['name']) > 0) $rid = 0;
$name = strip_request_item('name'); $start = date('Y-m-d 00:00');
else { $end = date('Y-m-d 00:00', time() + 24 * 60 * 60);
$ok = false;
$name = "";
$msg .= error("Gib bitte einen Namen für die Schicht(en) an.");
}
// Auswahl der sichtbaren Locations für die Schichten // Locations laden
$rooms = sql_select("SELECT * FROM `Room` WHERE `show`='Y' ORDER BY `Name`"); $rooms = sql_select("SELECT * FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
$room_array = array (); $room_array = array ();
foreach ($rooms as $room) foreach ($rooms as $room)
$room_array[$room['RID']] = $room['Name']; $room_array[$room['RID']] = $room['Name'];
if (isset ($_REQUEST['rid']) && preg_match("/^[0-9]+$/") && isset ($room_array[$_REQUEST['rid']])) if (isset ($_REQUEST['preview'])) {
$rid = $_REQUEST['rid']; // Name/Bezeichnung der Schicht, darf nicht leer sein
else { if (isset ($_REQUEST['name']) && strlen($_REQUEST['name']) > 0)
$ok = false; $name = strip_request_item('name');
$rid = 0; else {
$msg .= error("Wähle bitte einen Raum aus."); $ok = false;
} $name = "";
$msg .= error("Gib bitte einen Namen für die Schicht(en) an.");
}
// Auswahl der sichtbaren Locations für die Schichten
if (isset ($_REQUEST['rid']) && preg_match("/^[0-9]+$/", $_REQUEST['rid']) && isset ($room_array[$_REQUEST['rid']]))
$rid = $_REQUEST['rid'];
else {
$ok = false;
$rid = $rooms[0]['RID'];
$msg .= error("Wähle bitte einen Raum aus.");
}
}
$room_select = html_select_key('rid', $room_array, ''); $room_select = html_select_key('rid', $room_array, '');
$types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `Name`"); $types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `Name`");
@ -44,7 +50,11 @@ function admin_shifts() {
} }
return template_render('../templates/admin_shifts.html', array ( return template_render('../templates/admin_shifts.html', array (
'angel_types' => $angel_types, 'angel_types' => $angel_types,
'room_select' => $room_select 'room_select' => $room_select,
'msg' => $msg,
'name' => $name,
'start' => $start,
'end' => $end
)); ));
} }
?> ?>

@ -1,5 +1,9 @@
<noscript>
Diese Seite ist mit aktiviertem JavaScript sehr viel komfortabler.
</noscript>
<form action="" method="post"> <form action="" method="post">
<fieldset> <fieldset>
%msg%
<p> <p>
<label> <label>
Name/Beschreibung: Name/Beschreibung:
@ -15,13 +19,13 @@
<label> <label>
Beginn: Beginn:
</label> </label>
<input type="text" value="" /> <input type="text" name="start" value="%start%" />
</p> </p>
<p> <p>
<label> <label>
Ende: Ende:
</label> </label>
<input type="text" value="" /> <input type="text" name="end" value="%end%" />
</p><h2>Modus:</h2> </p><h2>Modus:</h2>
<p> <p>
<label> <label>

@ -5,10 +5,10 @@
<span class="spinner"><a id="type_%id%_down" href="#">-</a><input type="text" id="type_%id%" name="type_%id%" value="%value%" /><a id="type_%id%_up" href="#">+</a></span> <span class="spinner"><a id="type_%id%_down" href="#">-</a><input type="text" id="type_%id%" name="type_%id%" value="%value%" /><a id="type_%id%_up" href="#">+</a></span>
<script type="text/javascript"> <script type="text/javascript">
document.getElementById("type_%id%_up").onclick = function(e){ document.getElementById("type_%id%_up").onclick = function(e){
document.getElementById("type_%id%").value = parseInt(document.getElementById("type_%id%").value) + 1; document.getElementById("type_%id%").value = (parseInt(document.getElementById("type_%id%").value) + 101) % 100;
}; };
var down = document.getElementById("type_%id%_down").onclick = function(e){ document.getElementById("type_%id%_down").onclick = function(e){
document.getElementById("type_%id%").value = parseInt(document.getElementById("type_%id%").value) - 1; document.getElementById("type_%id%").value = (parseInt(document.getElementById("type_%id%").value) +99) % 100;
}; };
</script> </script>
</p> </p>

Loading…
Cancel
Save