feat: vários ginásios (/3070/ e /<código postal>/), CRUD de ginásios, modalidades após a galeria
Estrutura multi-ginásio: as mesmas secções do site, conteúdo próprio por ginásio, e cada um numa pasta da URL com o código postal da zona. - migration_20260926_gyms: tabela gyms (pasta, nome, localidade, publicado, principal, secções visíveis, título/imagem do header, SEO, galeria, Place ID, página CrossFit) com o FitMe 3070 como ginásio 1 em /3070/; gym_id em team, modalidades (o horário segue a modalidade), work_hours, memberships, membership_leads e website_offer (tudo o existente → ginásio 1); events com gym_id NULL = todos; fitme3070_info passa a uma linha por ginásio (id = gym). - Site: /<pasta>/, /<pasta>/crossfit, /<pasta>/agendar|inscricao. Ginásio por publicar → 404 para o público, pré-visualização (com faixa) para a equipa. / e /home → 301 para o ginásio principal (a manter a query); com mais de um ginásio publicado, a raiz passa a uma página para escolher. Secções desligadas não aparecem nem no menu; menu, canonical, JSON-LD, sitemap, formulários, e-mails e reviews (Place ID e cache) são do ginásio. - Backoffice: Gestão → Ginásios (criar/editar/apagar, secções, e «começar com o conteúdo de» outro ginásio — cópias independentes) e o seletor «A editar» no topo; equipa, modalidades, horários, horário de funcionamento, mensalidades, pedidos, contactos e reviews trabalham sobre o ginásio escolhido, e um registo de outro ginásio não abre. - Modalidades passam para logo a seguir à galeria das instalações. - Galeria sem cantos arredondados (raio da marca). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2f8f68c61a
commit
5e300fc341
33 files changed
+1146
-197
No files matched your search
@@ -14,23 +14,27 @@ function memberships_defaults(): array {
|
||||
}
|
||||
|
||||
function db_memberships_list(PDO $pdo, bool $include_deleted = false): array {
|
||||
$sql = "SELECT * FROM memberships";
|
||||
if (!$include_deleted) $sql .= " WHERE deleted_at IS NULL";
|
||||
// Scoped to the gym being edited in the backoffice (functions_gyms.php).
|
||||
$sql = "SELECT * FROM memberships WHERE gym_id = " . admin_gym_id();
|
||||
if (!$include_deleted) $sql .= " AND deleted_at IS NULL";
|
||||
$sql .= " ORDER BY deleted_at IS NOT NULL, item_order, name";
|
||||
return $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
// Public list: active, not deleted. Defensive — the table may not exist yet on
|
||||
// an install that hasn't run the migration.
|
||||
function site_memberships(PDO $pdo): array {
|
||||
function site_memberships(PDO $pdo, ?int $gym_id = null): array {
|
||||
try {
|
||||
return $pdo->query(
|
||||
"SELECT * FROM memberships WHERE deleted_at IS NULL AND is_active = 1 ORDER BY item_order, name"
|
||||
)->fetchAll(PDO::FETCH_ASSOC);
|
||||
$st = $pdo->prepare(
|
||||
"SELECT * FROM memberships WHERE deleted_at IS NULL AND is_active = 1 AND gym_id = ? ORDER BY item_order, name"
|
||||
);
|
||||
$st->execute([$gym_id ?? (int) current_gym()['id']]);
|
||||
return $st->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (Throwable $e) { return []; }
|
||||
}
|
||||
|
||||
function db_memberships_get(PDO $pdo, int $id): ?array {
|
||||
// Any gym (the public sign-up handler checks the gym itself).
|
||||
$stmt = $pdo->prepare("SELECT * FROM memberships WHERE id = ? LIMIT 1");
|
||||
$stmt->execute([$id]);
|
||||
return $stmt->fetch(PDO::FETCH_ASSOC) ?: null;
|
||||
@@ -70,7 +74,11 @@ function _memberships_params(array $d): array {
|
||||
}
|
||||
|
||||
function _memberships_clear_featured(PDO $pdo, int $except): void {
|
||||
$pdo->prepare("UPDATE memberships SET is_featured = 0 WHERE id <> ? AND is_featured = 1")->execute([$except]);
|
||||
// One featured card per gym.
|
||||
$pdo->prepare("UPDATE memberships SET is_featured = 0
|
||||
WHERE id <> ? AND is_featured = 1
|
||||
AND gym_id = (SELECT g FROM (SELECT gym_id AS g FROM memberships WHERE id = ?) x)")
|
||||
->execute([$except, $except]);
|
||||
}
|
||||
|
||||
function db_memberships_create(PDO $pdo, array $d): int {
|
||||
@@ -78,10 +86,10 @@ function db_memberships_create(PDO $pdo, array $d): int {
|
||||
$stmt = $pdo->prepare("
|
||||
INSERT INTO memberships (name, subtitle, price, is_addon, price_suffix, features,
|
||||
is_featured, featured_label, cta_label, item_order, is_active,
|
||||
created_at, updated_at)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?, NOW(), NOW())
|
||||
gym_id, created_at, updated_at)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?, NOW(), NOW())
|
||||
");
|
||||
$stmt->execute(_memberships_params($d));
|
||||
$stmt->execute(array_merge(_memberships_params($d), [admin_gym_id()]));
|
||||
$id = (int) $pdo->lastInsertId();
|
||||
if ($d['is_featured']) _memberships_clear_featured($pdo, $id);
|
||||
$pdo->commit();
|
||||
@@ -142,8 +150,8 @@ function membership_lead_statuses(): array {
|
||||
}
|
||||
|
||||
function db_membership_leads_list(PDO $pdo, string $status = ''): array {
|
||||
$sql = "SELECT * FROM membership_leads WHERE deleted_at IS NULL";
|
||||
$args = [];
|
||||
$sql = "SELECT * FROM membership_leads WHERE deleted_at IS NULL AND gym_id = ?";
|
||||
$args = [admin_gym_id()];
|
||||
if ($status !== '' && isset(membership_lead_statuses()[$status])) { $sql .= " AND status = ?"; $args[] = $status; }
|
||||
$sql .= " ORDER BY created_at DESC, id DESC";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
@@ -152,17 +160,18 @@ function db_membership_leads_list(PDO $pdo, string $status = ''): array {
|
||||
}
|
||||
|
||||
function db_membership_leads_count_new(PDO $pdo): int {
|
||||
try { return (int) $pdo->query("SELECT COUNT(*) FROM membership_leads WHERE status = 'novo' AND deleted_at IS NULL")->fetchColumn(); }
|
||||
try { return (int) $pdo->query("SELECT COUNT(*) FROM membership_leads WHERE status = 'novo' AND deleted_at IS NULL AND gym_id = " . admin_gym_id())->fetchColumn(); }
|
||||
catch (Throwable $e) { return 0; }
|
||||
}
|
||||
|
||||
function db_membership_lead_create(PDO $pdo, array $d): int {
|
||||
$stmt = $pdo->prepare("
|
||||
INSERT INTO membership_leads (membership_id, membership_name, name, email, phone, message,
|
||||
INSERT INTO membership_leads (gym_id, membership_id, membership_name, name, email, phone, message,
|
||||
consent, consent_text, ip, user_agent, created_at, updated_at)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?, NOW(), NOW())
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?, NOW(), NOW())
|
||||
");
|
||||
$stmt->execute([
|
||||
(int) ($d['gym_id'] ?? current_gym()['id']),
|
||||
$d['membership_id'] ?: null,
|
||||
mb_substr((string) ($d['membership_name'] ?? ''), 0, 100),
|
||||
mb_substr(trim((string) ($d['name'] ?? '')), 0, 150),
|
||||
|
||||
Reference in new issue
Block a user