91 lines
2.8 KiB
PHP
91 lines
2.8 KiB
PHP
<?php
|
|
require 'config.php';
|
|
//if (!isset($_SESSION['user_id'])) {
|
|
// header('Location: index.php');
|
|
// exit;
|
|
//}
|
|
// echo $_SESSION['user_id'];
|
|
error_log($_SESSION['user_id']);
|
|
|
|
// Login-Logik
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
|
|
$stmt->execute([$_POST['username']]);
|
|
$user = $stmt->fetch();
|
|
if ($user && password_verify($_POST['password'], $user['password'])) {
|
|
$_SESSION['user_id'] = $user['id'];
|
|
} else {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
}
|
|
|
|
// Daten abrufen
|
|
$sql="WITH user_names AS (SELECT p.id,b_single.username AS zahler,GROUP_CONCAT(b_array.username) AS personen FROM entries p LEFT JOIN users b_single ON p.user_id = b_single.id JOIN JSON_TABLE(p.person,'$[*]' COLUMNS(id INT PATH '$')) AS jt LEFT JOIN users b_array ON jt.id = b_array.id GROUP BY p.id, b_single.username) SELECT e.*, un.zahler, un.personen FROM entries e JOIN user_names un ON e.id = un.id;";
|
|
$stmt = $pdo->prepare($sql);
|
|
$stmt->execute();
|
|
$entries = $stmt->fetchAll();
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=0.8">
|
|
<title>FSCash - Dashboard</title>
|
|
<link rel="stylesheet" href="assets/css/style.css">
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<!-- Navigation -->
|
|
<nav class="nav">
|
|
<button class="hamburger">☰</button>
|
|
<ul class="nav-list">
|
|
<li><a href="dashboard.php">Start</a></li>
|
|
<li><a href="register.php">Neue User</a></li>
|
|
<li><a href="menu3.php" style="display: none;">Menüpunkt 3</a></li>
|
|
<li><a href="menu4.php" style="display: none;">Menüpunkt 4</a></li>
|
|
<li><a href="menu5.php" style="display: none;">Menüpunkt 5</a></li>
|
|
</ul>
|
|
<a href="logout.php" class="logout">Logout</a>
|
|
</nav>
|
|
|
|
<!-- Tabelle -->
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Datum</th>
|
|
<th class="hide-on-mobile">Zahler</th>
|
|
<th class="hide-on-mobile">Person</th>
|
|
<th class="hide-on-mobile">Kategorie</th>
|
|
<th>Zahlweise</th>
|
|
<th>Betreff</th>
|
|
<th>Betrag</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($entries as $entry): ?>
|
|
<tr>
|
|
<td><?= htmlspecialchars($entry['date']) ?></td>
|
|
<td class="hide-on-mobile"><?= htmlspecialchars($entry['zahler'] ?? '') ?></td>
|
|
<td class="hide-on-mobile"><?= htmlspecialchars($entry['personen'] ?? '') ?></td>
|
|
<td class="hide-on-mobile"><?= htmlspecialchars($entry['category'] ?? '') ?></td>
|
|
<td><?= htmlspecialchars($entry['payment_method'] ?? '') ?></td>
|
|
<td><?= htmlspecialchars($entry['subject']) ?></td>
|
|
<td><?= htmlspecialchars($entry['amount']) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
|
|
<!-- Neu-Button -->
|
|
<a href="new_entry.php" class="btn-xr">Neu</a>
|
|
</div>
|
|
|
|
<script>
|
|
// Hamburger-Menü-Funktion
|
|
document.querySelector('.hamburger').addEventListener('click', function() {
|
|
document.querySelector('.nav-list').classList.toggle('show');
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|