div TODOs

This commit is contained in:
2026-02-16 13:56:01 +01:00
parent 12141485ae
commit 510a248edb
36 changed files with 1500 additions and 1533 deletions

View File

@@ -0,0 +1,36 @@
<?php
/**
* app/modules/floors/delete.php
*/
header('Content-Type: application/json; charset=utf-8');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo json_encode(['success' => false, 'message' => 'Methode nicht erlaubt']);
exit;
}
$id = (int)($_POST['id'] ?? $_GET['id'] ?? 0);
if ($id <= 0) {
http_response_code(400);
echo json_encode(['success' => false, 'message' => 'ID fehlt']);
exit;
}
$exists = $sql->single("SELECT id FROM floors WHERE id = ?", "i", [$id]);
if (!$exists) {
http_response_code(404);
echo json_encode(['success' => false, 'message' => 'Stockwerk nicht gefunden']);
exit;
}
$rows = $sql->set("DELETE FROM floors WHERE id = ?", "i", [$id]);
if ($rows === false) {
http_response_code(500);
echo json_encode(['success' => false, 'message' => 'Loeschen fehlgeschlagen']);
exit;
}
echo json_encode(['success' => true, 'message' => 'Stockwerk geloescht']);

View File

@@ -10,7 +10,7 @@
// =========================
// Filter einlesen
// =========================
$search = trim($_GET['search'] ?? '');
$search = trim($_GET['search'] ?? ');
// =========================
// Floors laden
@@ -19,7 +19,7 @@ $whereClause = "";
$types = "";
$params = [];
if ($search !== '') {
if ($search !== ') {
$whereClause = "WHERE f.name LIKE ? OR f.comment LIKE ?";
$types = "ss";
$params = ["%$search%", "%$search%"];
@@ -105,7 +105,7 @@ $buildings = $sql->get("SELECT id, name FROM buildings ORDER BY name", "", []);
</td>
<td>
<small><?php echo htmlspecialchars($floor['comment'] ?? ''); ?></small>
<small><?php echo htmlspecialchars($floor['comment'] ?? '); ?></small>
</td>
<td class="actions">
@@ -233,9 +233,24 @@ $buildings = $sql->get("SELECT id, name FROM buildings ORDER BY name", "", []);
<script>
function confirmDelete(id) {
if (confirm('Dieses Stockwerk wirklich löschen? Alle Räume und Racks werden gelöscht.')) {
// TODO: AJAX-Delete implementieren
alert('Löschen noch nicht implementiert');
if (confirm('Dieses Stockwerk wirklich loeschen? Alle Raeume und Racks werden geloescht.')) {
fetch('?module=floors&action=delete', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
body: 'id=' + encodeURIComponent(id)
})
.then((res) => res.json())
.then((data) => {
if (data && data.success) {
window.location.reload();
return;
}
alert((data && data.message) ? data.message : 'Loeschen fehlgeschlagen');
})
.catch(() => {
alert('Loeschen fehlgeschlagen');
});
}
}
</script>