Added support for Streamdeck Pedal and updated UI to better fit the Packed UI style

This commit is contained in:
2026-02-27 22:47:08 +01:00
committed by erik
parent 5a70f775f1
commit 93faae5cc8
1463 changed files with 306917 additions and 0 deletions

139
pirp/public/customers.php Normal file
View File

@@ -0,0 +1,139 @@
<?php
require_once __DIR__ . '/../src/config.php';
require_once __DIR__ . '/../src/auth.php';
require_once __DIR__ . '/../src/customer_functions.php';
require_once __DIR__ . '/../src/icons.php';
require_login();
$action = $_GET['action'] ?? '';
$id = isset($_GET['id']) ? (int)$_GET['id'] : null;
$msg = '';
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$idPost = isset($_POST['id']) ? (int)$_POST['id'] : null;
$data = [
'name' => $_POST['name'] ?? '',
'address' => $_POST['address'] ?? '',
'zip' => $_POST['zip'] ?? '',
'city' => $_POST['city'] ?? '',
'country' => $_POST['country'] ?? '',
];
if (trim($data['name']) === '') {
$error = 'Name darf nicht leer sein.';
} else {
save_customer($idPost, $data);
$msg = 'Kunde gespeichert.';
$action = '';
$id = null;
}
}
if ($action === 'delete' && $id) {
delete_customer($id);
$msg = 'Kunde gelöscht.';
$action = '';
$id = null;
}
$customers = get_customers();
$editCustomer = null;
if ($action === 'edit' && $id) {
$editCustomer = get_customer($id);
}
?>
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>Kunden</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') ?>" class="active"><?= 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') ?>"><?= 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>
<?php if ($msg): ?><p class="success"><?= htmlspecialchars($msg) ?></p><?php endif; ?>
<?php if ($error): ?><p class="error"><?= htmlspecialchars($error) ?></p><?php endif; ?>
<section>
<h2><?= $editCustomer ? 'Kunde bearbeiten' : 'Neuer Kunde' ?></h2>
<form method="post">
<input type="hidden" name="id" value="<?= htmlspecialchars($editCustomer['id'] ?? '') ?>">
<label>Name:
<input type="text" name="name" value="<?= htmlspecialchars($editCustomer['name'] ?? '') ?>" required>
</label>
<label>Adresse:
<textarea name="address" rows="3"><?= htmlspecialchars($editCustomer['address'] ?? '') ?></textarea>
</label>
<div class="flex-row">
<label>PLZ:
<input type="text" name="zip" value="<?= htmlspecialchars($editCustomer['zip'] ?? '') ?>">
</label>
<label>Ort:
<input type="text" name="city" value="<?= htmlspecialchars($editCustomer['city'] ?? '') ?>">
</label>
<label>Land:
<input type="text" name="country" value="<?= htmlspecialchars($editCustomer['country'] ?? '') ?>">
</label>
</div>
<?php if (!empty($editCustomer['customer_number'])): ?>
<p>Kundennummer: <?= htmlspecialchars($editCustomer['customer_number']) ?></p>
<?php endif; ?>
<button type="submit">Speichern</button>
<?php if ($editCustomer): ?>
<a href="<?= url_for('customers.php') ?>">Abbrechen</a>
<?php endif; ?>
</form>
</section>
<section>
<h2>Alle Kunden</h2>
<table class="list">
<thead>
<tr>
<th>Kundennr.</th>
<th>Name</th>
<th>Adresse</th>
<th>Ort</th>
<th>Land</th>
<th>Aktion</th>
</tr>
</thead>
<tbody>
<?php foreach ($customers as $c): ?>
<tr>
<td><?= htmlspecialchars($c['customer_number'] ?? '') ?></td>
<td><?= htmlspecialchars($c['name']) ?></td>
<td><?= nl2br(htmlspecialchars($c['address'])) ?></td>
<td><?= htmlspecialchars($c['zip'] . ' ' . $c['city']) ?></td>
<td><?= htmlspecialchars($c['country']) ?></td>
<td>
<a href="<?= url_for('customers.php?action=edit&id=' . $c['id']) ?>">Bearbeiten</a>
<a href="<?= url_for('customers.php?action=delete&id=' . $c['id']) ?>" onclick="return confirm('Kunde wirklich löschen?');">Löschen</a>
</td>
</tr>
<?php endforeach; ?>
<?php if (empty($customers)): ?>
<tr><td colspan="6">Keine Kunden vorhanden.</td></tr>
<?php endif; ?>
</tbody>
</table>
</section>
</main>
<script src="assets/command-palette.js"></script>
</body>
</html>