Fix #56: Leistungszeitraum als freies Textfeld (von/bis-Felder entfernt)
This commit is contained in:
parent
7de93f14b8
commit
491f5c6dc5
7 changed files with 47 additions and 43 deletions
12
Changes.md
12
Changes.md
|
|
@ -2,6 +2,18 @@
|
|||
|
||||
---
|
||||
|
||||
## 2026-04-26 – Leistungszeitraum als freies Textfeld
|
||||
|
||||
### Geändert
|
||||
- `migrations/034_leistungszeitraum_text.sql`: Spalten `leistungszeitraum_von` (DATE) und `leistungszeitraum_bis` (DATE) wurden durch eine einzige Textspalte `leistungszeitraum` (VARCHAR 255) ersetzt; bestehende Datumswerte werden automatisch migriert
|
||||
- `src/Views/invoices/form.php`: Zwei Datumsfelder durch ein Freitextfeld „Leistungszeitraum" ersetzt, Grid von 4 auf 3 Spalten angepasst
|
||||
- `src/Models/Invoice.php`: INSERT/UPDATE verwenden jetzt `leistungszeitraum` statt `leistungszeitraum_von`/`leistungszeitraum_bis`
|
||||
- `src/Controllers/InvoiceController.php`: Datums-Defaults für `leistungszeitraum_von`/`leistungszeitraum_bis` entfernt
|
||||
- `src/Views/invoices/show.php`: Leistungszeitraum-Anzeige vereinfacht (kein Datumsformat, direkter Textausgabe)
|
||||
- `src/Services/PdfInvoiceService.php`: Leistungszeitraum-Ausgabe vereinfacht
|
||||
|
||||
---
|
||||
|
||||
## 2026-04-15 – KI-Erkennung: automatischer Aufruf aus Belegansicht entfernt
|
||||
|
||||
### Geändert
|
||||
|
|
|
|||
23
migrations/034_leistungszeitraum_text.sql
Normal file
23
migrations/034_leistungszeitraum_text.sql
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
-- Leistungszeitraum: von zwei DATE-Feldern zu einem freien Textfeld
|
||||
ALTER TABLE invoices
|
||||
ADD COLUMN leistungszeitraum VARCHAR(255) NULL AFTER leistungszeitraum_bis;
|
||||
|
||||
-- Bestehende Daten migrieren: Datumsfelder als lesbaren Text zusammenführen
|
||||
UPDATE invoices
|
||||
SET leistungszeitraum = CASE
|
||||
WHEN leistungszeitraum_von IS NOT NULL AND leistungszeitraum_bis IS NOT NULL
|
||||
AND leistungszeitraum_von != leistungszeitraum_bis
|
||||
THEN CONCAT(
|
||||
DATE_FORMAT(leistungszeitraum_von, '%d.%m.%Y'),
|
||||
' – ',
|
||||
DATE_FORMAT(leistungszeitraum_bis, '%d.%m.%Y')
|
||||
)
|
||||
WHEN leistungszeitraum_von IS NOT NULL
|
||||
THEN DATE_FORMAT(leistungszeitraum_von, '%d.%m.%Y')
|
||||
ELSE NULL
|
||||
END
|
||||
WHERE leistungszeitraum_von IS NOT NULL OR leistungszeitraum_bis IS NOT NULL;
|
||||
|
||||
ALTER TABLE invoices
|
||||
DROP COLUMN leistungszeitraum_von,
|
||||
DROP COLUMN leistungszeitraum_bis;
|
||||
|
|
@ -43,9 +43,7 @@ class InvoiceController
|
|||
$settings = Setting::get();
|
||||
|
||||
$invoiceDefaults = [
|
||||
'rechnungs_datum' => date('Y-m-d'),
|
||||
'leistungszeitraum_von' => date('Y-m-01'),
|
||||
'leistungszeitraum_bis' => date('Y-m-t'),
|
||||
'rechnungs_datum' => date('Y-m-d'),
|
||||
];
|
||||
|
||||
$preCustomerId = (int)($_GET['customer_id'] ?? 0);
|
||||
|
|
|
|||
|
|
@ -78,14 +78,13 @@ class Invoice
|
|||
$faellig = date('Y-m-d', strtotime($datum . " +{$payDays} days"));
|
||||
|
||||
Database::execute(
|
||||
'INSERT INTO invoices (customer_id, betreff, leistungszeitraum_von, leistungszeitraum_bis,
|
||||
'INSERT INTO invoices (customer_id, betreff, leistungszeitraum,
|
||||
rechnungs_datum, faellig_datum, status, notes)
|
||||
VALUES (?, ?, ?, ?, ?, ?, \'Entwurf\', ?)',
|
||||
VALUES (?, ?, ?, ?, ?, \'Entwurf\', ?)',
|
||||
[
|
||||
(int)$data['customer_id'],
|
||||
$data['betreff'],
|
||||
$data['leistungszeitraum_von'] ?: null,
|
||||
$data['leistungszeitraum_bis'] ?: null,
|
||||
($data['leistungszeitraum'] ?? '') !== '' ? $data['leistungszeitraum'] : null,
|
||||
$datum,
|
||||
$faellig,
|
||||
$data['notes'] ?? null,
|
||||
|
|
@ -116,14 +115,13 @@ class Invoice
|
|||
$faellig = date('Y-m-d', strtotime($datum . " +{$payDays} days"));
|
||||
|
||||
Database::execute(
|
||||
'UPDATE invoices SET customer_id=?, betreff=?, leistungszeitraum_von=?, leistungszeitraum_bis=?,
|
||||
'UPDATE invoices SET customer_id=?, betreff=?, leistungszeitraum=?,
|
||||
rechnungs_datum=?, faellig_datum=?, notes=?, updated_at=NOW()
|
||||
WHERE id=? AND status=\'Entwurf\'',
|
||||
[
|
||||
(int)$data['customer_id'],
|
||||
$data['betreff'],
|
||||
$data['leistungszeitraum_von'] ?: null,
|
||||
$data['leistungszeitraum_bis'] ?: null,
|
||||
($data['leistungszeitraum'] ?? '') !== '' ? $data['leistungszeitraum'] : null,
|
||||
$datum,
|
||||
$faellig,
|
||||
$data['notes'] ?? null,
|
||||
|
|
|
|||
|
|
@ -68,14 +68,7 @@ class PdfInvoiceService
|
|||
$logoWrapStyle = 'text-align:center';
|
||||
}
|
||||
|
||||
// Leistungszeitraum
|
||||
$lz = '';
|
||||
if (!empty($inv['leistungszeitraum_von'])) {
|
||||
$lz = $fmtDate($inv['leistungszeitraum_von']);
|
||||
if (!empty($inv['leistungszeitraum_bis']) && $inv['leistungszeitraum_bis'] !== $inv['leistungszeitraum_von']) {
|
||||
$lz .= ' – ' . $fmtDate($inv['leistungszeitraum_bis']);
|
||||
}
|
||||
}
|
||||
$lz = $inv['leistungszeitraum'] ?? '';
|
||||
|
||||
// Fälligkeitsdatum
|
||||
$fälligText = !empty($inv['faellig_datum'])
|
||||
|
|
|
|||
|
|
@ -37,21 +37,16 @@ $preCustomer = (int)($_GET['customer_id'] ?? 0);
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-grid form-grid-4 mb-2">
|
||||
<div class="form-grid form-grid-3 mb-2">
|
||||
<div class="form-group">
|
||||
<label for="rechnungs_datum">Rechnungsdatum *</label>
|
||||
<input type="date" id="rechnungs_datum" name="rechnungs_datum"
|
||||
value="<?= $h($invoice['rechnungs_datum'] ?? date('Y-m-d')) ?>" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="leistungszeitraum_von">Leistungszeitraum von</label>
|
||||
<input type="date" id="leistungszeitraum_von" name="leistungszeitraum_von"
|
||||
value="<?= $h($invoice['leistungszeitraum_von'] ?? '') ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="leistungszeitraum_bis">Leistungszeitraum bis</label>
|
||||
<input type="date" id="leistungszeitraum_bis" name="leistungszeitraum_bis"
|
||||
value="<?= $h($invoice['leistungszeitraum_bis'] ?? '') ?>">
|
||||
<label for="leistungszeitraum">Leistungszeitraum</label>
|
||||
<input type="text" id="leistungszeitraum" name="leistungszeitraum"
|
||||
value="<?= $h($invoice['leistungszeitraum'] ?? '') ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="payment_days">Zahlungsziel (Tage)</label>
|
||||
|
|
|
|||
|
|
@ -7,22 +7,7 @@ $customerName = !empty($invoice['firma'])
|
|||
? $invoice['firma']
|
||||
: trim(($invoice['anrede'] ?? '') . ' ' . ($invoice['vorname'] ?? '') . ' ' . $invoice['nachname']);
|
||||
|
||||
$lz = '';
|
||||
if (!empty($invoice['leistungszeitraum_von'])) {
|
||||
$lz = View::formatDate($invoice['leistungszeitraum_von']);
|
||||
if (!empty($invoice['leistungszeitraum_bis'])) {
|
||||
$lz .= ' – ' . View::formatDate($invoice['leistungszeitraum_bis']);
|
||||
}
|
||||
}
|
||||
|
||||
// Leistungszeitraum mit <br> für die Vorschau-Tabelle (Datumsangaben untereinander)
|
||||
$lzHtml = '';
|
||||
if (!empty($invoice['leistungszeitraum_von'])) {
|
||||
$lzHtml = $h(View::formatDate($invoice['leistungszeitraum_von']));
|
||||
if (!empty($invoice['leistungszeitraum_bis']) && $invoice['leistungszeitraum_bis'] !== $invoice['leistungszeitraum_von']) {
|
||||
$lzHtml .= '<br>' . $h(View::formatDate($invoice['leistungszeitraum_bis']));
|
||||
}
|
||||
}
|
||||
$lzHtml = $h($invoice['leistungszeitraum'] ?? '');
|
||||
|
||||
$badgeClass = match($invoice['status']) {
|
||||
'Bezahlt' => 'badge-green',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue