@extends('layouts.app') @section('title', 'User Management') @section('content')

User Management

Manage system users and their permissions
@if($isCurrentUserSuperAdmin) Add User @endif @if(auth()->user()->childUsers()->count() > 0) @endif
@if(session('original_user_id'))
Currently logged in as: {{ auth()->user()->name }} ({{ auth()->user()->email }})
Original user: {{ session('original_user_name') }}
@csrf
@endif @if(auth()->user()->role === 'reseller' && $macResellers->count() > 0)
My MAC Resellers
Clients with MAC addresses created by you and your child users
{{ $macResellers->count() }} MAC Resellers
@foreach($macResellers as $index => $client) @endforeach
# Client Name Username MAC Address IP Address Package Status Online Zone Branch Created By Connection Date Expiry Date Balance Due
{{ $index + 1 }}
{{ $client['name'] }}
{{ $client['phone'] }}
{{ $client['username'] }} {{ $client['mac_address'] }} @if($client['ip_address']) {{ $client['ip_address'] }} @else - @endif
{{ $client['package_name'] }}
BDT {{ number_format($client['package_price']) }}
@php $statusClass = match($client['status']) { 'active' => 'success', 'inactive' => 'secondary', 'suspended' => 'warning', 'expired' => 'danger', default => 'secondary' }; @endphp {{ ucfirst($client['status']) }} @if($client['is_online']) Online @else Offline @endif
{{ $client['zone'] ?? '-' }}
@if($client['sub_zone']) {{ $client['sub_zone'] }} @endif
{{ $client['branch_name'] }} @php $createdByUser = \App\Models\User::find($client['created_by_user']); @endphp @if($createdByUser)
{{ $createdByUser->name }}
{{ ucfirst($createdByUser->role) }}
@else Unknown @endif
{{ $client['connection_date'] ? \Carbon\Carbon::parse($client['connection_date'])->format('M d, Y') : '-' }} @php $expiryDate = $client['expiry_date'] ? \Carbon\Carbon::parse($client['expiry_date']) : null; $isExpired = $expiryDate && $expiryDate->isPast(); $expiresSoon = $expiryDate && $expiryDate->diffInDays(now()) <= 7; @endphp @if($expiryDate) {{ $expiryDate->format('M d, Y') }} @else - @endif BDT {{ number_format($client['balance']) }} @if($client['total_due'] > 0) BDT {{ number_format($client['total_due']) }} @else BDT 0 @endif
@endif
{{ $stats['total'] }}
Total Users
{{ $stats['active'] }}
Active Users
{{ $stats['inactive'] }}
Inactive Users
{{ $stats['admin'] }}
Admins
{{ $stats['manager'] }}
Managers
{{ $stats['technician'] }}
Technicians
@if($isCurrentUserSuperAdmin)
{{ $stats['super_admin'] }}
Super Admins
{{ $stats['reseller'] }}
Resellers
@endif
@php $currentUser = auth()->user(); $isAdmin = $currentUser->role === 'admin'; @endphp @if(!$isCurrentUserSuperAdmin && !$isAdmin)
Note: You can only view your own user information. Contact your administrator for access to other users.
@elseif($isAdmin && !$isCurrentUserSuperAdmin)
Note: You can only view your own user information. Contact super admin for access to all users.
@endif @if($isCurrentUserSuperAdmin && $superAdminUsers->count() > 0)
Super Admin Users ({{ $superAdminUsers->count() }} users)
@foreach($superAdminUsers as $index => $user) @endforeach
SL User ISP Name Total Users Total Branch Role Status Assign Menu Last Login Created Actions
{{ $index + 1 }}
@if($user->profile_photo) @php $imagePath = asset('storage/' . $user->profile_photo); @endphp {{ $user->name }} @endif
{{ $user->name }}
{{ $user->email }} @if($user->phone)
{{ $user->phone }} @endif
@if($user->company_name) {{ $user->company_name }} @elseif($user->branch) {{ $user->branch->name }}
{{ $user->branch->code }} @else No Company @endif
{{ $user->childUsers->count() }}
Child Users
@if($user->branch) {{ $user->branch->childBranches->count() }}
Sub Branches @else 0 @endif
Super Admin
{{ ucfirst($user->status) }} @if($isCurrentUserSuperAdmin)
is_active ? 'checked' : '' }} onchange="toggleUserStatus({{ $user->id }})">
@endif
{{ $user->menus()->count() }} Menus @if($isCurrentUserSuperAdmin) @endif
@if($user->last_login_at)
{{ $user->last_login_at->diffForHumans() }} {{ $user->last_login_at->format('M d, Y H:i') }}
@else
Never
@endif
{{ $user->created_at->format('M d, Y') }}
@if($user->is_active && $user->id !== auth()->id())
@csrf
@endif
@endif @if(!$isCurrentUserSuperAdmin)
Regular Users ({{ $users->total() ?? 0 }} users)
@forelse($users as $index => $user) @empty @endforelse
SL User ISP Name Total Users Total Branch Role Status Assign Menu Last Login Created Actions
{{ ($users->currentPage() - 1) * $users->perPage() + $index + 1 }}
@if($user->profile_photo) @php $imagePath = asset('storage/' . $user->profile_photo); @endphp {{ $user->name }} @endif
{{ $user->name }}
{{ $user->email }} @if($user->phone)
{{ $user->phone }} @endif
@if($user->company_name) {{ $user->company_name }} @elseif($user->branch) {{ $user->branch->name }}
{{ $user->branch->code }} @else No Company @endif
{{ $user->childUsers->count() }}
Child Users
@if($user->branch) {{ $user->branch->childBranches->count() }}
Sub Branches @else 0 @endif
{{ ucfirst($user->role) }}
{{ ucfirst($user->status) }} @if($isCurrentUserSuperAdmin)
is_active ? 'checked' : '' }} onchange="toggleUserStatus({{ $user->id }})">
@endif
{{ $user->menus()->count() }} Menus @if($isCurrentUserSuperAdmin) @endif
@if($user->last_login_at)
{{ $user->last_login_at->diffForHumans() }} {{ $user->last_login_at->format('M d, Y H:i') }}
@else
Never
@endif
{{ $user->created_at->format('M d, Y') }}
@if($user->is_active && (auth()->user()->role === 'super-admin' || auth()->user()->role === 'admin') && $user->id !== auth()->id())
@csrf
@endif @if(auth()->user()->role === 'super-admin' || auth()->user()->role === 'Super-admin' || stripos(auth()->user()->role, 'super') !== false) @endif

No users found.

@endif @if($resellerUsers->count() > 0)
Reseller Users ({{ $resellerUsers->count() }} users)
@foreach($resellerUsers as $index => $user) @endforeach
SL User ISP Name Total Users Total Branch Role Status Assign Menu Last Login Created Actions
{{ $index + 1 }}
{{ $user->name }}
{{ $user->email }} @if($user->phone)
{{ $user->phone }} @endif
@if($user->company_name) {{ $user->company_name }} @elseif($user->branch) {{ $user->branch->name }}
{{ $user->branch->code }} @else No Company @endif
{{ $user->childUsers->count() }}
Child Users
@if($user->branch) {{ $user->branch->childBranches->count() }}
Sub Branches @else 0 @endif
Reseller
{{ ucfirst($user->status) }} @if($isCurrentUserSuperAdmin)
is_active ? 'checked' : '' }} onchange="toggleUserStatus({{ $user->id }})">
@endif
{{ $user->menus()->count() }} Menus @if($isCurrentUserSuperAdmin) @endif
@if($user->last_login_at)
{{ $user->last_login_at->diffForHumans() }} {{ $user->last_login_at->format('M d, Y H:i') }}
@else
Never
@endif
{{ $user->created_at->format('M d, Y') }}
@if($user->is_active && $user->id !== auth()->id())
@csrf
@endif
@endif @if($macResellerUsers->count() > 0)
MAC Reseller Users ({{ $macResellerUsers->count() }} users)
@foreach($macResellerUsers as $index => $user) @endforeach
SL User Company Email Phone Role Status Assign Menu Last Login Created Actions
{{ $index + 1 }}
{{ $user->name }}
ID: {{ $user->id }}
{{ $user->company_name ?? '-' }} {{ $user->email }} {{ $user->phone ?? '-' }} {{ ucfirst($user->role) }} {{ ucfirst($user->status) }}
{{ $user->menus()->count() }} Menus @if($isCurrentUserSuperAdmin) @endif
@if($user->last_login_at) {{ \Carbon\Carbon::parse($user->last_login_at)->diffForHumans() }} @else Never @endif {{ \Carbon\Carbon::parse($user->created_at)->format('M d, Y') }}
@if($user->id !== auth()->id())
@csrf
@endif
@endif
@if(!$isCurrentUserSuperAdmin && isset($branchData) && $branchData->count() > 0)
Branch Network Overview
@foreach($branchData as $index => $branch) @endforeach
SL Name Admin User Parent Branch Parent User Assigned Router Total Clients Status Created Actions
{{ $index + 1 }}
{{ $branch['name'] }}
{{ $branch['code'] }}
{{ $branch['admin_user']['name'] }}
{{ $branch['admin_user']['email'] }}
{{ $branch['admin_user']['role'] }}
{{ $branch['parent_branch']['name'] }}
{{ $branch['parent_branch']['code'] }}
{{ $branch['parent_user']['name'] }}
{{ $branch['parent_user']['email'] }}
@foreach($branch['assigned_routers'] as $router)
{{ $router['name'] }}
{{ $router['ip'] }}
@endforeach
{{ $branch['total_clients'] }}
Clients
{{ $branch['status'] }}
{{ explode(' ', $branch['created_at'])[0] }}
{{ explode(' ', $branch['created_at'])[1] }}
@endif @if(!$isCurrentUserSuperAdmin && isset($allChildUsers) && $allChildUsers->count() > 0)
All Child Users ({{ $allChildUsers->count() }} users)
@foreach($allChildUsers as $index => $user) @endforeach
SL User Branch Role Status Assigned Menus Last Login Created Actions
{{ $index + 1 }}
{{ $user['name'] }}
{{ $user['email'] }} @if($user['phone'])
{{ $user['phone'] }} @endif
{{ $user['branch_name'] }}
{{ $user['branch_code'] }}
{{ ucfirst($user['role']) }}
{{ $user['is_active'] ? 'Active' : 'Inactive' }}
{{ $user['menus_count'] }} Menus {{ $user['last_login_at'] }} {{ $user['created_at'] }}
@endif @if($users->hasPages())
{{ $users->appends(request()->query())->links() }}
@endif
@endsection @section('scripts') @endsection