you can now edit, add and delete results
This commit is contained in:
@@ -4,13 +4,17 @@
|
|||||||
include("../scripts/functions.php");
|
include("../scripts/functions.php");
|
||||||
$user_data = check_login($con);
|
$user_data = check_login($con);
|
||||||
|
|
||||||
|
if($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||||
|
$s_id = sanitize_input($_GET['station']);
|
||||||
|
}
|
||||||
|
|
||||||
if($_SERVER['REQUEST_METHOD'] == "POST") {
|
if($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||||
if(isset($_POST['save'])){
|
$s_id = sanitize_input($_GET['station']);
|
||||||
|
if(isset($_POST['save']) && get_direct_points($con, $s_id)->fetch()['direkte_punkte'] == 1){
|
||||||
$points = sanitize_input($_POST['points']);
|
$points = sanitize_input($_POST['points']);
|
||||||
$minutes = sanitize_input($_POST['minutes']);
|
$minutes = sanitize_input($_POST['minutes']);
|
||||||
$seconds = sanitize_input($_POST['seconds']);
|
$seconds = sanitize_input($_POST['seconds']);
|
||||||
$miliseconds = sanitize_input($_POST['miliseconds']);
|
$miliseconds = sanitize_input($_POST['miliseconds']);
|
||||||
$s_id = sanitize_input($_GET['station']);
|
|
||||||
$m_id = sanitize_input($_POST['team']);
|
$m_id = sanitize_input($_POST['team']);
|
||||||
|
|
||||||
if($minutes == 0 && $seconds == 0 && $miliseconds == 0){
|
if($minutes == 0 && $seconds == 0 && $miliseconds == 0){
|
||||||
@@ -30,6 +34,10 @@
|
|||||||
$time = "00:" . $minutes . ":" . $seconds . "." . $miliseconds;
|
$time = "00:" . $minutes . ":" . $seconds . "." . $miliseconds;
|
||||||
}
|
}
|
||||||
write_points($con, $s_id, $m_id, $points, $time);
|
write_points($con, $s_id, $m_id, $points, $time);
|
||||||
|
} elseif (isset($_POST['save'])) {
|
||||||
|
$result = sanitize_input($_POST['result']);
|
||||||
|
$m_id = sanitize_input($_POST['team']);
|
||||||
|
write_result($con, $s_id, $m_id, $result);
|
||||||
}
|
}
|
||||||
header("Location: statistik.php");
|
header("Location: statistik.php");
|
||||||
die;
|
die;
|
||||||
@@ -51,27 +59,34 @@
|
|||||||
<?php load_teams_no_points($con, sanitize_input($_GET['station']))?>
|
<?php load_teams_no_points($con, sanitize_input($_GET['station']))?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="number_field">
|
<?php
|
||||||
<label for="points">Punkte: </label>
|
if(get_direct_points($con, $s_id)->fetch()['direkte_punkte'] == 1) {
|
||||||
<input name="points" id="points" type="number" max="15" min="0" value="0" required/>
|
echo "<div class=\"number_field\">
|
||||||
|
<label for=\"points\">Punkte: </label>
|
||||||
|
<input name=\"points\" id=\"points\" type=\"number\" max=\"15\" min=\"0\" value=\"0\" required/>
|
||||||
</div>
|
</div>
|
||||||
<div class="headline">
|
<div class=\"headline\">
|
||||||
<h3>Zeit</h3>
|
<h3>Zeit</h3>
|
||||||
</div>
|
</div>
|
||||||
<div id="zeit">
|
<div id=\"zeit\">
|
||||||
<div class="number_field">
|
<div class=\"number_field\">
|
||||||
<label for="minutes">Minuten</label>
|
<label for=\"minutes\">Minuten</label>
|
||||||
<input name="minutes" id="minutes" type="number" max="60" min="0" value="0"/>
|
<input name=\"minutes\" id=\"minutes\" type=\"number\" max=\"60\" min=\"0\" value=\"0\"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="number_field">
|
<div class=\"number_field\">
|
||||||
<label for="seconds">Sekunden</label>
|
<label for=\"seconds\">Sekunden</label>
|
||||||
<input name="seconds" id="seconds" type="number" max="60" min="0" value="0"/>
|
<input name=\"seconds\" id=\"seconds\" type=\"number\" max=\"60\" min=\"0\" value=\"0\"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="number_field">
|
<div class=\"number_field\">
|
||||||
<label for="miliseconds">Millisekunden</label>
|
<label for=\"miliseconds\">Millisekunden</label>
|
||||||
<input name="miliseconds" id="miliseconds" type="number" max="99" min="0" value="0"/>
|
<input name=\"miliseconds\" id=\"miliseconds\" type=\"number\" max=\"99\" min=\"0\" value=\"0\"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>";} else {
|
||||||
|
echo "<div class=\"number_field\">
|
||||||
|
<label for=\"result\">Ergebnis: </label>
|
||||||
|
<input name=\"result\" id=\"result\" type=\"number\" max=\"65535\" min=\"0\" value=\"0\" required/>
|
||||||
|
</div>";
|
||||||
|
}?>
|
||||||
<div>
|
<div>
|
||||||
<input id="button" type="submit" value="Eintragen" class="btn-confirm" name="save"/>
|
<input id="button" type="submit" value="Eintragen" class="btn-confirm" name="save"/>
|
||||||
<input id="close" type="submit" value="Schließen" class="btn-confirm" name="close">
|
<input id="close" type="submit" value="Schließen" class="btn-confirm" name="close">
|
||||||
|
|||||||
@@ -10,6 +10,13 @@
|
|||||||
$stmt->bindParam(1, $_POST["m_id"], PDO::PARAM_INT);
|
$stmt->bindParam(1, $_POST["m_id"], PDO::PARAM_INT);
|
||||||
$stmt->bindParam(2, $_POST["s_id"], PDO::PARAM_INT);
|
$stmt->bindParam(2, $_POST["s_id"], PDO::PARAM_INT);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
if(get_direct_points($con, $_POST['s_id'])->fetch()['direkte_punkte'] == 0) {
|
||||||
|
$stmt = $con->prepare("DELETE FROM Ergebnisse WHERE m_id = ? AND s_id =?");
|
||||||
|
$stmt->bindParam(1, $_POST["m_id"], PDO::PARAM_INT);
|
||||||
|
$stmt->bindParam(2, $_POST["s_id"], PDO::PARAM_INT);
|
||||||
|
$stmt->execute();
|
||||||
|
update_points($con, $_POST["s_id"]);
|
||||||
|
}
|
||||||
} catch(PDOException $e) {
|
} catch(PDOException $e) {
|
||||||
handle_pdo_exception($e);
|
handle_pdo_exception($e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,14 +5,16 @@
|
|||||||
$user_data=check_login($con);
|
$user_data=check_login($con);
|
||||||
|
|
||||||
if($_SERVER['REQUEST_METHOD'] == "GET") {
|
if($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||||
$row = get_result($con, $_GET["m_id"], $_GET['s_id'])->fetch();
|
$m_id = intval(sanitize_input($_GET['m_id']));
|
||||||
|
$s_id = intval(sanitize_input($_GET['s_id']));
|
||||||
|
$row = get_result($con, $m_id, $s_id)->fetch();
|
||||||
include("header_footer/header.php");
|
include("header_footer/header.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
if(isset($_POST['button'])) {
|
$s_id = intval(sanitize_input($_POST['s_id']));
|
||||||
$m_id = intval(sanitize_input($_POST['m_id']));
|
$m_id = intval(sanitize_input($_POST['m_id']));
|
||||||
$s_id = intval(sanitize_input($_POST['s_id']));
|
if(isset($_POST['save']) && get_direct_points($con, $s_id)->fetch()['direkte_punkte'] == 1) {
|
||||||
$points = intval(sanitize_input($_POST['points']));
|
$points = intval(sanitize_input($_POST['points']));
|
||||||
$minutes = intval(sanitize_input($_POST['minutes']));
|
$minutes = intval(sanitize_input($_POST['minutes']));
|
||||||
$seconds = intval(sanitize_input($_POST['seconds']));
|
$seconds = intval(sanitize_input($_POST['seconds']));
|
||||||
@@ -36,6 +38,9 @@
|
|||||||
$time = "00:" . $minutes . ":" . $seconds . "." . $millis;
|
$time = "00:" . $minutes . ":" . $seconds . "." . $millis;
|
||||||
change_time($con, $m_id, $s_id, $time);
|
change_time($con, $m_id, $s_id, $time);
|
||||||
}
|
}
|
||||||
|
} elseif(isset($_POST['save'])) {
|
||||||
|
$result = intval(sanitize_input($_POST['result']));
|
||||||
|
update_result($con, $s_id, $m_id, $result);
|
||||||
}
|
}
|
||||||
header("Location: statistik.php");
|
header("Location: statistik.php");
|
||||||
die;
|
die;
|
||||||
@@ -50,31 +55,58 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<label class="information">Mannschaftsname: <?php echo $row['name']?></label><br>
|
<label class="information">Mannschaftsname: <?php echo $row['name']?></label><br>
|
||||||
<label for="fire_department" class="information">Feuerwehr: <?php echo $row["feuerwehr"]?></label><br>
|
<label for="fire_department" class="information">Feuerwehr: <?php echo $row["feuerwehr"]?></label><br>
|
||||||
<div class="number_field">
|
<?php
|
||||||
<label for="points">Punkte:</label>
|
if (get_direct_points($con, $s_id)->fetch()['direkte_punkte'] == 1){
|
||||||
<input type="number" min="0" max="15" name="points" value="<?php echo $row['punkte']?>"/>
|
echo "<div class=\"number_field\">
|
||||||
|
<label for=\"points\">Punkte:</label>
|
||||||
|
<input type=\"number\" min=\"0\" max=\"15\" name=\"points\" value=\"" . $row['punkte'] . "\"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="headline">
|
<div class=\"headline\">
|
||||||
<h3>Zeit</h3>
|
<h3>Zeit</h3>
|
||||||
</div>
|
</div>
|
||||||
<div id="time">
|
<div id=\"time\">";
|
||||||
<?php $time_set = check_time($con, $row['m_id'], $row['s_id']);?>
|
$time_set = check_time($con, $m_id, $s_id);
|
||||||
<div class="number_field">
|
echo "<div class=\"number_field\">
|
||||||
<label for="minutes">Minuten:</label>
|
<label for=\"minutes\">Minuten:</label>
|
||||||
<input name="minutes" type="number" min="0" max="60" value=<?php if(!$time_set){echo "\"0\"";} else {echo "\"" . get_minutes($con, $row['m_id'], $row['s_id'])->fetch()['minutes'] . "\""; }?>/>
|
<input name=\"minutes\" type=\"number\" min=\"0\" max=\"60\" value=";
|
||||||
|
if(!$time_set){
|
||||||
|
echo "\"0\"";
|
||||||
|
} else {
|
||||||
|
echo "\"" . get_minutes($con, $m_id, $s_id)->fetch()['minutes'] . "\"";
|
||||||
|
}
|
||||||
|
echo "/>
|
||||||
</div>
|
</div>
|
||||||
<div class="number_field">
|
<div class=\"number_field\">
|
||||||
<label for="seconds">Sekunden</label>
|
<label for=\"seconds\">Sekunden</label>
|
||||||
<input name="seconds" type="number" min="0" max="60" value=<?php if(!$time_set){echo"\"0\"";} else { echo "\"" . get_seconds($con, $row['m_id'], $row['s_id'])->fetch()['seconds'] . "\""; }?>/>
|
<input name=\"seconds\" type=\"number\" min=\"0\" max=\"60\" value=";
|
||||||
|
if(!$time_set){
|
||||||
|
echo"\"0\"";
|
||||||
|
} else {
|
||||||
|
echo "\"" . get_seconds($con, $m_id, $s_id)->fetch()['seconds'] . "\""; }
|
||||||
|
echo"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="number_field">
|
<div class=\"number_field\">
|
||||||
<label for="millis">Millisekunden</label>
|
<label for=\"millis\">Millisekunden</label>
|
||||||
<input name="millis" type="number" min="0" max="99" value=<?php if(!$time_set){echo"\"0\"";} else { echo "\"" . get_millis($con, $row['m_id'], $row['s_id'])->fetch()['millis'] / 1e4 . "\""; }?>/>
|
<input name=\"millis\" type=\"number\" min=\"0\" max=\"99\" value=";
|
||||||
|
if(!$time_set) {
|
||||||
|
echo"\"0\"";
|
||||||
|
} else {
|
||||||
|
$millis = get_millis($con, $m_id, $s_id)->fetch()['millis'] / 1e4;
|
||||||
|
echo "\"" . $millis . "\"";
|
||||||
|
}
|
||||||
|
echo"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>";
|
||||||
<input type="hidden" name="m_id" value=<?php echo $row['m_id'] ?>/>
|
} else {
|
||||||
<input type="hidden" name="s_id" value=<?php echo $row['s_id'] ?>/>
|
echo "<div class=\"number_field\">
|
||||||
<input name="button" type="submit" value="Speichern" class="btn-confirm"/>
|
<label for=\"result\">Ergebnis: </label>
|
||||||
|
<input name=\"result\" type=\"number\" min=\"0\" max=\"65535\" value=";
|
||||||
|
echo "\"" . get_result_team_station($con, $s_id, $m_id) . "\"";
|
||||||
|
echo "</div>";
|
||||||
|
}?>
|
||||||
|
<input type="hidden" name="m_id" value=<?php echo $m_id ?>/>
|
||||||
|
<input type="hidden" name="s_id" value=<?php echo $s_id ?>/>
|
||||||
|
<input name="save" type="submit" value="Speichern" class="btn-confirm"/>
|
||||||
<input type="submit" name="close" value="Schließen" class="btn-confirm"/>
|
<input type="submit" name="close" value="Schließen" class="btn-confirm"/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -470,3 +470,63 @@ function update_team_fire_department($con, $m_id, $dep) {
|
|||||||
handle_pdo_exception($e);
|
handle_pdo_exception($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_direct_points($con, $s_id) {
|
||||||
|
try {
|
||||||
|
$stmt = $con->prepare("SELECT direkte_punkte FROM Station WHERE s_id = :s_id");
|
||||||
|
$stmt->execute(['s_id' => $s_id]);
|
||||||
|
$stmt->setFetchMode(PDO::FETCH_ASSOC);
|
||||||
|
return $stmt;
|
||||||
|
} catch(PDOException $e) {
|
||||||
|
handle_pdo_exception($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function write_result_db($con, $s_id, $m_id, $result) {
|
||||||
|
try {
|
||||||
|
$stmt = $con->prepare("INSERT INTO Ergebnisse (s_id, m_id, erg) VALUES (?, ?, ?)");
|
||||||
|
$stmt->bindParam(1, $s_id, PDO::PARAM_INT);
|
||||||
|
$stmt->bindParam(2, $m_id, PDO::PARAM_INT);
|
||||||
|
$stmt->bindParam(3, $result, PDO::PARAM_INT);
|
||||||
|
$stmt->execute();
|
||||||
|
} catch(PDOException $e) {
|
||||||
|
handle_pdo_exception($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_results($con, $s_id) {
|
||||||
|
try {
|
||||||
|
$stmt = $con->prepare("SELECT * FROM Ergebnisse WHERE s_id = :s_id ORDER BY erg DESC");
|
||||||
|
$stmt->execute(['s_id' => $s_id]);
|
||||||
|
$stmt->setFetchMode(PDO::FETCH_ASSOC);
|
||||||
|
return $stmt;
|
||||||
|
} catch(PDOException $e) {
|
||||||
|
handle_pdo_exception($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_result_db($con, $s_id, $m_id, $result) {
|
||||||
|
try {
|
||||||
|
$stmt = $con->prepare("UPDATE Ergebnisse SET erg = ? WHERE s_id = ? AND m_id = ?");
|
||||||
|
$stmt->bindParam(1, $result, PDO::PARAM_INT);
|
||||||
|
$stmt->bindParam(2, $s_id, PDO::PARAM_INT);
|
||||||
|
$stmt->bindParam(3, $m_id, PDO::PARAM_INT);
|
||||||
|
$stmt->execute();
|
||||||
|
} catch(PDOException $e) {
|
||||||
|
handle_pdo_exception($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_result_team_station($con, $s_id, $m_id) {
|
||||||
|
try {
|
||||||
|
$stmt = $con->prepare("SELECT * FROM Ergebnisse WHERE s_id = ? AND m_id = ?");
|
||||||
|
$stmt->bindParam(1, $s_id, PDO::PARAM_INT);
|
||||||
|
$stmt->bindParam(2, $m_id, PDO::PARAM_INT);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->setFetchMode(PDO::FETCH_ASSOC);
|
||||||
|
$result = $stmt->fetch()['erg'];
|
||||||
|
return $result;
|
||||||
|
} catch( PDOException $e) {
|
||||||
|
handle_pdo_exception($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -229,3 +229,23 @@ function sanitize_input ($input) {
|
|||||||
$return = strip_tags($input);
|
$return = strip_tags($input);
|
||||||
return htmlspecialchars($return, ENT_QUOTES);
|
return htmlspecialchars($return, ENT_QUOTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update_points($con, $s_id) {
|
||||||
|
$results = get_results($con, $s_id)->fetchAll();
|
||||||
|
$factor = $results[0]['erg']/ 15.0;
|
||||||
|
foreach($results as $row) {
|
||||||
|
$points = round($row['erg']/$factor);
|
||||||
|
change_points($con, $row['m_id'], $s_id, $points);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function write_result($con, $s_id, $m_id, $result) {
|
||||||
|
write_result_db($con, $s_id, $m_id, $result);
|
||||||
|
write_points($con, $s_id, $m_id, 0, null);
|
||||||
|
update_points($con, $s_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_result($con, $s_id, $m_id, $result) {
|
||||||
|
update_result_db($con, $s_id, $m_id, $result);
|
||||||
|
update_points($con, $s_id);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user