getConnection(); $id = (int)($_POST['id'] ?? 0); $name = trim($_POST['name'] ?? ''); $description = trim($_POST['description'] ?? ''); $is_problem = isset($_POST['is_problem']) ? (int)$_POST['is_problem'] : 0; if ($id <= 0) { echo json_encode(['success' => false, 'message' => 'ID non valido.']); exit; } if ($name === '') { echo json_encode(['success' => false, 'message' => 'Il nome รจ obbligatorio.']); exit; } try { $stmt = $pdo->prepare(" UPDATE pause_reasons SET name = :name, description = :description, is_problem = :is_problem WHERE id = :id "); $stmt->execute([ ':name' => $name, ':description' => $description !== '' ? $description : null, ':is_problem' => $is_problem, ':id' => $id ]); echo json_encode(['success' => true]); } catch (Exception $e) { echo json_encode(['success' => false, 'message' => $e->getMessage()]); }