feat(booking): abweichende Lieferadresse und Zusatzvereinbarungen
- Migration 017: bookings.delivery_street, bookings.delivery_city und bookings.agreements (Freitext, max. 1000 Zeichen); schema.sql nachgezogen - Buchungsformular: Felder „Lieferadresse/Lieferort (falls abweichend)“ und „Zusatzvereinbarungen“ (Textarea), Validierung, Werte in Neu/Bearbeiten - document_delivery_address() (Rückfall auf die Kundenanschrift) für Auftragsbestätigung und Mietvertrag; Zusatzvereinbarungen erscheinen als eigener Abschnitt vor den Unterschriften, Umbruch nur wenn nötig - Buchungsdetail und Kopiertext zeigen Lieferadresse und Vereinbarungen - Anleitung, README und ROADMAP (Feature 27)
This commit is contained in:
parent
2cf24226f4
commit
5ea0c5b2f9
10 changed files with 151 additions and 14 deletions
|
|
@ -652,6 +652,23 @@ function deposit_due_date(?string $fromIso = null): string
|
|||
return $cursor->format('Y-m-d');
|
||||
}
|
||||
|
||||
/**
|
||||
* Lieferadresse für die Auftragsbestätigung: abweichende Adresse, sonst die
|
||||
* Kundenanschrift (Straße, Ort).
|
||||
*/
|
||||
function document_delivery_address(array $booking): string
|
||||
{
|
||||
$address = trim(
|
||||
trim((string) ($booking['delivery_street'] ?? '')) . ', ' . trim((string) ($booking['delivery_city'] ?? '')),
|
||||
', '
|
||||
);
|
||||
if ($address !== '') {
|
||||
return $address;
|
||||
}
|
||||
$address = trim((string) $booking['street'] . ', ' . (string) $booking['city'], ', ');
|
||||
return $address !== '' ? $address : (string) $booking['city'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Nur die Gattung des Mietgegenstandes – ohne Anhänger-/Truhennummer.
|
||||
* Für die Auftragsbestätigung: „Kühlanhänger“ oder „Truhe“.
|
||||
|
|
@ -766,14 +783,13 @@ function document_contract_pdf(
|
|||
document_pdf_title($pdf, 'Mietvertrag', document_variant_label($variant) . ' · Buchung #' . (int) $booking['id']);
|
||||
$y = document_pdf_parties($pdf, 92, $booking);
|
||||
|
||||
$address = trim((string) $booking['street'] . ', ' . (string) $booking['city'], ', ');
|
||||
$period = 'von ' . fmt_date_with_time((string) $booking['start_date'], $booking['start_time'] ?? null)
|
||||
. ' bis ' . fmt_date_with_time((string) $booking['end_date'], $booking['end_time'] ?? null);
|
||||
|
||||
$y = document_pdf_heading($pdf, $y, 'Mietgegenstand und Mietzeit');
|
||||
$rows = [['Mietgegenstand', document_subject_line($booking, $texts)]];
|
||||
if ($variant === 'delivery') {
|
||||
$rows[] = ['Lieferadresse', $address !== '' ? $address : 'wie Mieteranschrift'];
|
||||
$rows[] = ['Lieferadresse', document_delivery_address($booking)];
|
||||
} else {
|
||||
$rows[] = ['Abholung', 'Selbstabholung bei ' . $owner . ', ' . $legal['street'] . ', ' . trim((string) $legal['postal_code'] . ' ' . $legal['city'])];
|
||||
}
|
||||
|
|
@ -894,8 +910,7 @@ function document_confirmation_pdf(array $booking, string $variant): string
|
|||
['Rücknahme durch', booking_return_employee_name($booking)],
|
||||
];
|
||||
if ($variant === 'delivery') {
|
||||
$address = trim((string) $booking['street'] . ', ' . (string) $booking['city'], ', ');
|
||||
$rows[] = ['Lieferadresse', $address !== '' ? $address : (string) $booking['city']];
|
||||
$rows[] = ['Lieferadresse', document_delivery_address($booking)];
|
||||
}
|
||||
$y = document_pdf_rows($pdf, $y, $rows);
|
||||
|
||||
|
|
@ -954,11 +969,43 @@ function document_confirmation_pdf(array $booking, string $variant): string
|
|||
. 'Bitte prüfen Sie die Angaben und melden Sie sich bei Abweichungen.';
|
||||
$y = $pdf->paragraph(50, $y + 8, $pdf->pageWidth() - 100, 9, $closing, false, 12.5);
|
||||
|
||||
// Unterschriftenfelder: links Ort/Datum (vorbelegt), rechts die hinterlegte
|
||||
// Unterschrift des Vermieters. Nur bei Platzmangel auf eine neue Seite.
|
||||
$owner = trim((string) ($legal['owner'] ?? '')) !== '' ? (string) $legal['owner'] : (string) $legal['business_name'];
|
||||
$signatureFile = owner_signature_path();
|
||||
$signatureTop = $y + ($signatureFile !== null ? 52 : 18);
|
||||
$signatureSpace = $signatureFile !== null ? 52 : 18;
|
||||
|
||||
// Zusatzvereinbarungen (Freitext aus der Buchung), falls hinterlegt.
|
||||
$agreements = trim((string) ($booking['agreements'] ?? ''));
|
||||
if ($agreements !== '') {
|
||||
$textWidth = $pdf->pageWidth() - 100;
|
||||
$agreementLines = 0;
|
||||
$agreementText = [];
|
||||
foreach (preg_split('/\R/', $agreements) ?: [] as $line) {
|
||||
if (trim($line) === '') {
|
||||
continue;
|
||||
}
|
||||
$wrapped = $pdf->wrap(trim($line), 9, $textWidth);
|
||||
$agreementLines += count($wrapped);
|
||||
foreach ($wrapped as $wrappedLine) {
|
||||
$agreementText[] = $wrappedLine;
|
||||
}
|
||||
}
|
||||
// Nur umbrechen, wenn Vereinbarungen + Unterschrift sonst nicht mehr passen.
|
||||
$needed = 26 + $agreementLines * 12.5 + $signatureSpace + 12;
|
||||
if ($y + $needed > 762) {
|
||||
document_pdf_footer($pdf, 'Auftragsbestätigung · Buchung #' . (int) $booking['id']);
|
||||
$pdf->newPage();
|
||||
$y = 90;
|
||||
}
|
||||
$y = document_pdf_heading($pdf, $y + 8, 'Zusatzvereinbarungen');
|
||||
foreach ($agreementText as $line) {
|
||||
$pdf->text(50, $y, 9, $line);
|
||||
$y += 12.5;
|
||||
}
|
||||
}
|
||||
|
||||
// Unterschriftenfelder: links Ort/Datum (vorbelegt), rechts die hinterlegte
|
||||
// Unterschrift des Vermieters. Nur bei Platzmangel auf eine neue Seite.
|
||||
$signatureTop = $y + $signatureSpace;
|
||||
if ($signatureTop > 762) {
|
||||
document_pdf_footer($pdf, 'Auftragsbestätigung · Buchung #' . (int) $booking['id']);
|
||||
$pdf->newPage();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue