Files

101 lines
4.2 KiB
PHP

<?php
/**
* card-salon.php — card singolo salone (parziale, va dentro un foreach)
* Richiede: $salon (array con i campi della tabella shops)
* Opzionale: $favIds (array di shop_id già nei preferiti dell'utente loggato)
*/
if (!isset($salon)) return;
$favIds = $favIds ?? [];
$sid = (int)$salon['id'];
$name = htmlspecialchars($salon['name'] ?? 'Salone');
$slug = urlencode($salon['slug'] ?? '');
$city = htmlspecialchars($salon['city'] ?? '');
$prov = htmlspecialchars($salon['province'] ?? '');
$cover = !empty($salon['cover_image']) ? htmlspecialchars($salon['cover_image']) : 'assets/img/tour/list/01.jpg';
$isFav = in_array($sid, $favIds, true);
// Link "indicazioni" con coordinate se presenti
if (isset($salon['latitude'], $salon['longitude']) && $salon['latitude'] !== null && $salon['longitude'] !== null) {
$mapUrl = 'https://www.google.com/maps/dir/?api=1&destination='
. rawurlencode($salon['latitude'] . ',' . $salon['longitude']);
} else {
$mapUrl = 'https://www.google.com/maps/search/?api=1&query='
. rawurlencode(trim(($salon['address'] ?? '') . ' ' . ($salon['city'] ?? '')));
}
// Prezzo minimo servizi, se la pagina lo ha calcolato e passato in $salon['min_price']
$minPrice = isset($salon['min_price']) && $salon['min_price'] !== null ? (float)$salon['min_price'] : null;
?>
<div class="tp-tour-item mb-40">
<div class="tp-tour-thumb p-relative fix">
<a href="salon.php?slug=<?= $slug ?>" class="image">
<img src="<?= $cover ?>" alt="<?= $name ?>">
</a>
<!-- Preferito (cuore) -->
<span class="tp-tour-wishlist js-fav <?= $isFav ? 'is-active' : '' ?>" data-id="<?= $sid ?>" title="Preferito" role="button" tabindex="0" aria-pressed="<?= $isFav ? 'true' : 'false' ?>" style="cursor:pointer;">
<i class="<?= $isFav ? 'fa-solid' : 'fa-regular' ?> fa-heart"></i>
</span>
<!-- Azioni rapide -->
<div class="tp-tour-media-meta">
<a href="<?= htmlspecialchars($mapUrl) ?>" target="_blank" rel="noopener" title="Indicazioni">
<i class="fa-solid fa-map-location-dot"></i>
</a>
</div>
</div>
<div class="tp-tour-content">
<?php /* Recensioni disattivate per ora — riattivare con tabella reviews
<div class="tp-tour-meta d-flex align-items-center">
<div class="tp-tour-review mr-5"> ...stelle... </div>
<span class="tp-tour-review-score tp-ff-inter">( 0 recensioni )</span>
</div>
*/ ?>
<h3 class="tp-tour-title fw-500 mb-10">
<a href="salon.php?slug=<?= $slug ?>"><?= $name ?></a>
</h3>
<?php if (!empty($salon['description'])): ?>
<p class="tp-tour-dec mb-20">
<?= htmlspecialchars(mb_strimwidth($salon['description'], 0, 90, '…')) ?>
</p>
<?php endif; ?>
<div class="tp-tour-info">
<span>
<i class="fa-solid fa-location-dot"></i>
<?php
$addr = trim($salon['address'] ?? '');
$loc = $addr !== '' ? $addr : '';
$loc .= $city ? ($loc ? ', ' . $city : $city) : '';
$loc .= $prov ? ' (' . $prov . ')' : '';
echo htmlspecialchars($loc ?: '—');
?>
</span>
<?php if (!empty($salon['phone'])): ?>
<span>
<i class="fa-solid fa-phone"></i>
<?= htmlspecialchars($salon['phone']) ?>
</span>
<?php endif; ?>
</div>
<div class="tp-tour-footer d-flex justify-content-between gap-2 align-items-center">
<div class="tp-tour-price">
<?php if ($minPrice !== null): ?>
<div class="tp-tour-bottom-price">
<span class="tp-tour-prefix">Da:</span>
<span class="tp-tour-new-price fw-700"><?= number_format($minPrice, 2, ',', '.') ?> €</span>
</div>
<?php endif; ?>
</div>
<div class="tp-tour-btn">
<a href="salon.php?slug=<?= $slug ?>" class="tp-btn-sm fw-500 tp-ff-inter">Prenota</a>
</div>
</div>
</div>
</div>