<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Brokers Pending Amount Report</title>
    <style>
        .table,
        .tcell,
        .thead {
            text-align: center;
            border: 1px solid black;
            text-align: center;
        }
        .table {
            width: 100%;
            border-collapse: collapse;
        }

    </style>
</head>

<body>
<div>
    <table style="width: 100%;border-collapse: collapse; margin-bottom: 10px">
        <tr>
            <td style="width:33.33%; text-align: left"><h4>{{ $business_name->name }}</h4></td>
            <td style="width:33.33%; text-align: center"><b>Brokers Pending Amount Report</b></td>
            <td style="width:33.33%; text-align: right"></td>
        </tr>
    </table>

    <table style="width: 100%;border-collapse: collapse; margin-bottom: 10px">
        <tr>
            <td style="width:33.33%; text-align: left">

            </td>
            <td style="width:33.33%; text-align: center">

            </td>
            <td style="width:33.33%; text-align: right">
                <span style="font-weight: bold">From Date:</span> <span
                    style="text-decoration: underline">{{ $data['form_date'] }}</span><br>
                <span style="font-weight: bold">To Date:</span> <span
                    style="text-decoration: underline">{{ $data['to_date'] }}</span>
            </td>
        </tr>
    </table>
</div>

<br>

<table class="table">
    <thead>
    <tr>
        <th class="thead">Broker</th>
        <th class="thead">Pending Amount</th>
    </tr>
    </thead>
    <tbody>

    @forelse ($data['ledgers'] as $key =>$ledger)

        <tr>
             <td class="thead">{{ucfirst($ledger->name)}}</td>
           @php
                  $broker_debit = $ledger->receivables->sum('debit');
                    $broker_credit = $ledger->receivables->sum('credit');
                    $total_broker =$broker_credit -  $broker_debit;
           @endphp
            <td class="thead">{{ number_format($total_broker,0) }}</td>

        </tr>
    @empty
        <tr>
            <td class="tcell" style="text-align: center" colspan="5"> No Data Available</td>
        </tr>
    @endforelse

    </tbody>
</table>

{{-- <div>
<div style="text-align: right;">
    Total: {{ $data['total_amount'] }}
</div>
</div> --}}
</body>

</html>
