This commit is contained in:
ninortbrgr
2025-10-10 13:45:59 +02:00
parent edde9f07fc
commit fa830f892e
16 changed files with 748 additions and 0 deletions

40
backend/save_ticket.php Normal file
View File

@@ -0,0 +1,40 @@
<?php
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo "Method not allowed";
exit;
}
$title = trim($_POST['title'] ?? '');
$description = trim($_POST['description'] ?? '');
$category = $_POST['category'] ?? 'Sonstiges';
$room = trim($_POST['room'] ?? '');
$name = trim($_POST['name'] ?? '');
$date = date("Y-m-d H:i:s");
$newTicket = [
'title' => $title,
'description' => $description,
'category' => $category,
'room' => $room,
'name' => $name,
'status' => 'To-Do',
'date' => $date
];
$ticketsPath = __DIR__ . '/tickets.json';
$tickets = [];
if (file_exists($ticketsPath)) {
$json = file_get_contents($ticketsPath);
$tickets = json_decode($json, true);
if (!is_array($tickets)) $tickets = [];
}
$tickets[] = $newTicket;
file_put_contents($ticketsPath, json_encode($tickets, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), LOCK_EX);
// Redirect zurück ins Dashboard oder zur Hauptseite
header('Location: ../index.html?success=1');
exit;