Initial import of fitme3070.pt platform
Plain-PHP fleet platform with id.andmore.pt SSO. Wires shared/platform-tools as a submodule (platform_update, backups, git/migration tools) like the other platforms. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
commit
e68d357177
2330 files changed
+215968
No files matched your search
@@ -0,0 +1,80 @@
|
||||
<?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();
|
||||
|
||||
$errors = [];
|
||||
$data = ['nome' => '', 'cor' => '#808080', 'icon' => '', 'descricao' => '', 'item_order' => 0];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
csrf_check();
|
||||
$data = [
|
||||
'nome' => trim($_POST['nome'] ?? ''),
|
||||
'cor' => trim($_POST['cor'] ?? '#808080'),
|
||||
'icon' => trim($_POST['icon'] ?? ''),
|
||||
'descricao' => trim($_POST['descricao'] ?? ''),
|
||||
'item_order' => (int) ($_POST['item_order'] ?? 0),
|
||||
];
|
||||
if ($data['nome'] === '') $errors[] = 'O nome é obrigatório.';
|
||||
|
||||
// An uploaded image, if any, wins over the typed icon filename.
|
||||
if (!$errors) {
|
||||
$icon_err = null;
|
||||
$uploaded = modalidades_icon_upload($_FILES['icon_file'] ?? [], $icon_err);
|
||||
if ($icon_err) $errors[] = $icon_err;
|
||||
elseif ($uploaded) $data['icon'] = $uploaded;
|
||||
}
|
||||
|
||||
if (!$errors) {
|
||||
$id = db_modalidades_create($pdo, $data);
|
||||
session()->setFlashdata('success', 'Modalidade criada.');
|
||||
header('Location: ' . base_url('views/admin/modalidades/edit.php?id=' . $id));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$icons = db_flaticon_list($pdo);
|
||||
$page_title = 'Adicionar Modalidade';
|
||||
include __DIR__ . '/../../../includes/header.php';
|
||||
?>
|
||||
<div class="container" style="max-width:700px;">
|
||||
<h1 class="h3 mb-4">Adicionar Modalidade</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="nome" required value="<?= htmlspecialchars($data['nome']) ?>"></div>
|
||||
<div class="col-md-4"><label class="form-label">Cor</label>
|
||||
<input type="color" class="form-control form-control-color" name="cor" value="<?= htmlspecialchars($data['cor']) ?>"></div>
|
||||
<div class="col-md-6"><label class="form-label">Ícone (nome do ficheiro)</label>
|
||||
<input class="form-control" name="icon" placeholder="ex: crossfit.png" value="<?= htmlspecialchars($data['icon']) ?>">
|
||||
<div class="form-text">Escolha um da biblioteca abaixo, ou carregue um novo.</div></div>
|
||||
<div class="col-md-6"><label class="form-label">Carregar imagem</label>
|
||||
<input type="file" class="form-control" name="icon_file" accept=".png,.jpg,.jpeg,.gif,.webp,.svg">
|
||||
<div class="form-text">Substitui o nome acima. Máx. 2 MB.</div></div>
|
||||
<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>
|
||||
</div>
|
||||
<?php if ($icons): ?>
|
||||
<div class="mt-3"><label class="form-label small text-muted">Ícones disponíveis</label>
|
||||
<div class="d-flex flex-wrap gap-3">
|
||||
<?php foreach ($icons as $icon): ?>
|
||||
<div class="text-center" style="width:90px">
|
||||
<img src="<?= base_url('uploads/modalidades/icons/' . $icon['name']) ?>" alt="" style="height:28px" onerror="this.style.display='none'">
|
||||
<div class="small text-muted text-truncate"><?= htmlspecialchars($icon['name']) ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<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'; ?>
|
||||
Reference in new issue
Block a user