feat(documents): Mietvertrag, Auftragsbestätigung und Rechnung zur Buchung
- Mietvertrag als PDF in drei Varianten (Mit Lieferung, Selbstabholer, Truhe), Seite 2+ mit der AGB aus app/agb.php – derselbe Text wie /agb. - Auftragsbestätigung als PDF, ebenfalls in drei Varianten. - PDF-Erzeuger ohne Fremdbibliothek (app/pdf.php, Helvetica + JPEG für die Unterschrift); Layout in app/documents.php. - Unterschrift auf dem Tablet (views/document_sign.php, Canvas -> JPEG) wird ins PDF gesetzt; Unterlagen lassen sich ansehen, drucken und per Mail an den Kunden senden (mail_send_attachment()). - Rechnung aus Lexware als PDF-Upload; Ablage unter storage/documents/<booking_id>/ (per .htaccess gesperrt). - Aufbewahrung: documents_cleanup() im Cron löscht einen Monat nach Mietende (app.document_retention_days), inklusive verwaister Dateien. - Migrationen per HTTP (/migrate?token=…, app/migrate.php), weil das Hosting kein SSH hat; deploy.sh ruft die Route nach dem Sync auf. - Schema: booking_documents (Migration 012, auch in schema.sql), Doku in README/ROADMAP/docs/todo_kundenemail_2026-11-30-unterlagen.md. Enthält außerdem die bislang nicht committeten Anpassungen in bootstrap.php und app.js/pages.php, die im selben Arbeitsstand lagen.
This commit is contained in:
parent
3e34a6c839
commit
2de8e95c15
24 changed files with 2412 additions and 49 deletions
47
app/mail.php
47
app/mail.php
|
|
@ -54,6 +54,53 @@ function mail_send(string $to, string $subject, string $body, array $extraHeader
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verschickt eine Textnachricht mit einem Dateianhang (multipart/mixed).
|
||||
*
|
||||
* Gedacht für Buchungsunterlagen (Mietvertrag, Auftragsbestätigung, Rechnung).
|
||||
* Der Anhang wird Base64-kodiert; Dateiname und MIME-Typ kommen vom Aufrufer.
|
||||
*/
|
||||
function mail_send_attachment(
|
||||
string $to,
|
||||
string $subject,
|
||||
string $body,
|
||||
string $fileName,
|
||||
string $mimeType,
|
||||
string $data
|
||||
): bool {
|
||||
if (!filter_var($to, FILTER_VALIDATE_EMAIL) || $data === '') {
|
||||
return false;
|
||||
}
|
||||
$safeName = trim((string) preg_replace('/[\r\n"]+/', '', $fileName));
|
||||
$safeType = trim((string) preg_replace('/[\r\n]+/', '', $mimeType));
|
||||
$boundary = 'dic-' . bin2hex(random_bytes(12));
|
||||
$headers = [
|
||||
'From: ' . (string) config('app.mail_from', 'Drink it cold <noreply@localhost>'),
|
||||
'MIME-Version: 1.0',
|
||||
'Content-Type: multipart/mixed; boundary="' . $boundary . '"',
|
||||
];
|
||||
$parts = [
|
||||
'--' . $boundary,
|
||||
'Content-Type: text/plain; charset=UTF-8',
|
||||
'Content-Transfer-Encoding: 8bit',
|
||||
'',
|
||||
$body,
|
||||
'--' . $boundary,
|
||||
'Content-Type: ' . $safeType . '; name="' . $safeName . '"',
|
||||
'Content-Transfer-Encoding: base64',
|
||||
'Content-Disposition: attachment; filename="' . $safeName . '"',
|
||||
'',
|
||||
chunk_split(base64_encode($data), 76, "\r\n"),
|
||||
'--' . $boundary . '--',
|
||||
];
|
||||
return @mail(
|
||||
$to,
|
||||
mb_encode_mimeheader($subject, 'UTF-8', 'B'),
|
||||
implode("\r\n", $parts),
|
||||
implode("\r\n", $headers)
|
||||
);
|
||||
}
|
||||
|
||||
function reminder_mail_recipients(): array
|
||||
{
|
||||
$sql = "SELECT u.employee_id, u.email, u.first_name, u.last_name, e.name AS employee_name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue