summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--views/mods/mod_rechnungen/archive.phtml105
-rw-r--r--views/mods/mod_rechnungen/settings_edit.phtml113
2 files changed, 119 insertions, 99 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 } ?>
+
diff --git a/views/mods/mod_rechnungen/settings_edit.phtml b/views/mods/mod_rechnungen/settings_edit.phtml
index 4ea6a3f..346dc43 100644
--- a/views/mods/mod_rechnungen/settings_edit.phtml
+++ b/views/mods/mod_rechnungen/settings_edit.phtml
@@ -283,103 +283,7 @@
</div>
<div id="tab4" role="tabpanel" class="tab-pane" >
- <?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 } ?>
+ <div id="wpsg_archive_list" data-url="<?php echo esc_url(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_rechnungen&noheader=1&do=archiveList'); ?>"><p><span class="spinner is-active" style="float:none; margin:0 8px 0 0;"></span><?php echo __('Archiv wird geladen …', 'wpsg'); ?></p></div>
<?php echo wpsg_drawForm_TextStart(); ?>
<p style="line-height:normal;"><?php echo __('Rechnungen und Rechnungskorrekturen sind acht Jahre ab Ende des Rechnungsjahres aufzubewahren (§ 147 AO). Gelöscht werden nur die Dateien; Rechnungsnummern und Einträge in den Bestellungen bleiben. „Fehlende Rechnungen nachbauen“ erzeugt gelöschte Zeiträume nicht neu.', 'wpsg'); ?></p>
@@ -394,9 +298,20 @@
jQuery(document).ready(function() {
+ jQuery('[href="#tab4"]').on('shown.bs.tab', function() {
+
+ var oList = jQuery('#wpsg_archive_list');
+
+ if (oList.data('loaded') === true) return;
+ oList.data('loaded', true);
+
+ jQuery.get(oList.data('url'), function(html) { oList.html(html); } );
+
+ } );
+
if (location.hash === '#tab4') jQuery('[href="#tab4"]').tab('show');
- jQuery('.wpsg_archive_toggle').on('click', function() {
+ jQuery('#wpsg_archive_list').on('click', '.wpsg_archive_toggle', function() {
var year = jQuery(this).closest('tr').data('year');
var oTable = jQuery(this).closest('table');
@@ -408,7 +323,7 @@
} );
- jQuery('.wpsg_archive_views .button').on('click', function() {
+ jQuery('#wpsg_archive_list').on('click', '.wpsg_archive_views .button', function() {
jQuery('.wpsg_archive_views .button').removeClass('button-primary');
jQuery(this).addClass('button-primary');