15 Commits

Author SHA1 Message Date
5590306959 Bump version to 1.16.2 2026-04-17 13:31:59 +02:00
96969bb0a2 Add data export/import under settings 2026-04-17 13:29:11 +02:00
6c793ad41a Add changelog entry for 1.16.1 2026-04-17 12:32:07 +02:00
295b67dcce Bump version to 1.16.1 2026-04-17 12:22:00 +02:00
f69a648ea5 Dashboard: Arbeitsstunden-Widget für laufendes Jahr
- Zeigt Mitglieder erfüllt/offen, fehlende Stunden und Gesamtaufschlag

- Hinweis und Link wenn keine Jahreseinstellungen hinterlegt
2026-04-16 22:11:03 +02:00
7d3d543954 Release 1.16.0
Arbeitsstunden-Modul hinzugefuegt

- Pflichtstunden pro Jahr inkl. Preis je fehlender Stunde

- Arbeitsarten, Arbeitseintraege und Mehrfachzuordnung von Mitgliedern

- Mitgliederuebersicht mit Berechnung fehlender Stunden und Aufschlag

- Datenbankschema fuer Arbeitsstunden erweitert

- Stable Tag und Changelog in README/readme.txt aktualisiert
2026-04-16 21:38:59 +02:00
f399cc30bc kgv-verein-manager.php aktualisiert 2026-04-16 14:56:52 +02:00
c0c1c46435 README.md aktualisiert 2026-04-15 22:07:14 +02:00
7d08fabaa6 README.md aktualisiert 2026-04-15 22:06:36 +02:00
199bc911eb README.md aktualisiert 2026-04-15 22:06:15 +02:00
f08dfc029a Release 1.15.6 2026-04-15 21:44:19 +02:00
daf72fa705 Standardize WordPress readme format 2026-04-15 21:36:08 +02:00
3cf3fec72c Release 1.15.5 2026-04-14 16:26:53 +02:00
a98e181c12 Release 1.15.4 2026-04-13 22:40:32 +02:00
9c9ec13684 Update to version 1.15.3 2026-04-13 22:20:31 +02:00
8 changed files with 1459 additions and 37 deletions

View File

@@ -1,36 +1,66 @@
# KGV Vereinsverwaltung (WordPress Plugin) === KGV Vereinsverwaltung ===
Contributors: ronnygrobel
Tags: verein, mitgliederverwaltung, parzellen, zaehler, abrechnung
Requires at least: 6.0
Tested up to: 6.8
Stable tag: 1.16.2
Requires PHP: 7.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
## Beschreibung
KGV Vereinsverwaltung ist ein WordPress-Plugin zur Verwaltung von Vereinsdaten, Parzellen, Zaehlern, Kosten, Kommunikation und Rollen im Vereinsumfeld.
## Voraussetzungen Umfassende Verwaltung von Vereinsdaten, Parzellen, Mitgliedern und Zaehlerstaenden.
- WordPress 6.x
- PHP entsprechend der WordPress-Anforderungen
- Schreibrechte fuer den Plugin-Ordner
## Installation == Description ==
1. Plugin-Ordner nach `wp-content/plugins/KGV-Verein-Manager/` hochladen.
2. Plugin in WordPress unter `Plugins` aktivieren.
3. Nach der Aktivierung die Menuepunkte im Backend pruefen.
4. Rollen und Berechtigungen fuer Vereinsfunktionen konfigurieren.
## Funktionen (Ueberblick) KGV Vereinsverwaltung bietet ein umfangreiches Backend fuer Kleingartenvereine mit Fokus auf Stammdaten, Verbraeuche und Organisation.
- Vereins-Dashboard im WordPress-Backend
- Verwaltung von Parzellen, Zaehlern und Verbraeuchen
- Kosten- und Stammdatenverwaltung
- Rollen- und Berechtigungskonzept fuer Vereinsmitglieder
- Interner Vereinschat
- PDF/Export-Funktionen (inkl. TCPDF-Bibliothek)
## Projektstruktur = Features =
- `kgv-verein-manager.php` - Plugin-Bootstrap
- `includes/` - Kernlogik, Admin-Bereiche, Repositories, Services
- `assets/` - CSS/JS und statische Ressourcen
- `languages/` - Sprachdateien
- `lib/` - Drittanbieterbibliotheken (u.a. TCPDF)
## Versionshinweis * Vereins-Dashboard
Aktuelle Plugin-Version laut Header: `1.15.1` * Verwaltung von Sparten, Parzellen, Mitgliedern und Paechtern
* Wasser- und Stromzaehlerverwaltung
* Kosten- und Stammdatenverwaltung
* Rollen- und Rechtekonzept
* PDF- und Exportfunktionen
## Lizenz == Installation ==
Siehe Angaben in den Quelltextdateien und in eingebundenen Drittanbieterbibliotheken.
1. Plugin in `wp-content/plugins/KGV-Verein-Manager/` hochladen.
2. Plugin aktivieren.
3. Menues, Rollen und Stammdaten im Backend einrichten.
== Frequently Asked Questions ==
= Welche Mindestanforderungen gelten? =
WordPress ab 6.0 und PHP ab 7.2.
= Ist das Plugin fuer Vereinsablaeufe ausgelegt? =
Ja, insbesondere fuer Kleingartenvereine und deren Verwaltungsprozesse.
== Changelog ==
= 1.16.2 =
* Neue Datensicherungsfunktion unter Einstellungen: Export und Import aller kgvvm-Tabellen als JSON.
* Import mit Sicherheitsprüfung und vollständigem Überschreiben der vorhandenen Plugin-Daten.
= 1.16.1 =
* Wartungsrelease mit synchronisierter Versionsnummer in Plugin-Header, Konstante und Readme-Dateien.
* Release-Tag 1.16.1 gesetzt.
= 1.16.0 =
* Neues Modul Arbeitsstunden im Adminbereich mit drei Bereichen: geleistete Arbeiten, Mitgliederuebersicht und Arbeitsarten.
* Pflichtstunden je Mitglied pro Jahr konfigurierbar, inklusive variablem Preis je fehlender Stunde fuer den Aufschlag in der Jahresrechnung.
* Arbeitseintraege mit Datum, Arbeitsart und Notiz sowie Mehrfachzuordnung von Mitgliedern mit individuellen Stundenwerten.
* Neue Datenbanktabellen fuer Arbeitsarten, Jahreseinstellungen, Arbeitseintraege und Stundenzuordnungen je Mitglied.
= 1.15.6 =
* Versionsabgleich zwischen Plugin-Header, Konstante und Readme.
* WordPress-Readme-Format weiter vereinheitlicht.
= 1.15.5 =
* Aktuelle Version laut Plugin-Header.
* Kontinuierliche Verbesserungen in Verwaltung und Datenpflege.

View File

@@ -300,3 +300,21 @@
break-inside: avoid; break-inside: avoid;
} }
} }
/* Arbeitsstunden sub-table */
.kgvvm-subtable {
border-collapse: collapse;
width: 100%;
max-width: 480px;
}
.kgvvm-subtable th,
.kgvvm-subtable td {
padding: 4px 8px;
border: 1px solid #ddd;
text-align: left;
vertical-align: middle;
}
.kgvvm-subtable thead th {
background: #f9f9f9;
font-weight: 600;
}

View File

@@ -17,7 +17,9 @@ use KGV\VereinManager\Repositories\MeterRepository;
use KGV\VereinManager\Repositories\ParcelRepository; use KGV\VereinManager\Repositories\ParcelRepository;
use KGV\VereinManager\Repositories\SectionRepository; use KGV\VereinManager\Repositories\SectionRepository;
use KGV\VereinManager\Repositories\TenantRepository; use KGV\VereinManager\Repositories\TenantRepository;
use KGV\VereinManager\Repositories\WorkRepository;
use KGV\VereinManager\Services\ParcelService; use KGV\VereinManager\Services\ParcelService;
use KGV\VereinManager\DataTransfer;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
@@ -43,7 +45,9 @@ class Admin {
private $assignments; private $assignments;
private $chat; private $chat;
private $costs; private $costs;
private $work;
private $parcel_service; private $parcel_service;
private $data_transfer;
/** /**
* Construct admin controller. * Construct admin controller.
@@ -58,7 +62,10 @@ class Admin {
$this->assignments = new AssignmentRepository(); $this->assignments = new AssignmentRepository();
$this->chat = new ChatRepository(); $this->chat = new ChatRepository();
$this->costs = new CostRepository(); $this->costs = new CostRepository();
$this->work = new WorkRepository();
$this->parcel_service = new ParcelService(); $this->parcel_service = new ParcelService();
global $wpdb;
$this->data_transfer = new DataTransfer( $wpdb );
} }
/** /**
@@ -101,6 +108,7 @@ class Admin {
add_submenu_page( 'kgvvm-dashboard', __( 'Zähler', KGVVM_TEXT_DOMAIN ), __( 'Zähler', KGVVM_TEXT_DOMAIN ), 'edit_zaehler', 'kgvvm-zaehler', array( $this, 'render_meters_page' ) ); add_submenu_page( 'kgvvm-dashboard', __( 'Zähler', KGVVM_TEXT_DOMAIN ), __( 'Zähler', KGVVM_TEXT_DOMAIN ), 'edit_zaehler', 'kgvvm-zaehler', array( $this, 'render_meters_page' ) );
add_submenu_page( 'kgvvm-dashboard', __( 'Verbrauch', KGVVM_TEXT_DOMAIN ), __( 'Verbrauch', KGVVM_TEXT_DOMAIN ), $cap, 'kgvvm-consumption', array( $this, 'render_consumption_page' ) ); add_submenu_page( 'kgvvm-dashboard', __( 'Verbrauch', KGVVM_TEXT_DOMAIN ), __( 'Verbrauch', KGVVM_TEXT_DOMAIN ), $cap, 'kgvvm-consumption', array( $this, 'render_consumption_page' ) );
add_submenu_page( 'kgvvm-dashboard', __( 'Kosten', KGVVM_TEXT_DOMAIN ), __( 'Kosten', KGVVM_TEXT_DOMAIN ), $cap, 'kgvvm-costs', array( $this, 'render_costs_page' ) ); add_submenu_page( 'kgvvm-dashboard', __( 'Kosten', KGVVM_TEXT_DOMAIN ), __( 'Kosten', KGVVM_TEXT_DOMAIN ), $cap, 'kgvvm-costs', array( $this, 'render_costs_page' ) );
add_submenu_page( 'kgvvm-dashboard', __( 'Arbeitsstunden', KGVVM_TEXT_DOMAIN ), __( 'Arbeitsstunden', KGVVM_TEXT_DOMAIN ), $cap, 'kgvvm-arbeit', array( $this, 'render_work_page' ) );
add_submenu_page( 'kgvvm-dashboard', __( 'Pächter', KGVVM_TEXT_DOMAIN ), __( 'Pächter', KGVVM_TEXT_DOMAIN ), 'edit_paechter', 'kgvvm-paechter', array( $this, 'render_tenants_page' ) ); add_submenu_page( 'kgvvm-dashboard', __( 'Pächter', KGVVM_TEXT_DOMAIN ), __( 'Pächter', KGVVM_TEXT_DOMAIN ), 'edit_paechter', 'kgvvm-paechter', array( $this, 'render_tenants_page' ) );
add_submenu_page( 'kgvvm-dashboard', __( 'Einstellungen', KGVVM_TEXT_DOMAIN ), __( 'Einstellungen', KGVVM_TEXT_DOMAIN ), Roles::SETTINGS_CAP, 'kgvvm-settings', array( $this, 'render_settings_page' ) ); add_submenu_page( 'kgvvm-dashboard', __( 'Einstellungen', KGVVM_TEXT_DOMAIN ), __( 'Einstellungen', KGVVM_TEXT_DOMAIN ), Roles::SETTINGS_CAP, 'kgvvm-settings', array( $this, 'render_settings_page' ) );
} }
@@ -229,6 +237,18 @@ class Admin {
case 'save_settings': case 'save_settings':
$this->save_settings(); $this->save_settings();
break; break;
case 'save_work_year_config':
$this->save_work_year_config();
break;
case 'save_work_job':
$this->save_work_job();
break;
case 'save_work_log':
$this->save_work_log();
break;
case 'import_plugin_data':
$this->import_plugin_data();
break;
} }
} }
@@ -299,6 +319,30 @@ class Admin {
case 'export_readings_csv': case 'export_readings_csv':
$this->export_readings_csv(); $this->export_readings_csv();
break; break;
case 'export_plugin_data':
$this->require_cap( Roles::SETTINGS_CAP );
if ( ! wp_verify_nonce( $nonce, 'kgvvm_export_plugin_data' ) ) {
$this->redirect_with_notice( 'kgvvm-settings', 'error', __( 'Export wurde aus Sicherheitsgründen abgebrochen.', KGVVM_TEXT_DOMAIN ) );
}
$this->data_transfer->send_download();
break;
case 'delete_work_job':
$this->require_cap( 'manage_kleingarten' );
if ( ! wp_verify_nonce( $nonce, 'kgvvm_delete_work_job_' . $id ) ) {
$this->redirect_with_notice( 'kgvvm-arbeit', 'error', __( 'Der Löschvorgang wurde aus Sicherheitsgründen abgebrochen.', KGVVM_TEXT_DOMAIN ) );
}
$this->work->delete_job( $id );
$this->redirect_with_notice( 'kgvvm-arbeit', 'success', __( 'Arbeitsart wurde gelöscht.', KGVVM_TEXT_DOMAIN ), array( 'tab' => 'jobs' ) );
break;
case 'delete_work_log':
$this->require_cap( 'manage_kleingarten' );
$year = absint( isset( $_GET['year'] ) ? $_GET['year'] : current_time( 'Y' ) );
if ( ! wp_verify_nonce( $nonce, 'kgvvm_delete_work_log_' . $id ) ) {
$this->redirect_with_notice( 'kgvvm-arbeit', 'error', __( 'Der Löschvorgang wurde aus Sicherheitsgründen abgebrochen.', KGVVM_TEXT_DOMAIN ), array( 'year' => $year ) );
}
$this->work->delete_log( $id );
$this->redirect_with_notice( 'kgvvm-arbeit', 'success', __( 'Arbeitseintrag wurde gelöscht.', KGVVM_TEXT_DOMAIN ), array( 'year' => $year ) );
break;
} }
} }
@@ -654,6 +698,59 @@ class Admin {
$this->redirect_with_notice( 'kgvvm-settings', 'success', __( 'Einstellungen wurden gespeichert.', KGVVM_TEXT_DOMAIN ) ); $this->redirect_with_notice( 'kgvvm-settings', 'success', __( 'Einstellungen wurden gespeichert.', KGVVM_TEXT_DOMAIN ) );
} }
/**
* Handle plugin data import from an uploaded JSON file.
*
* @return void
*/
private function import_plugin_data() {
$this->require_cap( Roles::SETTINGS_CAP );
check_admin_referer( 'kgvvm_import_plugin_data' );
if ( empty( $_FILES['kgvvm_import_file']['tmp_name'] ) ) {
$this->redirect_with_notice( 'kgvvm-settings', 'error', __( 'Bitte eine JSON-Datei auswählen.', KGVVM_TEXT_DOMAIN ) );
}
$file = $_FILES['kgvvm_import_file'];
// Validate MIME type.
$finfo = new \finfo( FILEINFO_MIME_TYPE );
$mimetype = $finfo->file( $file['tmp_name'] );
if ( ! in_array( $mimetype, array( 'application/json', 'text/plain' ), true ) ) {
$this->redirect_with_notice( 'kgvvm-settings', 'error', __( 'Die hochgeladene Datei ist keine gültige JSON-Datei.', KGVVM_TEXT_DOMAIN ) );
}
$raw = file_get_contents( $file['tmp_name'] ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
if ( false === $raw ) {
$this->redirect_with_notice( 'kgvvm-settings', 'error', __( 'Die Datei konnte nicht gelesen werden.', KGVVM_TEXT_DOMAIN ) );
}
$payload = json_decode( $raw, true );
if ( ! is_array( $payload ) ) {
$this->redirect_with_notice( 'kgvvm-settings', 'error', __( 'Die JSON-Datei konnte nicht verarbeitet werden. Bitte eine gültige Exportdatei hochladen.', KGVVM_TEXT_DOMAIN ) );
}
$result = $this->data_transfer->import( $payload );
if ( ! empty( $result['errors'] ) ) {
$this->redirect_with_notice( 'kgvvm-settings', 'error', implode( ' | ', $result['errors'] ) );
}
$summary = array();
foreach ( $result['imported'] as $key => $count ) {
$summary[] = $key . ': ' . $count;
}
$this->redirect_with_notice(
'kgvvm-settings',
'success',
sprintf(
/* translators: %s: summary of imported rows per table */
__( 'Import erfolgreich. Importierte Datensätze %s', KGVVM_TEXT_DOMAIN ),
implode( ', ', $summary )
)
);
}
/** /**
* Persist one year for the cost dropdown. * Persist one year for the cost dropdown.
* *
@@ -751,7 +848,26 @@ class Admin {
$meters_free = count( $this->meters->search( array( 'assignment' => 'free' ) ) ); $meters_free = count( $this->meters->search( array( 'assignment' => 'free' ) ) );
$meters_used = count( $this->meters->search( array( 'assignment' => 'assigned' ) ) ); $meters_used = count( $this->meters->search( array( 'assignment' => 'assigned' ) ) );
$tenants_total = count( $this->tenants->search() ); $tenants_total = count( $this->tenants->search() );
$members_total = count( $this->assignments->get_member_users() ); $all_members = $this->assignments->get_member_users();
$members_total = count( $all_members );
// Arbeitsstunden laufendes Jahr
$work_year = (int) current_time( 'Y' );
$work_config = $this->work->get_year_config( $work_year );
$work_summary = $this->work->get_member_summary( $work_year, $all_members );
$members_ok = 0;
$members_open = 0;
$total_missing_h = 0.0;
$total_surcharge = 0.0;
foreach ( $work_summary as $ws ) {
if ( $ws->missing_hours > 0 ) {
$members_open++;
$total_missing_h += $ws->missing_hours;
$total_surcharge += $ws->surcharge;
} else {
$members_ok++;
}
}
?> ?>
<div class='wrap'> <div class='wrap'>
<h1><?php echo esc_html__( 'Kleingartenverwaltung', KGVVM_TEXT_DOMAIN ); ?></h1> <h1><?php echo esc_html__( 'Kleingartenverwaltung', KGVVM_TEXT_DOMAIN ); ?></h1>
@@ -784,6 +900,42 @@ class Admin {
</div> </div>
</div> </div>
<?php /* Arbeitsstunden-Widget */ ?>
<div class='kgvvm-card'>
<h2><?php echo esc_html( sprintf( __( 'Arbeitsstunden %d', KGVVM_TEXT_DOMAIN ), $work_year ) ); ?></h2>
<?php if ( ! $work_config ) : ?>
<p class='kgvvm-help'><?php echo esc_html__( 'Für das laufende Jahr wurden noch keine Jahreseinstellungen für Arbeitsstunden hinterlegt.', KGVVM_TEXT_DOMAIN ); ?>
<a href='<?php echo esc_url( $this->admin_url( 'kgvvm-arbeit', array( 'year' => $work_year ) ) ); ?>'><?php echo esc_html__( 'Jetzt einrichten', KGVVM_TEXT_DOMAIN ); ?></a>
</p>
<?php else : ?>
<div class='kgvvm-grid' style='margin-top:8px;'>
<div class='kgvvm-card' style='background:#f0faf0;'>
<h2 style='color:#2e7d32;'><?php echo esc_html( $members_ok ); ?></h2>
<p><?php echo esc_html__( 'Mitglieder erfüllt', KGVVM_TEXT_DOMAIN ); ?></p>
</div>
<div class='kgvvm-card' style='background:#fff4f4;'>
<h2 style='color:#c00;'><?php echo esc_html( $members_open ); ?></h2>
<p><?php echo esc_html__( 'Mitglieder mit offenen Stunden', KGVVM_TEXT_DOMAIN ); ?></p>
</div>
<div class='kgvvm-card' style='background:#fff4f4;'>
<h2 style='color:#c00;'><?php echo esc_html( number_format_i18n( $total_missing_h, 2 ) ); ?> Std.</h2>
<p><?php echo esc_html__( 'Fehlende Stunden gesamt', KGVVM_TEXT_DOMAIN ); ?></p>
</div>
<div class='kgvvm-card' style='background:#fff4f4;'>
<h2 style='color:#c00;'><?php echo esc_html( $this->format_currency( $total_surcharge ) ); ?></h2>
<p><?php echo esc_html__( 'Aufschlag gesamt (Jahresrechnung)', KGVVM_TEXT_DOMAIN ); ?></p>
</div>
</div>
<?php if ( $members_open > 0 ) : ?>
<p style='margin-top:8px;'>
<a href='<?php echo esc_url( $this->admin_url( 'kgvvm-arbeit', array( 'year' => $work_year, 'tab' => 'summary' ) ) ); ?>' class='button button-secondary'>
<?php echo esc_html__( 'Mitgliederübersicht aufrufen', KGVVM_TEXT_DOMAIN ); ?>
</a>
</p>
<?php endif; ?>
<?php endif; ?>
</div>
<div class='kgvvm-card'> <div class='kgvvm-card'>
<h2><?php echo esc_html__( 'Fachmodell', KGVVM_TEXT_DOMAIN ); ?></h2> <h2><?php echo esc_html__( 'Fachmodell', KGVVM_TEXT_DOMAIN ); ?></h2>
<p><?php echo esc_html__( 'Das Plugin verwendet eigene Datenbanktabellen statt Custom Post Types, weil das Fachmodell stark relational ist: Sparten, Parzellen, Zähler, Pächter und Zuordnungen müssen performant gefiltert, eindeutig verknüpft und später um Zählerstände, Verträge oder Umlagen erweitert werden können.', KGVVM_TEXT_DOMAIN ); ?></p> <p><?php echo esc_html__( 'Das Plugin verwendet eigene Datenbanktabellen statt Custom Post Types, weil das Fachmodell stark relational ist: Sparten, Parzellen, Zähler, Pächter und Zuordnungen müssen performant gefiltert, eindeutig verknüpft und später um Zählerstände, Verträge oder Umlagen erweitert werden können.', KGVVM_TEXT_DOMAIN ); ?></p>
@@ -3239,6 +3391,33 @@ class Admin {
</table> </table>
<?php submit_button( __( 'Einstellungen speichern', KGVVM_TEXT_DOMAIN ) ); ?> <?php submit_button( __( 'Einstellungen speichern', KGVVM_TEXT_DOMAIN ) ); ?>
</form> </form>
<hr />
<h2><?php echo esc_html__( 'Datensicherung', KGVVM_TEXT_DOMAIN ); ?></h2>
<div class='kgvvm-grid'>
<div class='kgvvm-card'>
<h3><?php echo esc_html__( 'Export', KGVVM_TEXT_DOMAIN ); ?></h3>
<p><?php echo esc_html__( 'Exportiert alle Plugin-Tabellen (Sparten, Parzellen, Zähler, Verbrauch, Kosten, Arbeitsstunden usw.) als JSON-Datei.', KGVVM_TEXT_DOMAIN ); ?></p>
<a href='<?php echo esc_url( wp_nonce_url( $this->admin_url( 'kgvvm-settings', array( 'kgvvm_action' => 'export_plugin_data' ) ), 'kgvvm_export_plugin_data' ) ); ?>'
class='button button-secondary'>
<?php echo esc_html__( 'JSON-Export herunterladen', KGVVM_TEXT_DOMAIN ); ?>
</a>
</div>
<div class='kgvvm-card'>
<h3><?php echo esc_html__( 'Import', KGVVM_TEXT_DOMAIN ); ?></h3>
<p class='notice notice-warning inline' style='margin:0 0 10px;padding:6px 10px;'>
<?php echo esc_html__( 'Achtung: Der Import überschreibt alle vorhandenen Plugin-Daten vollständig. Bitte vorher einen Export erstellen.', KGVVM_TEXT_DOMAIN ); ?>
</p>
<form method='post' enctype='multipart/form-data'>
<?php wp_nonce_field( 'kgvvm_import_plugin_data' ); ?>
<input type='hidden' name='kgvvm_action' value='import_plugin_data' />
<input type='file' name='kgvvm_import_file' accept='.json,application/json' required style='margin-bottom:8px;display:block;' />
<?php submit_button( __( 'Import starten', KGVVM_TEXT_DOMAIN ), 'secondary', 'submit', false ); ?>
</form>
</div>
</div>
</div> </div>
<?php <?php
} }
@@ -4050,4 +4229,401 @@ class Admin {
return add_query_arg( $args, admin_url( 'admin.php' ) ); return add_query_arg( $args, admin_url( 'admin.php' ) );
} }
// =========================================================================
// ARBEITSSTUNDEN
// =========================================================================
/**
* Save work year configuration.
*
* @return void
*/
private function save_work_year_config() {
$this->require_cap( 'manage_kleingarten' );
check_admin_referer( 'kgvvm_save_work_year_config' );
$year = absint( isset( $_POST['entry_year'] ) ? $_POST['entry_year'] : 0 );
$required_hours = isset( $_POST['required_hours'] ) ? (float) $_POST['required_hours'] : 0;
$price_per_missing_hour = isset( $_POST['price_per_missing_hour'] ) ? (float) $_POST['price_per_missing_hour'] : 0;
if ( $year < 2000 || $year > 2100 ) {
$this->redirect_with_notice( 'kgvvm-arbeit', 'error', __( 'Bitte ein gültiges Jahr eingeben.', KGVVM_TEXT_DOMAIN ) );
}
$this->work->save_year_config( $year, $required_hours, $price_per_missing_hour );
$this->redirect_with_notice( 'kgvvm-arbeit', 'success', __( 'Jahreseinstellungen wurden gespeichert.', KGVVM_TEXT_DOMAIN ), array( 'year' => $year ) );
}
/**
* Save work job (add/update).
*
* @return void
*/
private function save_work_job() {
$this->require_cap( 'manage_kleingarten' );
check_admin_referer( 'kgvvm_save_work_job' );
$id = absint( isset( $_POST['id'] ) ? $_POST['id'] : 0 );
$name = sanitize_text_field( wp_unslash( isset( $_POST['job_name'] ) ? $_POST['job_name'] : '' ) );
if ( '' === $name ) {
$this->redirect_with_notice( 'kgvvm-arbeit', 'error', __( 'Bitte einen Namen für die Arbeitsart eingeben.', KGVVM_TEXT_DOMAIN ), array( 'tab' => 'jobs' ) );
}
if ( $this->work->job_name_exists( $name, $id ) ) {
$this->redirect_with_notice( 'kgvvm-arbeit', 'error', __( 'Eine Arbeitsart mit diesem Namen existiert bereits.', KGVVM_TEXT_DOMAIN ), array( 'tab' => 'jobs' ) );
}
$this->work->save_job(
array(
'name' => $name,
'description' => isset( $_POST['job_description'] ) ? wp_unslash( $_POST['job_description'] ) : '',
),
$id
);
$this->redirect_with_notice( 'kgvvm-arbeit', 'success', __( 'Arbeitsart wurde gespeichert.', KGVVM_TEXT_DOMAIN ), array( 'tab' => 'jobs' ) );
}
/**
* Save work log entry (add/update).
*
* @return void
*/
private function save_work_log() {
$this->require_cap( 'manage_kleingarten' );
check_admin_referer( 'kgvvm_save_work_log' );
$id = absint( isset( $_POST['id'] ) ? $_POST['id'] : 0 );
$job_id = absint( isset( $_POST['job_id'] ) ? $_POST['job_id'] : 0 );
$work_date = sanitize_text_field( wp_unslash( isset( $_POST['work_date'] ) ? $_POST['work_date'] : '' ) );
$year = $work_date ? (int) substr( $work_date, 0, 4 ) : (int) current_time( 'Y' );
if ( '' === $work_date ) {
$this->redirect_with_notice( 'kgvvm-arbeit', 'error', __( 'Bitte ein gültiges Datum eingeben.', KGVVM_TEXT_DOMAIN ), array( 'year' => $year ) );
}
$raw_members = isset( $_POST['member_hours'] ) ? (array) wp_unslash( $_POST['member_hours'] ) : array();
$members = array();
foreach ( $raw_members as $uid => $hours ) {
$uid = absint( $uid );
$hours = (float) $hours;
if ( $uid > 0 && $hours > 0 ) {
$members[ $uid ] = $hours;
}
}
if ( empty( $members ) ) {
$this->redirect_with_notice( 'kgvvm-arbeit', 'error', __( 'Bitte mindestens ein Mitglied mit Stundenzahl zuordnen.', KGVVM_TEXT_DOMAIN ), array( 'year' => $year ) );
}
$this->work->save_log(
array(
'job_id' => $job_id,
'work_date' => $work_date,
'note' => isset( $_POST['note'] ) ? wp_unslash( $_POST['note'] ) : '',
),
$id,
$members
);
$this->redirect_with_notice( 'kgvvm-arbeit', 'success', __( 'Arbeitseintrag wurde gespeichert.', KGVVM_TEXT_DOMAIN ), array( 'year' => $year ) );
}
/**
* Render the Arbeitsstunden admin page.
*
* @return void
*/
public function render_work_page() {
$this->require_cap( 'manage_kleingarten' );
$tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'logs';
$selected_year = isset( $_GET['year'] ) ? absint( $_GET['year'] ) : (int) current_time( 'Y' );
$selected_year = $selected_year > 0 ? $selected_year : (int) current_time( 'Y' );
$edit_log_id = absint( isset( $_GET['id'] ) ? $_GET['id'] : 0 );
$edit_job_id = absint( isset( $_GET['job_id'] ) ? $_GET['job_id'] : 0 );
$years = $this->work->get_years( $selected_year );
$year_config = $this->work->get_year_config( $selected_year );
$jobs = $this->work->get_jobs();
$all_members = $this->assignments->get_member_users();
$edit_log = null;
$edit_job = null;
if ( $edit_log_id ) {
$edit_log = $this->work->find_log( $edit_log_id );
}
if ( $edit_job_id ) {
$edit_job = $this->work->find_job( $edit_job_id );
}
$logs = $this->work->search_logs(
array(
'year' => $selected_year,
'orderby' => isset( $_GET['orderby'] ) ? sanitize_key( wp_unslash( $_GET['orderby'] ) ) : 'work_date',
'order' => isset( $_GET['order'] ) ? sanitize_key( wp_unslash( $_GET['order'] ) ) : 'DESC',
's' => isset( $_GET['s'] ) ? sanitize_text_field( wp_unslash( $_GET['s'] ) ) : '',
)
);
$summary = $this->work->get_member_summary( $selected_year, $all_members );
?>
<div class='wrap'>
<h1 class='wp-heading-inline'><?php echo esc_html__( 'Arbeitsstunden', KGVVM_TEXT_DOMAIN ); ?></h1>
<?php $this->render_notice(); ?>
<?php /* Year filter */ ?>
<form method='get' class='kgvvm-toolbar' style='margin-top:12px;'>
<input type='hidden' name='page' value='kgvvm-arbeit' />
<input type='hidden' name='tab' value='<?php echo esc_attr( $tab ); ?>' />
<div class='kgvvm-filters'>
<label for='kgvvm-work-year'><?php echo esc_html__( 'Jahr', KGVVM_TEXT_DOMAIN ); ?></label>
<select name='year' id='kgvvm-work-year'>
<?php foreach ( $years as $year ) : ?>
<option value='<?php echo esc_attr( $year ); ?>' <?php selected( $selected_year, $year ); ?>><?php echo esc_html( $year ); ?></option>
<?php endforeach; ?>
</select>
<button class='button'><?php echo esc_html__( 'Filtern', KGVVM_TEXT_DOMAIN ); ?></button>
</div>
</form>
<?php /* Year config card */ ?>
<div class='kgvvm-card' style='max-width:560px;margin-top:16px;'>
<h2><?php echo esc_html( sprintf( __( 'Jahreseinstellungen %d', KGVVM_TEXT_DOMAIN ), $selected_year ) ); ?></h2>
<form method='post'>
<?php wp_nonce_field( 'kgvvm_save_work_year_config' ); ?>
<input type='hidden' name='kgvvm_action' value='save_work_year_config' />
<input type='hidden' name='entry_year' value='<?php echo esc_attr( $selected_year ); ?>' />
<table class='form-table kgvvm-form-table'>
<tr>
<th scope='row'><label for='kgvvm-work-required-hours'><?php echo esc_html__( 'Pflichtstunden je Mitglied', KGVVM_TEXT_DOMAIN ); ?></label></th>
<td><input type='number' min='0' step='0.5' name='required_hours' id='kgvvm-work-required-hours'
value='<?php echo esc_attr( $year_config ? (float) $year_config->required_hours : 0 ); ?>' /> <?php echo esc_html__( 'Std.', KGVVM_TEXT_DOMAIN ); ?></td>
</tr>
<tr>
<th scope='row'><label for='kgvvm-work-price'><?php echo esc_html__( 'Preis je fehlender Stunde', KGVVM_TEXT_DOMAIN ); ?></label></th>
<td><input type='number' min='0' step='0.01' name='price_per_missing_hour' id='kgvvm-work-price'
value='<?php echo esc_attr( $year_config ? (float) $year_config->price_per_missing_hour : 0 ); ?>' /> € / Std.</td>
</tr>
</table>
<?php submit_button( __( 'Einstellungen speichern', KGVVM_TEXT_DOMAIN ), 'secondary' ); ?>
</form>
</div>
<?php /* Tabs */ ?>
<nav class='nav-tab-wrapper' style='margin-top:20px;'>
<a href='<?php echo esc_url( $this->admin_url( 'kgvvm-arbeit', array( 'year' => $selected_year, 'tab' => 'logs' ) ) ); ?>'
class='nav-tab <?php echo 'logs' === $tab ? 'nav-tab-active' : ''; ?>'><?php echo esc_html__( 'Geleistete Arbeiten', KGVVM_TEXT_DOMAIN ); ?></a>
<a href='<?php echo esc_url( $this->admin_url( 'kgvvm-arbeit', array( 'year' => $selected_year, 'tab' => 'summary' ) ) ); ?>'
class='nav-tab <?php echo 'summary' === $tab ? 'nav-tab-active' : ''; ?>'><?php echo esc_html__( 'Mitgliederübersicht', KGVVM_TEXT_DOMAIN ); ?></a>
<a href='<?php echo esc_url( $this->admin_url( 'kgvvm-arbeit', array( 'year' => $selected_year, 'tab' => 'jobs' ) ) ); ?>'
class='nav-tab <?php echo 'jobs' === $tab ? 'nav-tab-active' : ''; ?>'><?php echo esc_html__( 'Arbeitsarten', KGVVM_TEXT_DOMAIN ); ?></a>
</nav>
<?php if ( 'jobs' === $tab ) : ?>
<?php /* ---- ARBEITSARTEN ---- */ ?>
<div class='kgvvm-card' style='margin-top:0;border-top:none;padding-top:20px;'>
<h2><?php echo esc_html( $edit_job ? __( 'Arbeitsart bearbeiten', KGVVM_TEXT_DOMAIN ) : __( 'Neue Arbeitsart', KGVVM_TEXT_DOMAIN ) ); ?></h2>
<form method='post'>
<?php wp_nonce_field( 'kgvvm_save_work_job' ); ?>
<input type='hidden' name='kgvvm_action' value='save_work_job' />
<input type='hidden' name='id' value='<?php echo esc_attr( $edit_job ? $edit_job->id : 0 ); ?>' />
<table class='form-table kgvvm-form-table'>
<tr>
<th scope='row'><label for='kgvvm-job-name'><?php echo esc_html__( 'Name', KGVVM_TEXT_DOMAIN ); ?></label></th>
<td><input type='text' class='regular-text' name='job_name' id='kgvvm-job-name' required
value='<?php echo esc_attr( $edit_job ? $edit_job->name : '' ); ?>' /></td>
</tr>
<tr>
<th scope='row'><label for='kgvvm-job-description'><?php echo esc_html__( 'Beschreibung', KGVVM_TEXT_DOMAIN ); ?></label></th>
<td><textarea name='job_description' id='kgvvm-job-description' rows='3' class='large-text'><?php echo esc_textarea( $edit_job ? $edit_job->description : '' ); ?></textarea></td>
</tr>
</table>
<?php submit_button( $edit_job ? __( 'Arbeitsart aktualisieren', KGVVM_TEXT_DOMAIN ) : __( 'Arbeitsart anlegen', KGVVM_TEXT_DOMAIN ) ); ?>
<?php if ( $edit_job ) : ?>
<a href='<?php echo esc_url( $this->admin_url( 'kgvvm-arbeit', array( 'year' => $selected_year, 'tab' => 'jobs' ) ) ); ?>' class='button'><?php echo esc_html__( 'Abbrechen', KGVVM_TEXT_DOMAIN ); ?></a>
<?php endif; ?>
</form>
</div>
<?php if ( ! empty( $jobs ) ) : ?>
<table class='wp-list-table widefat fixed striped' style='margin-top:16px;'>
<thead>
<tr>
<th><?php echo esc_html__( 'Name', KGVVM_TEXT_DOMAIN ); ?></th>
<th><?php echo esc_html__( 'Beschreibung', KGVVM_TEXT_DOMAIN ); ?></th>
<th style='width:120px;'><?php echo esc_html__( 'Aktionen', KGVVM_TEXT_DOMAIN ); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ( $jobs as $job ) : ?>
<tr>
<td><strong><?php echo esc_html( $job->name ); ?></strong></td>
<td><?php echo esc_html( $job->description ); ?></td>
<td>
<a href='<?php echo esc_url( $this->admin_url( 'kgvvm-arbeit', array( 'tab' => 'jobs', 'year' => $selected_year, 'job_id' => $job->id ) ) ); ?>'><?php echo esc_html__( 'Bearbeiten', KGVVM_TEXT_DOMAIN ); ?></a>
&nbsp;|&nbsp;
<a href='<?php echo esc_url( wp_nonce_url( $this->admin_url( 'kgvvm-arbeit', array( 'kgvvm_action' => 'delete_work_job', 'id' => $job->id, 'year' => $selected_year, 'tab' => 'jobs' ) ), 'kgvvm_delete_work_job_' . $job->id ) ); ?>'
class='kgvvm-delete-link' onclick='return confirm("<?php echo esc_attr__( 'Diese Arbeitsart und alle zugehörigen Einträge wirklich löschen?', KGVVM_TEXT_DOMAIN ); ?>")'><?php echo esc_html__( 'Löschen', KGVVM_TEXT_DOMAIN ); ?></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else : ?>
<p class='kgvvm-help'><?php echo esc_html__( 'Noch keine Arbeitsarten angelegt.', KGVVM_TEXT_DOMAIN ); ?></p>
<?php endif; ?>
<?php elseif ( 'summary' === $tab ) : ?>
<?php /* ---- MITGLIEDERÜBERSICHT ---- */ ?>
<div style='margin-top:0;'>
<?php if ( ! $year_config ) : ?>
<p class='notice notice-warning inline'><?php echo esc_html__( 'Für dieses Jahr wurden noch keine Jahreseinstellungen hinterlegt.', KGVVM_TEXT_DOMAIN ); ?></p>
<?php endif; ?>
<table class='wp-list-table widefat fixed striped' style='margin-top:16px;'>
<thead>
<tr>
<th><?php echo esc_html__( 'Mitglied', KGVVM_TEXT_DOMAIN ); ?></th>
<th><?php echo esc_html__( 'Geleistet (Std.)', KGVVM_TEXT_DOMAIN ); ?></th>
<th><?php echo esc_html__( 'Pflicht (Std.)', KGVVM_TEXT_DOMAIN ); ?></th>
<th><?php echo esc_html__( 'Fehlend (Std.)', KGVVM_TEXT_DOMAIN ); ?></th>
<th><?php echo esc_html__( 'Aufschlag (€)', KGVVM_TEXT_DOMAIN ); ?></th>
</tr>
</thead>
<tbody>
<?php if ( empty( $summary ) ) : ?>
<tr><td colspan='5'><?php echo esc_html__( 'Keine Mitglieder gefunden.', KGVVM_TEXT_DOMAIN ); ?></td></tr>
<?php else : ?>
<?php foreach ( $summary as $row ) : ?>
<tr>
<td><?php echo esc_html( $row->display_name ); ?></td>
<td><?php echo esc_html( number_format_i18n( $row->completed_hours, 2 ) ); ?></td>
<td><?php echo esc_html( number_format_i18n( $row->required_hours, 2 ) ); ?></td>
<td><?php echo $row->missing_hours > 0 ? '<strong style="color:#c00">' . esc_html( number_format_i18n( $row->missing_hours, 2 ) ) . '</strong>' : esc_html( number_format_i18n( 0, 2 ) ); ?></td>
<td><?php echo $row->surcharge > 0 ? '<strong style="color:#c00">' . esc_html( $this->format_currency( $row->surcharge ) ) . '</strong>' : '—'; ?></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
<?php else : ?>
<?php /* ---- GELEISTETE ARBEITEN (logs) ---- */ ?>
<?php /* New/edit log form */ ?>
<div class='kgvvm-card' style='margin-top:0;border-top:none;padding-top:20px;'>
<h2><?php echo esc_html( $edit_log ? __( 'Arbeitseintrag bearbeiten', KGVVM_TEXT_DOMAIN ) : __( 'Neuer Arbeitseintrag', KGVVM_TEXT_DOMAIN ) ); ?></h2>
<form method='post'>
<?php wp_nonce_field( 'kgvvm_save_work_log' ); ?>
<input type='hidden' name='kgvvm_action' value='save_work_log' />
<input type='hidden' name='id' value='<?php echo esc_attr( $edit_log ? $edit_log->id : 0 ); ?>' />
<table class='form-table kgvvm-form-table'>
<tr>
<th scope='row'><label for='kgvvm-log-date'><?php echo esc_html__( 'Datum', KGVVM_TEXT_DOMAIN ); ?></label></th>
<td><input type='date' name='work_date' id='kgvvm-log-date' required
value='<?php echo esc_attr( $edit_log ? esc_attr( $edit_log->work_date ) : current_time( 'Y-m-d' ) ); ?>' /></td>
</tr>
<tr>
<th scope='row'><label for='kgvvm-log-job'><?php echo esc_html__( 'Arbeitsart', KGVVM_TEXT_DOMAIN ); ?></label></th>
<td>
<select name='job_id' id='kgvvm-log-job'>
<option value='0'><?php echo esc_html__( '— keine Zuordnung —', KGVVM_TEXT_DOMAIN ); ?></option>
<?php foreach ( $jobs as $job ) : ?>
<option value='<?php echo esc_attr( $job->id ); ?>' <?php selected( $edit_log ? (int) $edit_log->job_id : 0, (int) $job->id ); ?>><?php echo esc_html( $job->name ); ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<th scope='row'><label><?php echo esc_html__( 'Mitglieder & Stunden', KGVVM_TEXT_DOMAIN ); ?></label></th>
<td>
<?php
$existing_member_hours = array();
if ( $edit_log && ! empty( $edit_log->members ) ) {
foreach ( $edit_log->members as $m ) {
$existing_member_hours[ (int) $m->user_id ] = (float) $m->hours;
}
}
?>
<table class='kgvvm-subtable'>
<thead><tr><th><?php echo esc_html__( 'Mitglied', KGVVM_TEXT_DOMAIN ); ?></th><th><?php echo esc_html__( 'Stunden', KGVVM_TEXT_DOMAIN ); ?></th></tr></thead>
<tbody>
<?php foreach ( $all_members as $member ) : ?>
<?php
$uid = (int) $member->ID;
$hours_val = isset( $existing_member_hours[ $uid ] ) ? $existing_member_hours[ $uid ] : '';
?>
<tr>
<td><?php echo esc_html( $member->display_name ); ?></td>
<td><input type='number' min='0' step='0.25' style='width:80px;'
name='member_hours[<?php echo esc_attr( $uid ); ?>]'
value='<?php echo esc_attr( $hours_val ); ?>'
placeholder='0' /></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<p class='description'><?php echo esc_html__( 'Nur Mitglieder mit eingetragenen Stunden werden gespeichert.', KGVVM_TEXT_DOMAIN ); ?></p>
</td>
</tr>
<tr>
<th scope='row'><label for='kgvvm-log-note'><?php echo esc_html__( 'Notiz', KGVVM_TEXT_DOMAIN ); ?></label></th>
<td><textarea name='note' id='kgvvm-log-note' rows='3' class='large-text'><?php echo esc_textarea( $edit_log ? $edit_log->note : '' ); ?></textarea></td>
</tr>
</table>
<?php submit_button( $edit_log ? __( 'Arbeitseintrag aktualisieren', KGVVM_TEXT_DOMAIN ) : __( 'Arbeitseintrag speichern', KGVVM_TEXT_DOMAIN ) ); ?>
<?php if ( $edit_log ) : ?>
<a href='<?php echo esc_url( $this->admin_url( 'kgvvm-arbeit', array( 'year' => $selected_year ) ) ); ?>' class='button'><?php echo esc_html__( 'Abbrechen', KGVVM_TEXT_DOMAIN ); ?></a>
<?php endif; ?>
</form>
</div>
<?php /* Log list */ ?>
<?php if ( ! empty( $logs ) ) : ?>
<table class='wp-list-table widefat fixed striped' style='margin-top:16px;'>
<thead>
<tr>
<th><?php echo esc_html__( 'Datum', KGVVM_TEXT_DOMAIN ); ?></th>
<th><?php echo esc_html__( 'Arbeitsart', KGVVM_TEXT_DOMAIN ); ?></th>
<th><?php echo esc_html__( 'Mitglieder', KGVVM_TEXT_DOMAIN ); ?></th>
<th><?php echo esc_html__( 'Notiz', KGVVM_TEXT_DOMAIN ); ?></th>
<th style='width:120px;'><?php echo esc_html__( 'Aktionen', KGVVM_TEXT_DOMAIN ); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ( $logs as $log ) : ?>
<?php $log_members = $this->work->get_log_members( $log->id ); ?>
<tr>
<td><?php echo esc_html( date_i18n( get_option( 'date_format' ), strtotime( $log->work_date ) ) ); ?></td>
<td><?php echo esc_html( $log->job_name ?: '—' ); ?></td>
<td>
<?php foreach ( $log_members as $lm ) :
$u = get_userdata( $lm->user_id );
if ( $u ) : ?>
<?php echo esc_html( $u->display_name ); ?>: <strong><?php echo esc_html( number_format_i18n( (float) $lm->hours, 2 ) ); ?> Std.</strong><br>
<?php endif; ?>
<?php endforeach; ?>
</td>
<td><?php echo esc_html( $log->note ); ?></td>
<td>
<a href='<?php echo esc_url( $this->admin_url( 'kgvvm-arbeit', array( 'year' => $selected_year, 'id' => $log->id ) ) ); ?>'><?php echo esc_html__( 'Bearbeiten', KGVVM_TEXT_DOMAIN ); ?></a>
&nbsp;|&nbsp;
<a href='<?php echo esc_url( wp_nonce_url( $this->admin_url( 'kgvvm-arbeit', array( 'kgvvm_action' => 'delete_work_log', 'id' => $log->id, 'year' => $selected_year ) ), 'kgvvm_delete_work_log_' . $log->id ) ); ?>'
class='kgvvm-delete-link' onclick='return confirm("<?php echo esc_attr__( 'Diesen Arbeitseintrag wirklich löschen?', KGVVM_TEXT_DOMAIN ); ?>")'><?php echo esc_html__( 'Löschen', KGVVM_TEXT_DOMAIN ); ?></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else : ?>
<p class='kgvvm-help' style='margin-top:12px;'><?php echo esc_html( sprintf( __( 'Keine Arbeitseinträge für %d vorhanden.', KGVVM_TEXT_DOMAIN ), $selected_year ) ); ?></p>
<?php endif; ?>
<?php endif; ?>
</div>
<?php
}
} }

195
includes/DataTransfer.php Normal file
View File

@@ -0,0 +1,195 @@
<?php
/**
* Export and import all kgvvm plugin data as JSON.
*
* @package KGV\VereinManager
*/
namespace KGV\VereinManager;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class DataTransfer {
/** @var \wpdb */
private $wpdb;
/**
* Table keys in dependency order (parent before child).
*
* @var string[]
*/
private static $table_keys = array(
'sections',
'parcels',
'tenants',
'parcel_members',
'parcel_tenants',
'meters',
'meter_readings',
'chat_messages',
'cost_years',
'cost_rates',
'cost_entries',
'work_jobs',
'work_year_config',
'work_logs',
'work_log_members',
);
public function __construct( \wpdb $wpdb ) {
$this->wpdb = $wpdb;
}
// -------------------------------------------------------------------------
// Export
// -------------------------------------------------------------------------
/**
* Build the export payload as an associative array.
*
* @return array
*/
public function build_export() {
$payload = array(
'plugin' => 'kgv-verein-manager',
'version' => KGVVM_VERSION,
'exported' => gmdate( 'Y-m-d\TH:i:s\Z' ),
'tables' => array(),
);
foreach ( self::$table_keys as $key ) {
$table = Schema::table( $key );
if ( '' === $table ) {
continue;
}
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
$rows = $this->wpdb->get_results( "SELECT * FROM {$table}", ARRAY_A );
$payload['tables'][ $key ] = is_array( $rows ) ? $rows : array();
}
return $payload;
}
/**
* Send the export as a JSON file download and exit.
*
* @return void
*/
public function send_download() {
$payload = $this->build_export();
$json = wp_json_encode( $payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE );
$filename = 'kgvvm-export-' . gmdate( 'Y-m-d' ) . '.json';
nocache_headers();
header( 'Content-Type: application/json; charset=utf-8' );
header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
header( 'Content-Length: ' . strlen( $json ) );
echo $json; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
exit;
}
// -------------------------------------------------------------------------
// Import
// -------------------------------------------------------------------------
/**
* Validate and import data from a decoded JSON array.
*
* Returns an array with keys 'imported' (int[]), 'skipped' (string[]), 'errors' (string[]).
*
* @param array $payload Decoded JSON payload.
* @return array
*/
public function import( array $payload ) {
$result = array(
'imported' => array(),
'skipped' => array(),
'errors' => array(),
);
if ( empty( $payload['plugin'] ) || 'kgv-verein-manager' !== $payload['plugin'] ) {
$result['errors'][] = __( 'Die Datei stammt nicht vom KGV Verein Manager Plugin.', KGVVM_TEXT_DOMAIN );
return $result;
}
if ( empty( $payload['tables'] ) || ! is_array( $payload['tables'] ) ) {
$result['errors'][] = __( 'Die Exportdatei enthält keine Tabellendaten.', KGVVM_TEXT_DOMAIN );
return $result;
}
// Wrap everything in a transaction so a partial failure can be rolled back.
$this->wpdb->query( 'SET FOREIGN_KEY_CHECKS = 0' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
$this->wpdb->query( 'START TRANSACTION' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
// Truncate in reverse dependency order.
foreach ( array_reverse( self::$table_keys ) as $key ) {
if ( ! isset( $payload['tables'][ $key ] ) ) {
continue;
}
$table = Schema::table( $key );
if ( '' === $table ) {
continue;
}
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery
$this->wpdb->query( "TRUNCATE TABLE {$table}" );
}
// Re-insert in dependency order.
foreach ( self::$table_keys as $key ) {
if ( ! isset( $payload['tables'][ $key ] ) ) {
$result['skipped'][] = $key;
continue;
}
$table = Schema::table( $key );
if ( '' === $table ) {
$result['skipped'][] = $key;
continue;
}
$rows = (array) $payload['tables'][ $key ];
$count = 0;
foreach ( $rows as $row ) {
if ( ! is_array( $row ) || empty( $row ) ) {
continue;
}
// Sanitize keys only allow simple column names.
$clean = array();
foreach ( $row as $col => $val ) {
$col_clean = preg_replace( '/[^a-zA-Z0-9_]/', '', (string) $col );
if ( '' !== $col_clean ) {
$clean[ $col_clean ] = $val;
}
}
$inserted = $this->wpdb->insert( $table, $clean ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
if ( false !== $inserted ) {
$count++;
} else {
$result['errors'][] = sprintf(
/* translators: 1: table key 2: DB error */
__( 'Fehler beim Einfügen in %1$s: %2$s', KGVVM_TEXT_DOMAIN ),
$key,
(string) $this->wpdb->last_error
);
}
}
$result['imported'][ $key ] = $count;
}
if ( empty( $result['errors'] ) ) {
$this->wpdb->query( 'COMMIT' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
} else {
$this->wpdb->query( 'ROLLBACK' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
}
$this->wpdb->query( 'SET FOREIGN_KEY_CHECKS = 1' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
return $result;
}
}

View File

@@ -0,0 +1,470 @@
<?php
/**
* Work hours repository.
*
* @package KGV\VereinManager
*/
namespace KGV\VereinManager\Repositories;
use KGV\VereinManager\Schema;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class WorkRepository extends AbstractRepository {
/**
* Resolve main table (work_logs).
*
* @return string
*/
protected function resolve_table() {
return Schema::table( 'work_logs' );
}
/**
* Jobs table.
*
* @return string
*/
private function jobs_table() {
return Schema::table( 'work_jobs' );
}
/**
* Year config table.
*
* @return string
*/
private function year_config_table() {
return Schema::table( 'work_year_config' );
}
/**
* Log members table.
*
* @return string
*/
private function members_table() {
return Schema::table( 'work_log_members' );
}
// -------------------------------------------------------------------------
// Jobs
// -------------------------------------------------------------------------
/**
* Get all jobs.
*
* @return array
*/
public function get_jobs() {
$table = $this->jobs_table();
return $this->wpdb->get_results( "SELECT * FROM {$table} ORDER BY name ASC" ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery
}
/**
* Get a single job by ID.
*
* @param int $id Job ID.
* @return object|null
*/
public function find_job( $id ) {
$table = $this->jobs_table();
return $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM {$table} WHERE id = %d", absint( $id ) ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}
/**
* Save or update a job.
*
* @param array $data Job data.
* @param int $id Optional ID.
* @return int|false
*/
public function save_job( $data, $id = 0 ) {
$table = $this->jobs_table();
$payload = array(
'name' => sanitize_text_field( $data['name'] ),
'description' => isset( $data['description'] ) ? sanitize_textarea_field( $data['description'] ) : '',
'updated_at' => $this->now(),
);
$formats = array( '%s', '%s', '%s' );
if ( $id > 0 ) {
$this->wpdb->update( $table, $payload, array( 'id' => $id ), $formats, array( '%d' ) );
return $id;
}
$payload['created_at'] = $this->now();
$this->wpdb->insert( $table, $payload, array( '%s', '%s', '%s', '%s' ) );
return $this->wpdb->insert_id;
}
/**
* Delete a job and related log members/logs.
*
* @param int $id Job ID.
* @return bool
*/
public function delete_job( $id ) {
$id = absint( $id );
$logs_table = $this->table;
$mem_table = $this->members_table();
$jobs_table = $this->jobs_table();
// Delete members of all logs for this job.
$log_ids = $this->wpdb->get_col( $this->wpdb->prepare( "SELECT id FROM {$logs_table} WHERE job_id = %d", $id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
foreach ( array_map( 'absint', (array) $log_ids ) as $log_id ) {
$this->wpdb->delete( $mem_table, array( 'log_id' => $log_id ), array( '%d' ) );
}
// Delete logs.
$this->wpdb->delete( $logs_table, array( 'job_id' => $id ), array( '%d' ) );
// Delete job.
$result = $this->wpdb->delete( $jobs_table, array( 'id' => $id ), array( '%d' ) );
return false !== $result;
}
/**
* Check if a job name already exists (for uniqueness).
*
* @param string $name Job name.
* @param int $exclude_id Exclude this ID.
* @return bool
*/
public function job_name_exists( $name, $exclude_id = 0 ) {
$table = $this->jobs_table();
$sql = $this->wpdb->prepare( "SELECT COUNT(*) FROM {$table} WHERE name = %s", sanitize_text_field( $name ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
if ( $exclude_id > 0 ) {
$sql .= $this->wpdb->prepare( ' AND id != %d', absint( $exclude_id ) );
}
return (int) $this->wpdb->get_var( $sql ) > 0; // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}
// -------------------------------------------------------------------------
// Year config
// -------------------------------------------------------------------------
/**
* Get config for a specific year (creates if missing).
*
* @param int $year Year.
* @return object|null
*/
public function get_year_config( $year ) {
$year = absint( $year );
$table = $this->year_config_table();
$row = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM {$table} WHERE entry_year = %d", $year ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
return $row;
}
/**
* Get all available configured years.
*
* @param int $selected_year Optional selected year to always include.
* @return array
*/
public function get_years( $selected_year = 0 ) {
$config_table = $this->year_config_table();
$log_table = $this->table;
$current_year = (int) current_time( 'Y' );
$config_years = $this->wpdb->get_col( "SELECT entry_year FROM {$config_table} ORDER BY entry_year DESC" ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery
$log_years = $this->wpdb->get_col( "SELECT DISTINCT YEAR(work_date) FROM {$log_table}" ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery
$years = array_map( 'absint', array_merge( (array) $config_years, (array) $log_years ) );
$years[] = $current_year;
$years[] = $current_year - 1;
$years[] = $current_year + 1;
if ( $selected_year > 0 ) {
$years[] = absint( $selected_year );
}
$years = array_values( array_unique( array_filter( $years ) ) );
rsort( $years, SORT_NUMERIC );
return $years;
}
/**
* Save year configuration (upsert).
*
* @param int $year Year.
* @param float $required_hours Required hours per member.
* @param float $price_per_missing_hour Price per missing hour in €.
* @return bool
*/
public function save_year_config( $year, $required_hours, $price_per_missing_hour ) {
$year = absint( $year );
$required_hours = max( 0, (float) $required_hours );
$price_per_missing_hour = max( 0, (float) $price_per_missing_hour );
$table = $this->year_config_table();
$existing = $this->get_year_config( $year );
if ( $existing ) {
$result = $this->wpdb->update(
$table,
array(
'required_hours' => $required_hours,
'price_per_missing_hour' => $price_per_missing_hour,
'updated_at' => $this->now(),
),
array( 'entry_year' => $year ),
array( '%f', '%f', '%s' ),
array( '%d' )
);
return false !== $result;
}
$result = $this->wpdb->insert(
$table,
array(
'entry_year' => $year,
'required_hours' => $required_hours,
'price_per_missing_hour' => $price_per_missing_hour,
'created_at' => $this->now(),
'updated_at' => $this->now(),
),
array( '%d', '%f', '%f', '%s', '%s' )
);
return false !== $result;
}
// -------------------------------------------------------------------------
// Work logs
// -------------------------------------------------------------------------
/**
* Search work logs.
*
* @param array $args Query arguments (year, user_id, job_id, s, orderby, order).
* @return array
*/
public function search_logs( $args = array() ) {
$year = isset( $args['year'] ) ? absint( $args['year'] ) : 0;
$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : 0;
$job_id = isset( $args['job_id'] ) ? absint( $args['job_id'] ) : 0;
$search = isset( $args['s'] ) ? sanitize_text_field( wp_unslash( $args['s'] ) ) : '';
$orderby = $this->sanitize_orderby(
isset( $args['orderby'] ) ? sanitize_key( wp_unslash( $args['orderby'] ) ) : 'work_date',
array( 'work_date', 'job_name', 'updated_at', 'created_at' ),
'work_date'
);
$order = $this->sanitize_order( isset( $args['order'] ) ? sanitize_key( wp_unslash( $args['order'] ) ) : 'DESC' );
$logs_table = $this->table;
$jobs_table = $this->jobs_table();
$mem_table = $this->members_table();
$sql = "SELECT l.*, COALESCE(j.name, '') AS job_name FROM {$logs_table} l
LEFT JOIN {$jobs_table} j ON j.id = l.job_id WHERE 1=1";
$params = array();
if ( $year > 0 ) {
$sql .= ' AND YEAR(l.work_date) = %d';
$params[] = $year;
}
if ( $job_id > 0 ) {
$sql .= ' AND l.job_id = %d';
$params[] = $job_id;
}
if ( $user_id > 0 ) {
$sql .= " AND l.id IN (SELECT log_id FROM {$mem_table} WHERE user_id = %d)";
$params[] = $user_id;
}
if ( '' !== $search ) {
$like = '%' . $this->wpdb->esc_like( $search ) . '%';
$sql .= ' AND (j.name LIKE %s OR l.note LIKE %s)';
$params[] = $like;
$params[] = $like;
}
$sql .= " ORDER BY l.{$orderby} {$order}, l.id DESC";
if ( ! empty( $params ) ) {
return $this->wpdb->get_results( $this->wpdb->prepare( $sql, $params ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}
return $this->wpdb->get_results( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery
}
/**
* Get a work log with its member assignments.
*
* @param int $id Log ID.
* @return object|null
*/
public function find_log( $id ) {
$row = $this->find( $id );
if ( $row ) {
$row->members = $this->get_log_members( $id );
}
return $row;
}
/**
* Save or update a work log including member assignments.
*
* @param array $data Log data.
* @param int $id Optional log ID.
* @param array $members Array of [user_id => hours].
* @return int|false
*/
public function save_log( $data, $id = 0, $members = array() ) {
$payload = array(
'job_id' => absint( $data['job_id'] ),
'work_date' => sanitize_text_field( $data['work_date'] ),
'note' => isset( $data['note'] ) ? sanitize_textarea_field( $data['note'] ) : '',
'updated_at' => $this->now(),
);
$formats = array( '%d', '%s', '%s', '%s' );
if ( $id > 0 ) {
$this->wpdb->update( $this->table, $payload, array( 'id' => $id ), $formats, array( '%d' ) );
$log_id = $id;
} else {
$payload['created_at'] = $this->now();
$this->wpdb->insert( $this->table, $payload, array( '%d', '%s', '%s', '%s', '%s' ) );
$log_id = $this->wpdb->insert_id;
}
if ( $log_id && is_array( $members ) ) {
$this->sync_log_members( $log_id, $members );
}
return $log_id;
}
/**
* Delete a work log and its member assignments.
*
* @param int $id Log ID.
* @return bool
*/
public function delete_log( $id ) {
$id = absint( $id );
$this->wpdb->delete( $this->members_table(), array( 'log_id' => $id ), array( '%d' ) );
$result = $this->wpdb->delete( $this->table, array( 'id' => $id ), array( '%d' ) );
return false !== $result;
}
// -------------------------------------------------------------------------
// Log members
// -------------------------------------------------------------------------
/**
* Get member assignments for a log.
*
* @param int $log_id Log ID.
* @return array
*/
public function get_log_members( $log_id ) {
$table = $this->members_table();
return $this->wpdb->get_results( $this->wpdb->prepare( "SELECT * FROM {$table} WHERE log_id = %d", absint( $log_id ) ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}
/**
* Sync member assignments for a log.
*
* @param int $log_id Log ID.
* @param array $members Array of [user_id => hours].
* @return void
*/
public function sync_log_members( $log_id, $members ) {
$log_id = absint( $log_id );
$table = $this->members_table();
$now = $this->now();
$this->wpdb->delete( $table, array( 'log_id' => $log_id ), array( '%d' ) );
foreach ( $members as $user_id => $hours ) {
$user_id = absint( $user_id );
$hours = max( 0, (float) $hours );
if ( $user_id < 1 ) {
continue;
}
$this->wpdb->insert(
$table,
array(
'log_id' => $log_id,
'user_id' => $user_id,
'hours' => $hours,
'created_at' => $now,
),
array( '%d', '%d', '%f', '%s' )
);
}
}
// -------------------------------------------------------------------------
// Summary / statistics
// -------------------------------------------------------------------------
/**
* Get completed hours per member for a given year.
*
* @param int $year Year.
* @return array Array keyed by user_id with total hours.
*/
public function get_hours_per_member( $year ) {
$year = absint( $year );
$log_table = $this->table;
$mem_table = $this->members_table();
$rows = $this->wpdb->get_results(
$this->wpdb->prepare(
"SELECT m.user_id, SUM(m.hours) AS total_hours
FROM {$mem_table} m
INNER JOIN {$log_table} l ON l.id = m.log_id
WHERE YEAR(l.work_date) = %d
GROUP BY m.user_id", // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$year
)
);
$result = array();
foreach ( $rows as $row ) {
$result[ absint( $row->user_id ) ] = (float) $row->total_hours;
}
return $result;
}
/**
* Build per-member work summary for a year.
*
* Returns array of objects with user_id, display_name, completed_hours,
* required_hours, missing_hours, surcharge.
*
* @param int $year Year.
* @param array $all_members Array of WP_User objects.
* @return array
*/
public function get_member_summary( $year, $all_members ) {
$config = $this->get_year_config( $year );
$required_hours = $config ? (float) $config->required_hours : 0.0;
$price = $config ? (float) $config->price_per_missing_hour : 0.0;
$done_map = $this->get_hours_per_member( $year );
$summary = array();
foreach ( $all_members as $member ) {
$uid = (int) $member->ID;
$completed = isset( $done_map[ $uid ] ) ? $done_map[ $uid ] : 0.0;
$missing = max( 0.0, $required_hours - $completed );
$surcharge = round( $missing * $price, 2 );
$obj = new \stdClass();
$obj->user_id = $uid;
$obj->display_name = $member->display_name;
$obj->completed_hours = $completed;
$obj->required_hours = $required_hours;
$obj->missing_hours = $missing;
$obj->surcharge = $surcharge;
$summary[] = $obj;
}
return $summary;
}
}

View File

@@ -34,6 +34,10 @@ class Schema {
'cost_years' => $wpdb->prefix . 'kgvvm_cost_years', 'cost_years' => $wpdb->prefix . 'kgvvm_cost_years',
'cost_rates' => $wpdb->prefix . 'kgvvm_cost_rates', 'cost_rates' => $wpdb->prefix . 'kgvvm_cost_rates',
'cost_entries' => $wpdb->prefix . 'kgvvm_cost_entries', 'cost_entries' => $wpdb->prefix . 'kgvvm_cost_entries',
'work_jobs' => $wpdb->prefix . 'kgvvm_work_jobs',
'work_year_config' => $wpdb->prefix . 'kgvvm_work_year_config',
'work_logs' => $wpdb->prefix . 'kgvvm_work_logs',
'work_log_members' => $wpdb->prefix . 'kgvvm_work_log_members',
); );
return isset( $map[ $key ] ) ? $map[ $key ] : ''; return isset( $map[ $key ] ) ? $map[ $key ] : '';
@@ -205,6 +209,51 @@ class Schema {
KEY distribution_type (distribution_type) KEY distribution_type (distribution_type)
) {$charset_collate};"; ) {$charset_collate};";
$sql[] = "CREATE TABLE " . self::table( 'work_jobs' ) . " (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(190) NOT NULL,
description TEXT NULL,
created_at DATETIME NOT NULL,
updated_at DATETIME NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY name (name)
) {$charset_collate};";
$sql[] = "CREATE TABLE " . self::table( 'work_year_config' ) . " (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
entry_year SMALLINT UNSIGNED NOT NULL,
required_hours DECIMAL(8,2) NOT NULL DEFAULT 0.00,
price_per_missing_hour DECIMAL(12,2) NOT NULL DEFAULT 0.00,
created_at DATETIME NOT NULL,
updated_at DATETIME NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY entry_year (entry_year)
) {$charset_collate};";
$sql[] = "CREATE TABLE " . self::table( 'work_logs' ) . " (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
job_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
work_date DATE NOT NULL,
note TEXT NULL,
created_at DATETIME NOT NULL,
updated_at DATETIME NOT NULL,
PRIMARY KEY (id),
KEY job_id (job_id),
KEY work_date (work_date)
) {$charset_collate};";
$sql[] = "CREATE TABLE " . self::table( 'work_log_members' ) . " (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
log_id BIGINT UNSIGNED NOT NULL,
user_id BIGINT UNSIGNED NOT NULL,
hours DECIMAL(8,2) NOT NULL DEFAULT 0.00,
created_at DATETIME NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY log_user (log_id, user_id),
KEY user_id (user_id),
KEY log_id (log_id)
) {$charset_collate};";
foreach ( $sql as $statement ) { foreach ( $sql as $statement ) {
dbDelta( $statement ); dbDelta( $statement );
} }
@@ -230,6 +279,10 @@ class Schema {
self::table( 'cost_years' ), self::table( 'cost_years' ),
self::table( 'cost_rates' ), self::table( 'cost_rates' ),
self::table( 'cost_entries' ), self::table( 'cost_entries' ),
self::table( 'work_jobs' ),
self::table( 'work_year_config' ),
self::table( 'work_logs' ),
self::table( 'work_log_members' ),
); );
foreach ( $tables as $table ) { foreach ( $tables as $table ) {
@@ -248,6 +301,10 @@ class Schema {
global $wpdb; global $wpdb;
$tables = array( $tables = array(
self::table( 'work_log_members' ),
self::table( 'work_logs' ),
self::table( 'work_year_config' ),
self::table( 'work_jobs' ),
self::table( 'cost_entries' ), self::table( 'cost_entries' ),
self::table( 'cost_rates' ), self::table( 'cost_rates' ),
self::table( 'cost_years' ), self::table( 'cost_years' ),

View File

@@ -1,25 +1,37 @@
<?php <?php
/** /**
* @wordpress-plugin
* Plugin Name: KGV Vereinsverwaltung * Plugin Name: KGV Vereinsverwaltung
* Plugin URI: https://apex-project.de/ * Plugin URI: https://apex-project.de/
* Description: Verwaltung von Sparten, Parzellen, Mitgliedern, Pächtern sowie Wasser- und Stromzählern für Kleingartenvereine. * Description: Verwaltung von Sparten, Parzellen, Mitgliedern, Pächtern sowie Wasser- und Stromzählern für Kleingartenvereine.
* Version: 1.15.1 * Version: 1.16.2
* Author: Ronny Grobel * Author: Ronny Grobel
* Update URI: https://git.apex-project.de/RonnyG/KGV-Verein-Manager * Author URI: https://apex-project.de/
* GitHub Plugin URI: https://git.apex-project.de/RonnyG/KGV-Verein-Manager * License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Update URI: https://git.apex-project.de/Wordpress_Plugins/KGV-Verein-Manager.git
* Gitea Plugin URI: https://git.apex-project.de/Wordpress_Plugins/KGV-Verein-Manager.git
* Text Domain: kgv-verein-manager * Text Domain: kgv-verein-manager
* Domain Path: /languages * Domain Path: /languages
* Requires at least: 6.0 * Requires at least: 6.0
* Requires PHP: 7.2 * Requires PHP: 7.2
* * Requires Plugins: KGV-Updater
* @package KGV\VereinManager * @package KGV\VereinManager
* License: GPLv2+
*
* Php Version 5.6
*
* @package WordPress
* @author Ronny Grobel <dgsoft.de@gmail.com>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 2026-04-16
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
define( 'KGVVM_VERSION', '1.15.1' ); define( 'KGVVM_VERSION', '1.16.2' );
define( 'KGVVM_PLUGIN_FILE', __FILE__ ); define( 'KGVVM_PLUGIN_FILE', __FILE__ );
define( 'KGVVM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'KGVVM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'KGVVM_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'KGVVM_PLUGIN_URL', plugin_dir_url( __FILE__ ) );

64
readme.txt Normal file
View File

@@ -0,0 +1,64 @@
=== KGV Vereinsverwaltung ===
Contributors: ronnygrobel
Tags: verein, mitgliederverwaltung, parzellen, zaehler, abrechnung
Requires at least: 6.0
Tested up to: 6.8
Stable tag: 1.16.2
Requires PHP: 7.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Umfassende Verwaltung von Vereinsdaten, Parzellen, Mitgliedern und Zaehlerstaenden.
== Description ==
KGV Vereinsverwaltung bietet ein umfangreiches Backend fuer Kleingartenvereine mit Fokus auf Stammdaten, Verbraeuche und Organisation.
= Features =
* Vereins-Dashboard
* Verwaltung von Sparten, Parzellen, Mitgliedern und Paechtern
* Wasser- und Stromzaehlerverwaltung
* Kosten- und Stammdatenverwaltung
* Rollen- und Rechtekonzept
* PDF- und Exportfunktionen
== Installation ==
1. Plugin in `wp-content/plugins/KGV-Verein-Manager/` hochladen.
2. Plugin aktivieren.
3. Menues, Rollen und Stammdaten im Backend einrichten.
== Frequently Asked Questions ==
= Welche Mindestanforderungen gelten? =
WordPress ab 6.0 und PHP ab 7.2.
= Ist das Plugin fuer Vereinsablaeufe ausgelegt? =
Ja, insbesondere fuer Kleingartenvereine und deren Verwaltungsprozesse.
== Changelog ==
= 1.16.2 =
* Neue Datensicherungsfunktion unter Einstellungen: Export und Import aller kgvvm-Tabellen als JSON.
* Import mit Sicherheitsprüfung und vollständigem Überschreiben der vorhandenen Plugin-Daten.
= 1.16.1 =
* Wartungsrelease mit synchronisierter Versionsnummer in Plugin-Header, Konstante und Readme-Dateien.
* Release-Tag 1.16.1 gesetzt.
= 1.16.0 =
* Neues Modul Arbeitsstunden im Adminbereich mit drei Bereichen: geleistete Arbeiten, Mitgliederuebersicht und Arbeitsarten.
* Pflichtstunden je Mitglied pro Jahr konfigurierbar, inklusive variablem Preis je fehlender Stunde fuer den Aufschlag in der Jahresrechnung.
* Arbeitseintraege mit Datum, Arbeitsart und Notiz sowie Mehrfachzuordnung von Mitgliedern mit individuellen Stundenwerten.
* Neue Datenbanktabellen fuer Arbeitsarten, Jahreseinstellungen, Arbeitseintraege und Stundenzuordnungen je Mitglied.
= 1.15.6 =
* Versionsabgleich zwischen Plugin-Header, Konstante und Readme.
* WordPress-Readme-Format weiter vereinheitlicht.
= 1.15.5 =
* Aktuelle Version laut Plugin-Header.
* Kontinuierliche Verbesserungen in Verwaltung und Datenpflege.