diff --git a/app/public/css/styles.css b/app/public/css/styles.css
index 406463d..da5cf86 100644
--- a/app/public/css/styles.css
+++ b/app/public/css/styles.css
@@ -81,3 +81,11 @@ div.headline h2{
padding: 10px 0px;
font-weight: 400;
}
+
+tr.highlight {
+ background: #eef;
+}
+
+tr.clicked {
+ background: #ccd;
+}
\ No newline at end of file
diff --git a/app/public/edit_user.php b/app/public/edit_user.php
new file mode 100644
index 0000000..5137d1d
--- /dev/null
+++ b/app/public/edit_user.php
@@ -0,0 +1,72 @@
+fetch();
+ include("header_footer/header.php");
+ }
+
+ if($_SERVER['REQUEST_METHOD'] == "POST") {
+ $user = get_user($con, $_POST['id'])->fetch();
+
+ if($user['user_name'] != $_POST['user_name']) {
+ change_user_name($con, $_POST['id'], $_POST['user_name']);
+ }
+
+ if($user['user_group'] != $_POST['user_group']) {
+ if($_POST['user_group'] == "station") {
+ change_user_group($con, $_POST['id'], $_POST['user_group'], $_POST['bind_station']);
+ } else {
+ change_user_group($con, $_POST['id'], $_POST['user_group'], NULL);
+ }
+ }
+
+ if(!empty($_POST['password'])) {
+ $phash = generate_password_hash($_POST['password'], $user['salt']);
+ change_password($con, $_POST['id'], $phash);
+ }
+
+ header("Location: manage_user.php");
+ die;
+ }
+
+?>
+
+
+
Benutzer bearbeiten
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/public/header_footer/header.php b/app/public/header_footer/header.php
index 0d18442..4208c0e 100644
--- a/app/public/header_footer/header.php
+++ b/app/public/header_footer/header.php
@@ -6,9 +6,11 @@
+
+
Punktesystem-KSP
diff --git a/app/public/js/edit_user.js b/app/public/js/edit_user.js
new file mode 100644
index 0000000..2472f8f
--- /dev/null
+++ b/app/public/js/edit_user.js
@@ -0,0 +1,17 @@
+//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();
+ }
+}
\ No newline at end of file
diff --git a/app/public/js/select_table.js b/app/public/js/select_table.js
new file mode 100644
index 0000000..c8698fc
--- /dev/null
+++ b/app/public/js/select_table.js
@@ -0,0 +1,43 @@
+//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;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/public/manage_user.php b/app/public/manage_user.php
index ee9976f..ec175ee 100644
--- a/app/public/manage_user.php
+++ b/app/public/manage_user.php
@@ -16,8 +16,15 @@
+
+
+
+
-
+
| Name |
diff --git a/app/public/mannschaft.php b/app/public/mannschaft.php
index a781a92..44cbcec 100644
--- a/app/public/mannschaft.php
+++ b/app/public/mannschaft.php
@@ -18,7 +18,7 @@
-
+
| Name |
diff --git a/app/public/stationen.php b/app/public/stationen.php
index 6616925..6401289 100644
--- a/app/public/stationen.php
+++ b/app/public/stationen.php
@@ -18,7 +18,7 @@
-
+
| Name |
diff --git a/app/public/statistik.php b/app/public/statistik.php
index f5b0a18..fb9ce65 100644
--- a/app/public/statistik.php
+++ b/app/public/statistik.php
@@ -47,7 +47,7 @@
?>
-
+
prepare("SELECT user_name, user_group, s_id FROM users");
+ $stmt = $con->prepare("SELECT id, user_name, user_group, s_id FROM users");
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
return $stmt;
@@ -200,6 +200,17 @@ function get_users($con) {
}
}
+function get_user($con, $id) {
+ try {
+ $stmt = $con->prepare("SELECT * FROM users WHERE id = :id");
+ $stmt->execute(['id' => $id]);
+ $stmt->setFetchMode(PDO::FETCH_ASSOC);
+ return $stmt;
+ } catch(PDOException $e) {
+ handle_pdo_exception($e);
+ }
+}
+
function write_user($con, $user_name, $user_id, $phash, $salt, $user_group, $s_id) {
try {
$stmt = $con->prepare("INSERT INTO users (user_id, password, user_name, salt, user_group, s_id) VALUES (?, ?, ?, ?, ?, ?)");
@@ -213,4 +224,38 @@ function write_user($con, $user_name, $user_id, $phash, $salt, $user_group, $s_i
} catch(PDOException $e) {
handle_pdo_exception($e);
}
+}
+
+function change_user_name($con, $id, $user_name) {
+ try {
+ $stmt = $con->prepare("UPDATE users SET user_name = ? WHERE id= ?");
+ $stmt->bindParam(1, $user_name, PDO::PARAM_STR);
+ $stmt->bindParam(2, $id, PDO::PARAM_STR);
+ $stmt->execute();
+ } catch(PDOExeption $e) {
+ handle_pdo_exception($e);
+ }
+}
+
+function change_user_group($con, $id, $user_group, $s_id) {
+ try {
+ $stmt = $con->prepare("UPDATE users SET user_group = ?, s_id = ? WHERE id= ?");
+ $stmt->bindParam(1, $user_group, PDO::PARAM_STR);
+ $stmt->bindParam(2, $s_id, PDO::PARAM_INT);
+ $stmt->bindParam(3, $id, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch(PDOExeption $e) {
+ handle_pdo_exception($e);
+ }
+}
+
+function change_password($con, $id, $password) {
+ try {
+ $stmt = $con->prepare("UPDATE users SET password = ? WHERE id= ?");
+ $stmt->bindParam(1, $password, PDO::PARAM_STR);
+ $stmt->bindParam(2, $id, PDO::PARAM_STR);
+ $stmt->execute();
+ } catch(PDOExeption $e) {
+ handle_pdo_exception($e);
+ }
}
\ No newline at end of file
diff --git a/app/scripts/functions.php b/app/scripts/functions.php
index dccd485..007d1dc 100644
--- a/app/scripts/functions.php
+++ b/app/scripts/functions.php
@@ -143,7 +143,7 @@ function check_admin($con) {
function load_users($con) {
$stmt = get_users($con);
foreach($stmt->fetchAll() as $row) {
- echo "\n";
+ echo "
\n";
echo "| " . $row['user_name'] . " | \n";
echo "" . $row['user_group'] . " | \n";
echo "" . $row['s_id'] . " | \n";