diff --git a/app/public/add_entry.php b/app/public/add_entry.php
index 176c395..cfdb7d2 100644
--- a/app/public/add_entry.php
+++ b/app/public/add_entry.php
@@ -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");
diff --git a/app/public/edit_station.php b/app/public/edit_station.php
new file mode 100644
index 0000000..e69de29
diff --git a/app/public/edit_statistics.php b/app/public/edit_statistics.php
index 96162b0..58221ea 100644
--- a/app/public/edit_statistics.php
+++ b/app/public/edit_statistics.php
@@ -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;
+ }
?>
@@ -16,7 +36,23 @@
diff --git a/app/scripts/database_queries.php b/app/scripts/database_queries.php
index d845dca..65d14d2 100644
--- a/app/scripts/database_queries.php
+++ b/app/scripts/database_queries.php
@@ -270,4 +270,92 @@ function get_result($con, $m_id, $s_id) {
} catch(PDOException $e) {
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);
+ }
}
\ No newline at end of file
diff --git a/app/scripts/functions.php b/app/scripts/functions.php
index 741c0a4..686f86f 100644
--- a/app/scripts/functions.php
+++ b/app/scripts/functions.php
@@ -149,4 +149,13 @@ function load_users($con) {
echo "
" . $row['s_id'] . " | \n";
echo "\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;
+ }
}
\ No newline at end of file