Added support for Streamdeck Pedal and updated UI to better fit the Packed UI style
This commit is contained in:
168
pirp/public/journal_detail.php
Normal file
168
pirp/public/journal_detail.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../src/config.php';
|
||||
require_once __DIR__ . '/../src/auth.php';
|
||||
require_once __DIR__ . '/../src/db.php';
|
||||
require_once __DIR__ . '/../src/journal_functions.php';
|
||||
require_once __DIR__ . '/../src/icons.php';
|
||||
require_login();
|
||||
|
||||
$year_id = isset($_GET['year_id']) ? (int)$_GET['year_id'] : 0;
|
||||
$month = isset($_GET['month']) ? (int)$_GET['month'] : 0;
|
||||
$col_key = $_GET['col_key'] ?? '';
|
||||
|
||||
if (!$year_id || !$month || !$col_key) {
|
||||
header('Location: ' . url_for('journal_summary.php'));
|
||||
exit;
|
||||
}
|
||||
|
||||
// Jahr laden
|
||||
$years = get_journal_years();
|
||||
$current_year = null;
|
||||
foreach ($years as $y) {
|
||||
if ($y['id'] == $year_id) { $current_year = $y; break; }
|
||||
}
|
||||
|
||||
// Spalte finden
|
||||
$columns = get_journal_columns();
|
||||
$col = null;
|
||||
foreach ($columns as $c) {
|
||||
if ($c['key'] === $col_key) { $col = $c; break; }
|
||||
}
|
||||
|
||||
if (!$col) {
|
||||
header('Location: ' . url_for('journal_summary.php?year_id=' . $year_id));
|
||||
exit;
|
||||
}
|
||||
|
||||
// SQL aufbauen
|
||||
$pdo = get_db();
|
||||
|
||||
$where = "e.year_id = :year_id AND e.month = :month AND a.account_type = :account_type AND a.side = :side";
|
||||
$params = [
|
||||
':year_id' => $year_id,
|
||||
':month' => $month,
|
||||
':account_type' => $col['account_type'],
|
||||
':side' => $col['side'],
|
||||
];
|
||||
|
||||
if (($col['account_type'] === 'wareneingang' || $col['account_type'] === 'erloese') && $col['category_id']) {
|
||||
$where .= " AND a.revenue_category_id = :rev_cat_id";
|
||||
$params[':rev_cat_id'] = $col['category_id'];
|
||||
} elseif (($col['account_type'] === 'expense' || $col['account_type'] === 'deduction') && $col['category_id']) {
|
||||
$where .= " AND a.expense_category_id = :exp_cat_id";
|
||||
$params[':exp_cat_id'] = $col['category_id'];
|
||||
}
|
||||
|
||||
$sql = "SELECT e.id, e.entry_date, e.description, e.attachment_note, e.amount AS entry_amount,
|
||||
a.amount AS col_amount, a.note AS acct_note,
|
||||
s.name AS supplier_name
|
||||
FROM journal_entries e
|
||||
JOIN journal_entry_accounts a ON a.entry_id = e.id
|
||||
LEFT JOIN journal_suppliers s ON e.supplier_id = s.id
|
||||
WHERE $where
|
||||
ORDER BY e.entry_date, e.sort_order, e.id";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$entries = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$total = array_sum(array_column($entries, 'col_amount'));
|
||||
|
||||
$month_name = journal_month_name_full($month);
|
||||
$year_val = $current_year ? (int)$current_year['year'] : $year_id;
|
||||
$back_url = url_for('journal_summary.php?year_id=' . $year_id);
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?= htmlspecialchars($col['label']) ?> – <?= $month_name ?> <?= $year_val ?></title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>PIRP</h1>
|
||||
<nav>
|
||||
<a href="<?= url_for('index.php') ?>"><?= icon_dashboard() ?>Dashboard</a>
|
||||
<a href="<?= url_for('invoices.php') ?>"><?= icon_invoices() ?>Rechnungen</a>
|
||||
<a href="<?= url_for('customers.php') ?>"><?= icon_customers() ?>Kunden</a>
|
||||
<a href="<?= url_for('expenses.php') ?>"><?= icon_expenses() ?>Ausgaben</a>
|
||||
<a href="<?= url_for('belegarchiv.php') ?>"><?= icon_archive() ?>Belege</a>
|
||||
<a href="<?= url_for('journal.php') ?>" class="active"><?= icon_journal() ?>Journal</a>
|
||||
<a href="<?= url_for('euer.php') ?>"><?= icon_euer() ?>EÜR</a>
|
||||
<a href="<?= url_for('settings.php') ?>"><?= icon_settings() ?>Einstellungen</a>
|
||||
<a href="<?= url_for('logout.php') ?>"><?= icon_logout() ?>Logout (<?= htmlspecialchars($_SESSION['username'] ?? '') ?>)</a>
|
||||
<span class="cmd-k-hint" onclick="document.dispatchEvent(new KeyboardEvent('keydown',{key:'k',ctrlKey:true}))"><kbd>Ctrl+K</kbd></span>
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
<div class="journal-subnav">
|
||||
<a href="<?= url_for('journal.php?year_id=' . $year_id) ?>">Monatsansicht</a>
|
||||
<a href="<?= $back_url ?>">Jahressummen</a>
|
||||
<a href="<?= url_for('journal_search.php') ?>">Suche</a>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom:8px;">
|
||||
<a href="<?= $back_url ?>" style="font-size:11px;color:var(--text-dim);">← Zurück zu Jahressummen</a>
|
||||
<a href="<?= url_for('journal_search.php') ?>">Suche</a>
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<h2>
|
||||
<?= htmlspecialchars($col['label']) ?>
|
||||
<span style="font-weight:normal;font-size:13px;color:var(--text-dim);">
|
||||
– <?= $month_name ?> <?= $year_val ?>
|
||||
(<?= htmlspecialchars($col['group']) ?>, <?= $col['side'] === 'soll' ? 'Soll' : 'Haben' ?>)
|
||||
</span>
|
||||
</h2>
|
||||
|
||||
<?php if (empty($entries)): ?>
|
||||
<p style="color:var(--text-dim);">Keine Buchungen in diesem Zeitraum.</p>
|
||||
<?php else: ?>
|
||||
<div class="journal-table-wrap">
|
||||
<table class="journal-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="journal-col-date">Datum</th>
|
||||
<th class="journal-col-att">B</th>
|
||||
<th class="journal-col-text">Text</th>
|
||||
<th class="journal-col-betrag">Buchungsbetrag</th>
|
||||
<th class="journal-col-amount journal-<?= $col['side'] ?>"><?= htmlspecialchars($col['label']) ?></th>
|
||||
<th class="journal-col-text" style="min-width:80px;">Notiz</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($entries as $row): ?>
|
||||
<tr>
|
||||
<td class="journal-col-date"><?= htmlspecialchars(date('d.m.Y', strtotime($row['entry_date']))) ?></td>
|
||||
<td class="journal-col-att"><?= htmlspecialchars($row['attachment_note'] ?? '') ?></td>
|
||||
<td class="journal-col-text">
|
||||
<a href="<?= url_for('journal_entry.php?id=' . $row['id']) ?>" style="color:inherit;">
|
||||
<?= htmlspecialchars($row['description']) ?>
|
||||
</a>
|
||||
<?php if ($row['supplier_name']): ?>
|
||||
<span style="color:var(--text-dim);font-size:10px;"> · <?= htmlspecialchars($row['supplier_name']) ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="journal-col-betrag"><?= journal_format_amount((float)$row['entry_amount']) ?></td>
|
||||
<td class="journal-col-amount journal-<?= $col['side'] ?>"><?= journal_format_amount((float)$row['col_amount']) ?></td>
|
||||
<td style="font-size:10px;color:var(--text-dim);"><?= htmlspecialchars($row['acct_note'] ?? '') ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="journal-totals-row">
|
||||
<td colspan="4"><strong>Summe</strong></td>
|
||||
<td class="journal-col-amount journal-<?= $col['side'] ?>"><strong><?= journal_format_amount($total) ?></strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<p style="font-size:11px;color:var(--text-dim);margin-top:4px;"><?= count($entries) ?> Buchung(en)</p>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</main>
|
||||
<script src="assets/command-palette.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user