getConnection(); // Verifica che iduserlogin sia definito if (!isset($iduserlogin)) { die("Errore: ID utente non definito."); } // Recupera i dati della scuola in base all'utente loggato $stmt = $pdo->prepare(" SELECT id, name, website, email, phone, description, address_street, address_city, address_postal_code, address_province, address_country, logo, status FROM schools WHERE owner_id = ? "); $stmt->execute([$iduserlogin]); $school = $stmt->fetch(); if (!$school) { die("Errore: Nessuna scuola trovata per l'utente loggato."); } $school_id = $school['id']; $product_id = $_GET['product_id'] ?? 0; // Verifica che il prodotto appartenga alla scuola $stmt = $pdo->prepare("SELECT id FROM products WHERE id = ? AND school_id = ?"); $stmt->execute([$product_id, $school_id]); if (!$stmt->fetch()) { die("Errore: Prodotto non trovato o non autorizzato."); } $stmt = $pdo->prepare("SELECT class_type_id FROM product_class_types WHERE product_id = ?"); $stmt->execute([$product_id]); $class_types = $stmt->fetchAll(PDO::FETCH_COLUMN); header('Content-Type: application/json'); echo json_encode($class_types);