@extends('layouts.app')
@section('title', $title)
@section('page_title', $title)
@section('breadcrumbs')
    <li class="breadcrumb-item"><a href="{{ route('reports.index') }}">Reports</a></li><li class="breadcrumb-item active">Branch Summary</li>
@endsection
@section('page_actions')@include('reports._export', ['route' => 'reports.branch-summary'])@endsection

@section('content')
    <div class="card"><div class="card-body">
        <table class="table table-hover align-middle">
            <thead><tr><th>Branch</th><th>Code</th><th class="text-center">Students</th><th class="text-center">Active</th><th class="text-end">Revenue</th><th class="text-end">Outstanding</th></tr></thead>
            <tbody>
                @foreach($branches as $r)
                    <tr>
                        <td class="fw-semibold">{{ $r['branch']->name }}</td>
                        <td><span class="badge bg-soft-primary">{{ $r['branch']->code }}</span></td>
                        <td class="text-center">{{ number_format($r['students']) }}</td>
                        <td class="text-center">{{ number_format($r['active']) }}</td>
                        <td class="text-end text-success">{{ number_format($r['revenue']) }}</td>
                        <td class="text-end text-danger">{{ number_format($r['outstanding']) }}</td>
                    </tr>
                @endforeach
            </tbody>
            <tfoot class="table-light fw-bold">
                <tr>
                    <td colspan="2">Total</td>
                    <td class="text-center">{{ number_format($branches->sum('students')) }}</td>
                    <td class="text-center">{{ number_format($branches->sum('active')) }}</td>
                    <td class="text-end">{{ number_format($branches->sum('revenue')) }}</td>
                    <td class="text-end">{{ number_format($branches->sum('outstanding')) }}</td>
                </tr>
            </tfoot>
        </table>
    </div></div>
@endsection
