132 lines
3.5 KiB
PHP
132 lines
3.5 KiB
PHP
<?php
|
|
require 'config.php';
|
|
error_log('Session user_id: ' . (isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 'nicht gesetzt'));
|
|
// 1. Session-Prüfung (nur für geschützte Seiten)
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
|
|
// Ab hier: Nur für angemeldete Benutzer
|
|
error_log($_SESSION['user_id']);
|
|
|
|
// Prüfen, ob die user_id im Admin-Array ist
|
|
if (in_array($_SESSION['user_id'], $admin_ids, true)) {
|
|
$is_admin = "true";
|
|
}
|
|
// Prüfen, ob die user_id im Aktien-Array ist
|
|
if (in_array($_SESSION['user_id'], $aktien_ids, true)) {
|
|
$is_aktien = "true";
|
|
}
|
|
|
|
// Aktuelles Jahr und Monat ermitteln, ggf. aus GET-Parametern
|
|
$year = isset($_GET['year']) ? (int)$_GET['year'] : (int)date('Y');
|
|
$month = isset($_GET['month']) ? (int)$_GET['month'] : (int)date('m');
|
|
|
|
// Monats- und Jahresgrenzen prüfen und anpassen
|
|
if ($month < 1) {
|
|
$month = 12;
|
|
$year--;
|
|
} elseif ($month > 12) {
|
|
$month = 1;
|
|
$year++;
|
|
}
|
|
|
|
// Daten abrufen
|
|
$sql="SELECT
|
|
id,
|
|
WKNISIN,
|
|
Aktie,
|
|
kaufdatum,
|
|
kaufpreis,
|
|
anzahl,
|
|
(kaufpreis * anzahl) AS Kaufsumme
|
|
FROM
|
|
aktien;
|
|
";
|
|
|
|
$stmt = $pdo->prepare($sql);
|
|
$stmt->execute([
|
|
'year' => $year,
|
|
'month' => $month
|
|
]);
|
|
$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>
|
|
<?php if ($is_aktien === "true") echo '<li><a href="aktien.php">Aktien</a></li>'; ?>
|
|
<?php if ($is_admin === "true") echo '<li><a href="register.php">Neue User</a></li>'; ?>
|
|
<li><a href="rep-month.php">Report Monat</a></li>
|
|
<li><a href="rep-person.php">Report Personen</a></li>
|
|
<li><a href="menu5.php" style="display: none;">Menüpunkt 5</a></li>
|
|
</ul>
|
|
<!-- Container für die rechten Buttons -->
|
|
<div class="nav-right">
|
|
<a href="?year=<?= $year ?>&month=<?= $month - 1 ?>" class="nav-button"> < </a>
|
|
<a href="?year=<?= $year ?>&month=<?= $month + 1 ?>" class="nav-button"> > </a>
|
|
<a href="logout.php" class="logout">Logout</a>
|
|
</div>
|
|
</nav>
|
|
|
|
<h2><?= strftime('%B %Y', mktime(0, 0, 0, $month, 1, $year)) ?></h2>
|
|
|
|
<!-- Tabelle -->
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>WKN/ISIN</th>
|
|
<th>Aktie</th>
|
|
<th>Kaufdatum</th>
|
|
<th>Kaufpreis</th>
|
|
<th>Anzahl</th>
|
|
<th>Kaufsumme</th>
|
|
<th> </th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($entries as $entry): ?>
|
|
<tr>
|
|
<td><?= htmlspecialchars($entry['id']) ?></td>
|
|
<td><?= htmlspecialchars($entry['WKNISIN']) ?></td>
|
|
<td><?= htmlspecialchars($entry['Aktie']) ?></td>
|
|
<td><?= htmlspecialchars($entry['kaufdatum']) ?></td>
|
|
<td class="align-right"><?= htmlspecialchars(number_format($entry['kaufpreis'], 2, ',', '.')) ?></td>
|
|
<td class="align-right"><?= htmlspecialchars(number_format($entry['anzahl'], 4, ',', '.')) ?></td>
|
|
<td class="align-right"><?= htmlspecialchars(number_format($entry['kaufpreis'] * $entry['anzahl'], 2, ',', '.')) ?></td>
|
|
<td>
|
|
<a href="edit_entry.php?id=<?= $entry['id'] ?>">
|
|
<img class="pencil" src="/assets/img/pencil.png" width="20px" />
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
|
|
|
|
<!-- Neu-Button -->
|
|
<a href="new_entry.php" class="btn-xr">+</a>
|
|
</div>
|
|
|
|
<script>
|
|
// Hamburger-Menü-Funktion
|
|
document.querySelector('.hamburger').addEventListener('click', function() {
|
|
document.querySelector('.nav-list').classList.toggle('show');
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|