Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fca849c1a5 | |||
| 80600be607 | |||
| 6b15d7b2a1 | |||
| ba45d09bdd | |||
| e71868dac6 | |||
| b41e3c7bb1 | |||
| 62a25726e8 | |||
| 1e739cfd3f | |||
| 6602a56a1c | |||
| 1a6b1199cd | |||
| a1e6c52eaf | |||
| f1571d3c0e | |||
| 5590306959 | |||
| 96969bb0a2 | |||
| 6c793ad41a |
28
README.md
28
README.md
@@ -3,7 +3,7 @@ Contributors: ronnygrobel
|
|||||||
Tags: verein, mitgliederverwaltung, parzellen, zaehler, abrechnung
|
Tags: verein, mitgliederverwaltung, parzellen, zaehler, abrechnung
|
||||||
Requires at least: 6.0
|
Requires at least: 6.0
|
||||||
Tested up to: 6.8
|
Tested up to: 6.8
|
||||||
Stable tag: 1.16.1
|
Stable tag: 1.17.4
|
||||||
Requires PHP: 7.2
|
Requires PHP: 7.2
|
||||||
License: GPLv2 or later
|
License: GPLv2 or later
|
||||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
@@ -43,6 +43,32 @@ Ja, insbesondere fuer Kleingartenvereine und deren Verwaltungsprozesse.
|
|||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
|
= 1.17.4 =
|
||||||
|
Fix: Checkbox "Verpflichtende Position" bei Kostenposten wird jetzt korrekt gespeichert wenn sie deaktiviert ist.
|
||||||
|
|
||||||
|
= 1.17.3 =
|
||||||
|
Verbesserung: Kostenübersicht zeigt jetzt direkt pro Kostenposten den Status Verpflichtend oder Manuell in einer eigenen Spalte an.
|
||||||
|
|
||||||
|
= 1.17.2 =
|
||||||
|
Fix: Manuelle Kostenpositionen auf der Jahresabrechnung einer Parzelle werden nach dem Hinzufügen jetzt sofort korrekt berücksichtigt. Pflichtpositionen ohne Einschränkung werden in der Seitenleiste als automatisch aktiv dargestellt.
|
||||||
|
|
||||||
|
= 1.17.1 =
|
||||||
|
Feat: is_mandatory Flag für Kostenpositionstypen - Kostenposten können jetzt als "verpflichtend" oder "manuell/optional" gekennzeichnet werden. Checkbox in der Kostenposten-Bearbeitung.
|
||||||
|
|
||||||
|
= 1.17.0 =
|
||||||
|
Parzellenspezifische Kostenpositionenzuweisung: Kostenposten können jetzt einzelnen Parzellen zugeordnet werden (z.B. Versicherung nur für bestimmte Parzellen). Editor auf der Jahresabrechnung Parzelle Seite mit übersichtlicher Liste und Hinzufügen/Entfernen-Funktionen. Zuordnungen werden in einer separaten Tabelle gespeichert und sind vollständig in Export/Import integriert.
|
||||||
|
|
||||||
|
= 1.16.3 =
|
||||||
|
* Datensicherung erweitert: Export und Import umfassen jetzt zusätzlich die zugehörigen WordPress-Mitgliederkonten inklusive Metadaten.
|
||||||
|
|
||||||
|
= 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 =
|
= 1.16.0 =
|
||||||
* Neues Modul Arbeitsstunden im Adminbereich mit drei Bereichen: geleistete Arbeiten, Mitgliederuebersicht und Arbeitsarten.
|
* 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.
|
* Pflichtstunden je Mitglied pro Jahr konfigurierbar, inklusive variablem Preis je fehlender Stunde fuer den Aufschlag in der Jahresrechnung.
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use KGV\VereinManager\Repositories\SectionRepository;
|
|||||||
use KGV\VereinManager\Repositories\TenantRepository;
|
use KGV\VereinManager\Repositories\TenantRepository;
|
||||||
use KGV\VereinManager\Repositories\WorkRepository;
|
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;
|
||||||
@@ -46,6 +47,7 @@ class Admin {
|
|||||||
private $costs;
|
private $costs;
|
||||||
private $work;
|
private $work;
|
||||||
private $parcel_service;
|
private $parcel_service;
|
||||||
|
private $data_transfer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct admin controller.
|
* Construct admin controller.
|
||||||
@@ -62,6 +64,8 @@ class Admin {
|
|||||||
$this->costs = new CostRepository();
|
$this->costs = new CostRepository();
|
||||||
$this->work = new WorkRepository();
|
$this->work = new WorkRepository();
|
||||||
$this->parcel_service = new ParcelService();
|
$this->parcel_service = new ParcelService();
|
||||||
|
global $wpdb;
|
||||||
|
$this->data_transfer = new DataTransfer( $wpdb );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,6 +246,12 @@ class Admin {
|
|||||||
case 'save_work_log':
|
case 'save_work_log':
|
||||||
$this->save_work_log();
|
$this->save_work_log();
|
||||||
break;
|
break;
|
||||||
|
case 'import_plugin_data':
|
||||||
|
$this->import_plugin_data();
|
||||||
|
break;
|
||||||
|
case 'toggle_parcel_cost_assignment':
|
||||||
|
$this->toggle_parcel_cost_assignment();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,12 +316,20 @@ class Admin {
|
|||||||
$this->redirect_with_notice( 'kgvvm-costs', 'error', __( 'Der gewünschte Kostenposten wurde nicht gefunden.', KGVVM_TEXT_DOMAIN ), array( 'year' => $year ) );
|
$this->redirect_with_notice( 'kgvvm-costs', 'error', __( 'Der gewünschte Kostenposten wurde nicht gefunden.', KGVVM_TEXT_DOMAIN ), array( 'year' => $year ) );
|
||||||
}
|
}
|
||||||
$year = (int) $cost->entry_year;
|
$year = (int) $cost->entry_year;
|
||||||
|
$this->costs->delete_assignments_for_entry( $id );
|
||||||
$this->costs->delete( $id );
|
$this->costs->delete( $id );
|
||||||
$this->redirect_with_notice( 'kgvvm-costs', 'success', __( 'Kostenposten wurde gelöscht.', KGVVM_TEXT_DOMAIN ), array( 'year' => $year ) );
|
$this->redirect_with_notice( 'kgvvm-costs', 'success', __( 'Kostenposten wurde gelöscht.', KGVVM_TEXT_DOMAIN ), array( 'year' => $year ) );
|
||||||
break;
|
break;
|
||||||
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':
|
case 'delete_work_job':
|
||||||
$this->require_cap( 'manage_kleingarten' );
|
$this->require_cap( 'manage_kleingarten' );
|
||||||
if ( ! wp_verify_nonce( $nonce, 'kgvvm_delete_work_job_' . $id ) ) {
|
if ( ! wp_verify_nonce( $nonce, 'kgvvm_delete_work_job_' . $id ) ) {
|
||||||
@@ -684,6 +702,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.
|
||||||
*
|
*
|
||||||
@@ -768,6 +839,34 @@ class Admin {
|
|||||||
$this->redirect_with_notice( 'kgvvm-costs', 'success', __( 'Kostenposten wurde gespeichert.', KGVVM_TEXT_DOMAIN ), array( 'year' => $data['entry_year'] ) );
|
$this->redirect_with_notice( 'kgvvm-costs', 'success', __( 'Kostenposten wurde gespeichert.', KGVVM_TEXT_DOMAIN ), array( 'year' => $data['entry_year'] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add or remove a cost entry assignment for a specific parcel.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function toggle_parcel_cost_assignment() {
|
||||||
|
$this->require_cap( 'manage_kleingarten' );
|
||||||
|
check_admin_referer( 'kgvvm_toggle_parcel_cost' );
|
||||||
|
|
||||||
|
$parcel_id = absint( isset( $_POST['parcel_id'] ) ? $_POST['parcel_id'] : 0 );
|
||||||
|
$cost_entry_id = absint( isset( $_POST['cost_entry_id'] ) ? $_POST['cost_entry_id'] : 0 );
|
||||||
|
$mode = isset( $_POST['assignment_mode'] ) ? sanitize_key( wp_unslash( $_POST['assignment_mode'] ) ) : '';
|
||||||
|
$year = absint( isset( $_POST['year'] ) ? $_POST['year'] : 0 );
|
||||||
|
|
||||||
|
if ( $parcel_id < 1 || $cost_entry_id < 1 || ! in_array( $mode, array( 'add', 'remove' ), true ) ) {
|
||||||
|
$this->redirect_with_notice( 'kgvvm-costs', 'error', __( 'Ungültige Anfrage.', KGVVM_TEXT_DOMAIN ), array( 'view' => 'statement', 'statement_type' => 'parcel', 'subject_id' => $parcel_id, 'year' => $year ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( 'add' === $mode ) {
|
||||||
|
$this->costs->assign_to_parcel( $parcel_id, $cost_entry_id );
|
||||||
|
} else {
|
||||||
|
$this->costs->unassign_from_parcel( $parcel_id, $cost_entry_id );
|
||||||
|
}
|
||||||
|
|
||||||
|
wp_safe_redirect( $this->admin_url( 'kgvvm-costs', array( 'view' => 'statement', 'statement_type' => 'parcel', 'subject_id' => $parcel_id, 'year' => $year ) ) );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render dashboard.
|
* Render dashboard.
|
||||||
*
|
*
|
||||||
@@ -1274,6 +1373,17 @@ class Admin {
|
|||||||
<p class='kgvvm-help'><?php echo esc_html__( 'Betrag je ausgewählter Einheit, also pro Parzelle oder pro Mitglied.', KGVVM_TEXT_DOMAIN ); ?></p>
|
<p class='kgvvm-help'><?php echo esc_html__( 'Betrag je ausgewählter Einheit, also pro Parzelle oder pro Mitglied.', KGVVM_TEXT_DOMAIN ); ?></p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope='row'><?php echo esc_html__( 'Position', KGVVM_TEXT_DOMAIN ); ?></th>
|
||||||
|
<td>
|
||||||
|
<label>
|
||||||
|
<input type='hidden' name='is_mandatory' value='0' />
|
||||||
|
<input type='checkbox' name='is_mandatory' value='1' <?php checked( $cost ? (bool) $cost->is_mandatory : true, true ); ?> />
|
||||||
|
<?php echo esc_html__( 'Verpflichtende Position', KGVVM_TEXT_DOMAIN ); ?>
|
||||||
|
</label>
|
||||||
|
<p class='kgvvm-help'><?php echo esc_html__( 'Wenn aktiviert: Diese Position wird automatisch in allen Abrechnungen berechnet. Wenn deaktiviert: Diese Position wird als manuelle/optionale Position behandelt.', KGVVM_TEXT_DOMAIN ); ?></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope='row'><label for='kgvvm-cost-note'><?php echo esc_html__( 'Bemerkung', KGVVM_TEXT_DOMAIN ); ?></label></th>
|
<th scope='row'><label for='kgvvm-cost-note'><?php echo esc_html__( 'Bemerkung', KGVVM_TEXT_DOMAIN ); ?></label></th>
|
||||||
<td><textarea name='note' id='kgvvm-cost-note' rows='4' class='large-text'><?php echo esc_textarea( $cost ? $cost->note : '' ); ?></textarea></td>
|
<td><textarea name='note' id='kgvvm-cost-note' rows='4' class='large-text'><?php echo esc_textarea( $cost ? $cost->note : '' ); ?></textarea></td>
|
||||||
@@ -1357,6 +1467,7 @@ class Admin {
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><a href='<?php echo esc_url( $this->sort_url( 'kgvvm-costs', 'name' ) ); ?>'><?php echo esc_html__( 'Name', KGVVM_TEXT_DOMAIN ); ?></a></th>
|
<th><a href='<?php echo esc_url( $this->sort_url( 'kgvvm-costs', 'name' ) ); ?>'><?php echo esc_html__( 'Name', KGVVM_TEXT_DOMAIN ); ?></a></th>
|
||||||
|
<th><?php echo esc_html__( 'Status', KGVVM_TEXT_DOMAIN ); ?></th>
|
||||||
<th><?php echo esc_html__( 'Verteilung', KGVVM_TEXT_DOMAIN ); ?></th>
|
<th><?php echo esc_html__( 'Verteilung', KGVVM_TEXT_DOMAIN ); ?></th>
|
||||||
<th><?php echo esc_html__( 'Betrag', KGVVM_TEXT_DOMAIN ); ?></th>
|
<th><?php echo esc_html__( 'Betrag', KGVVM_TEXT_DOMAIN ); ?></th>
|
||||||
<th><a href='<?php echo esc_url( $this->sort_url( 'kgvvm-costs', 'total_cost' ) ); ?>'><?php echo esc_html__( 'Gesamt im Jahr', KGVVM_TEXT_DOMAIN ); ?></a></th>
|
<th><a href='<?php echo esc_url( $this->sort_url( 'kgvvm-costs', 'total_cost' ) ); ?>'><?php echo esc_html__( 'Gesamt im Jahr', KGVVM_TEXT_DOMAIN ); ?></a></th>
|
||||||
@@ -1367,11 +1478,18 @@ class Admin {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php if ( empty( $rows ) ) : ?>
|
<?php if ( empty( $rows ) ) : ?>
|
||||||
<tr><td colspan='7'><?php echo esc_html__( 'Für das gewählte Jahr sind noch keine Kostenposten vorhanden.', KGVVM_TEXT_DOMAIN ); ?></td></tr>
|
<tr><td colspan='8'><?php echo esc_html__( 'Für das gewählte Jahr sind noch keine Kostenposten vorhanden.', KGVVM_TEXT_DOMAIN ); ?></td></tr>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<?php foreach ( $rows as $row ) : ?>
|
<?php foreach ( $rows as $row ) : ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong><?php echo esc_html( $row->name ); ?></strong></td>
|
<td><strong><?php echo esc_html( $row->name ); ?></strong></td>
|
||||||
|
<td>
|
||||||
|
<?php if ( ! isset( $row->is_mandatory ) || (bool) $row->is_mandatory ) : ?>
|
||||||
|
<span style='color:#007017;'><?php echo esc_html__( 'Verpflichtend', KGVVM_TEXT_DOMAIN ); ?></span>
|
||||||
|
<?php else : ?>
|
||||||
|
<span style='color:#9a6700;'><?php echo esc_html__( 'Manuell', KGVVM_TEXT_DOMAIN ); ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
<td><?php echo esc_html( $this->get_cost_distribution_label( $row->distribution_type ) ); ?></td>
|
<td><?php echo esc_html( $this->get_cost_distribution_label( $row->distribution_type ) ); ?></td>
|
||||||
<td><?php echo esc_html( $this->format_currency( $row->unit_amount ) ); ?></td>
|
<td><?php echo esc_html( $this->format_currency( $row->unit_amount ) ); ?></td>
|
||||||
<td><?php echo esc_html( $this->format_currency( $row->calculated_total_cost ) ); ?></td>
|
<td><?php echo esc_html( $this->format_currency( $row->calculated_total_cost ) ); ?></td>
|
||||||
@@ -1606,7 +1724,31 @@ class Admin {
|
|||||||
$fixed_items = array();
|
$fixed_items = array();
|
||||||
$fixed_total = 0.0;
|
$fixed_total = 0.0;
|
||||||
|
|
||||||
|
// Load parcel-specific cost assignments so entries can either apply to
|
||||||
|
// all parcels (mandatory) or only to explicitly assigned parcels (manual).
|
||||||
|
$entries_with_assignments = $this->costs->get_entry_ids_with_assignments( $year );
|
||||||
|
$subject_assigned_ids = array();
|
||||||
|
|
||||||
|
foreach ( array_map( 'intval', $parcel_ids ) as $parcel_id ) {
|
||||||
|
$subject_assigned_ids = array_merge( $subject_assigned_ids, $this->costs->get_assigned_entry_ids( $parcel_id ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$subject_assigned_ids = array_values( array_unique( array_map( 'intval', $subject_assigned_ids ) ) );
|
||||||
|
|
||||||
foreach ( $cost_entries as $entry ) {
|
foreach ( $cost_entries as $entry ) {
|
||||||
|
$entry_id = (int) $entry->id;
|
||||||
|
$has_assignments = in_array( $entry_id, $entries_with_assignments, true );
|
||||||
|
$is_assigned = in_array( $entry_id, $subject_assigned_ids, true );
|
||||||
|
$is_mandatory = ! isset( $entry->is_mandatory ) || (bool) $entry->is_mandatory;
|
||||||
|
|
||||||
|
if ( ! $is_mandatory && ! $is_assigned ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $is_mandatory && $has_assignments && ! $is_assigned ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$distribution_type = $this->get_cost_distribution_type( $entry );
|
$distribution_type = $this->get_cost_distribution_type( $entry );
|
||||||
$unit_amount = $this->get_cost_unit_amount( $entry, count( $active_parcels ), count( $active_members ) );
|
$unit_amount = $this->get_cost_unit_amount( $entry, count( $active_parcels ), count( $active_members ) );
|
||||||
$subject_units = 'member' === $distribution_type ? $subject_member_count : $subject_parcel_count;
|
$subject_units = 'member' === $distribution_type ? $subject_member_count : $subject_parcel_count;
|
||||||
@@ -1647,6 +1789,18 @@ class Admin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
<style>
|
||||||
|
@media screen {
|
||||||
|
.kgvvm-statement-layout { display: flex; gap: 24px; align-items: flex-start; }
|
||||||
|
.kgvvm-statement-main { flex: 1 1 0; min-width: 0; }
|
||||||
|
.kgvvm-statement-sidebar { flex: 0 0 300px; width: 300px; }
|
||||||
|
}
|
||||||
|
@media print { .kgvvm-statement-sidebar { display: none !important; } }
|
||||||
|
.kgvvm-cost-assignment-list { list-style: none; margin: 0; padding: 0; }
|
||||||
|
.kgvvm-cost-assignment-list li { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #f0f0f0; gap: 8px; }
|
||||||
|
.kgvvm-cost-assignment-list li:last-child { border-bottom: none; }
|
||||||
|
.kgvvm-cost-assignment-list .kgvvm-entry-name { flex: 1; }
|
||||||
|
</style>
|
||||||
<div class='wrap kgvvm-print-page'>
|
<div class='wrap kgvvm-print-page'>
|
||||||
<h1><?php echo esc_html( $subject_label ); ?></h1>
|
<h1><?php echo esc_html( $subject_label ); ?></h1>
|
||||||
<div class='kgvvm-print-actions'>
|
<div class='kgvvm-print-actions'>
|
||||||
@@ -1655,6 +1809,9 @@ class Admin {
|
|||||||
<a href='<?php echo esc_url( $this->admin_url( 'kgvvm-costs', array( 'year' => $year ) ) ); ?>' class='button-secondary'><?php echo esc_html__( 'Zurück', KGVVM_TEXT_DOMAIN ); ?></a>
|
<a href='<?php echo esc_url( $this->admin_url( 'kgvvm-costs', array( 'year' => $year ) ) ); ?>' class='button-secondary'><?php echo esc_html__( 'Zurück', KGVVM_TEXT_DOMAIN ); ?></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class='kgvvm-statement-layout'>
|
||||||
|
<div class='kgvvm-statement-main'>
|
||||||
|
|
||||||
<?php if ( ! empty( $settings['pdf_club_name'] ) || ! empty( $settings['pdf_logo_url'] ) || ! empty( $settings['pdf_contact_block'] ) || ! empty( $settings['pdf_intro_text'] ) ) : ?>
|
<?php if ( ! empty( $settings['pdf_club_name'] ) || ! empty( $settings['pdf_logo_url'] ) || ! empty( $settings['pdf_contact_block'] ) || ! empty( $settings['pdf_intro_text'] ) ) : ?>
|
||||||
<div class='kgvvm-card'>
|
<div class='kgvvm-card'>
|
||||||
<table style='width:100%; border-collapse:collapse;'>
|
<table style='width:100%; border-collapse:collapse;'>
|
||||||
@@ -1752,6 +1909,75 @@ class Admin {
|
|||||||
<p><?php echo wp_kses_post( nl2br( esc_html( $settings['pdf_footer_text'] ) ) ); ?></p>
|
<p><?php echo wp_kses_post( nl2br( esc_html( $settings['pdf_footer_text'] ) ) ); ?></p>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
</div><!-- .kgvvm-statement-main -->
|
||||||
|
|
||||||
|
<?php if ( 'parcel' === $statement_type ) : ?>
|
||||||
|
<div class='kgvvm-statement-sidebar'>
|
||||||
|
<div class='kgvvm-card'>
|
||||||
|
<h3 style='margin-top:0;'><?php echo esc_html__( 'Kostenpositionen', KGVVM_TEXT_DOMAIN ); ?></h3>
|
||||||
|
<p class='description'><?php echo esc_html__( 'Hier legen Sie fest, welche Positionen dieser Parzelle berechnet werden. Positionen ohne Einschränkung gelten für alle Parzellen.', KGVVM_TEXT_DOMAIN ); ?></p>
|
||||||
|
|
||||||
|
<?php if ( empty( $cost_entries ) ) : ?>
|
||||||
|
<p><?php echo esc_html__( 'Für dieses Jahr sind keine Kostenposten hinterlegt.', KGVVM_TEXT_DOMAIN ); ?></p>
|
||||||
|
<?php else : ?>
|
||||||
|
<ul class='kgvvm-cost-assignment-list'>
|
||||||
|
<?php foreach ( $cost_entries as $entry ) :
|
||||||
|
$entry_id = (int) $entry->id;
|
||||||
|
$is_assigned = in_array( $entry_id, $subject_assigned_ids, true );
|
||||||
|
$has_any = in_array( $entry_id, $entries_with_assignments, true );
|
||||||
|
$is_mandatory = ! isset( $entry->is_mandatory ) || (bool) $entry->is_mandatory;
|
||||||
|
?>
|
||||||
|
<li>
|
||||||
|
<span class='kgvvm-entry-name'>
|
||||||
|
<?php if ( $is_assigned ) : ?>
|
||||||
|
<span style='color:#007017;' title='<?php esc_attr_e( 'Diese Parzelle ist zugeordnet', KGVVM_TEXT_DOMAIN ); ?>'>✓</span>
|
||||||
|
<?php elseif ( ! $is_mandatory || $has_any ) : ?>
|
||||||
|
<span style='color:#b32d2e;' title='<?php esc_attr_e( 'Diese Parzelle ist nicht zugeordnet', KGVVM_TEXT_DOMAIN ); ?>'>✗</span>
|
||||||
|
<?php else : ?>
|
||||||
|
<span style='color:#999;' title='<?php esc_attr_e( 'Gilt für alle Parzellen', KGVVM_TEXT_DOMAIN ); ?>'>—</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php echo esc_html( $entry->name ); ?>
|
||||||
|
</span>
|
||||||
|
<?php if ( $is_assigned ) : ?>
|
||||||
|
<form method='post' action='<?php echo esc_url( admin_url( 'admin.php' ) ); ?>' style='display:inline;'>
|
||||||
|
<?php wp_nonce_field( 'kgvvm_toggle_parcel_cost' ); ?>
|
||||||
|
<input type='hidden' name='kgvvm_action' value='toggle_parcel_cost_assignment' />
|
||||||
|
<input type='hidden' name='parcel_id' value='<?php echo esc_attr( $subject_id ); ?>' />
|
||||||
|
<input type='hidden' name='cost_entry_id' value='<?php echo esc_attr( $entry_id ); ?>' />
|
||||||
|
<input type='hidden' name='assignment_mode' value='remove' />
|
||||||
|
<input type='hidden' name='year' value='<?php echo esc_attr( $year ); ?>' />
|
||||||
|
<input type='hidden' name='page' value='kgvvm-costs' />
|
||||||
|
<button type='submit' class='button button-small'><?php echo esc_html__( 'Entfernen', KGVVM_TEXT_DOMAIN ); ?></button>
|
||||||
|
</form>
|
||||||
|
<?php elseif ( $is_mandatory && ! $has_any ) : ?>
|
||||||
|
<span class='button button-small' style='pointer-events:none; opacity:.65;'><?php echo esc_html__( 'Automatisch', KGVVM_TEXT_DOMAIN ); ?></span>
|
||||||
|
<?php else : ?>
|
||||||
|
<form method='post' action='<?php echo esc_url( admin_url( 'admin.php' ) ); ?>' style='display:inline;'>
|
||||||
|
<?php wp_nonce_field( 'kgvvm_toggle_parcel_cost' ); ?>
|
||||||
|
<input type='hidden' name='kgvvm_action' value='toggle_parcel_cost_assignment' />
|
||||||
|
<input type='hidden' name='parcel_id' value='<?php echo esc_attr( $subject_id ); ?>' />
|
||||||
|
<input type='hidden' name='cost_entry_id' value='<?php echo esc_attr( $entry_id ); ?>' />
|
||||||
|
<input type='hidden' name='assignment_mode' value='add' />
|
||||||
|
<input type='hidden' name='year' value='<?php echo esc_attr( $year ); ?>' />
|
||||||
|
<input type='hidden' name='page' value='kgvvm-costs' />
|
||||||
|
<button type='submit' class='button button-small button-primary'><?php echo esc_html__( 'Hinzufügen', KGVVM_TEXT_DOMAIN ); ?></button>
|
||||||
|
</form>
|
||||||
|
<?php endif; ?>
|
||||||
|
</li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<p class='description' style='margin-top:12px; font-size:11px;'>
|
||||||
|
<span style='color:#007017;'>✓</span> <?php echo esc_html__( 'zugeordnet', KGVVM_TEXT_DOMAIN ); ?>
|
||||||
|
<span style='color:#b32d2e;'>✗</span> <?php echo esc_html__( 'manuell oder ausgeschlossen', KGVVM_TEXT_DOMAIN ); ?>
|
||||||
|
<span style='color:#999;'>—</span> <?php echo esc_html__( 'Pflichtposition für alle Parzellen', KGVVM_TEXT_DOMAIN ); ?>
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
</div><!-- .kgvvm-statement-layout -->
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -3324,6 +3550,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.) sowie die zugehörigen WordPress-Mitgliederkonten 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
|
||||||
}
|
}
|
||||||
|
|||||||
413
includes/DataTransfer.php
Normal file
413
includes/DataTransfer.php
Normal file
@@ -0,0 +1,413 @@
|
|||||||
|
<?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',
|
||||||
|
'parcel_cost_assignments',
|
||||||
|
'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' ),
|
||||||
|
'members' => array(),
|
||||||
|
'tables' => array(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$payload['members'] = $this->export_members();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export all member user accounts relevant to the plugin.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function export_members() {
|
||||||
|
$ids = $this->collect_member_user_ids();
|
||||||
|
|
||||||
|
if ( empty( $ids ) ) {
|
||||||
|
return array(
|
||||||
|
'ids' => array(),
|
||||||
|
'users' => array(),
|
||||||
|
'usermeta' => array(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$placeholders = implode( ', ', array_fill( 0, count( $ids ), '%d' ) );
|
||||||
|
|
||||||
|
$users_sql = "SELECT ID, user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_activation_key, user_status, display_name
|
||||||
|
FROM {$this->wpdb->users}
|
||||||
|
WHERE ID IN ({$placeholders})
|
||||||
|
ORDER BY ID ASC";
|
||||||
|
|
||||||
|
$meta_sql = "SELECT user_id, meta_key, meta_value
|
||||||
|
FROM {$this->wpdb->usermeta}
|
||||||
|
WHERE user_id IN ({$placeholders})
|
||||||
|
ORDER BY user_id ASC, umeta_id ASC";
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
||||||
|
$users = $this->wpdb->get_results( $this->wpdb->prepare( $users_sql, $ids ), ARRAY_A );
|
||||||
|
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
||||||
|
$meta = $this->wpdb->get_results( $this->wpdb->prepare( $meta_sql, $ids ), ARRAY_A );
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'ids' => $ids,
|
||||||
|
'users' => is_array( $users ) ? $users : array(),
|
||||||
|
'usermeta' => is_array( $meta ) ? $meta : array(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collect all user IDs relevant for member data export.
|
||||||
|
*
|
||||||
|
* @return int[]
|
||||||
|
*/
|
||||||
|
private function collect_member_user_ids() {
|
||||||
|
$ids = array();
|
||||||
|
|
||||||
|
$member_query = new \WP_User_Query(
|
||||||
|
array(
|
||||||
|
'role' => Roles::MEMBER_ROLE,
|
||||||
|
'fields' => 'ID',
|
||||||
|
'number' => 2000,
|
||||||
|
'orderby' => 'ID',
|
||||||
|
'order' => 'ASC',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$ids = array_merge( $ids, (array) $member_query->get_results() );
|
||||||
|
|
||||||
|
$parcel_members_table = Schema::table( 'parcel_members' );
|
||||||
|
if ( '' !== $parcel_members_table ) {
|
||||||
|
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery
|
||||||
|
$ids = array_merge( $ids, (array) $this->wpdb->get_col( "SELECT DISTINCT user_id FROM {$parcel_members_table}" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$work_log_members_table = Schema::table( 'work_log_members' );
|
||||||
|
if ( '' !== $work_log_members_table ) {
|
||||||
|
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery
|
||||||
|
$ids = array_merge( $ids, (array) $this->wpdb->get_col( "SELECT DISTINCT user_id FROM {$work_log_members_table}" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$ids = array_values( array_unique( array_filter( array_map( 'absint', $ids ) ) ) );
|
||||||
|
sort( $ids, SORT_NUMERIC );
|
||||||
|
|
||||||
|
return $ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
|
||||||
|
if ( ! empty( $payload['members'] ) && is_array( $payload['members'] ) ) {
|
||||||
|
$member_result = $this->import_members( $payload['members'] );
|
||||||
|
if ( ! empty( $member_result['errors'] ) ) {
|
||||||
|
$result['errors'] = array_merge( $result['errors'], $member_result['errors'] );
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
$result['imported']['wp_members'] = isset( $member_result['users'] ) ? (int) $member_result['users'] : 0;
|
||||||
|
$result['imported']['wp_member_meta'] = isset( $member_result['meta'] ) ? (int) $member_result['meta'] : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import member user accounts and their usermeta.
|
||||||
|
*
|
||||||
|
* @param array $members Member payload from export.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function import_members( array $members ) {
|
||||||
|
$result = array(
|
||||||
|
'users' => 0,
|
||||||
|
'meta' => 0,
|
||||||
|
'errors' => array(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$users = isset( $members['users'] ) && is_array( $members['users'] ) ? $members['users'] : array();
|
||||||
|
$meta = isset( $members['usermeta'] ) && is_array( $members['usermeta'] ) ? $members['usermeta'] : array();
|
||||||
|
|
||||||
|
if ( empty( $users ) ) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
$imported_user_ids = array();
|
||||||
|
|
||||||
|
foreach ( $users as $row ) {
|
||||||
|
if ( ! is_array( $row ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_id = isset( $row['ID'] ) ? absint( $row['ID'] ) : 0;
|
||||||
|
$login = isset( $row['user_login'] ) ? sanitize_user( (string) $row['user_login'], true ) : '';
|
||||||
|
$email = isset( $row['user_email'] ) ? sanitize_email( (string) $row['user_email'] ) : '';
|
||||||
|
|
||||||
|
if ( $user_id < 1 || '' === $login || '' === $email ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'user_login' => $login,
|
||||||
|
'user_pass' => isset( $row['user_pass'] ) ? (string) $row['user_pass'] : '',
|
||||||
|
'user_nicename' => isset( $row['user_nicename'] ) ? sanitize_title( (string) $row['user_nicename'] ) : sanitize_title( $login ),
|
||||||
|
'user_email' => $email,
|
||||||
|
'user_url' => isset( $row['user_url'] ) ? esc_url_raw( (string) $row['user_url'] ) : '',
|
||||||
|
'user_registered' => isset( $row['user_registered'] ) ? (string) $row['user_registered'] : current_time( 'mysql', true ),
|
||||||
|
'user_activation_key' => isset( $row['user_activation_key'] ) ? (string) $row['user_activation_key'] : '',
|
||||||
|
'user_status' => isset( $row['user_status'] ) ? (int) $row['user_status'] : 0,
|
||||||
|
'display_name' => isset( $row['display_name'] ) ? sanitize_text_field( (string) $row['display_name'] ) : $login,
|
||||||
|
);
|
||||||
|
|
||||||
|
$exists = (int) $this->wpdb->get_var( $this->wpdb->prepare( "SELECT COUNT(*) FROM {$this->wpdb->users} WHERE ID = %d", $user_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
||||||
|
|
||||||
|
if ( $exists > 0 ) {
|
||||||
|
$updated = $this->wpdb->update( $this->wpdb->users, $data, array( 'ID' => $user_id ) );
|
||||||
|
if ( false === $updated ) {
|
||||||
|
$result['errors'][] = sprintf(
|
||||||
|
/* translators: %d: user id */
|
||||||
|
__( 'Mitglied mit ID %d konnte nicht aktualisiert werden.', KGVVM_TEXT_DOMAIN ),
|
||||||
|
$user_id
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$insert_data = $data;
|
||||||
|
$insert_data['ID'] = $user_id;
|
||||||
|
$inserted = $this->wpdb->insert( $this->wpdb->users, $insert_data );
|
||||||
|
if ( false === $inserted ) {
|
||||||
|
$result['errors'][] = sprintf(
|
||||||
|
/* translators: 1: user id 2: DB error */
|
||||||
|
__( 'Mitglied mit ID %1$d konnte nicht angelegt werden: %2$s', KGVVM_TEXT_DOMAIN ),
|
||||||
|
$user_id,
|
||||||
|
(string) $this->wpdb->last_error
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$imported_user_ids[] = $user_id;
|
||||||
|
$result['users']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$imported_user_ids = array_values( array_unique( array_filter( array_map( 'absint', $imported_user_ids ) ) ) );
|
||||||
|
|
||||||
|
if ( empty( $imported_user_ids ) || empty( $meta ) ) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
$placeholders = implode( ', ', array_fill( 0, count( $imported_user_ids ), '%d' ) );
|
||||||
|
$delete_sql = "DELETE FROM {$this->wpdb->usermeta} WHERE user_id IN ({$placeholders})";
|
||||||
|
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
||||||
|
$this->wpdb->query( $this->wpdb->prepare( $delete_sql, $imported_user_ids ) );
|
||||||
|
|
||||||
|
$allowed_ids = array_flip( $imported_user_ids );
|
||||||
|
|
||||||
|
foreach ( $meta as $row ) {
|
||||||
|
if ( ! is_array( $row ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_id = isset( $row['user_id'] ) ? absint( $row['user_id'] ) : 0;
|
||||||
|
if ( $user_id < 1 || ! isset( $allowed_ids[ $user_id ] ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$meta_key = isset( $row['meta_key'] ) ? (string) $row['meta_key'] : '';
|
||||||
|
if ( '' === $meta_key ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$meta_value = isset( $row['meta_value'] ) ? maybe_serialize( maybe_unserialize( $row['meta_value'] ) ) : '';
|
||||||
|
|
||||||
|
$inserted = $this->wpdb->insert(
|
||||||
|
$this->wpdb->usermeta,
|
||||||
|
array(
|
||||||
|
'user_id' => $user_id,
|
||||||
|
'meta_key' => $meta_key,
|
||||||
|
'meta_value' => $meta_value,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( false !== $inserted ) {
|
||||||
|
$result['meta']++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -93,11 +93,12 @@ class CostRepository extends AbstractRepository {
|
|||||||
'distribution_type' => isset( $data['distribution_type'] ) ? $data['distribution_type'] : 'parcel',
|
'distribution_type' => isset( $data['distribution_type'] ) ? $data['distribution_type'] : 'parcel',
|
||||||
'unit_amount' => isset( $data['unit_amount'] ) ? (float) $data['unit_amount'] : 0,
|
'unit_amount' => isset( $data['unit_amount'] ) ? (float) $data['unit_amount'] : 0,
|
||||||
'total_cost' => (float) $data['total_cost'],
|
'total_cost' => (float) $data['total_cost'],
|
||||||
|
'is_mandatory' => isset( $data['is_mandatory'] ) ? (int) (bool) $data['is_mandatory'] : 1,
|
||||||
'note' => $data['note'],
|
'note' => $data['note'],
|
||||||
'updated_at' => $this->now(),
|
'updated_at' => $this->now(),
|
||||||
);
|
);
|
||||||
|
|
||||||
$formats = array( '%d', '%s', '%s', '%f', '%f', '%s', '%s' );
|
$formats = array( '%d', '%s', '%s', '%f', '%f', '%d', '%s', '%s' );
|
||||||
|
|
||||||
$this->ensure_year( $payload['entry_year'] );
|
$this->ensure_year( $payload['entry_year'] );
|
||||||
|
|
||||||
@@ -107,7 +108,7 @@ class CostRepository extends AbstractRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$payload['created_at'] = $this->now();
|
$payload['created_at'] = $this->now();
|
||||||
$this->wpdb->insert( $this->table, $payload, array( '%d', '%s', '%s', '%f', '%f', '%s', '%s', '%s' ) );
|
$this->wpdb->insert( $this->table, $payload, array( '%d', '%s', '%s', '%f', '%f', '%d', '%s', '%s', '%s' ) );
|
||||||
|
|
||||||
return $this->wpdb->insert_id;
|
return $this->wpdb->insert_id;
|
||||||
}
|
}
|
||||||
@@ -310,4 +311,146 @@ class CostRepository extends AbstractRepository {
|
|||||||
|
|
||||||
return (float) $total;
|
return (float) $total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// Parcel cost assignments
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the parcel cost assignments table name.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function assignment_table() {
|
||||||
|
return Schema::table( 'parcel_cost_assignments' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get cost entry IDs assigned to a specific parcel.
|
||||||
|
*
|
||||||
|
* @param int $parcel_id Parcel ID.
|
||||||
|
* @return int[]
|
||||||
|
*/
|
||||||
|
public function get_assigned_entry_ids( $parcel_id ) {
|
||||||
|
$parcel_id = absint( $parcel_id );
|
||||||
|
$table = $this->assignment_table();
|
||||||
|
|
||||||
|
if ( $parcel_id < 1 || '' === $table ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$ids = $this->wpdb->get_col( $this->wpdb->prepare( "SELECT cost_entry_id FROM {$table} WHERE parcel_id = %d", $parcel_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
||||||
|
|
||||||
|
return array_map( 'intval', (array) $ids );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all cost entry IDs that have at least one parcel assignment.
|
||||||
|
*
|
||||||
|
* @param int $year Optional – filter by entry year (0 = all years).
|
||||||
|
* @return int[]
|
||||||
|
*/
|
||||||
|
public function get_entry_ids_with_assignments( $year = 0 ) {
|
||||||
|
$table = $this->assignment_table();
|
||||||
|
|
||||||
|
if ( '' === $table ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$year = absint( $year );
|
||||||
|
|
||||||
|
if ( $year > 0 ) {
|
||||||
|
$ids = $this->wpdb->get_col( $this->wpdb->prepare( // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
||||||
|
"SELECT DISTINCT a.cost_entry_id FROM {$table} a
|
||||||
|
INNER JOIN {$this->table} e ON e.id = a.cost_entry_id
|
||||||
|
WHERE e.entry_year = %d",
|
||||||
|
$year
|
||||||
|
) );
|
||||||
|
} else {
|
||||||
|
$ids = $this->wpdb->get_col( "SELECT DISTINCT cost_entry_id FROM {$table}" ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_map( 'intval', (array) $ids );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign a cost entry to a parcel.
|
||||||
|
*
|
||||||
|
* @param int $parcel_id Parcel ID.
|
||||||
|
* @param int $cost_entry_id Cost entry ID.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function assign_to_parcel( $parcel_id, $cost_entry_id ) {
|
||||||
|
$parcel_id = absint( $parcel_id );
|
||||||
|
$cost_entry_id = absint( $cost_entry_id );
|
||||||
|
$table = $this->assignment_table();
|
||||||
|
|
||||||
|
if ( $parcel_id < 1 || $cost_entry_id < 1 || '' === $table ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$exists = (int) $this->wpdb->get_var( $this->wpdb->prepare( // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
||||||
|
"SELECT COUNT(*) FROM {$table} WHERE parcel_id = %d AND cost_entry_id = %d",
|
||||||
|
$parcel_id,
|
||||||
|
$cost_entry_id
|
||||||
|
) );
|
||||||
|
|
||||||
|
if ( $exists > 0 ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->wpdb->insert(
|
||||||
|
$table,
|
||||||
|
array(
|
||||||
|
'parcel_id' => $parcel_id,
|
||||||
|
'cost_entry_id' => $cost_entry_id,
|
||||||
|
'created_at' => $this->now(),
|
||||||
|
),
|
||||||
|
array( '%d', '%d', '%s' )
|
||||||
|
);
|
||||||
|
|
||||||
|
return false !== $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a cost entry assignment from a parcel.
|
||||||
|
*
|
||||||
|
* @param int $parcel_id Parcel ID.
|
||||||
|
* @param int $cost_entry_id Cost entry ID.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function unassign_from_parcel( $parcel_id, $cost_entry_id ) {
|
||||||
|
$parcel_id = absint( $parcel_id );
|
||||||
|
$cost_entry_id = absint( $cost_entry_id );
|
||||||
|
$table = $this->assignment_table();
|
||||||
|
|
||||||
|
if ( $parcel_id < 1 || $cost_entry_id < 1 || '' === $table ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->wpdb->delete(
|
||||||
|
$table,
|
||||||
|
array(
|
||||||
|
'parcel_id' => $parcel_id,
|
||||||
|
'cost_entry_id' => $cost_entry_id,
|
||||||
|
),
|
||||||
|
array( '%d', '%d' )
|
||||||
|
);
|
||||||
|
|
||||||
|
return false !== $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all parcel assignments for a cost entry (e.g. when the entry is deleted).
|
||||||
|
*
|
||||||
|
* @param int $cost_entry_id Cost entry ID.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function delete_assignments_for_entry( $cost_entry_id ) {
|
||||||
|
$table = $this->assignment_table();
|
||||||
|
|
||||||
|
if ( '' !== $table && absint( $cost_entry_id ) > 0 ) {
|
||||||
|
$this->wpdb->delete( $table, array( 'cost_entry_id' => absint( $cost_entry_id ) ), array( '%d' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class Schema {
|
|||||||
'work_year_config' => $wpdb->prefix . 'kgvvm_work_year_config',
|
'work_year_config' => $wpdb->prefix . 'kgvvm_work_year_config',
|
||||||
'work_logs' => $wpdb->prefix . 'kgvvm_work_logs',
|
'work_logs' => $wpdb->prefix . 'kgvvm_work_logs',
|
||||||
'work_log_members' => $wpdb->prefix . 'kgvvm_work_log_members',
|
'work_log_members' => $wpdb->prefix . 'kgvvm_work_log_members',
|
||||||
|
'parcel_cost_assignments' => $wpdb->prefix . 'kgvvm_parcel_cost_assignments',
|
||||||
);
|
);
|
||||||
|
|
||||||
return isset( $map[ $key ] ) ? $map[ $key ] : '';
|
return isset( $map[ $key ] ) ? $map[ $key ] : '';
|
||||||
@@ -200,6 +201,7 @@ class Schema {
|
|||||||
distribution_type VARCHAR(20) NOT NULL DEFAULT 'parcel',
|
distribution_type VARCHAR(20) NOT NULL DEFAULT 'parcel',
|
||||||
unit_amount DECIMAL(12,2) NULL,
|
unit_amount DECIMAL(12,2) NULL,
|
||||||
total_cost DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
total_cost DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||||
|
is_mandatory TINYINT(1) NOT NULL DEFAULT 1,
|
||||||
note TEXT NULL,
|
note TEXT NULL,
|
||||||
created_at DATETIME NOT NULL,
|
created_at DATETIME NOT NULL,
|
||||||
updated_at DATETIME NOT NULL,
|
updated_at DATETIME NOT NULL,
|
||||||
@@ -254,6 +256,14 @@ class Schema {
|
|||||||
KEY log_id (log_id)
|
KEY log_id (log_id)
|
||||||
) {$charset_collate};";
|
) {$charset_collate};";
|
||||||
|
|
||||||
|
$sql[] = "CREATE TABLE " . self::table( 'parcel_cost_assignments' ) . " (
|
||||||
|
parcel_id BIGINT UNSIGNED NOT NULL,
|
||||||
|
cost_entry_id BIGINT UNSIGNED NOT NULL,
|
||||||
|
created_at DATETIME NOT NULL,
|
||||||
|
PRIMARY KEY (parcel_id, cost_entry_id),
|
||||||
|
KEY cost_entry_id (cost_entry_id)
|
||||||
|
) {$charset_collate};";
|
||||||
|
|
||||||
foreach ( $sql as $statement ) {
|
foreach ( $sql as $statement ) {
|
||||||
dbDelta( $statement );
|
dbDelta( $statement );
|
||||||
}
|
}
|
||||||
@@ -283,6 +293,7 @@ class Schema {
|
|||||||
self::table( 'work_year_config' ),
|
self::table( 'work_year_config' ),
|
||||||
self::table( 'work_logs' ),
|
self::table( 'work_logs' ),
|
||||||
self::table( 'work_log_members' ),
|
self::table( 'work_log_members' ),
|
||||||
|
self::table( 'parcel_cost_assignments' ),
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ( $tables as $table ) {
|
foreach ( $tables as $table ) {
|
||||||
@@ -301,6 +312,7 @@ class Schema {
|
|||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$tables = array(
|
$tables = array(
|
||||||
|
self::table( 'parcel_cost_assignments' ),
|
||||||
self::table( 'work_log_members' ),
|
self::table( 'work_log_members' ),
|
||||||
self::table( 'work_logs' ),
|
self::table( 'work_logs' ),
|
||||||
self::table( 'work_year_config' ),
|
self::table( 'work_year_config' ),
|
||||||
|
|||||||
@@ -259,6 +259,7 @@ class Validator {
|
|||||||
$unit_amount = isset( $data['unit_amount'] ) ? str_replace( ',', '.', wp_unslash( $data['unit_amount'] ) ) : '';
|
$unit_amount = isset( $data['unit_amount'] ) ? str_replace( ',', '.', wp_unslash( $data['unit_amount'] ) ) : '';
|
||||||
$entry_year = $this->sanitize_cost_year( $data );
|
$entry_year = $this->sanitize_cost_year( $data );
|
||||||
$distribution_type = sanitize_key( wp_unslash( isset( $data['distribution_type'] ) ? $data['distribution_type'] : 'parcel' ) );
|
$distribution_type = sanitize_key( wp_unslash( isset( $data['distribution_type'] ) ? $data['distribution_type'] : 'parcel' ) );
|
||||||
|
$is_mandatory = isset( $data['is_mandatory'] ) && '1' === (string) wp_unslash( $data['is_mandatory'] );
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'entry_year' => $entry_year,
|
'entry_year' => $entry_year,
|
||||||
@@ -266,6 +267,7 @@ class Validator {
|
|||||||
'distribution_type' => $distribution_type,
|
'distribution_type' => $distribution_type,
|
||||||
'unit_amount' => '' === trim( (string) $unit_amount ) ? '' : (float) $unit_amount,
|
'unit_amount' => '' === trim( (string) $unit_amount ) ? '' : (float) $unit_amount,
|
||||||
'total_cost' => 0.0,
|
'total_cost' => 0.0,
|
||||||
|
'is_mandatory' => $is_mandatory,
|
||||||
'note' => sanitize_textarea_field( wp_unslash( isset( $data['note'] ) ? $data['note'] : '' ) ),
|
'note' => sanitize_textarea_field( wp_unslash( isset( $data['note'] ) ? $data['note'] : '' ) ),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* 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.16.1
|
* Version: 1.17.4
|
||||||
* Author: Ronny Grobel
|
* Author: Ronny Grobel
|
||||||
* Author URI: https://apex-project.de/
|
* Author URI: https://apex-project.de/
|
||||||
* License: GPL v2 or later
|
* License: GPL v2 or later
|
||||||
@@ -31,7 +31,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
define( 'KGVVM_VERSION', '1.16.1' );
|
define( 'KGVVM_VERSION', '1.17.4' );
|
||||||
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__ ) );
|
||||||
|
|||||||
28
readme.txt
28
readme.txt
@@ -3,7 +3,7 @@ Contributors: ronnygrobel
|
|||||||
Tags: verein, mitgliederverwaltung, parzellen, zaehler, abrechnung
|
Tags: verein, mitgliederverwaltung, parzellen, zaehler, abrechnung
|
||||||
Requires at least: 6.0
|
Requires at least: 6.0
|
||||||
Tested up to: 6.8
|
Tested up to: 6.8
|
||||||
Stable tag: 1.16.1
|
Stable tag: 1.17.4
|
||||||
Requires PHP: 7.2
|
Requires PHP: 7.2
|
||||||
License: GPLv2 or later
|
License: GPLv2 or later
|
||||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
@@ -41,6 +41,32 @@ Ja, insbesondere fuer Kleingartenvereine und deren Verwaltungsprozesse.
|
|||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
|
= 1.17.4 =
|
||||||
|
Fix: Checkbox "Verpflichtende Position" bei Kostenposten wird jetzt korrekt gespeichert wenn sie deaktiviert ist.
|
||||||
|
|
||||||
|
= 1.17.3 =
|
||||||
|
Verbesserung: Kostenübersicht zeigt jetzt direkt pro Kostenposten den Status Verpflichtend oder Manuell in einer eigenen Spalte an.
|
||||||
|
|
||||||
|
= 1.17.2 =
|
||||||
|
Fix: Manuelle Kostenpositionen auf der Jahresabrechnung einer Parzelle werden nach dem Hinzufügen jetzt sofort korrekt berücksichtigt. Pflichtpositionen ohne Einschränkung werden in der Seitenleiste als automatisch aktiv dargestellt.
|
||||||
|
|
||||||
|
= 1.17.1 =
|
||||||
|
Feat: is_mandatory Flag für Kostenpositionstypen - Kostenposten können jetzt als "verpflichtend" oder "manuell/optional" gekennzeichnet werden. Checkbox in der Kostenposten-Bearbeitung.
|
||||||
|
|
||||||
|
= 1.17.0 =
|
||||||
|
Parzellenspezifische Kostenpositionenzuweisung: Kostenposten können jetzt einzelnen Parzellen zugeordnet werden (z.B. Versicherung nur für bestimmte Parzellen). Editor auf der Jahresabrechnung Parzelle Seite mit übersichtlicher Liste und Hinzufügen/Entfernen-Funktionen. Zuordnungen werden in einer separaten Tabelle gespeichert und sind vollständig in Export/Import integriert.
|
||||||
|
|
||||||
|
= 1.16.3 =
|
||||||
|
* Datensicherung erweitert: Export und Import umfassen jetzt zusätzlich die zugehörigen WordPress-Mitgliederkonten inklusive Metadaten.
|
||||||
|
|
||||||
|
= 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 =
|
= 1.16.0 =
|
||||||
* Neues Modul Arbeitsstunden im Adminbereich mit drei Bereichen: geleistete Arbeiten, Mitgliederuebersicht und Arbeitsarten.
|
* 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.
|
* Pflichtstunden je Mitglied pro Jahr konfigurierbar, inklusive variablem Preis je fehlender Stunde fuer den Aufschlag in der Jahresrechnung.
|
||||||
|
|||||||
Reference in New Issue
Block a user