Files
fitme3070.pt/site/includes/contactos.php
T
andre f018fa582d feat(contactos): embed the FitMe app contact form
Replaces the Zoho form in the contacts section with the app.fitme3070.pt
site-contacto iframe (passes page URL and UTM params, auto-height).
2026-10-27 13:47:35 +00:00

122 lines
6.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// Informações e contactos — partilhado entre a home (site/index.php) e o
// CrossFit (site/crossfit.php), para as duas páginas darem sempre a mesma
// informação de contacto em vez de reencaminhar para a home só para isso.
// $data: whours, work_hours_days (Horário de Funcionamento, opcional),
// assunto (pré-preenche "Razão" no formulário), show (gym_section_on, default true).
$whours = $whours ?? [];
$work_hours_days = $work_hours_days ?? ['Segunda-Sexta' => 'segunda', 'Sábado' => 'sabado', 'Domingo/Feriados' => 'domingo'];
$assunto = $assunto ?? '';
$show = $show ?? true;
$session = session();
?>
<?php if ($show): ?>
<?php /* contacts-bg.jpg never existed — outside2.jpg is the current photo in img/contactos/ */ ?>
<section id="contactos" class="contact-section set-bg" data-setbg="<?= base_url('site/assets/img/contactos/outside2.jpg') ?>" aria-labelledby="contactos-title">
<div class="container">
<?php if (($_GET['agendar'] ?? '') === 'ok'): ?>
<div class="alert alert-success text-center" role="alert">
Pedido enviado! Entraremos em contacto para confirmar a tua aula experimental.
</div>
<?php elseif (($_GET['agendar'] ?? '') === 'erro'): ?>
<div class="alert alert-danger text-center" role="alert">
Não foi possível enviar o pedido. Verifica os dados e tenta novamente.
</div>
<?php endif; ?>
<div class="row">
<div class="col-lg-4">
<h2 id="contactos-title" class="contact-title text-center text-md-left">Informações</h2>
<div class="contact-info-warp text-center text-md-left">
<h3>Localização</h3>
<div class="contact-info">
<a href="<?= htmlspecialchars($info['google_maps_link'] ?? '') ?>" target="_blank" rel="noopener">
<p><?= htmlspecialchars($info['adress'] ?? '') ?></p>
</a>
</div>
</div>
<div class="contact-info-warp text-center text-md-left">
<h3>Telefone</h3>
<div class="contact-info">
<a href="tel:<?= htmlspecialchars(site_tel($info['phone'] ?? '')) ?>">
<p><?= htmlspecialchars($info['phone'] ?? '') ?></p>
</a>
<?php if (($info['telephone'] ?? '') !== ''): ?>
<a href="tel:<?= htmlspecialchars(site_tel($info['telephone'])) ?>">
<p><?= htmlspecialchars($info['telephone']) ?></p>
</a>
<?php endif; ?>
</div>
</div>
<div class="contact-info-warp text-center text-md-left">
<h3>E-mail</h3>
<div class="contact-info">
<a href="mailto:<?= htmlspecialchars($info['email'] ?? '') ?>">
<p><?= htmlspecialchars($info['email'] ?? '') ?></p>
</a>
<a href="#contactos">
<p><?= htmlspecialchars($info['website'] ?? '') ?></p>
</a>
</div>
</div>
<?php if ($whours): ?>
<div class="contact-info-warp text-center">
<h3>Horário de Funcionamento</h3>
<div class="contact-info wh-text text-center">
<?php foreach ($work_hours_days as $key => $value):
$ranges = [];
foreach ($whours as $h) {
if ($h['week_day'] == $value) {
$ranges[] = substr($h['open'], 0, 5) . ' – ' . substr($h['close'], 0, 5);
}
}
?>
<div class="wh-day">
<strong><?= htmlspecialchars($key) ?></strong>
<?php if ($ranges): foreach ($ranges as $r): ?><p><?= htmlspecialchars($r) ?></p><?php endforeach; ?>
<?php else: ?><p class="wh-closed">Encerrado</p><?php endif; ?>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
</div>
<div class="col-lg-8">
<div id="contact-form">
<h3 class="contact-title text-center text-md-left">Envia-nos uma mensagem</h3>
<?php /* Formulário da app FitMe (app.fitme3070.pt), em iframe; a altura acompanha o conteúdo via postMessage. */ ?>
<div id="fitme-form-site-contacto-wrap"></div>
<script>
(function () {
var p = new URLSearchParams(location.search), q = new URLSearchParams({ embed: "1", page: location.href });
["utm_source","utm_medium","utm_campaign","utm_content","utm_term"].forEach(function (k) { if (p.get(k)) q.set(k, p.get(k)); });
var f = document.createElement("iframe");
f.src = "https://app.fitme3070.pt/f/site-contacto?" + q.toString(); f.id = "fitme-form-site-contacto"; f.title = "Envia-nos uma Mensagem";
f.style.cssText = "width:100%;max-width:480px;border:0;"; f.height = "640"; f.loading = "lazy";
document.getElementById("fitme-form-site-contacto-wrap").appendChild(f);
window.addEventListener("message", function (e) {
if (e.origin === "https://app.fitme3070.pt" && e.data && e.data.type === "fitme-form-height" && e.data.slug === "site-contacto") f.style.height = e.data.height + "px";
});
})();
</script>
</div>
</div>
</div>
<?php // Mapa a toda a largura, por baixo do grid de informações + formulário ?>
<div class="row">
<div class="col-12">
<div class="map map-full" id="map">
<?php
// Defer the Google Maps iframe until the user scrolls near it.
$maps_embed = $info['google_maps'] ?? '';
if (strpos($maps_embed, 'loading=') === false) {
$maps_embed = str_replace('<iframe ', '<iframe loading="lazy" ', $maps_embed);
}
echo map_click_to_load(clean_map_embed($maps_embed), (string) ($info['google_maps_link'] ?? ''));
?>
</div>
</div>
</div>
</div>
</section>
<?php endif; ?>