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>
35 lines
1.4 KiB
PHP
35 lines
1.4 KiB
PHP
<?php
|
|
// ─── Work hours (Horário de Funcionamento) CRUD helpers ────────────────────────
|
|
// Simple table: id, week_day (enum), open (time), close (time).
|
|
|
|
function db_whours_list(PDO $pdo): array {
|
|
return $pdo->query("
|
|
SELECT * FROM work_hours
|
|
ORDER BY FIELD(week_day,'segunda','terça','quarta','quinta','sexta','sabado','domingo','feriados')
|
|
")->fetchAll(PDO::FETCH_ASSOC);
|
|
}
|
|
|
|
function db_whours_get(PDO $pdo, int $id): ?array {
|
|
$stmt = $pdo->prepare("SELECT * FROM work_hours WHERE id = ? LIMIT 1");
|
|
$stmt->execute([$id]);
|
|
return $stmt->fetch(PDO::FETCH_ASSOC) ?: null;
|
|
}
|
|
|
|
function db_whours_create(PDO $pdo, array $data): int {
|
|
$stmt = $pdo->prepare("INSERT INTO work_hours (week_day, open, close) VALUES (?, ?, ?)");
|
|
$stmt->execute([$data['week_day'], $data['open'], $data['close']]);
|
|
return (int) $pdo->lastInsertId();
|
|
}
|
|
|
|
function db_whours_update(PDO $pdo, int $id, array $data): bool {
|
|
$stmt = $pdo->prepare("UPDATE work_hours SET week_day = ?, open = ?, close = ? WHERE id = ?");
|
|
$stmt->execute([$data['week_day'], $data['open'], $data['close'], $id]);
|
|
return $stmt->rowCount() > 0;
|
|
}
|
|
|
|
function db_whours_delete(PDO $pdo, int $id): bool {
|
|
$stmt = $pdo->prepare("DELETE FROM work_hours WHERE id = ?");
|
|
$stmt->execute([$id]);
|
|
return $stmt->rowCount() > 0;
|
|
}
|