diff --git a/app/public/edit_team.php b/app/public/edit_team.php
new file mode 100644
index 0000000..ee131a7
--- /dev/null
+++ b/app/public/edit_team.php
@@ -0,0 +1,51 @@
+fetch();
+ }
+
+ if($_SERVER['REQUEST_METHOD'] == "POST") {
+ $row = get_team($con, $_POST['m_id'])->fetch();
+
+ if($_POST['team_name'] != $row['name']) {
+ update_team_name($con, $_POST['m_id'], $_POST['team_name']);
+ }
+
+ if($_POST['fire_department'] != $row['feuerwehr']) {
+ update_team_fire_department($con, $_POST['m_id'], $_POST['fire_department']);
+ }
+
+ header("Location: mannschaft.php");
+ die;
+ }
+
+ include("header_footer/header.php");
+?>
+
+
+
Mannschaft bearbeiten
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/public/js/edit_table.js b/app/public/js/edit_table.js
index 4cf396f..f6ee1e2 100644
--- a/app/public/js/edit_table.js
+++ b/app/public/js/edit_table.js
@@ -13,6 +13,7 @@ function init() {
user_edit_button();
statistic_edit_button();
station_edit_button();
+ team_edit_button();
}
var selected = null;
@@ -77,4 +78,15 @@ function station_edit_button() {
this.form.submit();
}
}
+}
+
+function team_edit_button() {
+ var button = document.getElementById('edit_team');
+ if(button != null) {
+ button.onclick = function() {
+ var row = document.getElementsByClassName('selected')[0];
+ document.getElementById('m_id').value = row.id;
+ this.form.submit();
+ }
+ }
}
\ No newline at end of file
diff --git a/app/public/mannschaft.php b/app/public/mannschaft.php
index 44cbcec..4ff9224 100644
--- a/app/public/mannschaft.php
+++ b/app/public/mannschaft.php
@@ -14,7 +14,13 @@
+
+
+
diff --git a/app/scripts/database_queries.php b/app/scripts/database_queries.php
index 22a2008..5e93da8 100644
--- a/app/scripts/database_queries.php
+++ b/app/scripts/database_queries.php
@@ -76,7 +76,7 @@ function get_stations_all($con) {
function get_teams($con) {
try {
- $stmt = $con->prepare("SELECT name, feuerwehr FROM Mannschaft");
+ $stmt = $con->prepare("SELECT * FROM Mannschaft");
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
return $stmt;
@@ -373,8 +373,6 @@ function get_station_all($con, $s_id) {
function update_station_name($con, $s_id, $name) {
try {
- echo $s_id . "\n";
- echo $name . "\n";
$stmt = $con->prepare("UPDATE Station SET name = ? WHERE s_id = ?");
$stmt->bindParam(1, $name, PDO::PARAM_STR);
$stmt->bindParam(2, $s_id, PDO::PARAM_INT);
@@ -393,4 +391,37 @@ function update_station_pos($con, $s_id, $pos) {
} catch(PDOException $e) {
handle_pdo_exception($e);
}
+}
+
+function get_team($con, $m_id) {
+ try {
+ $stmt = $con->prepare("SELECT * FROM Mannschaft WHERE m_id = :m_id");
+ $stmt->execute(['m_id' => $m_id]);
+ $stmt->setFetchMode(PDO::FETCH_ASSOC);
+ return $stmt;
+ } catch(PDOException $e) {
+ handle_pdo_exception($e);
+ }
+}
+
+function update_team_name($con, $m_id, $name) {
+ try {
+ $stmt = $con->prepare("UPDATE Mannschaft SET name = ? WHERE m_id = ?");
+ $stmt->bindParam(1, $name, PDO::PARAM_STR);
+ $stmt->bindParam(2, $m_id, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch(PDOException $e) {
+ handle_pdo_exception($e);
+ }
+}
+
+function update_team_fire_department($con, $m_id, $dep) {
+ try {
+ $stmt = $con->prepare("UPDATE Mannschaft SET feuerwehr = ? WHERE m_id = ?");
+ $stmt->bindParam(1, $dep, PDO::PARAM_STR);
+ $stmt->bindParam(2, $m_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 0ac2913..32c0cf0 100644
--- a/app/scripts/functions.php
+++ b/app/scripts/functions.php
@@ -47,7 +47,7 @@ function load_stations_table($con) {
function load_teams_table($con) {
$stmt = get_teams($con);
foreach($stmt->fetchAll() as $row) {
- echo "
";
+ echo "
";
echo "| " . $row['name'] . " | ";
echo "" . $row['feuerwehr'] . " | ";
echo "
";