@extends('layouts.user_type.auth') @php $hmHour = (int) now()->format('G'); $hmGreeting = $hmHour < 12 ? 'Good morning' : ($hmHour < 17 ? 'Good afternoon' : 'Good evening'); $hmFirst = \Illuminate\Support\Str::of(auth()->user()->name)->trim()->explode(' ')->first(); $hmCronErrors = (int) ($cron_errors_24h ?? 0); $hmTrend = fn ($p) => \Illuminate\Support\Str::contains($p ?? '', '-') ? 'z-badge--danger' : 'z-badge--success'; $hmTrendIcon = fn ($p) => \Illuminate\Support\Str::contains($p ?? '', '-') ? 'ri-arrow-right-down-line' : 'ri-arrow-right-up-line'; $hmInitials = fn ($n) => strtoupper(collect(preg_split('/\s+/', trim($n ?: '?')))->filter()->take(2)->map(fn ($p) => mb_substr($p, 0, 1))->implode('')); $hmTone = fn ($n) => 'c' . ((array_sum(array_map('ord', str_split($n ?: ''))) % 6) + 1); // presentation only: shares and averages worked out from the numbers the controller already sends $hmIsAdmin = in_array(auth()->user()->user_type, ['admin', 'super_admin'], true); $hmTotal = max(0, (int) ($total_company ?? 0)); $hmActive = max(0, (int) ($subscribed_company ?? 0)); $hmExpired = max(0, (int) ($expired_company ?? 0)); $hmPct = fn ($n) => $hmTotal > 0 ? min(100, (int) round($n / $hmTotal * 100)) : 0; $hmCoverage = $hmPct($hmActive); $hmRing = 2 * M_PI * 52; // ring circumference (r = 52) $hmNum = fn ($v) => (float) str_replace(',', '', (string) ($v ?? 0)); $hmMeter = function ($today, $week) use ($hmNum) { // today vs the 7-day daily average $avg = $hmNum($week) / 7; $t = $hmNum($today); $max = max($t, $avg, 1); return ['avg' => rtrim(rtrim(number_format($avg, 1), '0'), '.'), 'today' => (int) round($t / $max * 100), 'mark' => (int) round($avg / $max * 100)]; }; $hmFollowUps = method_exists($subscriptions, 'total') ? (int) $subscriptions->total() : 0; @endphp {{-- the hero below carries the greeting, so the standard page header is hidden --}} @section('pageHead', '') @section('home')
@include('components.alert') {{-- Hero: greeting, live summary, plan coverage --}}
{{ now()->format('l, d F Y') }}

{{ $hmGreeting }}, {{ $hmFirst }}

{{ $hmTotal }} {{ \Illuminate\Support\Str::plural('company', $hmTotal) }} on the platform, {{ $hmActive }} on an active plan{!! $hmExpired > 0 ? ', ' . $hmExpired . ' expired' : '' !!}. @if ($hmFollowUps > 0) {{ $hmFollowUps }} {{ \Illuminate\Support\Str::plural('renewal', $hmFollowUps) }} to follow up. @else No renewals need attention right now. @endif

@if (hasPermission('companyProfile', 'view')) Companies @endif @if (hasPermission('subscriptionPackage', 'view')) Subscriptions @endif
{{-- Database backup status (from the crontab backup script) --}} @if (hasPermission('backupLog', 'view') && \Illuminate\Support\Facades\Schema::hasTable('backup_logs')) @php $qcLb = \App\Models\Admin\BackupLog::lastSuccess(); $qcStale = !$qcLb || $qcLb->ran_at->lt(now()->subHours(\App\Models\Admin\BackupLog::staleAfterHours())); @endphp @if($qcLb) Last database backup {{ $qcLb->ran_at->diffForHumans() }} ({{ $qcLb->ran_at->format('d M Y, H:i') }} · {{ $qcLb->size_for_humans }}){{ $qcStale ? ' — overdue, check the backup crontab.' : '.' }} @else No database backup recorded yet — connect the crontab backup script. @endif View backups @endif {{-- KPIs --}}
{{ $total_company }}
Total companies
Companies on the platform
{{ $subscribed_company }}
Subscribed
{{ $hmPct($hmActive) }}% on an active plan
{{ $expired_company }}
Expired
{{ $hmExpired > 0 ? 'Follow up for renewal' : 'Nothing to renew' }}
@if ($hmIsAdmin)
{{ $total_user }}
Total users
Admin console users
@else
{{ $openTicketsCount }}
Open tickets
Waiting for a reply
@endif
{{-- Expirations + quick actions --}}
Upcoming expirations
Companies requiring attention in the next billing cycle.
@if($subscriptions->total()) {{ $subscriptions->total() }} to follow up @endif
@forelse($subscriptions as $index => $subscription) @php $days = $subscription['days']; $isExpired = $days < 0; $dayTone = $isExpired ? 'z-badge--danger' : ($days < 7 ? 'z-badge--warning' : 'z-badge--success'); @endphp @empty @endforelse
Company Package Expiry date Time left
{{ $hmInitials($subscription['company_name']) }} {{ $subscription['company_name'] }} {{ $isExpired ? 'Expired' : 'Expiring soon' }}
{{ $subscription['package_name'] }} {{ \Carbon\Carbon::parse($subscription['expires_at'])->format('d M, Y') }} {{ $isExpired ? abs($days).' days overdue' : ($days == 0 ? 'Expires today' : $days.' days left') }}
All caught up
No upcoming expirations in this billing cycle.
@if($subscriptions->hasPages()) @include('components.pagination', ['paginator' => $subscriptions]) @endif
Quick actions
@if (hasPermission('companyProfile', 'view')) CompaniesClient profiles and setup @endif @if (hasPermission('subscriptionPackage', 'view')) SubscriptionsPlans, renewals and invoices @endif @if (hasPermission('user', 'view')) UsersAdmin console access @endif @if (hasPermission('ticketSupport', 'view')) Support ticketsReply to open requests @endif @if (hasPermission('systemHealth', 'view')) System healthBackups, security and activity @endif
{{-- Today's pulse --}}
Today's pulseCompared with the 7-day daily average
@php $m = $hmMeter($visits_today ?? 0, $visits_7_day_total ?? 0); @endphp
TrafficWebsite visitors {{ $visits_today_percentage ?? '+0%' }}
{{ $visits_today ?? '0' }}visits today
7-day average {{ $m['avg'] }} / dayLast 7 days {{ $visits_7_day_total ?? '0' }}
@if (hasPermission('visitorTracker', 'view')) View visitor log @endif
@php $m = $hmMeter($contact_us_today ?? 0, $contact_us_7_day_total ?? 0); @endphp
InquiriesWebsite contact requests {{ $contact_us_percentage ?? '+0%' }}
{{ $contact_us_today ?? '0' }}requests today
7-day average {{ $m['avg'] }} / dayLast 7 days {{ $contact_us_7_day_total ?? '0' }}
@if (hasPermission('contactUs', 'view')) Open inquiries @endif
Scheduled jobsCron job monitor {{ $hmCronErrors > 0 ? 'Needs attention' : 'All good' }}
{{ $cron_errors_24h ?? '0' }}errors in the last 24 hours
Last successful run{{ $last_cron_run ?? 'Just now' }}
@if (hasPermission('cronLog', 'view')) Open job log @endif
@endsection