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:
andreandClaude Opus 4.8 committed 2026-06-12 10:44:58 +01:00
commit e68d357177
2330 files changed
+215968

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
<?php
// ─── Team CRUD helpers ─────────────────────────────────────────────────────────
// Soft-delete via deleted_at. All functions accept PDO $pdo as first argument.
// Used by views/admin/team/*.php
function db_team_list(PDO $pdo, bool $include_deleted = false): array {
$sql = "SELECT * FROM team";
if (!$include_deleted) $sql .= " WHERE deleted_at IS NULL";
$sql .= " ORDER BY FIELD(status,'ativo','inativo'), name";
return $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
}
function db_team_get(PDO $pdo, int $id): ?array {
$stmt = $pdo->prepare("SELECT * FROM team WHERE id = ? LIMIT 1");
$stmt->execute([$id]);
return $stmt->fetch(PDO::FETCH_ASSOC) ?: null;
}
function db_team_create(PDO $pdo, array $data): int {
$stmt = $pdo->prepare("
INSERT INTO team (name, birthday, `at`, status, description, photo, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, NOW(), NOW())
");
$stmt->execute([
$data['name'],
$data['birthday'] ?: null,
$data['at'] ?: null,
$data['status'] ?? 'ativo',
$data['description'] ?? null,
$data['photo'] ?? null,
]);
return (int) $pdo->lastInsertId();
}
function db_team_update(PDO $pdo, int $id, array $data, ?string $photo = null): bool {
$sets = ["name = ?", "birthday = ?", "`at` = ?", "status = ?", "description = ?", "updated_at = NOW()"];
$params = [
$data['name'],
$data['birthday'] ?: null,
$data['at'] ?: null,
$data['status'] ?? 'ativo',
$data['description'] ?? null,
];
if ($photo !== null) {
$sets[] = "photo = ?";
$params[] = $photo;
}
$params[] = $id;
$stmt = $pdo->prepare("UPDATE team SET " . implode(', ', $sets) . " WHERE id = ?");
$stmt->execute($params);
return $stmt->rowCount() > 0;
}
function db_team_delete(PDO $pdo, int $id): bool {
$stmt = $pdo->prepare("UPDATE team SET deleted_at = NOW() WHERE id = ? AND deleted_at IS NULL");
$stmt->execute([$id]);
return $stmt->rowCount() > 0;
}
function db_team_restore(PDO $pdo, int $id): bool {
$stmt = $pdo->prepare("UPDATE team SET deleted_at = NULL WHERE id = ? AND deleted_at IS NOT NULL");
$stmt->execute([$id]);
return $stmt->rowCount() > 0;
}