centra e ordina per vicinanza. Fallback: Milano centro. // Distanze calcolate lato JavaScript. Nessuna modifica al database. ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); if (session_status() === PHP_SESSION_NONE) { session_start(); } require_once(__DIR__ . '/userarea/class/db-functions.php'); $pdo = DBHandlerSelect::getInstance()->getConnection(); // --- Parametri ricerca --- $q_city = trim($_GET['city'] ?? ''); $q_service = trim($_GET['service'] ?? ''); // --- Query saloni attivi (solo con coordinate: servono per la mappa) --- $where = ["sh.active = 1", "sh.latitude IS NOT NULL", "sh.longitude IS NOT NULL"]; $params = []; if ($q_city !== '') { $where[] = "sh.city = ?"; $params[] = $q_city; } if ($q_service !== '') { $where[] = "EXISTS (SELECT 1 FROM services sv WHERE sv.shop_id = sh.id AND sv.is_active = 1 AND sv.name = ?)"; $params[] = $q_service; } $whereSql = implode(' AND ', $where); $sql = " SELECT sh.id, sh.name, sh.slug, sh.description, sh.address, sh.city, sh.province, sh.phone, sh.latitude, sh.longitude, sh.logo, sh.cover_image, (SELECT MIN(sv.price) FROM services sv WHERE sv.shop_id = sh.id AND sv.is_active = 1) AS min_price FROM shops sh WHERE $whereSql ORDER BY sh.name ASC "; $stmt = $pdo->prepare($sql); $stmt->execute($params); $salons = $stmt->fetchAll(PDO::FETCH_ASSOC); $totalSalons = count($salons); // Città e servizi per i filtri della booking-bar $cities = $pdo->query(" SELECT DISTINCT city FROM shops WHERE active = 1 AND city IS NOT NULL AND city <> '' ORDER BY city ASC ")->fetchAll(PDO::FETCH_COLUMN); $allServices = $pdo->query(" SELECT DISTINCT name FROM services WHERE is_active = 1 AND name IS NOT NULL AND name <> '' ORDER BY name ASC ")->fetchAll(PDO::FETCH_COLUMN); // Preferiti dell'utente loggato $favIds = []; if (!empty($_SESSION['iduserlogin'])) { $fstmt = $pdo->prepare("SELECT shop_id FROM user_favorite_shops WHERE user_id = ?"); $fstmt->execute([$_SESSION['iduserlogin']]); $favIds = $fstmt->fetchAll(PDO::FETCH_COLUMN); } // Dati saloni per il JavaScript (mappa + distanze) $salonsJs = array_map(function ($s) { return [ 'id' => (int)$s['id'], 'name' => $s['name'], 'slug' => $s['slug'], 'city' => $s['city'], 'address'=> $s['address'], 'lat' => (float)$s['latitude'], 'lng' => (float)$s['longitude'], 'logo' => $s['logo'], 'price' => $s['min_price'] !== null ? (float)$s['min_price'] : null, ]; }, $salons); ?>

Trova il tuo parrucchiere

salon a

Nessun salone trovato

Prova a cambiare città o servizio.