feat: complete jobcard client management foundation
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user