false, "data" => [], "message" => ""]; try { $db = DBHandlerSelect::getInstance(); $pdo = $db->getConnection(); if (!$pdo) { throw new Exception('Database connection failed.'); } // Recupera solo i template attivi $stmt = $pdo->query("SELECT id, button_label, button_size, button_bg_color, button_text_color, source_type FROM excel_templates WHERE status = 'active' ORDER BY button_label ASC"); $templates = $stmt->fetchAll(PDO::FETCH_ASSOC); $response["success"] = true; $response["data"] = $templates; } catch (PDOException $e) { $response["message"] = "Database error: " . $e->getMessage(); } catch (Exception $e) { $response["message"] = "Error: " . $e->getMessage(); } echo json_encode($response);