@extends('layouts.app') @section('content') @if(in_array(auth()->user()->role->name, ['super_admin', 'company_admin', 'company_owner']))
Back to Disconnections

Disconnection History

Full timeline of disconnection events for {{ $client->name ?? 'Client' }}

Client

{{ $client->name ?? 'Unknown' }}

Account Number

{{ $client->account_number ?? 'N/A' }}

Status @php $latestStatus = $history->first()->disconnection_status ?? 'none'; $statusLabel = $latestStatus === 'disconnected' ? 'Disconnected' : ($latestStatus === 'notice_sent' ? 'Notice Pending' : 'Active'); $statusBg = $latestStatus === 'disconnected' ? 'danger' : ($latestStatus === 'notice_sent' ? 'warning' : 'success'); @endphp

{{ $statusLabel }}

Total Events

{{ count($history ?? []) }}

Complete Timeline
@if(count($history ?? []) > 0)
@php $statusIcons = [ 'notice_sent' => ['icon' => 'fas fa-bell', 'color' => 'warning', 'label' => 'Disconnection Notice Sent'], 'disconnected' => ['icon' => 'fas fa-times-circle', 'color' => 'danger', 'label' => 'Service Disconnected'], 'reconnected' => ['icon' => 'fas fa-check-circle', 'color' => 'success', 'label' => 'Service Reconnected'], 'late_fee' => ['icon' => 'fas fa-money-bill', 'color' => 'warning', 'label' => 'Late Fee Applied'], 'none' => ['icon' => 'fas fa-info-circle', 'color' => 'secondary', 'label' => 'System Event'] ]; @endphp @foreach($history as $index => $event) @php $eventType = $event->disconnection_status ?? 'none'; $eventConfig = $statusIcons[$eventType] ?? $statusIcons['none']; @endphp
{{ $eventConfig['label'] }}
{{ $event->created_at ? $event->created_at->format('M d, Y H:i A') : 'N/A' }}
@if($event->billing_id) @endif @if($event->amount)
Amount

₱{{ number_format($event->amount ?? 0, 2) }}

@endif @if($event->payment_type)
Payment Type

{{ ucfirst(str_replace('_', ' ', $event->payment_type)) }}

@endif
{{ ucfirst($event->status ?? 'added') }}
@if($event->notes)
Notes: {{ $event->notes }}
@endif @if($event->reference_number)

Ref: {{ $event->reference_number }}

@endif
@endforeach

History Summary
@php $historyItems = collect($history->items()); $disconnectEvents = $historyItems->filter(fn($h) => $h->disconnection_status === 'disconnected')->count(); $reconnectEvents = $historyItems->filter(fn($h) => $h->disconnection_status === 'reconnected')->count(); $noticeEvents = $historyItems->filter(fn($h) => $h->disconnection_status === 'notice_sent')->count(); $lateFeeEvents = $historyItems->filter(fn($h) => $h->payment_type === 'late_fee')->count(); $totalFeeAmount = $historyItems->filter(fn($h) => $h->payment_type === 'late_fee')->sum('amount'); @endphp
Disconnections

{{ $disconnectEvents }}

Reconnections

{{ $reconnectEvents }}

Notices Sent

{{ $noticeEvents }}

Late Fees

{{ $lateFeeEvents }}

₱{{ number_format($totalFeeAmount, 2) }}

Export Options
@else

No disconnection history

This client hasn't had any disconnection events.

@endif
@else

Access Denied

Only Super Admin and Company Admin users can access the Disconnection Management system.

Back to Dashboard
@endif @endsection