summaryrefslogtreecommitdiff
path: root/views/mods/mod_rechnungen/archive.phtml
diff options
context:
space:
mode:
authorRoger Rehnelt <noreply@maennchen1.de>2026-09-27 21:24:41 +0200
committerRoger Rehnelt <noreply@maennchen1.de>2026-09-27 21:24:41 +0200
commitf98173fd80a7f7ce0a6d7337925d2ba2783b1c83 (patch)
treeced5a35d67a0f55bc2a3051763c5da8e25ed88b7 /views/mods/mod_rechnungen/archive.phtml
parent50cc5195a4ee85f543acf33acaea730e7b2af30d (diff)
Rechnungsarchiv: Liste erst beim Öffnen des Reiters laden
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'views/mods/mod_rechnungen/archive.phtml')
-rw-r--r--views/mods/mod_rechnungen/archive.phtml105
1 files changed, 105 insertions, 0 deletions
diff --git a/views/mods/mod_rechnungen/archive.phtml b/views/mods/mod_rechnungen/archive.phtml
new file mode 100644
index 0000000..8397037
--- /dev/null
+++ b/views/mods/mod_rechnungen/archive.phtml
@@ -0,0 +1,105 @@
+<?php
+
+ /**
+ * Archivliste im Reiter „Archiv“ (wird beim Anklicken nachgeladen)
+ */
+
+?>
+<?php if (sizeof($this->view['arArchive']) === 0) { ?>
+ <p><?php echo __('Es sind noch keine Rechnungen vorhanden.', 'wpsg'); ?></p>
+<?php } else { ?>
+
+<?php
+
+ $archive_url = function($do, $period) {
+
+ return wp_nonce_url(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_rechnungen&noheader=1&do='.$do.'&period='.rawurlencode($period), 'wpsg-mod_rechnungen-archive');
+
+ };
+
+ $archive_actions = function($period, $year, $files) use ($archive_url) {
+
+ if ($files <= 0) return '';
+
+ $keep_until = $this->callMod('wpsg_mod_rechnungen', 'getArchiveKeepUntil', [$year]);
+ $confirm = wpsg_translate(__('Alle Rechnungsdateien aus #1# endgültig löschen? Die Einträge in den Bestellungen bleiben, die PDFs lassen sich danach nicht mehr herunterladen. Vorher das ZIP sichern!', 'wpsg'), $period);
+
+ if (date('Y-m-d') <= $keep_until) $confirm = wpsg_translate(__('Achtung: Die Aufbewahrungsfrist für #1# läuft noch bis #2#.', 'wpsg'), $period, wpsg_formatTimestamp(strtotime($keep_until), true))."\n\n".$confirm;
+
+ return '<span style="white-space:nowrap;"><a href="'.esc_url($archive_url('archiveZip', $period)).'" class="button">'.__('ZIP', 'wpsg').'</a> '.
+ '<a href="'.esc_url($archive_url('archiveDelete', $period)).'" class="button" onclick="return confirm(\''.esc_js($confirm).'\');">'.__('Löschen', 'wpsg').'</a></span> ';
+
+ };
+
+?>
+
+<style>.wpsg_mod_rechnungen_archive td { white-space:nowrap; } .wpsg_mod_rechnungen_archive th, .wpsg_mod_rechnungen_archive .wpsg_archive_deleted { white-space:normal; } .wpsg_archive_toggle { text-decoration:none; color:inherit; } .wpsg_archive_toggle .dashicons { vertical-align:text-bottom; }</style>
+<?php
+
+ // Jahre ohne verbliebene Dateien, aber mit Löschvermerk: Ansicht „Gelöscht“
+ $arArchiveView = ['present' => [], 'deleted' => []];
+
+ foreach ($this->view['arArchive'] as $year => $arMonth) {
+
+ $bDeleted = (array_sum(array_column($arMonth, 'files')) === 0 && sizeof(array_filter(array_column($arMonth, 'deleted'))) > 0);
+ $arArchiveView[($bDeleted)?'deleted':'present'][$year] = $arMonth;
+
+ }
+
+?>
+
+<p class="wpsg_archive_views">
+ <a href="#" class="button button-primary" data-view="present"><?php echo wpsg_translate(__('Vorhanden (#1#)', 'wpsg'), sizeof($arArchiveView['present'])); ?></a>
+ <?php if (sizeof($arArchiveView['deleted']) > 0) { ?>
+ <a href="#" class="button" data-view="deleted"><?php echo wpsg_translate(__('Gelöscht (#1#)', 'wpsg'), sizeof($arArchiveView['deleted'])); ?></a>
+ <?php } ?>
+</p>
+
+<?php foreach ($arArchiveView as $view => $arYear) { if (sizeof($arYear) === 0) continue; ?>
+<table class="table wpsg_mod_rechnungen_archive" data-view="<?php echo $view; ?>" <?php echo ($view === 'deleted')?'style="display:none;"':''; ?>>
+ <thead>
+ <tr>
+ <th><?php echo __('Zeitraum', 'wpsg'); ?></th>
+ <th class="col_number"><?php echo __('Rechnungen', 'wpsg'); ?></th>
+ <th class="col_number"><?php echo str_replace('skorrektur', 's&shy;korrektur', esc_html(__('Rechnungskorrekturen', 'wpsg'))); ?></th>
+ <th class="col_number"><?php echo __('Dateien', 'wpsg'); ?></th>
+ <th class="col_number"><?php echo __('Größe', 'wpsg'); ?></th>
+ <th><?php echo __('Aufbewahrung bis', 'wpsg'); ?></th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php $bOpen = ($view === 'present'); ?>
+ <?php foreach ($arYear as $year => $arMonth) { ?>
+ <?php $files = array_sum(array_column($arMonth, 'files')); ?>
+ <tr class="wpsg_archive_year" data-year="<?php echo $year; ?>">
+ <td><a href="#" class="wpsg_archive_toggle"><span class="dashicons dashicons-arrow-<?php echo ($bOpen)?'down':'right'; ?>"></span><strong><?php echo $year; ?></strong></a></td>
+ <td class="col_number"><strong><?php echo array_sum(array_column($arMonth, 'rnr')); ?></strong></td>
+ <td class="col_number"><strong><?php echo array_sum(array_column($arMonth, 'gnr')); ?></strong></td>
+ <td class="col_number"><strong><?php echo $files; ?></strong></td>
+ <td class="col_number"><strong><?php echo ($files > 0)?size_format(array_sum(array_column($arMonth, 'size')), 1):''; ?></strong></td>
+ <td><?php echo wpsg_formatTimestamp(strtotime($this->callMod('wpsg_mod_rechnungen', 'getArchiveKeepUntil', [$year])), true); ?></td>
+ <td class="col_actions"><?php echo $archive_actions(strval($year), $year, $files); ?></td>
+ </tr>
+ <?php foreach ($arMonth as $month => $m) { ?>
+ <tr class="wpsg_archive_month" data-year="<?php echo $year; ?>" <?php echo ($bOpen)?'':'style="display:none;"'; ?>>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $year.'/'.$month; ?></td>
+ <td class="col_number"><?php echo $m['rnr']; ?></td>
+ <td class="col_number"><?php echo $m['gnr']; ?></td>
+ <td class="col_number"><?php echo $m['files']; ?></td>
+ <td class="col_number"><?php echo ($m['files'] > 0)?size_format($m['size'], 1):''; ?></td>
+ <td></td>
+ <td class="col_actions" style="white-space:normal;">
+ <?php if ($m['files'] > 0) echo $archive_actions($year.'/'.$month, $year, $m['files']); ?>
+ <?php if ($m['deleted'] !== false) echo '<span class="wpsg_archive_deleted">'.wpsg_translate(__('Dateien gelöscht am #1#', 'wpsg'), wpsg_formatTimestamp(strtotime($m['deleted']), true)).'</span>'; ?>
+ </td>
+ </tr>
+ <?php } ?>
+ <?php $bOpen = false; ?>
+ <?php } ?>
+ </tbody>
+</table>
+<?php } ?>
+
+<?php } ?>
+