fix categ
Deploy HouseHub / deploy (push) Successful in 2s

This commit is contained in:
FeFeClochette committed 2026-09-09 12:49:20 +02:00
1 parent 8a7b5b6644
commit dc8a2e5244
5 files changed
+66 -26

No files matched your search

+11 -1
View File
@@ -1,6 +1,7 @@
<?php
require __DIR__ . '/../../../../includes/auth.php';
require __DIR__ . '/../../../../includes/db.php';
require_once __DIR__ . '/../../../../includes/i18n.php';
require_login();
header('Content-Type: application/json');
@@ -105,6 +106,15 @@ try {
if ($action === 'delete_category') {
$id = (int)($_POST['id'] ?? 0);
$stmtCheck = $pdo->prepare("SELECT code FROM pf_budget_categories WHERE id = ?");
$stmtCheck->execute([$id]);
$catCode = $stmtCheck->fetchColumn();
if ($catCode && in_array(strtoupper($catCode), ['FIXED', 'INCOME'])) {
throw new Exception(tr('bud_err_delete_system_cat'));
}
$stmt = $pdo->prepare("DELETE FROM pf_budget_categories WHERE id = ?");
$stmt->execute([$id]);
echo json_encode(['success' => true]);
@@ -188,7 +198,7 @@ try {
throw new Exception("Action API inconnue.");
} catch (Exception $e) {
} catch (\Throwable $e) {
http_response_code(400);
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}