fix(gyms): saving no longer fails before the brand-colour migration; upload header image and logo instead of typing paths
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
965a123834
commit
a85bec6851
5 files changed
+104
-26
No files matched your search
@@ -41,9 +41,16 @@ foreach (array_keys(gym_sections()) as $k) if (gym_section_on($data, $k)) $secti
|
||||
<input class="form-control" name="hero_subtitle" maxlength="150" placeholder="& Acompanhamento" value="<?= htmlspecialchars($data['hero_subtitle'] ?? '') ?>">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Imagem do header</label>
|
||||
<input class="form-control font-monospace" name="hero_image" maxlength="255" placeholder="site/assets/img/home.jpg" value="<?= htmlspecialchars($data['hero_image'] ?? '') ?>">
|
||||
<div class="form-text">Caminho de uma imagem do site. Vazio = a do ginásio principal.</div>
|
||||
<label class="form-label" for="hero_file">Imagem do header</label>
|
||||
<?php if (($data['hero_image'] ?? '') !== ''): ?>
|
||||
<div class="mb-2"><img src="<?= htmlspecialchars(base_url($data['hero_image'])) ?>" alt="" class="rounded border" style="max-width:100%;max-height:110px;object-fit:cover"></div>
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="hero_image" value="<?= htmlspecialchars($data['hero_image'] ?? '') ?>">
|
||||
<input type="file" class="form-control" id="hero_file" name="hero_file" accept="image/jpeg,image/png,image/webp">
|
||||
<div class="form-text">JPG, PNG ou WebP (até 6 MB). Vazio = a do ginásio principal.</div>
|
||||
<?php if (($data['hero_image'] ?? '') !== ''): ?>
|
||||
<div class="form-check mt-1"><input class="form-check-input" type="checkbox" name="hero_remove" value="1" id="hero_remove"><label class="form-check-label small" for="hero_remove">Remover a imagem atual</label></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Galeria das instalações</label>
|
||||
@@ -87,9 +94,19 @@ foreach (array_keys(gym_sections()) as $k) if (gym_section_on($data, $k)) $secti
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Logótipo (botão no menu dos outros ginásios)</label>
|
||||
<input class="form-control font-monospace" name="logo" maxlength="255" placeholder="site/assets/img/logos/ginasio.svg" value="<?= htmlspecialchars($data['logo'] ?? '') ?>">
|
||||
<div class="form-text">Opcional. Aparece a uma só cor (a do texto do botão); funciona melhor com SVG de uma cor.</div>
|
||||
<label class="form-label" for="logo_file">Logótipo (botão no menu dos outros ginásios)</label>
|
||||
<?php if (($data['logo'] ?? '') !== ''): ?>
|
||||
<div class="mb-2"><img src="<?= htmlspecialchars(base_url($data['logo'])) ?>" alt="" class="rounded border p-2" style="max-width:100%;max-height:70px;background:#e9ecef"></div>
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="logo" value="<?= htmlspecialchars($data['logo'] ?? '') ?>">
|
||||
<input type="file" class="form-control" id="logo_file" name="logo_file" accept="image/svg+xml,image/png,image/webp,image/jpeg">
|
||||
<div class="form-text">SVG, PNG, WebP ou JPG (até 6 MB). Opcional. Aparece a uma só cor (a do texto do botão); funciona melhor com SVG de uma cor.</div>
|
||||
<?php if (!_gyms_has_col($pdo, 'gyms', 'logo')): ?>
|
||||
<div class="form-text text-warning">Falta aplicar a migração <code>migration_20261013_gym_brand_color.sql</code> (Sistema → Atualizar plataforma) para guardar o logótipo e a cor da marca.</div>
|
||||
<?php endif; ?>
|
||||
<?php if (($data['logo'] ?? '') !== ''): ?>
|
||||
<div class="form-check mt-1"><input class="form-check-input" type="checkbox" name="logo_remove" value="1" id="logo_remove"><label class="form-check-label small" for="logo_remove">Remover o logótipo atual</label></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="col-sm-6 col-lg-4">
|
||||
<label class="form-label" for="brand_color">Cor da marca</label>
|
||||
|
||||
@@ -42,7 +42,7 @@ include __DIR__ . '/../../../includes/header.php';
|
||||
<a class="btn btn-outline-secondary btn-sm" href="index.php"><i class="bi bi-arrow-left me-1"></i>Voltar</a>
|
||||
</div>
|
||||
<?php foreach ($errors as $e): ?><div class="alert alert-danger"><?= htmlspecialchars($e) ?></div><?php endforeach; ?>
|
||||
<form method="POST" class="card shadow-sm"><div class="card-body">
|
||||
<form method="POST" enctype="multipart/form-data" class="card shadow-sm"><div class="card-body">
|
||||
<?= csrf_field() ?>
|
||||
<?php include __DIR__ . '/_form.php'; ?>
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
}
|
||||
if (!$errors) {
|
||||
$changed = db_gyms_update($pdo, $id, $data);
|
||||
// Uploaded images that were replaced or removed are no longer referenced.
|
||||
foreach (['hero_image', 'logo'] as $f) if (($item[$f] ?? '') !== ($data[$f] ?? '')) gyms_remove_image($item[$f] ?? '');
|
||||
session()->setFlashdata($changed ? 'success' : 'warning', $changed ? 'Ginásio atualizado.' : 'Nenhuma alteração.');
|
||||
header('Location: ' . base_url('views/admin/gyms/edit.php?id=' . $id));
|
||||
exit;
|
||||
@@ -47,7 +49,7 @@ include __DIR__ . '/../../../includes/header.php';
|
||||
<button class="btn btn-sm btn-primary text-nowrap">Editar conteúdo deste</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<form method="POST" class="card shadow-sm"><div class="card-body">
|
||||
<form method="POST" enctype="multipart/form-data" class="card shadow-sm"><div class="card-body">
|
||||
<?= csrf_field() ?>
|
||||
<?php include __DIR__ . '/_form.php'; ?>
|
||||
<div class="mt-4 d-flex gap-2">
|
||||
|
||||
Reference in new issue
Block a user