sackey cbae4564b9
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
Add customer portal views for dashboard, estimates, invoices, vehicles, and work orders
- Implemented dashboard view with vehicle stats, active services, recent activity, and upcoming appointments.
- Created estimates view with filtering options and a list of service estimates.
- Developed invoices view to manage service invoices and payment history with filtering.
- Added vehicles view to display registered vehicles and their details.
- Built work orders view to track the progress of vehicle services with filtering and detailed information.
2025-08-08 09:56:26 +00:00

411 lines
26 KiB
PHP

<div class="p-6">
<!-- Header -->
<div class="flex flex-col lg:flex-row lg:items-center justify-between space-y-4 lg:space-y-0 mb-6">
<div>
<h1 class="text-2xl font-semibold text-zinc-900 dark:text-white">Users Management</h1>
<p class="text-zinc-600 dark:text-zinc-400">Manage system users, roles, and permissions</p>
</div>
<div class="flex items-center space-x-3">
<button wire:click="exportUsers"
class="inline-flex items-center px-4 py-2 text-zinc-700 dark:text-zinc-300 bg-zinc-100 dark:bg-zinc-700 text-sm font-medium rounded-md hover:bg-zinc-200 dark:hover:bg-zinc-600 transition-colors">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
Export
</button>
<a href="{{ route('users.create') }}"
class="inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-md transition-colors"
wire:navigate>
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
</svg>
Add User
</a>
</div>
</div>
<!-- Stats Cards -->
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-6">
<div class="bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-lg p-4">
<div class="text-sm font-medium text-zinc-600 dark:text-zinc-400">Total Users</div>
<div class="text-2xl font-bold text-zinc-900 dark:text-white">{{ $stats['total'] }}</div>
</div>
<div class="bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-lg p-4">
<div class="text-sm font-medium text-zinc-600 dark:text-zinc-400">Active</div>
<div class="text-2xl font-bold text-green-600">{{ $stats['active'] }}</div>
</div>
<div class="bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-lg p-4">
<div class="text-sm font-medium text-zinc-600 dark:text-zinc-400">Inactive</div>
<div class="text-2xl font-bold text-gray-600">{{ $stats['inactive'] }}</div>
</div>
<div class="bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-lg p-4">
<div class="text-sm font-medium text-zinc-600 dark:text-zinc-400">Suspended</div>
<div class="text-2xl font-bold text-red-600">{{ $stats['suspended'] }}</div>
</div>
<div class="bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-lg p-4">
<div class="text-sm font-medium text-zinc-600 dark:text-zinc-400">Customers</div>
<div class="text-2xl font-bold text-purple-600">{{ $stats['customers'] }}</div>
</div>
<div class="bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-lg p-4">
<div class="text-sm font-medium text-zinc-600 dark:text-zinc-400">Staff</div>
<div class="text-2xl font-bold text-blue-600">{{ $stats['staff'] }}</div>
</div>
</div>
<!-- Filters -->
<div class="bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-lg p-6 mb-6">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 xl:grid-cols-6 gap-4">
<!-- Search -->
<div class="col-span-1 md:col-span-2">
<label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300 mb-2">Search</label>
<input type="text"
wire:model.live.debounce.300ms="search"
placeholder="Search by name, email, or employee ID..."
class="w-full rounded-md border-zinc-300 dark:border-zinc-600 dark:bg-zinc-700 dark:text-white shadow-sm focus:border-blue-500 focus:ring-blue-500">
</div>
<!-- Role Filter -->
<div>
<label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300 mb-2">Role</label>
<select wire:model.live="roleFilter"
class="w-full rounded-md border-zinc-300 dark:border-zinc-600 dark:bg-zinc-700 dark:text-white shadow-sm focus:border-blue-500 focus:ring-blue-500">
<option value="">All Roles</option>
@foreach($roles as $role)
<option value="{{ $role->name }}">{{ $role->display_name }}</option>
@endforeach
</select>
</div>
<!-- Status Filter -->
<div>
<label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300 mb-2">Status</label>
<select wire:model.live="statusFilter"
class="w-full rounded-md border-zinc-300 dark:border-zinc-600 dark:bg-zinc-700 dark:text-white shadow-sm focus:border-blue-500 focus:ring-blue-500">
<option value="">All Status</option>
<option value="active">Active</option>
<option value="inactive">Inactive</option>
<option value="suspended">Suspended</option>
</select>
</div>
<!-- Department Filter -->
<div>
<label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300 mb-2">Department</label>
<select wire:model.live="departmentFilter"
class="w-full rounded-md border-zinc-300 dark:border-zinc-600 dark:bg-zinc-700 dark:text-white shadow-sm focus:border-blue-500 focus:ring-blue-500">
<option value="">All Departments</option>
@foreach($departments as $department)
<option value="{{ $department }}">{{ $department }}</option>
@endforeach
</select>
</div>
<!-- Branch Filter -->
<div>
<label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300 mb-2">Branch</label>
<select wire:model.live="branchFilter"
class="w-full rounded-md border-zinc-300 dark:border-zinc-600 dark:bg-zinc-700 dark:text-white shadow-sm focus:border-blue-500 focus:ring-blue-500">
<option value="">All Branches</option>
@foreach($branches as $branch)
<option value="{{ $branch }}">{{ $branch }}</option>
@endforeach
</select>
</div>
<!-- Customer Filter -->
<div>
<label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300 mb-2">Customer Type</label>
<select wire:model.live="customerFilter"
class="w-full rounded-md border-zinc-300 dark:border-zinc-600 dark:bg-zinc-700 dark:text-white shadow-sm focus:border-blue-500 focus:ring-blue-500">
<option value="">All Users</option>
<option value="customers_only">Customers Only</option>
<option value="non_customers">Staff Only</option>
</select>
</div>
</div>
<!-- Filter Actions -->
<div class="flex items-center justify-between mt-4 pt-4 border-t border-zinc-200 dark:border-zinc-700">
<div class="flex items-center space-x-4">
<label class="flex items-center">
<input type="checkbox"
wire:model.live="showInactive"
class="rounded border-zinc-300 dark:border-zinc-600 text-blue-600 shadow-sm focus:border-blue-500 focus:ring-blue-500">
<span class="ml-2 text-sm text-zinc-700 dark:text-zinc-300">Show inactive users</span>
</label>
</div>
<button wire:click="clearFilters"
class="text-sm text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-200">
Clear filters
</button>
</div>
</div>
<!-- Bulk Actions -->
@if(!empty($selectedUsers))
<div class="bg-blue-50 dark:bg-blue-900/50 border border-blue-200 dark:border-blue-700 rounded-lg p-4 mb-6">
<div class="flex items-center justify-between">
<div class="text-sm text-blue-800 dark:text-blue-200">
{{ count($selectedUsers) }} user(s) selected
</div>
<div class="flex items-center space-x-2">
<button wire:click="bulkActivate"
class="text-sm bg-green-600 hover:bg-green-700 text-white px-3 py-1 rounded-md transition-colors">
Activate
</button>
<button wire:click="bulkDeactivate"
class="text-sm bg-gray-600 hover:bg-gray-700 text-white px-3 py-1 rounded-md transition-colors">
Deactivate
</button>
<button wire:click="$set('selectedUsers', [])"
class="text-sm text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-200">
Clear selection
</button>
</div>
</div>
</div>
@endif
<!-- Users Table -->
<div class="bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-lg overflow-hidden">
<!-- Table Header -->
<div class="px-6 py-4 border-b border-zinc-200 dark:border-zinc-700">
<div class="flex items-center justify-between">
<h3 class="text-lg font-medium text-zinc-900 dark:text-white">
Users ({{ $users->total() }})
</h3>
<div class="flex items-center space-x-2">
<label class="text-sm text-zinc-600 dark:text-zinc-400">Per page:</label>
<select wire:model.live="perPage"
class="text-sm rounded border-zinc-300 dark:border-zinc-600 dark:bg-zinc-700 dark:text-white shadow-sm focus:border-blue-500 focus:ring-blue-500">
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</div>
</div>
</div>
<!-- Table Content -->
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-zinc-200 dark:divide-zinc-700">
<thead class="bg-zinc-50 dark:bg-zinc-900">
<tr>
<th class="px-6 py-3 text-left">
<input type="checkbox"
wire:model="selectAll"
wire:click="selectAllUsers"
class="rounded border-zinc-300 dark:border-zinc-600 text-blue-600 shadow-sm focus:border-blue-500 focus:ring-blue-500">
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-zinc-500 dark:text-zinc-400 uppercase tracking-wider cursor-pointer"
wire:click="sortBy('name')">
<div class="flex items-center space-x-1">
<span>User</span>
@if($sortField === 'name')
<svg class="w-4 h-4 {{ $sortDirection === 'asc' ? 'rotate-180' : '' }}" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"/>
</svg>
@endif
</div>
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-zinc-500 dark:text-zinc-400 uppercase tracking-wider cursor-pointer"
wire:click="sortBy('email')">
<div class="flex items-center space-x-1">
<span>Contact</span>
@if($sortField === 'email')
<svg class="w-4 h-4 {{ $sortDirection === 'asc' ? 'rotate-180' : '' }}" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"/>
</svg>
@endif
</div>
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-zinc-500 dark:text-zinc-400 uppercase tracking-wider">Roles</th>
<th class="px-6 py-3 text-left text-xs font-medium text-zinc-500 dark:text-zinc-400 uppercase tracking-wider cursor-pointer"
wire:click="sortBy('status')">
<div class="flex items-center space-x-1">
<span>Status</span>
@if($sortField === 'status')
<svg class="w-4 h-4 {{ $sortDirection === 'asc' ? 'rotate-180' : '' }}" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"/>
</svg>
@endif
</div>
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-zinc-500 dark:text-zinc-400 uppercase tracking-wider cursor-pointer"
wire:click="sortBy('created_at')">
<div class="flex items-center space-x-1">
<span>Created</span>
@if($sortField === 'created_at')
<svg class="w-4 h-4 {{ $sortDirection === 'asc' ? 'rotate-180' : '' }}" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"/>
</svg>
@endif
</div>
</th>
<th class="px-6 py-3 text-right text-xs font-medium text-zinc-500 dark:text-zinc-400 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="bg-white dark:bg-zinc-800 divide-y divide-zinc-200 dark:divide-zinc-700">
@forelse($users as $user)
<tr class="hover:bg-zinc-50 dark:hover:bg-zinc-700/50">
<td class="px-6 py-4">
<input type="checkbox"
wire:model="selectedUsers"
value="{{ $user->id }}"
class="rounded border-zinc-300 dark:border-zinc-600 text-blue-600 shadow-sm focus:border-blue-500 focus:ring-blue-500">
</td>
<td class="px-6 py-4">
<div class="flex items-center space-x-3">
<div class="flex-shrink-0 w-10 h-10 bg-gradient-to-br from-blue-500 to-purple-600 rounded-lg flex items-center justify-center text-white font-medium text-sm">
{{ $user->initials() }}
</div>
<div>
<div class="text-sm font-medium text-zinc-900 dark:text-white">
<a href="{{ route('users.show', $user) }}"
class="hover:text-blue-600 dark:hover:text-blue-400"
wire:navigate>
{{ $user->name }}
</a>
</div>
<div class="text-sm text-zinc-500 dark:text-zinc-400">
{{ $user->position ?? 'User' }}
@if($user->department)
{{ $user->department }}
@endif
</div>
@if($user->employee_id)
<div class="text-xs font-mono text-zinc-400 dark:text-zinc-500">
ID: {{ $user->employee_id }}
</div>
@endif
</div>
</div>
</td>
<td class="px-6 py-4">
<div class="text-sm text-zinc-900 dark:text-white">{{ $user->email }}</div>
@if($user->phone)
<div class="text-sm text-zinc-500 dark:text-zinc-400">{{ $user->phone }}</div>
@endif
@if($user->branch_code)
<div class="text-xs text-zinc-400 dark:text-zinc-500">Branch: {{ $user->branch_code }}</div>
@endif
</td>
<td class="px-6 py-4">
<div class="flex flex-wrap gap-1">
@foreach($user->activeRoles() as $role)
<span class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium {{ $this->getRoleBadgeClass($role->name) }}">
{{ $role->display_name }}
</span>
@endforeach
@if($user->customer)
<span class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-purple-100 dark:bg-purple-900 text-purple-800 dark:text-purple-200">
Customer
</span>
@endif
</div>
</td>
<td class="px-6 py-4">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium {{ $this->getStatusBadgeClass($user->status) }}">
{{ ucfirst($user->status) }}
</span>
</td>
<td class="px-6 py-4 text-sm text-zinc-500 dark:text-zinc-400">
{{ $user->created_at->format('M j, Y') }}
</td>
<td class="px-6 py-4 text-right text-sm font-medium">
<div class="flex items-center justify-end space-x-2">
<a href="{{ route('users.show', $user) }}"
class="text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-200"
wire:navigate
title="View">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path>
</svg>
</a>
<a href="{{ route('users.edit', $user) }}"
class="text-zinc-600 dark:text-zinc-400 hover:text-zinc-800 dark:hover:text-zinc-200"
wire:navigate
title="Edit">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path>
</svg>
</a>
@if($user->id !== auth()->id())
@if($user->status === 'active')
<button wire:click="deactivateUser({{ $user->id }})"
class="text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200"
title="Deactivate">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728L5.636 5.636m12.728 12.728L18.364 5.636M5.636 18.364l12.728-12.728"></path>
</svg>
</button>
@elseif($user->status === 'inactive')
<button wire:click="activateUser({{ $user->id }})"
class="text-green-600 dark:text-green-400 hover:text-green-800 dark:hover:text-green-200"
title="Activate">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
</button>
@endif
@if($user->status !== 'suspended')
<button wire:click="suspendUser({{ $user->id }})"
class="text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-200"
title="Suspend">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728L5.636 5.636"></path>
</svg>
</button>
@endif
@endif
</div>
</td>
</tr>
@empty
<tr>
<td colspan="7" class="px-6 py-12 text-center">
<div class="text-zinc-500 dark:text-zinc-400">
<svg class="mx-auto h-12 w-12 text-zinc-400 dark:text-zinc-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" />
</svg>
<h3 class="mt-2 text-sm font-medium text-zinc-900 dark:text-zinc-100">No users found</h3>
<p class="mt-1 text-sm text-zinc-500 dark:text-zinc-400">
@if($search || $roleFilter || $statusFilter || $departmentFilter || $branchFilter || $customerFilter)
Try adjusting your filters to find more users.
@else
Get started by creating a new user.
@endif
</p>
@if(!$search && !$roleFilter && !$statusFilter && !$departmentFilter && !$branchFilter && !$customerFilter)
<div class="mt-6">
<a href="{{ route('users.create') }}"
class="inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-md transition-colors"
wire:navigate>
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
</svg>
Add your first user
</a>
</div>
@endif
</div>
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<!-- Pagination -->
@if($users->hasPages())
<div class="px-6 py-4 border-t border-zinc-200 dark:border-zinc-700">
{{ $users->links() }}
</div>
@endif
</div>
</div>