28 lines
835 B
PHP
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);
|