@extends('layouts.app') @section('title', 'ISP Management') @section('page-title', 'ISP Management') @section('content')
ISP Management
@php $superAdminRoles = ['super_admin', 'Super-admin', 'Super Admin', 'super_admin', 'SuperAdmin', 'SUPER_ADMIN', 'super-admin']; $isSuperAdmin = in_array(auth()->user()->role, $superAdminRoles) || stripos(auth()->user()->role, 'super') !== false; @endphp @if($isSuperAdmin) Add New ISP @endif
@php $currentUser = auth()->user(); $superAdminRoles = ['super_admin', 'Super-admin', 'Super Admin', 'super_admin', 'SuperAdmin', 'SUPER_ADMIN', 'super-admin']; $isSuperAdmin = in_array($currentUser->role, $superAdminRoles) || stripos($currentUser->role, 'super') !== false; @endphp @if($isSuperAdmin)
Super Admin Access: You have FULL ACCESS to all ISPs. No assignment needed. Total ISPs: {{ \App\Models\Branch::count() }}
Debug: Your role is "{{ $currentUser->role }}"
@else
Your ISP: Showing ISP(s) assigned to {{ $currentUser->name }} ({{ $currentUser->role }}).
Debug: Your role is "{{ $currentUser->role }}" - Not recognized as Super Admin
@endif @if($branches->count() > 0)
@foreach($branches as $index => $branch) @endforeach
ID ISP Name User Name Total Branch Total Router Clients Status Created Actions
{{ $branch->id }} {{ $branch->name }} ({{ $branch->code }}) @if($branch->description)
{{ Str::limit($branch->description, 50) }} @endif
@if($branch->users->count() > 0) @foreach($branch->users as $user)
{{ $user->name }}
@endforeach @else No User @endif
{{ $branch->childBranches->count() }}
Branches
@php $mainBranchRouters = $branch->mikrotikServers->count(); $subBranchRouters = 0; foreach($branch->childBranches as $childBranch) { $subBranchRouters += $childBranch->mikrotikServers->count(); } $totalRouters = $mainBranchRouters + $subBranchRouters; @endphp @php $allRouters = collect(); $allRouters = $allRouters->merge($branch->mikrotikServers->map(function($router) { return [ 'name' => $router->name, 'type' => 'Main', 'location' => $branch->name ]; })); foreach($branch->childBranches as $childBranch) { $allRouters = $allRouters->merge($childBranch->mikrotikServers->map(function($router) use ($childBranch) { return [ 'name' => $router->name, 'type' => 'Sub-Branch', 'location' => $childBranch->name ]; })); } $tooltipText = $allRouters->count() > 0 ? $allRouters->map(function($router) { return $router['name'] . ' (' . $router['type'] . ' - ' . $router['location'] . ')'; })->join(', ') : 'No routers assigned'; @endphp
{{ $totalRouters }} Routers
@if($mainBranchRouters > 0 || $subBranchRouters > 0) {{ $mainBranchRouters }} Main @if($subBranchRouters > 0) {{ $subBranchRouters }} Sub @endif @endif
@php $mainBranchClients = $branch->clients_count; $subBranchClients = 0; $subBranchRouterClients = 0; foreach($branch->childBranches as $childBranch) { $subBranchClients += $childBranch->clients_count; // Add clients from routers in sub-branches foreach($childBranch->mikrotikServers as $router) { $subBranchRouterClients += $router->clients->count(); } } // Add clients from main branch routers $mainBranchRouterClients = 0; foreach($branch->mikrotikServers as $router) { $mainBranchRouterClients += $router->clients->count(); } $totalClients = $mainBranchClients + $subBranchClients + $mainBranchRouterClients + $subBranchRouterClients; @endphp
{{ $totalClients }} Clients
@if($mainBranchClients > 0 || $subBranchClients > 0 || $mainBranchRouterClients > 0 || $subBranchRouterClients > 0) @if($mainBranchClients > 0 || $mainBranchRouterClients > 0) {{ $mainBranchClients + $mainBranchRouterClients }} Main @endif @if($subBranchClients > 0 || $subBranchRouterClients > 0) {{ $subBranchClients + $subBranchRouterClients }} Sub @endif @if($mainBranchRouterClients > 0 || $subBranchRouterClients > 0) {{ $mainBranchRouterClients + $subBranchRouterClients }} from Routers @endif @endif
@if($branch->is_active) Active @else Inactive @endif {{ $branch->created_at->format('M d, Y') }}
@if($isSuperAdmin) @endif
@include('custom-pagination', ['paginator' => $branches])
@else
@if($isSuperAdmin)
No ISPs Found

Start by creating your first ISP.

Create First ISP @else
No ISP Assigned

You don't have any ISP assigned to your account.

Contact your administrator to get an ISP assigned.

@endif
@endif
@endsection @section('scripts') @endsection