diff --git a/README.md b/README.md
index 713bc14..4073f4d 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,23 @@ Die Anforderungen stammen aus
- **Übersicht** mit heutiger Auslastung, freien Anhängern, nächsten Übergaben
und Rücknahmen sowie offenen Erinnerungen.
+## PWA / Installation
+
+Die App ist als Progressive Web App eingerichtet:
+
+- `manifest.webmanifest` mit Namen, Farben, Icons (192/512, maskable) und
+ Shortcuts für Kalender, neue Buchung und Erinnerungen.
+- `sw.js` macht die App installierbar, lädt statische Assets schneller und
+ zeigt offline eine eigene Seite. **Buchungen und HTML-Seiten werden nicht
+ gecacht**, damit niemand veraltete Daten sieht – die Terminplanung braucht
+ online immer den aktuellen Stand.
+- Installation: in Chrome/Edge über das Installations-Symbol in der Adresszeile
+ oder **Menü → App installieren**; auf iPhone/iPad über **Teilen → Zum
+ Home-Bildschirm**. Ein Installations-Eintrag erscheint zusätzlich im
+ Benutzermenü, sobald der Browser die Installation anbietet.
+- Voraussetzung ist HTTPS (live erfüllt). Lokal funktioniert der Service Worker
+ auch über `http://127.0.0.1`.
+
## Technik
- PHP 8.1+ (getestet mit 8.3), MariaDB 10.11, keine Build-Tools nötig.
diff --git a/app/util.php b/app/util.php
index c515798..5061ce3 100644
--- a/app/util.php
+++ b/app/util.php
@@ -89,7 +89,7 @@ function url(string $path = '/'): string
}
/** Cache-Buster: bei Änderungen an app.css/app.js erhöhen. */
-const DIC_ASSET_VERSION = '1';
+const DIC_ASSET_VERSION = '2';
function asset(string $path): string
{
diff --git a/docs/architecture.md b/docs/architecture.md
index f2adad4..dc55c8b 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -127,6 +127,23 @@ sind die primäre Anzeige und funktionieren ohne Mailversand.
| 9. Übersicht | Dashboard mit Auslastung, freien Anhängern, Übergaben/Rücknahmen, Erinnerungen |
| Benutzerverwaltung tippspiel2027 | Admin-only, Vorname/Nachname/Passwort, keine Selbstregistrierung |
+## PWA
+
+- **Manifest:** `web/manifest.webmanifest` (Name, Theme `#196abc`, Icons in
+ `web/assets/icons/`, Shortcuts).
+- **Service Worker:** `web/sw.js`. Strategie:
+ - Navigationen: network-first, bei fehlender Verbindung `offline.html`.
+ - Statische Assets: stale-while-revalidate (schnell, aktualisiert im
+ Hintergrund).
+ - Manifest/Offline-Seite: cache-first.
+ - Authentifizierte HTML-Seiten, Formulare und API-Antworten werden bewusst
+ nicht gecacht. Die App zeigt online immer den aktuellen Buchungsstand.
+- Der Service Worker wird in `web/assets/app.js` registriert; die Icons liegen
+ als PNG (192/512, maskable) und SVG vor, dazu ein Apple-Touch-Icon.
+- Bei Änderungen an CSS/JS `DIC_ASSET_VERSION` in `app/util.php` und `VERSION`
+ in `web/sw.js` erhöhen. Der Deploy lädt die Dateien per FTP hoch; Apache
+ liefert `sw.js` mit `no-cache` aus.
+
## Betrieb
- Installation: `install.php?token=…` legt Schema und Grunddaten an, erzeugt den
diff --git a/views/layout.php b/views/layout.php
index 30d5c65..51af2ba 100644
--- a/views/layout.php
+++ b/views/layout.php
@@ -21,12 +21,21 @@ $navActive = static function (string $area) use ($path): string {
-
+
+
+
+
+
+
+
+
= e($title) ?> · Drink it cold
+
-
+
+
@@ -61,6 +70,7 @@ $navActive = static function (string $area) use ($path): string {
+
@@ -108,6 +118,7 @@ $navActive = static function (string $area) use ($path): string {
Mein Konto
+
Benutzerverwaltung
diff --git a/views/login.php b/views/login.php
index c2fed13..acd1f71 100644
--- a/views/login.php
+++ b/views/login.php
@@ -9,14 +9,24 @@
-
+
+
+
+
+
+
+
+
Anmelden · Drink it cold
+
-
+
+
+
diff --git a/web/.htaccess b/web/.htaccess
index c9dd6fb..771b312 100644
--- a/web/.htaccess
+++ b/web/.htaccess
@@ -6,6 +6,10 @@ Options -Indexes
DirectoryIndex index.php index.html
AddDefaultCharset UTF-8
+
+ AddType application/manifest+json .webmanifest
+
+
RewriteEngine On
@@ -32,6 +36,13 @@ AddDefaultCharset UTF-8
Header set Cache-Control "public, max-age=604800"
+
+ Header set Cache-Control "no-cache, no-store, must-revalidate"
+ Header set Service-Worker-Allowed "/"
+
+
+ Header set Cache-Control "public, max-age=3600"
+
diff --git a/web/assets/app.css b/web/assets/app.css
index 6dc4c12..34a1d0c 100644
--- a/web/assets/app.css
+++ b/web/assets/app.css
@@ -778,6 +778,18 @@ a .ico, button .ico { pointer-events: none; }
.error-card h1 { margin-bottom: 8px; }
.error-card p { color: var(--muted); margin-bottom: 18px; }
+
+/* --------------------------------------------------------------- PWA */
+@supports (padding: env(safe-area-inset-top)) {
+ .topbar { padding-top: env(safe-area-inset-top); }
+ .page { padding-bottom: max(48px, calc(48px + env(safe-area-inset-bottom))); }
+ .auth-panel { padding-bottom: max(clamp(22px, 4vw, 56px), calc(22px + env(safe-area-inset-bottom))); }
+}
+@media (display-mode: standalone) {
+ .footer { padding-bottom: calc(30px + env(safe-area-inset-bottom)); }
+ .auth-foot { bottom: calc(22px + env(safe-area-inset-bottom)); }
+}
+
/* --------------------------------------------------------------- Responsive */
@media (max-width: 1240px) {
.dash-grid { grid-template-columns: 1fr; }
diff --git a/web/assets/app.js b/web/assets/app.js
index c19cdc8..042606a 100644
--- a/web/assets/app.js
+++ b/web/assets/app.js
@@ -3,7 +3,48 @@
'use strict';
const csrf = document.querySelector('meta[name="csrf-token"]')?.content || '';
+ const swMeta = document.querySelector('meta[name="sw-url"]');
let toastTimer = 0;
+ let installPrompt = null;
+
+ /* --------------------------------------------------------------- PWA */
+ const registerServiceWorker = () => {
+ if (!('serviceWorker' in navigator) || !swMeta) return;
+ navigator.serviceWorker.register(swMeta.content).catch(() => {
+ /* Installation ist optional; die App funktioniert auch ohne SW. */
+ });
+ };
+ if (document.readyState === 'complete') {
+ registerServiceWorker();
+ } else {
+ window.addEventListener('load', registerServiceWorker, { once: true });
+ }
+
+ window.addEventListener('beforeinstallprompt', (event) => {
+ event.preventDefault();
+ installPrompt = event;
+ document.querySelectorAll('[data-install-app]').forEach((button) => { button.hidden = false; });
+ });
+
+ window.addEventListener('appinstalled', () => {
+ installPrompt = null;
+ document.querySelectorAll('[data-install-app]').forEach((button) => { button.hidden = true; });
+ toast('Die App wurde installiert.');
+ });
+
+ document.addEventListener('click', async (event) => {
+ const button = event.target.closest('[data-install-app]');
+ if (!button || !installPrompt) return;
+ const prompt = installPrompt;
+ installPrompt = null;
+ button.hidden = true;
+ try {
+ prompt.prompt();
+ await prompt.userChoice;
+ } catch (error) {
+ /* Der Browser kann die Installation trotzdem abgelehnt haben. */
+ }
+ });
const toast = (message, isError = false) => {
const el = document.getElementById('toast');
diff --git a/web/assets/icons/apple-touch-icon-180.png b/web/assets/icons/apple-touch-icon-180.png
new file mode 100644
index 0000000..ac7db4b
Binary files /dev/null and b/web/assets/icons/apple-touch-icon-180.png differ
diff --git a/web/assets/icons/icon-192.png b/web/assets/icons/icon-192.png
new file mode 100644
index 0000000..9fe969c
Binary files /dev/null and b/web/assets/icons/icon-192.png differ
diff --git a/web/assets/icons/icon-32.png b/web/assets/icons/icon-32.png
new file mode 100644
index 0000000..c00123c
Binary files /dev/null and b/web/assets/icons/icon-32.png differ
diff --git a/web/assets/icons/icon-512.png b/web/assets/icons/icon-512.png
new file mode 100644
index 0000000..059fabf
Binary files /dev/null and b/web/assets/icons/icon-512.png differ
diff --git a/web/assets/icons/icon-maskable-192.png b/web/assets/icons/icon-maskable-192.png
new file mode 100644
index 0000000..755e2e1
Binary files /dev/null and b/web/assets/icons/icon-maskable-192.png differ
diff --git a/web/assets/icons/icon-maskable-512.png b/web/assets/icons/icon-maskable-512.png
new file mode 100644
index 0000000..e9515ac
Binary files /dev/null and b/web/assets/icons/icon-maskable-512.png differ
diff --git a/web/assets/icons/icon-maskable.svg b/web/assets/icons/icon-maskable.svg
new file mode 100644
index 0000000..4069cf1
--- /dev/null
+++ b/web/assets/icons/icon-maskable.svg
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/assets/icons/icon.svg b/web/assets/icons/icon.svg
new file mode 100644
index 0000000..d2e8379
--- /dev/null
+++ b/web/assets/icons/icon.svg
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/manifest.webmanifest b/web/manifest.webmanifest
new file mode 100644
index 0000000..4bdb650
--- /dev/null
+++ b/web/manifest.webmanifest
@@ -0,0 +1,88 @@
+{
+ "id": "/",
+ "name": "Drink it cold – Terminplanung",
+ "short_name": "Drink it cold",
+ "description": "Kühlanhänger-Verleih: Buchungen, Kalender, Übergaben und automatische Erinnerungen für das Team.",
+ "lang": "de",
+ "dir": "ltr",
+ "start_url": "/?source=pwa",
+ "scope": "/",
+ "display": "standalone",
+ "background_color": "#f4f9fe",
+ "theme_color": "#196abc",
+ "categories": ["business", "productivity"],
+ "prefer_related_applications": false,
+ "icons": [
+ {
+ "src": "/assets/icons/icon-192.png",
+ "sizes": "192x192",
+ "type": "image/png",
+ "purpose": "any"
+ },
+ {
+ "src": "/assets/icons/icon-512.png",
+ "sizes": "512x512",
+ "type": "image/png",
+ "purpose": "any"
+ },
+ {
+ "src": "/assets/icons/icon-maskable-192.png",
+ "sizes": "192x192",
+ "type": "image/png",
+ "purpose": "maskable"
+ },
+ {
+ "src": "/assets/icons/icon-maskable-512.png",
+ "sizes": "512x512",
+ "type": "image/png",
+ "purpose": "maskable"
+ },
+ {
+ "src": "/assets/icons/icon.svg",
+ "sizes": "any",
+ "type": "image/svg+xml",
+ "purpose": "any"
+ }
+ ],
+ "shortcuts": [
+ {
+ "name": "Kalender",
+ "short_name": "Kalender",
+ "description": "Wochenkalender aller acht Anhänger öffnen",
+ "url": "/calendar?view=week",
+ "icons": [
+ {
+ "src": "/assets/icons/icon-192.png",
+ "sizes": "192x192",
+ "type": "image/png"
+ }
+ ]
+ },
+ {
+ "name": "Neue Buchung",
+ "short_name": "Buchung",
+ "description": "Mietzeitraum und Kundendaten erfassen",
+ "url": "/bookings/new",
+ "icons": [
+ {
+ "src": "/assets/icons/icon-192.png",
+ "sizes": "192x192",
+ "type": "image/png"
+ }
+ ]
+ },
+ {
+ "name": "Erinnerungen",
+ "short_name": "Erinnerungen",
+ "description": "Fällige Übergaben und Rücknahmen anzeigen",
+ "url": "/reminders",
+ "icons": [
+ {
+ "src": "/assets/icons/icon-192.png",
+ "sizes": "192x192",
+ "type": "image/png"
+ }
+ ]
+ }
+ ]
+}
diff --git a/web/offline.html b/web/offline.html
new file mode 100644
index 0000000..2799f96
--- /dev/null
+++ b/web/offline.html
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+ Offline · Drink it cold
+
+
+
+
+
+
+
+
+ Drink it cold · Terminplanung
+ Keine Verbindung
+ Die Terminplanung braucht eine Internetverbindung, damit alle Mitarbeiter denselben aktuellen Stand sehen. Gerade können keine Buchungen geladen werden.
+
+ Erneut versuchen
+
+ Sobald die Verbindung wieder da ist, steht der aktuelle Kalender sofort zur Verfügung.
+
+
+
diff --git a/web/sw.js b/web/sw.js
new file mode 100644
index 0000000..5671747
--- /dev/null
+++ b/web/sw.js
@@ -0,0 +1,140 @@
+/* Drink it cold – Service Worker
+ *
+ * Die App braucht für aktuelle Buchungsdaten eine Verbindung. Der Service
+ * Worker macht sie installierbar und beschleunigt die statischen Assets.
+ * Authentifizierte HTML-Seiten und API-Antworten werden bewusst NICHT
+ * zwischengespeichert, damit niemand veraltete Buchungen sieht.
+ */
+
+const VERSION = 'dic-v2';
+const CACHE = VERSION;
+const BASE = new URL(self.registration.scope).pathname.replace(/\/$/, '');
+
+const PRECACHE = [
+ '/manifest.webmanifest',
+ '/offline.html',
+ '/assets/app.css',
+ '/assets/app.js',
+ '/assets/logo-mark.svg',
+ '/assets/favicon.svg',
+ '/assets/fonts/manrope-latin.woff2',
+ '/assets/fonts/inter-latin.woff2',
+ '/assets/img/hero-800.webp',
+ '/assets/img/hero-1280.webp',
+ '/assets/icons/icon-192.png',
+ '/assets/icons/icon-512.png',
+ '/assets/icons/icon-maskable-192.png',
+ '/assets/icons/icon-maskable-512.png',
+ '/assets/icons/apple-touch-icon-180.png'
+].map((path) => `${BASE}${path}`);
+
+const offlineUrl = `${BASE}/offline.html`;
+const assetPrefix = `${BASE}/assets/`;
+
+self.addEventListener('install', (event) => {
+ event.waitUntil(
+ caches.open(CACHE)
+ .then((cache) => cache.addAll(PRECACHE))
+ .then(() => self.skipWaiting())
+ );
+});
+
+self.addEventListener('activate', (event) => {
+ event.waitUntil(
+ caches.keys()
+ .then((keys) => Promise.all(
+ keys
+ .filter((key) => key.startsWith('dic-') && key !== CACHE)
+ .map((key) => caches.delete(key))
+ ))
+ .then(() => self.clients.claim())
+ );
+});
+
+function cacheKey(request) {
+ const url = new URL(request.url);
+ url.search = '';
+ return url.toString();
+}
+
+async function cacheFirst(event, request) {
+ const cache = await caches.open(CACHE);
+ const cached = await cache.match(request, { ignoreSearch: true });
+ const network = fetch(request)
+ .then((response) => {
+ if (response && response.ok) {
+ cache.put(cacheKey(request), response.clone());
+ }
+ return response;
+ })
+ .catch(() => null);
+
+ if (cached) {
+ event.waitUntil(network);
+ return cached;
+ }
+ return (await network) || new Response('', { status: 504, statusText: 'Offline' });
+}
+
+async function staleWhileRevalidate(event, request) {
+ const cache = await caches.open(CACHE);
+ const cached = await cache.match(request, { ignoreSearch: true });
+ const network = fetch(request)
+ .then((response) => {
+ if (response && response.ok) {
+ cache.put(cacheKey(request), response.clone());
+ }
+ return response;
+ })
+ .catch(() => null);
+
+ if (cached) {
+ event.waitUntil(network);
+ return cached;
+ }
+ return (await network) || new Response('', { status: 504, statusText: 'Offline' });
+}
+
+async function navigate(request) {
+ try {
+ return await fetch(request);
+ } catch (error) {
+ const cache = await caches.open(CACHE);
+ const offline = await cache.match(offlineUrl);
+ if (offline) {
+ return offline;
+ }
+ return new Response(
+ 'Offline '
+ + ''
+ + 'Keine Verbindung Bitte die Internetverbindung prüfen und erneut versuchen.
',
+ { status: 503, headers: { 'Content-Type': 'text/html; charset=utf-8' } }
+ );
+ }
+}
+
+self.addEventListener('fetch', (event) => {
+ const request = event.request;
+ if (request.method !== 'GET') {
+ return;
+ }
+
+ const url = new URL(request.url);
+ if (url.origin !== self.location.origin) {
+ return;
+ }
+
+ if (request.mode === 'navigate') {
+ event.respondWith(navigate(request));
+ return;
+ }
+
+ if (url.pathname.startsWith(assetPrefix)) {
+ event.respondWith(staleWhileRevalidate(event, request));
+ return;
+ }
+
+ if (url.pathname === `${BASE}/manifest.webmanifest` || url.pathname === offlineUrl) {
+ event.respondWith(cacheFirst(event, request));
+ }
+});