Abgleich mit Live-Daten
This commit is contained in:
+113
-113
@@ -1,114 +1,114 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once("inc/config.inc.php");
|
||||
require_once("inc/functions.inc.php");
|
||||
//Überprüfe, dass der User eingeloggt ist
|
||||
//Der Aufruf von check_user() muss in alle internen Seiten eingebaut sein
|
||||
$user = check_user();
|
||||
?>
|
||||
|
||||
<?php include 'header.php'; ?>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
|
||||
<?php
|
||||
// Überprüfen, ob eine Benutzer-ID in der Session vorhanden ist
|
||||
if (!isset($_SESSION['userid'])) {
|
||||
die("Kein Benutzer angemeldet.");
|
||||
}
|
||||
if($user["admin"] != 1){
|
||||
die("Kein Admin-Rechte.");
|
||||
}
|
||||
// Bearbeitungslogik
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['email'])) {
|
||||
$email = $_POST['email'];
|
||||
$vorname = $_POST['vorname'];
|
||||
$nachname = $_POST['nachname'];
|
||||
|
||||
// Füge neuen Mitarbeiter hinzu
|
||||
$sql = "INSERT INTO users (email, vorname, nachname) VALUES (?, ?, ?)";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$email, $vorname, $nachname]);
|
||||
|
||||
|
||||
echo "<br><div class='alert alert-success' role='alert'>Vorgang erfolgreich ausgeführt.</div>";
|
||||
}
|
||||
|
||||
// Abfrage der Mitarbeiterdaten
|
||||
$sql = "SELECT id, email, vorname, nachname, zeiterfassung, worker, admin, card_id, card2_id FROM users";
|
||||
$stmt = $pdo->query($sql);
|
||||
?>
|
||||
|
||||
<div class="container mt-5">
|
||||
<h2>Mitarbeiterliste</h2>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Email</th>
|
||||
<th>Vorname</th>
|
||||
<th>Nachname</th>
|
||||
<th>Zeiterfassung</th>
|
||||
<th>worker</th>
|
||||
<th>Admin</th>
|
||||
<th>Card ID</th>
|
||||
<th>Card2 ID</th>
|
||||
<th>Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
echo "<tr>";
|
||||
echo "<td>" . htmlspecialchars($row['id']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($row['email']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($row['vorname']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($row['nachname']) . "</td>";
|
||||
echo "<td>" ;
|
||||
if($row['zeiterfassung'] == "1"){echo "Ja";}
|
||||
echo "</td>";
|
||||
echo "<td>" ;
|
||||
if($row['worker'] == "1"){echo "Ja";}
|
||||
echo "</td>";
|
||||
echo "<td>" ;
|
||||
if($row['admin'] == "1"){echo "Ja";}
|
||||
echo "</td>";
|
||||
echo "<td>" . htmlspecialchars($row['card_id']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($row['card2_id']) . "</td>";
|
||||
echo "<td><a class='btn btn-primary btn-sm' href='editworker.php?id=" . $row["id"] . "'>Bearbeiten</a></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h2>Neuen Mitarbeiter hinzufügen</h2>
|
||||
<form action="" method="post" >
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<input type="text" class="form-control" id="email" name="email" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="vorname">Vorname</label>
|
||||
<input type="text" class="form-control" id="vorname" name="vorname" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="nachname">Nachname</label>
|
||||
<input type="text" class="form-control" id="nachname" name="nachname" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">Hinzufügen</button>
|
||||
</form>
|
||||
|
||||
|
||||
<br>
|
||||
<button type="button" class="btn btn-secondary" onclick="history.back();">Zurück</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
session_start();
|
||||
require_once("inc/config.inc.php");
|
||||
require_once("inc/functions.inc.php");
|
||||
//Überprüfe, dass der User eingeloggt ist
|
||||
//Der Aufruf von check_user() muss in alle internen Seiten eingebaut sein
|
||||
$user = check_user();
|
||||
?>
|
||||
|
||||
<?php include 'header.php'; ?>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
|
||||
<?php
|
||||
// Überprüfen, ob eine Benutzer-ID in der Session vorhanden ist
|
||||
if (!isset($_SESSION['userid'])) {
|
||||
die("Kein Benutzer angemeldet.");
|
||||
}
|
||||
if($user["admin"] != 1){
|
||||
die("Kein Admin-Rechte.");
|
||||
}
|
||||
// Bearbeitungslogik
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['email'])) {
|
||||
$email = $_POST['email'];
|
||||
$vorname = $_POST['vorname'];
|
||||
$nachname = $_POST['nachname'];
|
||||
|
||||
// Füge neuen Mitarbeiter hinzu
|
||||
$sql = "INSERT INTO users (email, vorname, nachname) VALUES (?, ?, ?)";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$email, $vorname, $nachname]);
|
||||
|
||||
|
||||
echo "<br><div class='alert alert-success' role='alert'>Vorgang erfolgreich ausgeführt.</div>";
|
||||
}
|
||||
|
||||
// Abfrage der Mitarbeiterdaten
|
||||
$sql = "SELECT id, email, vorname, nachname, zeiterfassung, worker, admin, card_id, card2_id FROM users";
|
||||
$stmt = $pdo->query($sql);
|
||||
?>
|
||||
|
||||
<div class="container mt-5">
|
||||
<h2>Mitarbeiterliste</h2>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Email</th>
|
||||
<th>Vorname</th>
|
||||
<th>Nachname</th>
|
||||
<th>Zeiterfassung</th>
|
||||
<th>worker</th>
|
||||
<th>Admin</th>
|
||||
<th>Card ID</th>
|
||||
<th>Card2 ID</th>
|
||||
<th>Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
echo "<tr>";
|
||||
echo "<td>" . htmlspecialchars($row['id']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($row['email']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($row['vorname']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($row['nachname']) . "</td>";
|
||||
echo "<td>" ;
|
||||
if($row['zeiterfassung'] == "1"){echo "Ja";}
|
||||
echo "</td>";
|
||||
echo "<td>" ;
|
||||
if($row['worker'] == "1"){echo "Ja";}
|
||||
echo "</td>";
|
||||
echo "<td>" ;
|
||||
if($row['admin'] == "1"){echo "Ja";}
|
||||
echo "</td>";
|
||||
echo "<td>" . htmlspecialchars($row['card_id']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($row['card2_id']) . "</td>";
|
||||
echo "<td><a class='btn btn-primary btn-sm' href='editworker.php?id=" . $row["id"] . "'>Bearbeiten</a></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h2>Neuen Mitarbeiter hinzufügen</h2>
|
||||
<form action="" method="post" >
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<input type="text" class="form-control" id="email" name="email" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="vorname">Vorname</label>
|
||||
<input type="text" class="form-control" id="vorname" name="vorname" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="nachname">Nachname</label>
|
||||
<input type="text" class="form-control" id="nachname" name="nachname" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">Hinzufügen</button>
|
||||
</form>
|
||||
|
||||
|
||||
<br>
|
||||
<button type="button" class="btn btn-secondary" onclick="history.back();">Zurück</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'footer.php'; ?>
|
||||
Reference in New Issue
Block a user