This commit is contained in:
andre committed 2026-06-12 21:20:23 +01:00
1 parent e68d357177
commit 3e3382df57
65 files changed
+1836 -42

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../config/db.php';
require __DIR__ . '/../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
// Counts for the dashboard widgets.
$counts = [
+104
View File
@@ -0,0 +1,104 @@
<?php
// Shared event form fields, rendered inside the <form> of both create.php and
// edit.php. Expects:
// $data : associative array with every events column (see events_defaults())
// $item : the existing row on edit (for the current hero preview), or null
$item = $item ?? null;
// datetime-local inputs want "YYYY-MM-DDTHH:MM"; DB gives "YYYY-MM-DD HH:MM:SS".
$dt = static function ($v): string {
$v = trim((string) $v);
if ($v === '' || $v === '0000-00-00 00:00:00') return '';
return substr(str_replace(' ', 'T', $v), 0, 16);
};
?>
<div class="row g-3">
<div class="col-md-8">
<label class="form-label">Título <span class="text-danger">*</span></label>
<input class="form-control" name="title" required maxlength="180" value="<?= htmlspecialchars($data['title'] ?? '') ?>">
</div>
<div class="col-md-4">
<label class="form-label">Cor de destaque</label>
<input type="color" class="form-control form-control-color" name="cor" value="<?= htmlspecialchars($data['cor'] ?? '#C2D500') ?>">
</div>
<div class="col-12">
<label class="form-label">Subtítulo</label>
<input class="form-control" name="subtitle" maxlength="255" value="<?= htmlspecialchars($data['subtitle'] ?? '') ?>">
<div class="form-text">Frase curta mostrada por baixo do título no topo da página.</div>
</div>
<div class="col-12">
<label class="form-label">Resumo</label>
<textarea class="form-control" name="summary" rows="2" maxlength="400"><?= htmlspecialchars($data['summary'] ?? '') ?></textarea>
<div class="form-text">Texto curto usado no banner da página inicial.</div>
</div>
<div class="col-12">
<label class="form-label">Descrição (conteúdo da página)</label>
<textarea class="form-control js-wysiwyg" data-wysiwyg-height="320" name="description" rows="8"><?= htmlspecialchars($data['description'] ?? '') ?></textarea>
<div class="form-text">Editor de texto formatado — é o corpo da landing page.</div>
</div>
<div class="col-md-6">
<label class="form-label">Imagem de destaque (hero)</label>
<input type="file" class="form-control" name="hero_file" accept=".png,.jpg,.jpeg,.gif,.webp">
<div class="form-text">Fundo do topo da landing page. Máx. 6&nbsp;MB.</div>
<?php if ($item && !empty($item['hero_image'])): ?>
<div class="mt-2 d-flex align-items-center gap-2">
<img src="<?= base_url('uploads/events/' . rawurlencode($item['hero_image'])) ?>" alt="" style="height:48px;border-radius:4px;">
<div class="form-check mb-0">
<input class="form-check-input" type="checkbox" name="remove_hero" id="remove_hero" value="1">
<label class="form-check-label small" for="remove_hero">Remover imagem atual</label>
</div>
</div>
<?php endif; ?>
</div>
<div class="col-md-6">
<label class="form-label">Local</label>
<input class="form-control" name="location" maxlength="200" value="<?= htmlspecialchars($data['location'] ?? '') ?>">
<div class="form-text">Onde decorre o evento (opcional).</div>
</div>
<div class="col-12"><hr class="my-1"><span class="small text-uppercase text-muted fw-semibold">Quando decorre o evento</span></div>
<div class="col-md-6">
<label class="form-label">Início do evento</label>
<input type="datetime-local" class="form-control" name="event_starts_at" value="<?= htmlspecialchars($dt($data['event_starts_at'] ?? '')) ?>">
</div>
<div class="col-md-6">
<label class="form-label">Fim do evento</label>
<input type="datetime-local" class="form-control" name="event_ends_at" value="<?= htmlspecialchars($dt($data['event_ends_at'] ?? '')) ?>">
</div>
<div class="col-12"><hr class="my-1"><span class="small text-uppercase text-muted fw-semibold">Janela de publicação no site</span></div>
<div class="col-md-6">
<label class="form-label">Publicar a partir de <span class="text-danger">*</span></label>
<input type="datetime-local" class="form-control" name="publish_from" required value="<?= htmlspecialchars($dt($data['publish_from'] ?? '')) ?>">
</div>
<div class="col-md-6">
<label class="form-label">Publicar até <span class="text-danger">*</span></label>
<input type="datetime-local" class="form-control" name="publish_until" required value="<?= htmlspecialchars($dt($data['publish_until'] ?? '')) ?>">
</div>
<div class="col-12">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" name="is_active" id="is_active" value="1" <?= (int) ($data['is_active'] ?? 1) === 1 ? 'checked' : '' ?>>
<label class="form-check-label" for="is_active">Ativo (interruptor manual — só aparece dentro da janela acima)</label>
</div>
</div>
<div class="col-12"><hr class="my-1"><span class="small text-uppercase text-muted fw-semibold">Chamada para ação &amp; inscrições</span></div>
<div class="col-md-6">
<label class="form-label">Texto do botão</label>
<input class="form-control" name="cta_label" maxlength="80" placeholder="ex: Inscreve-te já!" value="<?= htmlspecialchars($data['cta_label'] ?? '') ?>">
</div>
<div class="col-md-6">
<label class="form-label">Link do botão</label>
<input class="form-control" name="cta_url" maxlength="255" placeholder="(vazio = ir para o formulário abaixo)" value="<?= htmlspecialchars($data['cta_url'] ?? '') ?>">
<div class="form-text">URL externo ou âncora. Em branco, o botão desce até ao formulário de inscrição.</div>
</div>
<div class="col-12">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" name="show_lead_form" id="show_lead_form" value="1" <?= (int) ($data['show_lead_form'] ?? 1) === 1 ? 'checked' : '' ?>>
<label class="form-check-label" for="show_lead_form">Mostrar formulário de inscrição na landing page</label>
</div>
</div>
</div>
+73
View File
@@ -0,0 +1,73 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = require_admin();
$errors = [];
$data = events_defaults();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
csrf_check();
$data = [
'title' => trim($_POST['title'] ?? ''),
'slug' => trim($_POST['slug'] ?? ''),
'subtitle' => trim($_POST['subtitle'] ?? ''),
'summary' => trim($_POST['summary'] ?? ''),
'description' => trim($_POST['description'] ?? ''),
'cor' => trim($_POST['cor'] ?? '#C2D500'),
'location' => trim($_POST['location'] ?? ''),
'event_starts_at' => trim($_POST['event_starts_at'] ?? ''),
'event_ends_at' => trim($_POST['event_ends_at'] ?? ''),
'publish_from' => trim($_POST['publish_from'] ?? ''),
'publish_until' => trim($_POST['publish_until'] ?? ''),
'is_active' => isset($_POST['is_active']) ? 1 : 0,
'cta_label' => trim($_POST['cta_label'] ?? ''),
'cta_url' => trim($_POST['cta_url'] ?? ''),
'show_lead_form' => isset($_POST['show_lead_form']) ? 1 : 0,
'hero_image' => '',
];
if ($data['title'] === '') $errors[] = 'O título é obrigatório.';
if ($data['publish_from'] === '') $errors[] = 'A data de início da publicação é obrigatória.';
if ($data['publish_until'] === '') $errors[] = 'A data de fim da publicação é obrigatória.';
if ($data['publish_from'] !== '' && $data['publish_until'] !== ''
&& strtotime($data['publish_until']) < strtotime($data['publish_from'])) {
$errors[] = 'A data de fim da publicação não pode ser anterior à de início.';
}
if (!$errors) {
$hero_err = null;
$uploaded = events_image_upload($_FILES['hero_file'] ?? [], $hero_err);
if ($hero_err) $errors[] = $hero_err;
elseif ($uploaded) $data['hero_image'] = $uploaded;
}
if (!$errors) {
$data['slug'] = events_make_slug($pdo, $data['slug'] !== '' ? $data['slug'] : $data['title']);
$id = db_events_create($pdo, $data);
session()->setFlashdata('success', 'Evento criado.');
header('Location: ' . base_url('views/admin/events/edit.php?id=' . $id));
exit;
}
}
$page_title = 'Adicionar Evento';
include __DIR__ . '/../../../includes/header.php';
?>
<div class="container" style="max-width:820px;">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="h3 mb-0">Adicionar Evento</h1>
<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" 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">
<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'; ?>
+167
View File
@@ -0,0 +1,167 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = require_admin();
$id = (int) ($_GET['id'] ?? 0);
if (!$id) { header('Location: index.php'); exit; }
if (isset($_GET['restore'])) {
csrf_check();
db_events_restore($pdo, $id);
session()->setFlashdata('success', 'Evento restaurado.');
header('Location: ' . base_url('views/admin/events/edit.php?id=' . $id));
exit;
}
$item = db_events_get($pdo, $id);
if (!$item) { header('Location: index.php'); exit; }
// Delete a single lead.
if (isset($_POST['delete_lead'])) {
csrf_check();
db_event_lead_delete($pdo, (int) $_POST['delete_lead'], $id);
session()->setFlashdata('success', 'Inscrição removida.');
header('Location: ' . base_url('views/admin/events/edit.php?id=' . $id . '#leads'));
exit;
}
$errors = [];
$data = $item;
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['save_event'])) {
csrf_check();
$data = [
'title' => trim($_POST['title'] ?? ''),
'slug' => trim($_POST['slug'] ?? ''),
'subtitle' => trim($_POST['subtitle'] ?? ''),
'summary' => trim($_POST['summary'] ?? ''),
'description' => trim($_POST['description'] ?? ''),
'cor' => trim($_POST['cor'] ?? '#C2D500'),
'location' => trim($_POST['location'] ?? ''),
'event_starts_at' => trim($_POST['event_starts_at'] ?? ''),
'event_ends_at' => trim($_POST['event_ends_at'] ?? ''),
'publish_from' => trim($_POST['publish_from'] ?? ''),
'publish_until' => trim($_POST['publish_until'] ?? ''),
'is_active' => isset($_POST['is_active']) ? 1 : 0,
'cta_label' => trim($_POST['cta_label'] ?? ''),
'cta_url' => trim($_POST['cta_url'] ?? ''),
'show_lead_form' => isset($_POST['show_lead_form']) ? 1 : 0,
'hero_image' => $item['hero_image'],
];
if ($data['title'] === '') $errors[] = 'O título é obrigatório.';
if ($data['publish_from'] === '') $errors[] = 'A data de início da publicação é obrigatória.';
if ($data['publish_until'] === '') $errors[] = 'A data de fim da publicação é obrigatória.';
if ($data['publish_from'] !== '' && $data['publish_until'] !== ''
&& strtotime($data['publish_until']) < strtotime($data['publish_from'])) {
$errors[] = 'A data de fim da publicação não pode ser anterior à de início.';
}
// Hero: a new upload replaces the current image; an explicit "remover" clears it.
$uploaded = null;
if (!$errors) {
$hero_err = null;
$uploaded = events_image_upload($_FILES['hero_file'] ?? [], $hero_err);
if ($hero_err) $errors[] = $hero_err;
}
if (!$errors) {
if ($uploaded) {
events_image_remove($item['hero_image']);
$data['hero_image'] = $uploaded;
} elseif (!empty($_POST['remove_hero'])) {
events_image_remove($item['hero_image']);
$data['hero_image'] = '';
}
// Slug: keep the field's value (auto-regenerate from title only if emptied).
$data['slug'] = events_make_slug($pdo, $data['slug'] !== '' ? $data['slug'] : $data['title'], $id);
db_events_update($pdo, $id, $data);
session()->setFlashdata('success', 'Evento atualizado.');
header('Location: ' . base_url('views/admin/events/edit.php?id=' . $id));
exit;
}
// On error keep the existing slug for the form.
$data['slug'] = $item['slug'];
}
$leads = db_event_leads_list($pdo, $id);
$status = events_status($item);
$page_title = 'Editar Evento';
include __DIR__ . '/../../../includes/header.php';
?>
<div class="container" style="max-width:820px;">
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h1 class="h3 mb-0">Editar Evento</h1>
<div class="small text-muted">/evento/<?= htmlspecialchars($item['slug']) ?></div>
</div>
<div class="d-flex gap-2">
<?php if (events_is_live($item)): ?>
<a class="btn btn-outline-secondary btn-sm" href="<?= base_url('evento/' . rawurlencode($item['slug'])) ?>" target="_blank" rel="noopener"><i class="bi bi-box-arrow-up-right me-1"></i>Ver página</a>
<?php endif; ?>
<a class="btn btn-outline-secondary btn-sm" href="index.php"><i class="bi bi-arrow-left me-1"></i>Voltar</a>
</div>
</div>
<?php if ($item['deleted_at']): ?>
<div class="alert alert-warning d-flex justify-content-between align-items-center">
<span>Este evento está apagado.</span>
<form method="POST" action="<?= base_url('views/admin/events/edit.php?id=' . $id . '&restore=1') ?>" class="mb-0">
<?= csrf_field() ?><button class="btn btn-sm btn-info">Restaurar</button>
</form>
</div>
<?php endif; ?>
<?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 mb-4"><div class="card-body">
<?= csrf_field() ?>
<input type="hidden" name="save_event" value="1">
<div class="mb-3">
<label class="form-label">Slug (URL)</label>
<input class="form-control" name="slug" value="<?= htmlspecialchars($data['slug'] ?? '') ?>">
<div class="form-text">Deixe em branco para gerar a partir do título.</div>
</div>
<?php include __DIR__ . '/_form.php'; ?>
<div class="mt-4 d-flex gap-2">
<button type="submit" class="btn btn-primary">Atualizar</button>
<a class="btn btn-outline-secondary" href="index.php">Cancelar</a>
</div>
</div></form>
<!-- ── Inscrições (leads) ─────────────────────────────────────────────── -->
<div class="card shadow-sm" id="leads"><div class="card-body">
<h2 class="h5 mb-3">Inscrições <span class="badge bg-secondary"><?= count($leads) ?></span></h2>
<?php if (!$leads): ?>
<p class="text-muted mb-0">Ainda não há inscrições para este evento.</p>
<?php else: ?>
<div class="table-responsive">
<table class="table table-sm table-hover align-middle mb-0">
<thead class="table-light"><tr>
<th>Data</th><th>Nome</th><th>Email</th><th>Telefone</th><th>Mensagem</th><th class="text-center">Consent.</th><th></th>
</tr></thead>
<tbody>
<?php foreach ($leads as $lead): ?>
<tr>
<td class="small text-nowrap"><?= htmlspecialchars(format_date_pt((string) $lead['created_at'])) ?></td>
<td><?= htmlspecialchars($lead['name']) ?></td>
<td class="small"><?php if ($lead['email']): ?><a href="mailto:<?= htmlspecialchars($lead['email']) ?>"><?= htmlspecialchars($lead['email']) ?></a><?php else: ?><span class="text-muted">—</span><?php endif; ?></td>
<td class="small"><?= $lead['phone'] !== '' ? htmlspecialchars($lead['phone']) : '<span class="text-muted">—</span>' ?></td>
<td class="small" style="max-width:240px;"><?= $lead['message'] !== '' ? nl2br(htmlspecialchars($lead['message'])) : '<span class="text-muted">—</span>' ?></td>
<td class="text-center"><?php if (!empty($lead['consent'])): ?><span class="badge bg-success" title="<?= htmlspecialchars($lead['ip'] ?? '') ?>"><i class="bi bi-check-lg"></i></span><?php else: ?><span class="badge bg-secondary">—</span><?php endif; ?></td>
<td>
<form method="POST" class="mb-0" onsubmit="return confirm('Remover esta inscrição?')">
<?= csrf_field() ?>
<button class="btn btn-sm btn-outline-danger" name="delete_lead" value="<?= (int) $lead['lead_id'] ?>"><i class="bi bi-trash"></i></button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div></div>
</div>
<?php include __DIR__ . '/../../../includes/footer.php'; ?>
+82
View File
@@ -0,0 +1,82 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = require_admin();
// Handle delete BEFORE any output
if (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
csrf_check();
db_events_delete($pdo, (int) $_GET['delete']);
session()->setFlashdata('success', 'Evento apagado.');
header('Location: ' . base_url('views/admin/events/index.php'));
exit;
}
$items = db_events_list($pdo, true); // include soft-deleted so they can be restored
// Status badge styling + label (PT).
$badge = [
'active' => ['bg-success', 'Ativo'],
'scheduled' => ['bg-info text-dark', 'Agendado'],
'expired' => ['bg-secondary', 'Expirado'],
'inactive' => ['bg-warning text-dark', 'Inativo'],
'deleted' => ['bg-dark', 'Apagado'],
];
$page_title = 'Eventos';
include __DIR__ . '/../../../includes/header.php';
?>
<div class="container">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="h3 mb-0">Eventos</h1>
<a class="btn btn-primary" href="<?= base_url('views/admin/events/create.php') ?>"><i class="bi bi-plus-lg me-1"></i>Adicionar Evento</a>
</div>
<div class="card shadow-sm"><div class="card-body p-0">
<table class="table table-hover align-middle mb-0">
<thead class="table-light"><tr>
<th>Evento</th><th>Estado</th><th>Janela de publicação</th><th class="text-center">Leads</th><th style="width:160px">Ações</th>
</tr></thead>
<tbody>
<?php if (!$items): ?>
<tr><td colspan="5" class="text-center text-muted py-4">Nenhum evento. <a href="<?= base_url('views/admin/events/create.php') ?>">Criar o primeiro</a>.</td></tr>
<?php else: ?>
<?php foreach ($items as $item):
$status = events_status($item);
[$cls, $lbl] = $badge[$status] ?? ['bg-light text-dark', $status];
$leads = db_event_leads_count($pdo, (int) $item['e_id']);
?>
<tr<?= $item['deleted_at'] ? ' class="opacity-50"' : '' ?>>
<td>
<strong><?= htmlspecialchars($item['title']) ?></strong>
<?php if ($item['summary']): ?><div class="small text-muted text-truncate" style="max-width:340px;"><?= htmlspecialchars($item['summary']) ?></div><?php endif; ?>
<div class="small text-muted">/evento/<?= htmlspecialchars($item['slug']) ?></div>
</td>
<td><span class="badge <?= $cls ?>"><?= $lbl ?></span></td>
<td class="small">
<?= htmlspecialchars(format_date_pt((string) $item['publish_from'])) ?>
&rarr;
<?= htmlspecialchars(format_date_pt((string) $item['publish_until'])) ?>
</td>
<td class="text-center"><?= $leads > 0 ? '<span class="badge bg-primary">' . $leads . '</span>' : '<span class="text-muted">0</span>' ?></td>
<td>
<?php if ($item['deleted_at']): ?>
<form method="POST" action="<?= base_url('views/admin/events/edit.php?id=' . $item['e_id'] . '&restore=1') ?>" class="d-inline">
<?= csrf_field() ?>
<button class="btn btn-sm btn-outline-info">Restaurar</button>
</form>
<?php else: ?>
<?php if (events_is_live($item)): ?>
<a class="btn btn-sm btn-outline-secondary" href="<?= base_url('evento/' . rawurlencode($item['slug'])) ?>" target="_blank" rel="noopener" title="Ver página"><i class="bi bi-box-arrow-up-right"></i></a>
<?php endif; ?>
<a class="btn btn-sm btn-outline-primary" href="edit.php?id=<?= $item['e_id'] ?>"><i class="bi bi-pencil"></i></a>
<a class="btn btn-sm btn-outline-danger" href="?delete=<?= $item['e_id'] ?>" onclick="return confirm('Apagar este evento?')"><i class="bi bi-trash"></i></a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; endif; ?>
</tbody>
</table>
</div></div>
</div>
<?php include __DIR__ . '/../../../includes/footer.php';
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
$errors = [];
$name = '';
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
$id = (int) ($_GET['id'] ?? 0);
if (!$id) { header('Location: index.php'); exit; }
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
// Handle delete BEFORE any output
if (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
$dias = ['segunda'=>'Segunda','terça'=>'Terça','quarta'=>'Quarta','quinta'=>'Quinta','sexta'=>'Sexta','sábado'=>'Sábado','domingo'=>'Domingo'];
$salas = ['sala1'=>'Sala 1','sala2'=>'Sala 2','crossfit'=>'CrossFit',''=>'Outro'];
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
$errors = [];
$data = ['id_modalidade' => '', 'dia_semana' => '', 'hora_inicio' => '09:00', 'hora_fim' => '10:00', 'local' => 'sala1'];
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
$id = (int) ($_GET['id'] ?? 0);
if (!$id) { header('Location: index.php'); exit; }
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
// Handle delete BEFORE any output
if (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
/* ── Background image upload (AJAX, JSON) ─────────────────────────────────────
Mirrors the fotografia "Spots IG" generator: saves a reusable background under
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
$errors = [];
$data = ['nome' => '', 'cor' => '#808080', 'icon' => '', 'descricao' => '', 'item_order' => 0];
@@ -57,7 +57,7 @@ include __DIR__ . '/../../../includes/header.php';
<div class="col-md-3"><label class="form-label">Ordem</label>
<input type="number" class="form-control" name="item_order" value="<?= (int) $data['item_order'] ?>" min="0"></div>
<div class="col-12"><label class="form-label">Descrição</label>
<textarea class="form-control" name="descricao" rows="3"><?= htmlspecialchars($data['descricao']) ?></textarea></div>
<textarea class="form-control js-wysiwyg" data-wysiwyg-height="200" name="descricao" rows="3"><?= htmlspecialchars($data['descricao']) ?></textarea></div>
</div>
<?php if ($icons): ?>
<div class="mt-3"><label class="form-label small text-muted">Ícones disponíveis</label>
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
$id = (int) ($_GET['id'] ?? 0);
if (!$id) { header('Location: index.php'); exit; }
@@ -89,7 +89,7 @@ include __DIR__ . '/../../../includes/header.php';
<div class="col-md-3"><label class="form-label">Ordem</label>
<input type="number" class="form-control" name="item_order" value="<?= (int) ($data['item_order'] ?? 0) ?>" min="0"></div>
<div class="col-12"><label class="form-label">Descrição</label>
<textarea class="form-control" name="descricao" rows="3"><?= htmlspecialchars($data['descricao'] ?? '') ?></textarea></div>
<textarea class="form-control js-wysiwyg" data-wysiwyg-height="200" name="descricao" rows="3"><?= htmlspecialchars($data['descricao'] ?? '') ?></textarea></div>
</div>
<?php if ($icons): ?>
<div class="mt-3"><label class="form-label small text-muted">Ícones disponíveis</label>
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
// Handle delete BEFORE any output
if (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
$errors = [];
$data = ['name' => '', 'birthday' => '', 'at' => '', 'status' => 'ativo', 'description' => ''];
@@ -71,7 +71,7 @@ include __DIR__ . '/../../../includes/header.php';
<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">Descrição</label>
<textarea class="form-control" name="description" rows="3"><?= htmlspecialchars($data['description']) ?></textarea></div>
<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>
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
$id = (int) ($_GET['id'] ?? 0);
if (!$id) { header('Location: index.php'); exit; }
@@ -93,7 +93,7 @@ include __DIR__ . '/../../../includes/header.php';
<input type="file" class="form-control" name="photo" accept=".jpg,.jpeg,.png,.gif,.webp">
</div>
<div class="col-12"><label class="form-label">Descrição</label>
<textarea class="form-control" name="description" rows="3"><?= htmlspecialchars($data['description'] ?? '') ?></textarea></div>
<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">Atualizar</button>
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
// Handle delete BEFORE any output
if (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
$errors = [];
$data = ['week_day' => '', 'open' => '09:00', 'close' => '18:00'];
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
$id = (int) ($_GET['id'] ?? 0);
if (!$id) { header('Location: index.php'); exit; }
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../../config/db.php';
require __DIR__ . '/../../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
// Handle delete BEFORE any output
if (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
+1 -1
View File
@@ -3,5 +3,5 @@ $repo_root = dirname(__DIR__, 2);
require_once $repo_root . '/config/db.php';
require_once $repo_root . '/config/functions.php';
require_once $repo_root . '/config/functions_backup.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_sysadmin();
$user = require_sysadmin();
require $repo_root . '/shared/platform-tools/backups.php';
+1 -1
View File
@@ -2,5 +2,5 @@
$repo_root = dirname(__DIR__, 2);
require_once $repo_root . '/config/db.php';
require_once $repo_root . '/config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_sysadmin();
$user = require_sysadmin();
require $repo_root . '/shared/platform-tools/platform_update.php';
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../config/db.php';
require __DIR__ . '/../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
$logo_dir = __DIR__ . '/../../assets/img/logo/';
$allowed_ext = ['png', 'jpg', 'jpeg', 'svg', 'webp'];
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../config/db.php';
require __DIR__ . '/../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"client"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_login();
$user = require_login();
include __DIR__ . '/../../includes/header.php';
?>
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../config/db.php';
require __DIR__ . '/../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
$user = require_admin();
$users = $pdo->query(
"SELECT id, name, email, phone, role, is_active, andmore_id, last_login_at, last_login_ua
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require __DIR__ . '/../../config/db.php';
require __DIR__ . '/../../config/functions.php';
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"client"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_login();
$user = require_login();
// Editable per-tenant fields only. Name/email are owned by Andmore ID and synced
// on login by sso_resolve_session(); the password is managed centrally.