Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
55 lines
1.6 KiB
PHP
55 lines
1.6 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../lib/auth.php';
|
|
require_once __DIR__ . '/../lib/db.php';
|
|
require_login();
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
header('Location: ../pages/einsatzbewertung.php');
|
|
exit;
|
|
}
|
|
|
|
$back = '../pages/einsatzbewertung.php';
|
|
|
|
$einsatzort = trim($_POST['einsatzort'] ?? '');
|
|
$von = trim($_POST['von'] ?? '');
|
|
$bis = trim($_POST['bis'] ?? '');
|
|
$bewertung = (int)($_POST['bewertung'] ?? 0);
|
|
$wieder = isset($_POST['wieder']) ? 1 : 0;
|
|
$feedback = trim($_POST['feedback'] ?? '');
|
|
|
|
if ($einsatzort === '') {
|
|
header('Location: ' . $back . '?error=' . urlencode('Bitte den Einsatzort angeben.'));
|
|
exit;
|
|
}
|
|
|
|
if ($von === '' || $bis === '') {
|
|
header('Location: ' . $back . '?error=' . urlencode('Von und Bis sind Pflichtfelder.'));
|
|
exit;
|
|
}
|
|
|
|
if (!strtotime($von) || !strtotime($bis)) {
|
|
header('Location: ' . $back . '?error=' . urlencode('Ungültiges Datum.'));
|
|
exit;
|
|
}
|
|
|
|
if (strtotime($von) > strtotime($bis)) {
|
|
header('Location: ' . $back . '?error=' . urlencode('Das Startdatum muss vor dem Enddatum liegen.'));
|
|
exit;
|
|
}
|
|
|
|
if ($bewertung < 1 || $bewertung > 5) {
|
|
header('Location: ' . $back . '?error=' . urlencode('Bitte eine Bewertung von 1 bis 5 Sternen auswählen.'));
|
|
exit;
|
|
}
|
|
|
|
$user_id = current_user()['id'];
|
|
$now = date('c');
|
|
|
|
db()->prepare(
|
|
'INSERT INTO einsatzbewertungen (user_id, einsatzort, von, bis, bewertung, wieder, feedback, created_at)
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
|
|
)->execute([$user_id, $einsatzort, $von, $bis, $bewertung, $wieder, $feedback, $now]);
|
|
|
|
header('Location: ' . $back . '?success=1');
|
|
exit;
|