added back&forth buttons for dashboard + sorted CSV by category&user_id
This commit is contained in:
parent
7099eed7c6
commit
c927cb5b5c
2 changed files with 27 additions and 4 deletions
|
|
@ -15,6 +15,19 @@ if (in_array($_SESSION['user_id'], $admin_ids, true)) {
|
|||
$is_admin = "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="WITH user_names AS (
|
||||
SELECT
|
||||
|
|
@ -41,14 +54,17 @@ JOIN user_names un ON e.id = un.id
|
|||
LEFT JOIN categories c ON e.category = c.category_id
|
||||
LEFT JOIN payment_methods pm ON e.payment_method = pm.payment_method_id
|
||||
WHERE
|
||||
EXTRACT(YEAR FROM e.date) = EXTRACT(YEAR FROM CURRENT_DATE())
|
||||
AND EXTRACT(MONTH FROM e.date) = EXTRACT(MONTH FROM CURRENT_DATE())
|
||||
EXTRACT(YEAR FROM e.date) = :year
|
||||
AND EXTRACT(MONTH FROM e.date) = :month
|
||||
ORDER BY
|
||||
e.date DESC, id desc;
|
||||
";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->execute([
|
||||
'year' => $year,
|
||||
'month' => $month
|
||||
]);
|
||||
$entries = $stmt->fetchAll();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
|
@ -71,9 +87,16 @@ $entries = $stmt->fetchAll();
|
|||
<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>
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ WHERE
|
|||
EXTRACT(YEAR FROM e.date) = :year
|
||||
AND EXTRACT(MONTH FROM e.date) = :month
|
||||
ORDER BY
|
||||
e.date ASC
|
||||
e.user_id, e.category ASC
|
||||
";
|
||||
|
||||
$stmt_csv = $pdo->prepare($sql_csv);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue