Files
omsorg/omsorgWeb/mitarbeiter-app-legacy/actions/submit-abwesenheitsantrag.php
T
Felix KemmlerandClaude Sonnet 5 b6c1389c55 Reorganize into monorepo layout, move mitarbeiter-app to legacy reference
Consolidates the previously separate omsorgapp and omsorgCore repos
(each had their own nested .git with GitHub history) plus the old
root-level website/mitarbeiter-app into a single monorepo, matching
the structure already documented in the root CLAUDE.md. Also moves
the PHP employee app aside as omsorgWeb/mitarbeiter-app-legacy/ to
serve as a template for a ground-up rewrite.

Fixes .gitignore in the same pass: the config-secrets/uploads/data
patterns were unanchored (relative to repo root, not depth-agnostic),
so they silently stopped matching once the app moved under omsorgWeb/.
Patterns are now **/-prefixed and cover both mitarbeiter-app and
mitarbeiter-app-legacy, keeping DB/SMTP credentials and uploaded
employee documents out of version control.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-07 14:21:37 +02:00

74 lines
2.4 KiB
PHP

<?php
require_once __DIR__ . '/../lib/auth.php';
require_once __DIR__ . '/../lib/mail.php';
require_login();
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header('Location: ../pages/abwesenheitsantrag.php');
exit;
}
$back = '../pages/abwesenheitsantrag.php';
$von = trim($_POST['von'] ?? '');
$bis = trim($_POST['bis'] ?? '');
$grund = trim($_POST['grund'] ?? '');
$vertretung = trim($_POST['vertretung'] ?? '');
$nachricht = trim($_POST['nachricht'] ?? '');
if ($von === '' || $bis === '' || $grund === '') {
header('Location: ' . $back . '?error=' . urlencode('Von, Bis und Grund sind Pflichtfelder.'));
exit;
}
$allowed_grund = ['krankheit', 'arztbesuch', 'behoerdengang', 'sonderurlaub', 'elternzeit_pflegezeit', 'sonstiges'];
if (!in_array($grund, $allowed_grund, true)) {
header('Location: ' . $back . '?error=' . urlencode('Ungültiger Grund.'));
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;
}
$user_id = current_user()['id'];
$now = date('c');
db()->prepare(
'INSERT INTO requests_abwesenheitsantrag (user_id, status, admin_note, created_at, updated_at, von, bis, grund, vertretung, nachricht)
VALUES (?, \'pending\', \'\', ?, ?, ?, ?, ?, ?, ?)'
)->execute([$user_id, $now, $now, $von, $bis, $grund, $vertretung, $nachricht]);
$grund_labels = [
'krankheit' => 'Krankheit',
'arztbesuch' => 'Arztbesuch',
'behoerdengang' => 'Behördengang',
'sonderurlaub' => 'Sonderurlaub',
'elternzeit_pflegezeit' => 'Elternzeit / Pflegezeit',
'sonstiges' => 'Sonstiges',
];
$config = require __DIR__ . '/../lib/config.php';
smtp_send(
$config,
$config['mail_sabrina'],
'Neuer Abwesenheitsantrag: ' . current_name(),
"Ein Abwesenheitsantrag wurde eingereicht.\n\n"
. 'Mitarbeiter: ' . current_name() . "\n"
. 'Von: ' . $von . "\n"
. 'Bis: ' . $bis . "\n"
. 'Grund: ' . ($grund_labels[$grund] ?? $grund) . "\n"
. 'Vertretung: ' . ($vertretung ?: '—') . "\n"
. 'Nachricht: ' . ($nachricht ?: '—') . "\n\n"
. "---\nGesendet über OMSORG Connect"
);
header('Location: ' . $back . '?success=1');
exit;