began with implementing edeting for statistics

This commit is contained in:
2022-06-10 16:20:22 +02:00
parent 20970ebf3a
commit afbfe52688
8 changed files with 55 additions and 69 deletions

View File

@@ -0,0 +1,26 @@
<?php
session_start();
include("../scripts/connection.php");
include("../scripts/functions.php");
$user_data=check_login($con);
if($_SERVER['REQUEST_METHOD'] == "GET") {
$row = get_result($con, $_GET["m_id"], $_GET['s_id'])->fetch();
include("header_footer/header.php");
}
?>
<body>
<div class="headline">
<h2>Ergebniss bearbeiten</h2>
</div>
<div>
<form method="post">
<label for="team_name">Mannschaftsname: </label>
<label for=""><?php echo $row['name']?></label>
</form>
</div>
</body>
<?php
$con = null;
echo file_get_contents("header_footer/footer.html");
?>

View File

@@ -6,11 +6,10 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/styles.css">
<script src="js/select_table.js"></script>
<script src="js/edit_table.js"></script>
</head>
<header>
<script src="js/http_req.js" type="module"></script>
<section>
<div id="logo">
Punktesystem-KSP

View File

@@ -1,17 +0,0 @@
//wait for html site to be ready before executing init()
if (document.readyState == "complete") {
init();
} else {
document.addEventListener("DOMContentLoaded", init);
}
function init() {
var button = document.getElementById("edit_user");
button.onclick = function() {
var row = document.getElementsByClassName("selected")[0];
document.getElementById('user_id_val').value = row.id;
this.form.submit();
}
}

View File

@@ -1,43 +0,0 @@
//wait for html site to be ready before executing init()
if (document.readyState == "complete") {
init();
} else {
document.addEventListener("DOMContentLoaded", init);
}
function init() {
if(document.getElementById('table') != null) {
highlight_row();
}
}
var selected = null;
function highlight_row() {
var table = document.getElementById('table');
var cells = table.getElementsByTagName('td');
for( var i = 0; i < cells.length; i++) {
var cell = cells[i];
cell.onclick = function() {
var rowId = this.parentNode.rowIndex;
var rowsNotSelected = table.getElementsByTagName('tr');
for ( var row = 0; row < rowsNotSelected.length; row++) {
rowsNotSelected[row].style.backgroundColor = "";
rowsNotSelected[row].classList.remove('selected');
}
var rowSelected = table.getElementsByTagName('tr')[rowId];
if (selected != null && selected == rowId) {
selected = null;
rowSelected.style.backgroundColor = "";
rowSelected.classList.remove('selected');
document.getElementsByClassName("edit")[0].disabled = true;
} else {
selected = rowId;
rowSelected.style.backgroundColor = "yellow";
rowSelected.className += " selected";
document.getElementsByClassName("edit")[0].disabled = false;
}
}
}
}

View File

@@ -22,7 +22,6 @@
<input id="user_id_val" type="hidden" name="id"/>
</form>
</div>
<script src="js/edit_user.js"></script>
<div class="table-div">
<table id="table">
<thead>

View File

@@ -41,11 +41,21 @@
echo "<form action=\"add_entry.php\" method=\"get\">
<input type=\"hidden\" name=\"station\" value=\"$session\"/>
<input type=\"submit\" value=\"Ergebniss eintragen\"/>
</form>";
</form>\n";
}
?>
</div>
<?php
if ($session != "total-score") {
echo "<div>
<form action=\"edit_statistics.php\" method=\"get\">
<input type=\"button\" id=\"edit_statistic\" value=\"Eintrag bearbeiten\" class=\"edit\" disabled=true/>
<input type=\"hidden\" id=\"team_id\" name=\"m_id\"/>
<input type=\"hidden\" id=\"station_id\" name=\"s_id\" value=\"". $session . "\"/>
</form>
</div>";
} ?>
<div class="table-div">
<table id="table">
<?php

View File

@@ -109,7 +109,7 @@ function get_station_name($con, $s_id) {
function get_station($con, $s_id) {
try {
$stmt = $con->prepare("SELECT M.name as Name, M.feuerwehr as Feuerwehr, P.punkte as Punkte, P.zeit as Zeit FROM Punkte as P, Station as S, Mannschaft as M WHERE P.s_id = S.s_id AND S.s_id = :s_id AND M.m_id = P.m_id ORDER BY Punkte DESC");
$stmt = $con->prepare("SELECT P.m_id as m_id, M.name as Name, M.feuerwehr as Feuerwehr, P.punkte as Punkte, P.zeit as Zeit FROM Punkte as P, Station as S, Mannschaft as M WHERE P.s_id = S.s_id AND S.s_id = :s_id AND M.m_id = P.m_id ORDER BY Punkte DESC");
$stmt->execute(['s_id' => $s_id]);
$stmt->setFetchMode(PDO::FETCH_ASSOC);
return $stmt;
@@ -232,7 +232,7 @@ function change_user_name($con, $id, $user_name) {
$stmt->bindParam(1, $user_name, PDO::PARAM_STR);
$stmt->bindParam(2, $id, PDO::PARAM_STR);
$stmt->execute();
} catch(PDOExeption $e) {
} catch(PDOException $e) {
handle_pdo_exception($e);
}
}
@@ -244,7 +244,7 @@ function change_user_group($con, $id, $user_group, $s_id) {
$stmt->bindParam(2, $s_id, PDO::PARAM_INT);
$stmt->bindParam(3, $id, PDO::PARAM_INT);
$stmt->execute();
} catch(PDOExeption $e) {
} catch(PDOException $e) {
handle_pdo_exception($e);
}
}
@@ -255,7 +255,19 @@ function change_password($con, $id, $password) {
$stmt->bindParam(1, $password, PDO::PARAM_STR);
$stmt->bindParam(2, $id, PDO::PARAM_STR);
$stmt->execute();
} catch(PDOExeption $e) {
} catch(PDOException $e) {
handle_pdo_exception($e);
}
}
function get_result($con, $m_id, $s_id) {
try {
$stmt = $con->prepare("SELECT P.*, M.name as name, M.feuerwehr as feuerwehr FROM Punkte P, Mannschaft M WHERE M.m_id = P.m_id AND P.m_id = ? AND P.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);
}
}

View File

@@ -102,7 +102,7 @@ function load_station_table($con, $s_id) {
<tbody>\n";
$stmt = get_station($con, $s_id);
foreach($stmt->fetchAll() as $row) {
echo "<tr>\n";
echo "<tr id=\"" . $row['m_id'] . "\" class=\"row\">\n";
echo "<td>" . $row['Name'] . "</td>\n";
echo "<td>" . $row['Feuerwehr'] . "</td>\n";
echo "<td>" . $row['Punkte'] . "</td>\n";