you can now set if a station needs points or get the results of the excersice and the website should calculate the points
This commit is contained in:
@@ -8,7 +8,8 @@
|
|||||||
if(isset($_POST['save'])){
|
if(isset($_POST['save'])){
|
||||||
$station_name = sanitize_input($_POST['station_name']);
|
$station_name = sanitize_input($_POST['station_name']);
|
||||||
$station_pos = sanitize_input($_POST['station_pos']);
|
$station_pos = sanitize_input($_POST['station_pos']);
|
||||||
write_station($con, $station_name, $station_pos);
|
$station_direct_points = sanitize_input($_POST['direkte_punkte']);
|
||||||
|
write_station($con, $station_name, $station_pos, $station_direct_points);
|
||||||
}
|
}
|
||||||
header("Location: stationen.php");
|
header("Location: stationen.php");
|
||||||
die;
|
die;
|
||||||
@@ -34,6 +35,13 @@
|
|||||||
<span></span>
|
<span></span>
|
||||||
<label for="station_pos">Standort</label>
|
<label for="station_pos">Standort</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="dropdown">
|
||||||
|
<label for="direkte_punkte">Punkte eintragen</label>
|
||||||
|
<select name="direkte_punkte" id="direkte_punkte">
|
||||||
|
<option value="1" selected>Ja</option>
|
||||||
|
<option value="0">Nein</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<input id="button" type="submit" value="Hinzufügen" class="btn-confirm" name="save"/>
|
<input id="button" type="submit" value="Hinzufügen" class="btn-confirm" name="save"/>
|
||||||
<a href="stationen.php" class="btn-close">Schließen</a>
|
<a href="stationen.php" class="btn-close">Schließen</a>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -16,11 +16,13 @@
|
|||||||
$station_name = sanitize_input($_POST['station_name']);
|
$station_name = sanitize_input($_POST['station_name']);
|
||||||
$station_pos = sanitize_input($_POST['station_pos']);
|
$station_pos = sanitize_input($_POST['station_pos']);
|
||||||
$station_gewertet = sanitize_input($_POST['gewertet']);
|
$station_gewertet = sanitize_input($_POST['gewertet']);
|
||||||
|
$station_direct_points = sanitize_input($_POST['direkte_punkte']);
|
||||||
$station = get_station_all($con, $station_id)->fetch();
|
$station = get_station_all($con, $station_id)->fetch();
|
||||||
$s_id = intval($station['s_id']);
|
$s_id = intval($station['s_id']);
|
||||||
$name = strval($station['name']);
|
$name = strval($station['name']);
|
||||||
$standort = strval($station['standort']);
|
$standort = strval($station['standort']);
|
||||||
$gewertet = intval($station['gewertet']);
|
$gewertet = intval($station['gewertet']);
|
||||||
|
$direct_points = intval($station['direkte_punkte']);
|
||||||
if($name != $station_name) {
|
if($name != $station_name) {
|
||||||
update_station_name($con, $s_id, $station_name);
|
update_station_name($con, $s_id, $station_name);
|
||||||
}
|
}
|
||||||
@@ -32,6 +34,10 @@
|
|||||||
if($gewertet != $station_gewertet) {
|
if($gewertet != $station_gewertet) {
|
||||||
update_station_gewertet($con, $s_id, $station_gewertet);
|
update_station_gewertet($con, $s_id, $station_gewertet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($direct_points != $station_direct_points) {
|
||||||
|
update_station_direct_points($con, $s_id, $station_direct_points);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
header("Location: stationen.php");
|
header("Location: stationen.php");
|
||||||
die;
|
die;
|
||||||
@@ -62,6 +68,13 @@
|
|||||||
<option value="0" <?php if($row['gewertet'] == '0'){echo " selected";}?>>Nein</option>
|
<option value="0" <?php if($row['gewertet'] == '0'){echo " selected";}?>>Nein</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="dropdown">
|
||||||
|
<label for="direkte_punkte">Punkte eintragen</label>
|
||||||
|
<select name="direkte_punkte" id="direkte_punkte">
|
||||||
|
<option value="1" <?php if($row['direkte_punkte'] == '1'){echo " selected";}?>>Ja</option>
|
||||||
|
<option value="0" <?php if($row['direkte_punkte'] == '0'){echo " selected";}?>>Nein</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<input type="hidden" name="station_id" <?php echo "value=\"" . $row ['s_id'] . "\""?>/>
|
<input type="hidden" name="station_id" <?php echo "value=\"" . $row ['s_id'] . "\""?>/>
|
||||||
<div>
|
<div>
|
||||||
<input type="submit" value="Speichern" class="btn-confirm"/>
|
<input type="submit" value="Speichern" class="btn-confirm"/>
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
<th scope="col">Name</th>
|
<th scope="col">Name</th>
|
||||||
<th scope="col">Standort</th>
|
<th scope="col">Standort</th>
|
||||||
<th scope="col">Gewertet</th>
|
<th scope="col">Gewertet</th>
|
||||||
|
<th scope="col">Direkt Punkte eintragen</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|||||||
@@ -167,11 +167,12 @@ function write_points($con, $s_id, $m_id, $points, $time) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function write_station($con, $station_name, $station_pos) {
|
function write_station($con, $station_name, $station_pos, $station_direct_points) {
|
||||||
try {
|
try {
|
||||||
$stmt = $con->prepare("INSERT INTO Station (name, standort) VALUES (?, ?)");
|
$stmt = $con->prepare("INSERT INTO Station (name, standort, direkte_punkte) VALUES (?, ?, ?)");
|
||||||
$stmt->bindParam(1, $station_name, PDO::PARAM_STR);
|
$stmt->bindParam(1, $station_name, PDO::PARAM_STR);
|
||||||
$stmt->bindParam(2, $station_pos, PDO::PARAM_STR);
|
$stmt->bindParam(2, $station_pos, PDO::PARAM_STR);
|
||||||
|
$stmt->bindParam(3, $station_direct_points, PDO::PARAM_INT);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
} catch(PDOException $e) {
|
} catch(PDOException $e) {
|
||||||
handle_pdo_exceptio($e);
|
handle_pdo_exceptio($e);
|
||||||
@@ -426,6 +427,17 @@ function update_station_gewertet($con, $s_id, $gewertet) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update_station_direct_points($con, $s_id, $direct_points) {
|
||||||
|
try {
|
||||||
|
$stmt = $con->prepare("UPDATE Station SET direkte_punkte = ? WHERE s_id = ?");
|
||||||
|
$stmt->bindParam(1, $direct_points, PDO::PARAM_INT);
|
||||||
|
$stmt->bindParam(2, $s_id, PDO::PARAM_INT);
|
||||||
|
$stmt->execute();
|
||||||
|
} catch(PDOExeption $e) {
|
||||||
|
handle_pdo_exception($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function get_team($con, $m_id) {
|
function get_team($con, $m_id) {
|
||||||
try {
|
try {
|
||||||
$stmt = $con->prepare("SELECT * FROM Mannschaft WHERE m_id = :m_id");
|
$stmt = $con->prepare("SELECT * FROM Mannschaft WHERE m_id = :m_id");
|
||||||
|
|||||||
@@ -38,14 +38,20 @@ function load_stations_table($con) {
|
|||||||
$stmt = get_stations_all($con);
|
$stmt = get_stations_all($con);
|
||||||
foreach($stmt->fetchAll() as $row) {
|
foreach($stmt->fetchAll() as $row) {
|
||||||
if ($row['gewertet'] == '1') {
|
if ($row['gewertet'] == '1') {
|
||||||
$checked = "ja";
|
$checked = "Ja";
|
||||||
} else {
|
} else {
|
||||||
$checked = "nein";
|
$checked = "Nein";
|
||||||
|
}
|
||||||
|
if ($row['direkte_punkte'] == '1') {
|
||||||
|
$direkte_punkte = "Ja";
|
||||||
|
} else {
|
||||||
|
$direkte_punkte = "Nein";
|
||||||
}
|
}
|
||||||
echo "<tr id=\"" . $row['s_id'] . "\">";
|
echo "<tr id=\"" . $row['s_id'] . "\">";
|
||||||
echo "<td>" . $row['name'] . "</td>";
|
echo "<td>" . $row['name'] . "</td>";
|
||||||
echo "<td>" . $row['standort'] . "</td>";
|
echo "<td>" . $row['standort'] . "</td>";
|
||||||
echo "<td>". $checked . "</td>";
|
echo "<td>". $checked . "</td>";
|
||||||
|
echo "<td>" . $direkte_punkte . "</td>";
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user