<!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>Opening Balance 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>Opening Balance 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">Date</th>
        <th class="thead">Party Type</th>
        <th class="thead">Party </th>
        <th class="thead">Amount</th>
    </tr>
    </thead>
    <tbody>

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

        <tr>
            <td class="thead">{{ date('F j, Y', strtotime($ledger->date)) }}</td>
            <td class="thead">{{ucfirst($ledger->ref_type)}}</td>
            <td class="thead">
                @if ($ledger->ref_type== 'broker')
                    {{  $ledger->broker->name }}
                @endif
                @if ($ledger->ref_type== 'vehicle')
                    {{  $ledger->vehicle->vehicle_no}}
                @endif
                @if ($ledger->ref_type== 'customer')
                    {{  $ledger->customer->name}}
                @endif
                @if ($ledger->ref_type== 'broker')
                    {{  $ledger->broker->name}}
                @endif
                @if ($ledger->ref_type== 'pump')
                    {{  $ledger->pump->name}}
                @endif
            </td>
            <td class="thead">{{ number_format($ledger->amount,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>
