feat: complete jobcard client management foundation

This commit is contained in:
Marco0300
2026-09-01 20:43:24 +02:00
parent 168c15c6ae
commit de2bf277c4
34 changed files with 2072 additions and 74 deletions
+10
View File
@@ -128,6 +128,16 @@ function can_access_jobcard(int $jobcardId): bool
return (bool)$stmt->fetchColumn();
}
function can_access_client(int $clientId): bool
{
$user = current_user();
if (!$user) return false;
if ($user['role_name'] !== 'Technician') return can('clients.view');
$stmt = db()->prepare('SELECT 1 FROM jobcard_assignments ja JOIN jobcards j ON j.id = ja.jobcard_id WHERE ja.user_id = :user AND j.client_id = :client LIMIT 1');
$stmt->execute(['user' => $user['id'], 'client' => $clientId]);
return (bool)$stmt->fetchColumn();
}
function audit(string $action, string $entityType, ?int $entityId = null, array $metadata = []): void
{
$user = current_user();