<!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>{{ $data['from_city']->name }} TO {{ $data['to_city']->name }} 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">{{ $business_name->name }}</td>
            <td style="width:33.33%; text-align: center"><b>{{ $data['from_city']->name }} TO
                    {{ $data['to_city']->name }} 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">Sr. No.</th>

        <th class="thead">Vehicle</th>
        <th class="thead">Trip#</th>
        <th class="thead">Total Diesel</th>
        <th class="thead">Diesel Average</th>
        <th class="thead">Toll Plaza</th>
        <th class="thead">Total KM</th>
        {{-- <th class="thead">Status</th> --}}
    </tr>
    </thead>
    <tbody>
    @php
        $i= 1;
    @endphp
    @forelse ($data['ledgers'] as $key =>$ledger)
        @foreach ($ledger->trip_details as $l_key => $value)
            <tr>
                <td class="thead">{{ $i }}</td>
                <td class="thead">{{ $value->vehicle->vehicle_no }}</td>
                <td class="thead">{{ $ledger->id }}</td>
                <td class="thead">{{ number_format($ledger->diesel(),0) }} Lr</td>
                <td class="thead">
                    @php
                        $kilometers = $ledger->end_reading - $ledger->start_reading;
                        $diesel = $ledger->diesel();
                        $oil = $ledger->oil();
                        if($diesel == 0){
                            $avg=0;
                        }else{
                        $avg = $kilometers / $diesel;
                        }
                    @endphp
                    {{  number_format($avg,0) }} Lr/KM
                </td>
                <td class="thead">{{  number_format($ledger->toll_plaza(),0) }}</td>
                <td class="thead">{{  number_format($kilometers ,0) }}</td>
                {{-- <th class="thead">Status</th> --}}
            </tr>
            @php $i = $i + $loop->iteration @endphp
        @endforeach
    @empty
        <tr>
            <td class="tcell" style="text-align: center" colspan="7"> No Data Available</td>
        </tr>
    @endforelse

    </tbody>
</table>

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

</html>
