@@ -1377,6 +1377,7 @@ class Admin {
<th scope='row'><?php echo esc_html__( 'Position', KGVVM_TEXT_DOMAIN ); ?></th>
<th scope='row'><?php echo esc_html__( 'Position', KGVVM_TEXT_DOMAIN ); ?></th>
<td>
<td>
<label>
<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 ); ?> />
<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 ); ?>
<?php echo esc_html__( 'Verpflichtende Position', KGVVM_TEXT_DOMAIN ); ?>
</label>
</label>
@@ -1466,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>
@@ -1476,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>
@@ -1715,22 +1724,28 @@ class Admin {
$fixed_items = array();
$fixed_items = array();
$fixed_total = 0.0;
$fixed_total = 0.0;
// Load parcel-specific cost assignments so that entries with explicit
// Load parcel-specific cost assignments so entries can either apply to
// assignments are only charged to the assigned parcels.
// all parcels (mandatory) or only to explicitly assigned parcels (manual) .
$entries_with_assignments = ( 'parcel' === $statement_type )
$entries_with_assignments = $this->costs->get_entry_ids_with_assignments( $year );
? $this->costs->get_entry_ids_with_assignments( $year )
$subject_assigned_ids = array();
: array();
$parcel_assigned_ids = ( 'parcel' === $statement_type )
foreach ( array_map( 'intval', $parcel_ids ) as $parcel_id ) {
? $this->costs->get_assigned_entry_ids( $subject _id )
$subject_assigned_ids = array_merge( $subject_assigned_ids, $this->costs->get_assigned_entry_ids( $parcel _id ) );
: array();
}
$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;
$entry_id = (int) $entry->id;
$has_assignments = in_array( $entry_id, $entries_with_assignments, true );
$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;
// For parcel statements: if this entry has any parcel restrictions,
if ( ! $is_mandatory && ! $is_assigned ) {
// skip it unless this specific parcel is assigned.
continue;
if ( 'parcel' === $statement_type && $has_assignments && ! in_array( $entry_id, $parcel_assigned_ids, true ) ) {
}
if ( $is_mandatory && $has_assignments && ! $is_assigned ) {
continue;
continue;
}
}
@@ -1858,8 +1873,7 @@ class Admin {
<thead>
<thead>
<tr>
<tr>
<th><?php echo esc_html__( 'Kostenposten', KGVVM_TEXT_DOMAIN ); ?></th>
<th><?php echo esc_html__( 'Kostenposten', KGVVM_TEXT_DOMAIN ); ?></th>
<th><?php echo esc_html__( 'Gesamtkosten ', KGVVM_TEXT_DOMAIN ); ?></th>
<th style='width:140px; white-space:nowrap;' ><?php echo esc_html__( 'Anteil ', KGVVM_TEXT_DOMAIN ); ?></th>
<th><?php echo esc_html__( 'Anteil', KGVVM_TEXT_DOMAIN ); ?></th>
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
@@ -1870,8 +1884,7 @@ class Admin {
<br /><span class="kgvvm-help"><?php echo esc_html( sprintf( __( '%1$s × %2$s zu je %3$s', KGVVM_TEXT_DOMAIN ), $item['distribution_label'], number_format_i18n( (int) $item['units'], 0 ), $this->format_currency( $item['unit_amount'] ) ) ); ?></span>
<br /><span class="kgvvm-help"><?php echo esc_html( sprintf( __( '%1$s × %2$s zu je %3$s', KGVVM_TEXT_DOMAIN ), $item['distribution_label'], number_format_i18n( (int) $item['units'], 0 ), $this->format_currency( $item['unit_amount'] ) ) ); ?></span>
<?php echo $item['note'] ? '<br /><span class="kgvvm-help">' . esc_html( $item['note'] ) . '</span>' : ''; ?>
<?php echo $item['note'] ? '<br /><span class="kgvvm-help">' . esc_html( $item['note'] ) . '</span>' : ''; ?>
</td>
</td>
<td><?php echo esc_html( $this->format_currency( $item['total '] ) ); ?></td>
<td style='width:140px; white-space:nowrap; text-align:right;' ><?php echo esc_html( $this->format_currency( $item['share '] ) ); ?></td>
<td><?php echo esc_html( $this->format_currency( $item['share'] ) ); ?></td>
</tr>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
</tbody>
@@ -1908,15 +1921,16 @@ class Admin {
<?php else : ?>
<?php else : ?>
<ul class='kgvvm-cost-assignment-list'>
<ul class='kgvvm-cost-assignment-list'>
<?php foreach ( $cost_entries as $entry ) :
<?php foreach ( $cost_entries as $entry ) :
$entry_id = (int) $entry->id;
$entry_id = (int) $entry->id;
$is_assigned = in_array( $entry_id, $parcel _assigned_ids, true );
$is_assigned = in_array( $entry_id, $subject _assigned_ids, true );
$has_any = in_array( $entry_id, $entries_with_assignments, true );
$has_any = in_array( $entry_id, $entries_with_assignments, true );
$is_mandatory = ! isset( $entry->is_mandatory ) || (bool) $entry->is_mandatory;
?>
?>
<li>
<li>
<span class='kgvvm-entry-name'>
<span class='kgvvm-entry-name'>
<?php if ( $is_assigned ) : ?>
<?php if ( $is_assigned ) : ?>
<span style='color:#007017;' title='<?php esc_attr_e( 'Diese Parzelle ist zugeordnet', KGVVM_TEXT_DOMAIN ); ?>'>✓</span>
<span style='color:#007017;' title='<?php esc_attr_e( 'Diese Parzelle ist zugeordnet', KGVVM_TEXT_DOMAIN ); ?>'>✓</span>
<?php elseif ( $has_any ) : ?>
<?php elseif ( ! $is_mandatory || $has_any ) : ?>
<span style='color:#b32d2e;' title='<?php esc_attr_e( 'Diese Parzelle ist nicht zugeordnet', KGVVM_TEXT_DOMAIN ); ?>'>✗</span>
<span style='color:#b32d2e;' title='<?php esc_attr_e( 'Diese Parzelle ist nicht zugeordnet', KGVVM_TEXT_DOMAIN ); ?>'>✗</span>
<?php else : ?>
<?php else : ?>
<span style='color:#999;' title='<?php esc_attr_e( 'Gilt für alle Parzellen', KGVVM_TEXT_DOMAIN ); ?>'>—</span>
<span style='color:#999;' title='<?php esc_attr_e( 'Gilt für alle Parzellen', KGVVM_TEXT_DOMAIN ); ?>'>—</span>
@@ -1934,6 +1948,8 @@ class Admin {
<input type='hidden' name='page' value='kgvvm-costs' />
<input type='hidden' name='page' value='kgvvm-costs' />
<button type='submit' class='button button-small'><?php echo esc_html__( 'Entfernen', KGVVM_TEXT_DOMAIN ); ?></button>
<button type='submit' class='button button-small'><?php echo esc_html__( 'Entfernen', KGVVM_TEXT_DOMAIN ); ?></button>
</form>
</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 : ?>
<?php else : ?>
<form method='post' action='<?php echo esc_url( admin_url( 'admin.php' ) ); ?>' style='display:inline;'>
<form method='post' action='<?php echo esc_url( admin_url( 'admin.php' ) ); ?>' style='display:inline;'>
<?php wp_nonce_field( 'kgvvm_toggle_parcel_cost' ); ?>
<?php wp_nonce_field( 'kgvvm_toggle_parcel_cost' ); ?>
@@ -1951,8 +1967,8 @@ class Admin {
</ul>
</ul>
<p class='description' style='margin-top:12px; font-size:11px;'>
<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:#007017;'>✓</span> <?php echo esc_html__( 'zugeordnet', KGVVM_TEXT_DOMAIN ); ?>
<span style='color:#b32d2e;'>✗</span> <?php echo esc_html__( 'nicht 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__( 'alle Parzellen', KGVVM_TEXT_DOMAIN ); ?>
<span style='color:#999;'>—</span> <?php echo esc_html__( 'Pflichtposition für alle Parzellen', KGVVM_TEXT_DOMAIN ); ?>
</p>
</p>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
@@ -2054,24 +2070,24 @@ class Admin {
<h2><?php echo esc_html__( 'Zusammenfassung', KGVVM_TEXT_DOMAIN ); ?></h2>
<h2><?php echo esc_html__( 'Zusammenfassung', KGVVM_TEXT_DOMAIN ); ?></h2>
<table cellpadding="5" cellspacing="0" border="1">
<table cellpadding="5" cellspacing="0" border="1">
<tr>
<tr>
<th><strong><?php echo esc_html__( 'Position', KGVVM_TEXT_DOMAIN ); ?></strong></th>
<th style="width:76%;" ><strong><?php echo esc_html__( 'Position', KGVVM_TEXT_DOMAIN ); ?></strong></th>
<th><strong><?php echo esc_html__( 'Betrag', KGVVM_TEXT_DOMAIN ); ?></strong></th>
<th style="width:24%; text-align:right; white-space:nowrap;" ><strong><?php echo esc_html__( 'Betrag', KGVVM_TEXT_DOMAIN ); ?></strong></th>
</tr>
</tr>
<tr>
<tr>
<td><?php echo esc_html__( 'Anteilige Grundkosten', KGVVM_TEXT_DOMAIN ); ?></td>
<td><?php echo esc_html__( 'Anteilige Grundkosten', KGVVM_TEXT_DOMAIN ); ?></td>
<td><?php echo esc_html( $this->format_currency( $statement['fixed_total'] ) ); ?></td>
<td style="text-align:right; white-space:nowrap;" ><?php echo esc_html( $this->format_currency( $statement['fixed_total'] ) ); ?></td>
</tr>
</tr>
<tr>
<tr>
<td><?php echo esc_html__( 'Wasserkosten', KGVVM_TEXT_DOMAIN ); ?></td>
<td><?php echo esc_html__( 'Wasserkosten', KGVVM_TEXT_DOMAIN ); ?></td>
<td><?php echo esc_html( $this->format_currency( $statement['water_cost_total'] ) ); ?></td>
<td style="text-align:right; white-space:nowrap;" ><?php echo esc_html( $this->format_currency( $statement['water_cost_total'] ) ); ?></td>
</tr>
</tr>
<tr>
<tr>
<td><?php echo esc_html__( 'Stromkosten', KGVVM_TEXT_DOMAIN ); ?></td>
<td><?php echo esc_html__( 'Stromkosten', KGVVM_TEXT_DOMAIN ); ?></td>
<td><?php echo esc_html( $this->format_currency( $statement['power_cost_total'] ) ); ?></td>
<td style="text-align:right; white-space:nowrap;" ><?php echo esc_html( $this->format_currency( $statement['power_cost_total'] ) ); ?></td>
</tr>
</tr>
<tr>
<tr>
<td><strong><?php echo esc_html__( 'Gesamtbetrag', KGVVM_TEXT_DOMAIN ); ?></strong></td>
<td><strong><?php echo esc_html__( 'Gesamtbetrag', KGVVM_TEXT_DOMAIN ); ?></strong></td>
<td><strong><?php echo esc_html( $this->format_currency( $statement['grand_total'] ) ); ?></strong></td>
<td style="text-align:right; white-space:nowrap;" ><strong><?php echo esc_html( $this->format_currency( $statement['grand_total'] ) ); ?></strong></td>
</tr>
</tr>
</table>
</table>
@@ -2081,15 +2097,13 @@ class Admin {
<?php else : ?>
<?php else : ?>
<table cellpadding="5" cellspacing="0" border="1">
<table cellpadding="5" cellspacing="0" border="1">
<tr>
<tr>
<th><strong><?php echo esc_html__( 'Kostenposten', KGVVM_TEXT_DOMAIN ); ?></strong></th>
<th style="width:76%;" ><strong><?php echo esc_html__( 'Kostenposten', KGVVM_TEXT_DOMAIN ); ?></strong></th>
<th><strong><?php echo esc_html__( 'Gesamtkosten ', KGVVM_TEXT_DOMAIN ); ?></strong></th>
<th style="width:24%; text-align:right; white-space:nowrap;" ><strong><?php echo esc_html__( 'Anteil ', KGVVM_TEXT_DOMAIN ); ?></strong></th>
<th><strong><?php echo esc_html__( 'Anteil', KGVVM_TEXT_DOMAIN ); ?></strong></th>
</tr>
</tr>
<?php foreach ( $statement['fixed_items'] as $item ) : ?>
<?php foreach ( $statement['fixed_items'] as $item ) : ?>
<tr>
<tr>
<td><?php echo esc_html( $item['name'] . ' – ' . sprintf( __( '%1$s × %2$s zu je %3$s', KGVVM_TEXT_DOMAIN ), $item['distribution_label'], number_format_i18n( (int) $item['units'], 0 ), $this->format_currency( $item['unit_amount'] ) ) ); ?></td>
<td style="width:76%;" ><?php echo esc_html( $item['name'] . ' – ' . sprintf( __( '%1$s × %2$s zu je %3$s', KGVVM_TEXT_DOMAIN ), $item['distribution_label'], number_format_i18n( (int) $item['units'], 0 ), $this->format_currency( $item['unit_amount'] ) ) ); ?></td>
<td><?php echo esc_html( $this->format_currency( $item['total '] ) ); ?></td>
<td style="width:24%; text-align:right; white-space:nowrap;" ><?php echo esc_html( $this->format_currency( $item['share '] ) ); ?></td>
<td><?php echo esc_html( $this->format_currency( $item['share'] ) ); ?></td>
</tr>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</table>
</table>