Kundenmail 26.11.: Feiertage NRW, Abwesenheitsfilter, Von/Bis-Automatik, Navigation, zweiter Mitarbeiter im Kalender, Bearbeitungsrechte, Bemerkungsfeld, Frei-bis
- Feiertage NRW im Kalender markiert (eigene Osterformel, keine Extra-Extension) - Abwesenheiten: Zeitraeume 'Naechster Monat'/'Alle' plus Mitarbeiterfilter - 'Bis' folgt 'Von' per data-date-pair; Kalender waehlt Zeitraum mit zwei Klicks - Hauptnavigation: Uebersicht - Erinnerungen - Kalender - Abwesenheiten - Verwaltung - Kalender zeigt abweichenden Ruecknahme-Mitarbeiter auch bei kurzen Buchungen - Buchungen bearbeiten/verschieben fuer alle Mitarbeiter; Anlegen, Storno, Loeschen und Betraege/Rechnungsdaten bleiben beim Admin (serverseitig erzwungen) - Bemerkungsfeld je Buchung (Migration 008_booking_note.sql, nicht im Kundentext) - Uebersicht: 'Frei bis <Datum>' bei freien Anhaengern
This commit is contained in:
parent
1ade7624e2
commit
7e462d84a1
20 changed files with 969 additions and 91 deletions
46
app/data.php
46
app/data.php
|
|
@ -125,6 +125,13 @@ function booking_conflicts(int $trailerId, string $start, string $end, int $excl
|
|||
}
|
||||
|
||||
/** Formulardaten in ein normalisiertes Array übersetzen. */
|
||||
/** Bemerkung normalisieren: Zeilenumbrüche vereinheitlichen und trimmen. */
|
||||
function booking_note_clean(string $note): string
|
||||
{
|
||||
$note = str_replace(["\r\n", "\r"], "\n", $note);
|
||||
return trim($note);
|
||||
}
|
||||
|
||||
function booking_input(array $source): array
|
||||
{
|
||||
$kind = (string) ($source['kind'] ?? 'pickup');
|
||||
|
|
@ -163,6 +170,7 @@ function booking_input(array $source): array
|
|||
'city' => trim((string) ($source['city'] ?? '')),
|
||||
'mobile' => trim((string) ($source['mobile'] ?? '')),
|
||||
'email' => trim((string) ($source['email'] ?? '')),
|
||||
'note' => booking_note_clean((string) ($source['note'] ?? '')),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -189,6 +197,7 @@ function booking_to_input(array $booking): array
|
|||
'city' => (string) $booking['city'],
|
||||
'mobile' => (string) $booking['mobile'],
|
||||
'email' => (string) $booking['email'],
|
||||
'note' => (string) ($booking['note'] ?? ''),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -248,6 +257,9 @@ function booking_validate(array $data, int $excludeId = 0, int $allowTrailerId =
|
|||
} elseif (mb_strlen($data['customer_name']) > 190) {
|
||||
$errors['customer_name'] = 'Der Kundenname ist zu lang (max. 190 Zeichen).';
|
||||
}
|
||||
if (mb_strlen((string) ($data['note'] ?? '')) > 500) {
|
||||
$errors['note'] = 'Die Bemerkung ist zu lang (max. 500 Zeichen).';
|
||||
}
|
||||
foreach (['street' => 'Straße', 'city' => 'Ort', 'mobile' => 'Handy'] as $field => $label) {
|
||||
if (mb_strlen((string) $data[$field]) > 190) {
|
||||
$errors[$field] = $label . ' ist zu lang (max. 190 Zeichen).';
|
||||
|
|
@ -345,6 +357,21 @@ function absence_find(int $id): ?array
|
|||
return $row ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Früheste und späteste Abwesenheit – Zeitfenster für die Vollansicht
|
||||
* „Alle“ auf der Team-Seite.
|
||||
*
|
||||
* @return array{0: string, 1: string} [erster Tag, letzter Tag] oder ['', '']
|
||||
*/
|
||||
function absence_bounds(): array
|
||||
{
|
||||
$row = db()->query('SELECT MIN(start_date) AS first_day, MAX(end_date) AS last_day FROM absences')->fetch();
|
||||
if (!$row || $row['first_day'] === null) {
|
||||
return ['', ''];
|
||||
}
|
||||
return [(string) $row['first_day'], (string) $row['last_day']];
|
||||
}
|
||||
|
||||
/** Abwesenheit, die den Mitarbeiter im Zeitraum (inkl. Vorlauf) betrifft. */
|
||||
function booking_absence_conflict(int $employeeId, string $startDate, string $endDate): ?array
|
||||
{
|
||||
|
|
@ -460,8 +487,8 @@ function booking_create(array $data, int $userId): int
|
|||
'INSERT INTO bookings
|
||||
(trailer_id, employee_id, return_employee_id, start_date, end_date, start_time, end_time, deposit_cents,
|
||||
rent_cents, delivery_cents, total_cents, invoice, invoice_no, kind,
|
||||
customer_name, street, city, mobile, email, status, created_at, updated_at, created_by, updated_by)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "active", ?, ?, ?, ?)'
|
||||
customer_name, street, city, mobile, email, note, status, created_at, updated_at, created_by, updated_by)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "active", ?, ?, ?, ?)'
|
||||
);
|
||||
$stmt->execute([
|
||||
$data['trailer_id'], $data['employee_id'], $data['return_employee_id'] ?: null,
|
||||
|
|
@ -470,6 +497,7 @@ function booking_create(array $data, int $userId): int
|
|||
$data['deposit_cents'], $data['rent_cents'], $data['delivery_cents'], $data['total_cents'],
|
||||
$data['invoice'], null_if_empty($data['invoice_no']), $data['kind'],
|
||||
$data['customer_name'], $data['street'], $data['city'], $data['mobile'], $data['email'],
|
||||
(string) ($data['note'] ?? ''),
|
||||
utc_now(), utc_now(), $userId, $userId,
|
||||
]);
|
||||
$id = (int) $pdo->lastInsertId();
|
||||
|
|
@ -500,7 +528,7 @@ function booking_update(int $id, array $data, int $userId): void
|
|||
'UPDATE bookings SET trailer_id = ?, employee_id = ?, return_employee_id = ?, start_date = ?, end_date = ?,
|
||||
start_time = ?, end_time = ?, deposit_cents = ?, rent_cents = ?, delivery_cents = ?,
|
||||
total_cents = ?, invoice = ?, invoice_no = ?, kind = ?, customer_name = ?, street = ?,
|
||||
city = ?, mobile = ?, email = ?, updated_at = ?, updated_by = ? WHERE id = ?'
|
||||
city = ?, mobile = ?, email = ?, note = ?, updated_at = ?, updated_by = ? WHERE id = ?'
|
||||
);
|
||||
$stmt->execute([
|
||||
$data['trailer_id'], $data['employee_id'], $data['return_employee_id'] ?: null,
|
||||
|
|
@ -509,6 +537,7 @@ function booking_update(int $id, array $data, int $userId): void
|
|||
$data['deposit_cents'], $data['rent_cents'], $data['delivery_cents'], $data['total_cents'],
|
||||
$data['invoice'], null_if_empty($data['invoice_no']), $data['kind'],
|
||||
$data['customer_name'], $data['street'], $data['city'], $data['mobile'], $data['email'],
|
||||
(string) ($data['note'] ?? ''),
|
||||
utc_now(), $userId, $id,
|
||||
]);
|
||||
$pdo->commit();
|
||||
|
|
@ -1001,6 +1030,17 @@ function calendar_geometry(array $booking, string $from, string $to, int $lanes)
|
|||
];
|
||||
}
|
||||
|
||||
/** Nächste aktive Buchung eines Anhängers ab einem Datum (für „Frei bis …“). */
|
||||
function next_booking_start(int $trailerId, string $fromDate): ?array
|
||||
{
|
||||
$sql = BOOKING_SELECT . " WHERE b.trailer_id = ? AND b.status = 'active' AND b.start_date > ?
|
||||
ORDER BY b.start_date LIMIT 1";
|
||||
$stmt = db()->prepare($sql);
|
||||
$stmt->execute([$trailerId, $fromDate]);
|
||||
$row = $stmt->fetch();
|
||||
return $row ?: null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- Auswertung */
|
||||
|
||||
function bookings_by_date(string $date): array
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue