This commit is contained in:
2026-03-20 17:13:38 +01:00
parent 4c84735b75
commit c043ee9a52
1152 changed files with 317560 additions and 0 deletions
+134
View File
@@ -0,0 +1,134 @@
<?php
//Since this page writes to a session, initialise it here
session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["action"] == "PDF anzeigen") {
// Weiterleitung zur createPDF.php mit den Parametern
$userId = $_POST["user"];
$selectedMonth = $_POST["month"];
$monthYear = explode("/", $selectedMonth);
$month = $monthYear[0];
$year = $monthYear[1];
// Weiterleitung zur createPDF.php mit den Parametern
# echo "Location: createPDF.php?id=$userId&month=$month&year=$year";
header("Location: createPDF.php?id=$userId&month=$month&year=$year");
exit();
}
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.");
}
$user_id = $_SESSION['userid'];
// Monate für den Dropdown-Menü erhalten
try {
$months_stmt = $pdo->prepare("SELECT DISTINCT MONTH(timestamp_datetime) as month, YEAR(timestamp_datetime) as year FROM timestamps WHERE employee_id = ? ORDER BY timestamp_datetime DESC");
$months_stmt->bindParam(1, $user_id);
$months_stmt->execute();
$months = $months_stmt->fetchAll(PDO::FETCH_ASSOC);
} catch(PDOException $e) {
echo "Datenbankfehler: " . $e->getMessage();
}
$selectedMonth = $_POST['month'] ?? '';
#$selectedYear = $_POST['year'] ?? '';
// Zeiten für den ausgewählten Monat erhalten
if ($selectedMonth ) {
try {
$selectedYear = explode('/',$selectedMonth)[1];
$times_stmt = $pdo->prepare("SELECT timestamp_datetime, timestamp_type FROM timestamps WHERE employee_id = ? AND MONTH(timestamp_datetime) = ? AND YEAR(timestamp_datetime) = ? ORDER BY timestamp_datetime ASC");
$times_stmt->bindParam(1, $user_id);
$times_stmt->bindParam(2, $selectedMonth);
$times_stmt->bindParam(3, $selectedYear);
$times_stmt->execute();
$times = $times_stmt->fetchAll(PDO::FETCH_ASSOC);
} catch(PDOException $e) {
echo "Datenbankfehler: " . $e->getMessage();
}
// Gruppieren der Zeiten nach Tagen
$groupedTimes = [];
foreach ($times as $time) {
$date = date('Y-m-d', strtotime($time['timestamp_datetime']));
$groupedTimes[$date][] = $time;
}
}
?>
<h2>Zeitenübersicht</h2>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<div class="form-group">
<label for="month">Monat auswählen:</label>
<select name="month" id="month" class="form-control">
<?php foreach ($months as $month): ?>
<option value="<?php echo $month['month'] . '/' . $month['year']; ?>" <?php if ($month['month'] == $selectedMonth && $month['year'] == $selectedYear) echo 'selected'; ?>>
<?php echo $month['month'] . '/' . $month['year']; ?>
</option>
<?php endforeach; ?>
</select>
<br><br>
<input type="submit" value="Zeiten anzeigen" class="btn btn-primary btn-lg">
<!-- Button zum Anzeigen der PDF -->
<input type="submit" name="action" value="PDF anzeigen" class="btn btn-primary btn-lg" formtarget="_blank">
</div>
</form>
<?php if ($selectedMonth): ?>
<table class="table table-striped table-hover">
<tr>
<th>Datum</th>
<th>Typ</th>
<th>Aktionen</th>
</tr>
<?php foreach ($groupedTimes as $date => $times): ?>
<tr>
<td><?php echo date('d.m.Y', strtotime($date)); ?></td>
<td>
<?php foreach ($times as $time): ?>
<div><?php echo date('H:i:s', strtotime($time['timestamp_datetime'])) . ' - ' . $time['timestamp_type']; ?></div>
<?php endforeach; ?>
</td>
<td>
<!-- Hier können Sie Aktionen für jeden Tag hinzufügen, z.B. Bearbeiten/Löschen des gesamten Tages -->
<a href="editDayEntries.php?employee_id=<?php echo $user_id; ?>&datum=<?php echo date('Y-m-d', strtotime($time['timestamp_datetime'])); ?>" class="btn btn-primary">Anpassen</a>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</div>
</div>
</div>
<?php include 'footer.php'; ?>