- Contactos: nova página no backoffice (fitme3070_info) e 964 201 137 como telefone principal; o telefone secundário só aparece quando existe. - Equipa: título, aptidões/funções e formações; o cartão mostra foto, nome e título e abre um cartão horizontal de detalhe (hover no desktop, toque no telemóvel) sem mexer na grelha. - Mensalidades: cartões editáveis com um destaque, modal de inscrição que guarda o pedido (RGPD + estado + campos reservados para o CRM) e avisa o ginásio por e-mail; lista de pedidos com estados, notas e CSV. - Reviews Google via Places API (New), filtradas por classificação mínima e em cache configurável; página de configuração com pesquisa do Place ID. - Assets com ?v=<mtime>: site/assets é servido com cache imutável de 1 ano. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
95 lines
5.5 KiB
PHP
95 lines
5.5 KiB
PHP
<?php
|
|
require __DIR__ . '/../../../config/db.php';
|
|
require __DIR__ . '/../../../config/functions.php';
|
|
$user = require_admin();
|
|
|
|
$errors = [];
|
|
$data = ['name' => '', 'title' => '', 'birthday' => '', 'at' => '', 'status' => 'ativo', 'description' => '',
|
|
'skills' => '', 'certifications' => ''];
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
csrf_check();
|
|
$data = [
|
|
'name' => trim($_POST['name'] ?? ''),
|
|
'birthday' => trim($_POST['birthday'] ?? ''),
|
|
'at' => trim($_POST['at'] ?? ''),
|
|
'status' => $_POST['status'] ?? 'ativo',
|
|
'description' => trim($_POST['description'] ?? ''),
|
|
'title' => mb_substr(trim($_POST['title'] ?? ''), 0, 100),
|
|
'skills' => trim($_POST['skills'] ?? ''),
|
|
'certifications' => trim($_POST['certifications'] ?? ''),
|
|
];
|
|
if ($data['name'] === '') $errors[] = 'O nome é obrigatório.';
|
|
|
|
// Photo upload
|
|
$photo_name = null;
|
|
if (!empty($_FILES['photo']['tmp_name']) && $_FILES['photo']['error'] === UPLOAD_ERR_OK) {
|
|
$ext = strtolower(pathinfo($_FILES['photo']['name'], PATHINFO_EXTENSION));
|
|
if (!in_array($ext, ['jpg','jpeg','png','gif','webp'])) $errors[] = 'Formato de foto inválido.';
|
|
else {
|
|
$upload_dir = __DIR__ . '/../../../uploads/team/foto/';
|
|
if (!is_dir($upload_dir)) @mkdir($upload_dir, 0775, true);
|
|
$photo_name = bin2hex(random_bytes(16)) . '.' . $ext;
|
|
if (!move_uploaded_file($_FILES['photo']['tmp_name'], $upload_dir . $photo_name)) {
|
|
$errors[] = 'Falha ao guardar a foto.';
|
|
$photo_name = null;
|
|
} else {
|
|
img_optimize($upload_dir . $photo_name, IMG_MAX_TEAM);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!$errors) {
|
|
$data['photo'] = $photo_name;
|
|
$id = db_team_create($pdo, $data);
|
|
session()->setFlashdata('success', 'Membro criado com sucesso.');
|
|
header('Location: ' . base_url('views/admin/team/edit.php?id=' . $id));
|
|
exit;
|
|
}
|
|
}
|
|
|
|
$page_title = 'Adicionar Membro';
|
|
include __DIR__ . '/../../../includes/header.php';
|
|
?>
|
|
<div class="container" style="max-width:700px;">
|
|
<h1 class="h3 mb-4">Adicionar Membro</h1>
|
|
<?php foreach ($errors as $e): ?><div class="alert alert-danger"><?= htmlspecialchars($e) ?></div><?php endforeach; ?>
|
|
|
|
<form method="POST" enctype="multipart/form-data" class="card shadow-sm"><div class="card-body">
|
|
<?= csrf_field() ?>
|
|
<div class="row g-3">
|
|
<div class="col-md-8"><label class="form-label">Nome <span class="text-danger">*</span></label>
|
|
<input class="form-control" name="name" required value="<?= htmlspecialchars($data['name']) ?>"></div>
|
|
<div class="col-md-4"><label class="form-label">Nascimento</label>
|
|
<input type="date" class="form-control" name="birthday" value="<?= htmlspecialchars($data['birthday']) ?>"></div>
|
|
<div class="col-md-4"><label class="form-label">Área</label>
|
|
<select class="form-select" name="at"><option value="">—</option>
|
|
<option value="gym" <?= $data['at'] === 'gym' ? 'selected' : '' ?>>Gym</option>
|
|
<option value="crossfit" <?= $data['at'] === 'crossfit' ? 'selected' : '' ?>>CrossFit</option>
|
|
</select></div>
|
|
<div class="col-md-4"><label class="form-label">Estado</label>
|
|
<select class="form-select" name="status">
|
|
<option value="ativo" <?= $data['status'] === 'ativo' ? 'selected' : '' ?>>Ativo</option>
|
|
<option value="inativo" <?= $data['status'] === 'inativo' ? 'selected' : '' ?>>Inativo</option>
|
|
</select></div>
|
|
<div class="col-md-4"><label class="form-label">Foto</label>
|
|
<input type="file" class="form-control" name="photo" accept=".jpg,.jpeg,.png,.gif,.webp"></div>
|
|
<div class="col-12"><label class="form-label">Título</label>
|
|
<input class="form-control" name="title" maxlength="100" placeholder="ex.: Personal Trainer · Coach CrossFit" value="<?= htmlspecialchars($data['title'] ?? '') ?>">
|
|
<div class="form-text">Aparece no site por baixo do nome.</div></div>
|
|
<div class="col-md-6"><label class="form-label">Aptidões / Funções</label>
|
|
<textarea class="form-control" name="skills" rows="5" placeholder="Uma por linha"><?= htmlspecialchars($data['skills'] ?? '') ?></textarea></div>
|
|
<div class="col-md-6"><label class="form-label">Formações</label>
|
|
<textarea class="form-control" name="certifications" rows="5" placeholder="Uma por linha"><?= htmlspecialchars($data['certifications'] ?? '') ?></textarea></div>
|
|
<div class="col-12"><div class="form-text mt-0">Aptidões e formações aparecem no cartão de detalhe do site (hover no computador, toque no telemóvel).</div></div>
|
|
<div class="col-12"><label class="form-label">Descrição <span class="text-muted small">(opcional — aparece no cartão de detalhe)</span></label>
|
|
<textarea class="form-control js-wysiwyg" data-wysiwyg-height="200" name="description" rows="3"><?= htmlspecialchars($data['description']) ?></textarea></div>
|
|
</div>
|
|
<div class="mt-4 d-flex gap-2">
|
|
<button type="submit" class="btn btn-primary">Guardar</button>
|
|
<a class="btn btn-outline-secondary" href="index.php">Cancelar</a>
|
|
</div>
|
|
</div></form>
|
|
</div>
|
|
<?php include __DIR__ . '/../../../includes/footer.php'; ?>
|