added edit statistics
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
if($minutes == 0 && $seconds == 0 && $miliseconds == 0){
|
||||
$time = null;
|
||||
} else {
|
||||
$time = $minutes . ":" . $seconds . "." . $miliseconds;
|
||||
$time = "00:" . $minutes . ":" . $seconds . "." . $miliseconds;
|
||||
}
|
||||
write_points($con, $_GET['station'], $_POST['team'], $points, $time);
|
||||
header("Location: statistik.php");
|
||||
|
||||
0
app/public/edit_station.php
Normal file
0
app/public/edit_station.php
Normal file
@@ -8,6 +8,26 @@
|
||||
$row = get_result($con, $_GET["m_id"], $_GET['s_id'])->fetch();
|
||||
include("header_footer/header.php");
|
||||
}
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$m_id = intval($_POST['m_id']);
|
||||
$s_id = intval($_POST['s_id']);
|
||||
$points = intval($_POST['points']);
|
||||
$minutes = intval($_POST['minutes']);
|
||||
$seconds = intval($_POST['seconds']);
|
||||
$millis = intval($_POST['millis']);
|
||||
if (get_points($con, $m_id, $s_id)->fetch()['punkte'] != $points) {
|
||||
change_points($con, $m_id, $s_id, $points);
|
||||
}
|
||||
|
||||
if (get_minutes($con, $m_id, $s_id)->fetch()['minutes'] != $minutes || get_seconds($con, $m_id, $s_id)->fetch()['seconds'] != $seconds || get_millis($con, $m_id, $s_id)->fetch()['millis'] != $millis) {
|
||||
$time = "00:" . $minutes . ":" . $seconds . "." . $millis;
|
||||
change_time($con, $m_id, $s_id, $time);
|
||||
}
|
||||
|
||||
header("Location: statistik.php");
|
||||
die;
|
||||
}
|
||||
?>
|
||||
<body>
|
||||
<div class="headline">
|
||||
@@ -16,7 +36,23 @@
|
||||
<div>
|
||||
<form method="post">
|
||||
<label for="team_name">Mannschaftsname: </label>
|
||||
<label for=""><?php echo $row['name']?></label>
|
||||
<label for="" name="team_name"><?php echo $row['name']?></label><br>
|
||||
<label for="fire_department">Feuerwehr:</label>
|
||||
<label for="" name="fire_department"><?php echo $row["feuerwehr"]?></label><br>
|
||||
<label for="points">Punkte:</label>
|
||||
<input type="number" min="0" max="15" name="points" value="<?php echo $row['punkte']?>"/><br>
|
||||
<div id="time">
|
||||
<?php $time_set = check_time($con, $row['m_id'], $row['s_id']);?>
|
||||
<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'] . "\""; }?>/><br>
|
||||
<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'] . "\""; }?>/><br>
|
||||
<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'] . "\""; }?>/><br>
|
||||
</div>
|
||||
<input type="hidden" name="m_id" value=<?php echo $row['m_id'] ?>/>
|
||||
<input type="hidden" name="s_id" value=<?php echo $row['s_id'] ?>/>
|
||||
<input name="button" type="submit" value="Speichern"/>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -271,3 +271,91 @@ function get_result($con, $m_id, $s_id) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
|
||||
function get_time($con, $m_id, $s_id) {
|
||||
try {
|
||||
$stmt = $con->prepare("SELECT zeit FROM Punkte WHERE m_id = ? AND s_id = ?");
|
||||
$stmt->bindParam(1, $m_id, PDO::PARAM_INT);
|
||||
$stmt->bindParam(2, $s_id, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$stmt->setFetchMode(PDO::FETCH_ASSOC);
|
||||
return $stmt;
|
||||
} catch(PDOException $e) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
|
||||
function get_minutes($con, $m_id, $s_id) {
|
||||
try {
|
||||
$stmt = $con->prepare("SELECT MINUTE(zeit) as minutes FROM Punkte WHERE m_id = ? AND s_id = ?");
|
||||
$stmt->bindParam(1, $m_id, PDO::PARAM_INT);
|
||||
$stmt->bindParam(2, $s_id, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$stmt->setFetchMode(PDO::FETCH_ASSOC);
|
||||
return $stmt;
|
||||
} catch(PDOException $e) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
|
||||
function get_seconds($con, $m_id, $s_id) {
|
||||
try {
|
||||
$stmt = $con->prepare("SELECT SECOND(zeit) as seconds FROM Punkte WHERE m_id = ? AND s_id = ?");
|
||||
$stmt->bindParam(1, $m_id, PDO::PARAM_INT);
|
||||
$stmt->bindParam(2, $s_id, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$stmt->setFetchMode(PDO::FETCH_ASSOC);
|
||||
return $stmt;
|
||||
} catch(PDOException $e) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
|
||||
function get_millis($con, $m_id, $s_id) {
|
||||
try {
|
||||
$stmt = $con->prepare("SELECT MICROSECOND(zeit) as millis FROM Punkte WHERE m_id = ? AND s_id = ?");
|
||||
$stmt->bindParam(1, $m_id, PDO::PARAM_INT);
|
||||
$stmt->bindParam(2, $s_id, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$stmt->setFetchMode(PDO::FETCH_ASSOC);
|
||||
return $stmt;
|
||||
} catch(PDOException $e) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
|
||||
function get_points($con, $m_id, $s_id) {
|
||||
try {
|
||||
$stmt = $con->prepare("SELECT punkte FROM Punkte WHERE m_id = ? AND s_id = ?");
|
||||
$stmt->bindParam(1, $m_id, PDO::PARAM_INT);
|
||||
$stmt->bindParam(2, $s_id, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
return $stmt;
|
||||
} catch(PDOException $e) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
|
||||
function change_points($con, $m_id, $s_id, $points) {
|
||||
try {
|
||||
$stmt = $con->prepare("UPDATE Punkte as P SET P.punkte = ? WHERE P.m_id = ? AND P.s_id = ?");
|
||||
$stmt->bindParam(1, $points, PDO::PARAM_INT);
|
||||
$stmt->bindParam(2, $m_id, PDO::PARAM_INT);
|
||||
$stmt->bindParam(3, $s_id, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
} catch(PDOException $e) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
|
||||
function change_time($con, $m_id, $s_id, $time) {
|
||||
try {
|
||||
$stmt = $con->prepare("UPDATE Punkte as P SET P.zeit = ? WHERE P.m_id = ? AND P.s_id = ?");
|
||||
$stmt->bindParam(1, $time, PDO::PARAM_INT);
|
||||
$stmt->bindParam(2, $m_id, PDO::PARAM_INT);
|
||||
$stmt->bindParam(3, $s_id, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
} catch(PDOException $e) {
|
||||
handle_pdo_exception($e);
|
||||
}
|
||||
}
|
||||
@@ -150,3 +150,12 @@ function load_users($con) {
|
||||
echo "</tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
function check_time($con, $m_id, $s_id) {
|
||||
$stmt = get_time($con, $m_id, $s_id);
|
||||
if (($stmt->fetch()) == NULL) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user