Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
74 lines
2.2 KiB
PHP
74 lines
2.2 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../lib/auth.php';
|
|
require_once __DIR__ . '/../lib/upload.php';
|
|
require_once __DIR__ . '/../lib/mail.php';
|
|
require_login();
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
header('Location: ../pages/fortbildungsantrag.php');
|
|
exit;
|
|
}
|
|
|
|
$back = '../pages/fortbildungsantrag.php';
|
|
|
|
$anliegen = trim($_POST['anliegen'] ?? '');
|
|
$thema = trim($_POST['thema'] ?? '');
|
|
$nachricht = trim($_POST['nachricht'] ?? '');
|
|
|
|
$allowed_anliegen = ['wbl_pdl', 'fortbildung', 'pflichtschulung'];
|
|
if (!in_array($anliegen, $allowed_anliegen, true)) {
|
|
redirect_error($back, 'Bitte ein Anliegen auswählen.');
|
|
}
|
|
|
|
if ($thema === '') {
|
|
redirect_error($back, 'Bitte ein Thema angeben.');
|
|
}
|
|
|
|
$up = handle_upload($_FILES['datei'] ?? [], [
|
|
'allowed' => UPLOAD_TYPES_DOCS,
|
|
'dir' => dirname(__DIR__) . '/uploads/',
|
|
'prefix' => 'fortbildung',
|
|
'required' => false,
|
|
]);
|
|
if (!$up['ok']) {
|
|
redirect_error($back, $up['error']);
|
|
}
|
|
|
|
$filename = $up['filename'] ?? '';
|
|
$original_name = $up['original_name'] ?? '';
|
|
$mime = $up['mime'] ?? null;
|
|
|
|
$user_id = current_user()['id'];
|
|
$now = date('c');
|
|
|
|
db()->prepare(
|
|
'INSERT INTO requests_fortbildungsantrag
|
|
(user_id, status, admin_note, anliegen, thema, nachricht, filename, original_name, created_at, updated_at)
|
|
VALUES (?, \'pending\', \'\', ?, ?, ?, ?, ?, ?, ?)'
|
|
)->execute([$user_id, $anliegen, $thema, $nachricht, $filename, $original_name, $now, $now]);
|
|
|
|
$anliegen_labels = [
|
|
'wbl_pdl' => 'WBL / PDL',
|
|
'fortbildung' => 'Fortbildung',
|
|
'pflichtschulung' => 'Pflichtschulung',
|
|
];
|
|
|
|
$config = require __DIR__ . '/../lib/config.php';
|
|
$attach = ($filename !== '')
|
|
? ['path' => dirname(__DIR__) . '/uploads/' . $filename, 'name' => $original_name, 'mime' => $mime]
|
|
: [];
|
|
smtp_send(
|
|
$config,
|
|
$config['mail_info'],
|
|
'Neuer Fortbildungsantrag: ' . current_name(),
|
|
"Ein Fortbildungsantrag wurde eingereicht.\n\n"
|
|
. 'Mitarbeiter: ' . current_name() . "\n"
|
|
. 'Anliegen: ' . ($anliegen_labels[$anliegen] ?? $anliegen) . "\n"
|
|
. 'Thema: ' . $thema . "\n"
|
|
. 'Nachricht: ' . ($nachricht ?: '—') . "\n\n"
|
|
. "---\nGesendet über OMSORG Connect",
|
|
$attach
|
|
);
|
|
|
|
redirect_ok($back);
|