Added support for Streamdeck Pedal and updated UI to better fit the Packed UI style
This commit is contained in:
147
pirp/public/recurring.php
Normal file
147
pirp/public/recurring.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../src/config.php';
|
||||
require_once __DIR__ . '/../src/auth.php';
|
||||
require_once __DIR__ . '/../src/db.php';
|
||||
require_once __DIR__ . '/../src/recurring_functions.php';
|
||||
require_once __DIR__ . '/../src/icons.php';
|
||||
require_login();
|
||||
|
||||
$msg = '';
|
||||
$error = '';
|
||||
|
||||
$action = $_GET['action'] ?? '';
|
||||
$id = isset($_GET['id']) ? (int)$_GET['id'] : null;
|
||||
|
||||
// Aktionen verarbeiten
|
||||
if ($action === 'delete' && $id) {
|
||||
delete_recurring_template($id);
|
||||
$msg = 'Abo-Vorlage gelöscht.';
|
||||
}
|
||||
|
||||
if ($action === 'toggle' && $id) {
|
||||
$pdo = get_db();
|
||||
$stmt = $pdo->prepare("UPDATE recurring_templates SET is_active = NOT is_active WHERE id = :id");
|
||||
$stmt->execute([':id' => $id]);
|
||||
$msg = 'Status geändert.';
|
||||
}
|
||||
|
||||
// Filter
|
||||
$show_all = isset($_GET['show_all']);
|
||||
$templates = get_recurring_templates(!$show_all);
|
||||
$pending_count = count_pending_recurring_invoices();
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Abo-Rechnungen</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') ?>" class="active"><?= 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') ?>"><?= 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="module-subnav">
|
||||
<a href="<?= url_for('invoices.php') ?>">Übersicht</a>
|
||||
<a href="<?= url_for('invoice_new.php') ?>">Neue Rechnung</a>
|
||||
<a href="<?= url_for('recurring.php') ?>" class="active">Abo-Rechnungen</a>
|
||||
</div>
|
||||
<?php if ($msg): ?><p class="success"><?= htmlspecialchars($msg) ?></p><?php endif; ?>
|
||||
<?php if ($error): ?><p class="error"><?= htmlspecialchars($error) ?></p><?php endif; ?>
|
||||
|
||||
<?php if ($pending_count > 0): ?>
|
||||
<div class="warning">
|
||||
<strong><?= $pending_count ?> Abo-Rechnung<?= $pending_count > 1 ? 'en' : '' ?> fällig!</strong>
|
||||
<a href="<?= url_for('recurring_generate.php') ?>" class="button" style="margin-left:10px;">Jetzt generieren</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<section>
|
||||
<h2>Abo-Vorlagen</h2>
|
||||
<div>
|
||||
<p>
|
||||
<a href="<?= url_for('recurring_edit.php') ?>" class="button">Neue Abo-Vorlage</a>
|
||||
<a href="<?= url_for('recurring_generate.php') ?>" class="button-secondary">Rechnungen generieren</a>
|
||||
<?php if ($show_all): ?>
|
||||
<a href="<?= url_for('recurring.php') ?>" class="button-secondary">Nur aktive anzeigen</a>
|
||||
<?php else: ?>
|
||||
<a href="<?= url_for('recurring.php?show_all=1') ?>" class="button-secondary">Alle anzeigen</a>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Kunde</th>
|
||||
<th>Intervall</th>
|
||||
<th>Nächste Fälligkeit</th>
|
||||
<th>Status</th>
|
||||
<th>Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($templates as $t): ?>
|
||||
<?php
|
||||
$is_due = $t['is_active'] && strtotime($t['next_due_date']) <= time();
|
||||
?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($t['template_name']) ?></td>
|
||||
<td>
|
||||
<?= htmlspecialchars($t['customer_name']) ?>
|
||||
<?php if ($t['customer_number']): ?>
|
||||
<br><small><?= htmlspecialchars($t['customer_number']) ?></small>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<span class="interval-badge interval-<?= $t['interval_type'] ?>">
|
||||
<?= get_interval_label($t['interval_type']) ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<?= date('d.m.Y', strtotime($t['next_due_date'])) ?>
|
||||
<?php if ($is_due): ?>
|
||||
<span class="badge badge-warning">Fällig</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($t['is_active']): ?>
|
||||
<span class="badge badge-success">Aktiv</span>
|
||||
<?php else: ?>
|
||||
<span class="badge badge-danger">Inaktiv</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<a href="<?= url_for('recurring_edit.php?id=' . $t['id']) ?>">Bearbeiten</a>
|
||||
<a href="<?= url_for('recurring.php?action=toggle&id=' . $t['id']) ?>">
|
||||
<?= $t['is_active'] ? 'Deaktivieren' : 'Aktivieren' ?>
|
||||
</a>
|
||||
<a href="<?= url_for('recurring.php?action=delete&id=' . $t['id']) ?>"
|
||||
onclick="return confirm('Abo-Vorlage wirklich löschen?');">Löschen</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php if (empty($templates)): ?>
|
||||
<tr><td colspan="6">Keine Abo-Vorlagen gefunden.</td></tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
<script src="assets/command-palette.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user