feat: complete package 2 delete flows and package 3 port management
This commit is contained in:
@@ -2,30 +2,48 @@
|
||||
/**
|
||||
* app/modules/floor_infrastructure/delete.php
|
||||
*
|
||||
* Loescht Patchpanels oder Wandbuchsen.
|
||||
* Loescht Patchpanels oder Wandbuchsen (AJAX-POST bevorzugt).
|
||||
*/
|
||||
|
||||
$type = strtolower(trim((string)($_GET['type'] ?? '')));
|
||||
$id = (int)($_GET['id'] ?? 0);
|
||||
$isPost = ($_SERVER['REQUEST_METHOD'] ?? '') === 'POST';
|
||||
$type = strtolower(trim((string)($_POST['type'] ?? $_GET['type'] ?? '')));
|
||||
$id = (int)($_POST['id'] ?? $_GET['id'] ?? 0);
|
||||
|
||||
if ($id <= 0 || !in_array($type, ['patchpanel', 'outlet'], true)) {
|
||||
if ($isPost) {
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
http_response_code(400);
|
||||
echo json_encode(['success' => false, 'message' => 'Ungueltige Anfrage']);
|
||||
exit;
|
||||
}
|
||||
header('Location: ?module=floor_infrastructure&action=list');
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($type === 'patchpanel') {
|
||||
$sql->set(
|
||||
$rows = $sql->set(
|
||||
"DELETE FROM floor_patchpanels WHERE id = ?",
|
||||
"i",
|
||||
[$id]
|
||||
);
|
||||
} else {
|
||||
$sql->set(
|
||||
$rows = $sql->set(
|
||||
"DELETE FROM network_outlets WHERE id = ?",
|
||||
"i",
|
||||
[$id]
|
||||
);
|
||||
}
|
||||
|
||||
if ($isPost) {
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
if ($rows > 0) {
|
||||
echo json_encode(['success' => true, 'message' => 'Infrastrukturobjekt geloescht']);
|
||||
} else {
|
||||
http_response_code(404);
|
||||
echo json_encode(['success' => false, 'message' => 'Infrastrukturobjekt nicht gefunden oder bereits geloescht']);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Location: ?module=floor_infrastructure&action=list');
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user