theloftstore/public/userarea/load_active_templates.php
2025-03-08 08:34:00 +01:00

28 lines
835 B
PHP

<?php
header('Content-Type: application/json');
require_once 'class/db-functions.php';
$response = ["success" => 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_bg_color, button_text_color, button_size FROM excel_templates WHERE status = 'active'");
$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);