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

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Print</title>
    <!-- Google Font: Source Sans Pro -->
    
<style>
   /*@page { size: 1000pt 0pt; }*/
   /*embed{*/
   /*    width="1000px";*/
   /*    height="500px";*/
   /*}*/
   th{
       background-color:orange;
       text-align:left;
   }
   td{
       border-left:1px solid grey;
       border-bottom:1px solid grey;
   }
   .logo img{
       width:300px;
       margin:0 auto;
   }
</style>
</head>

<body class="abc">

   <div class="logo">
            {{-- <img src="{{asset('style/assets/img/'.$logo->logo)}}" alt="img"> --}}
            <center> <img src="<?php  echo $pic ?>"   ></center>
        </div>

          <table  class="table table-bordered table-striped">
                <thead >
                  <tr>
                    <th style="width:30px">Sl.no</th>
                     <th>Date</th>
                    <th>Company Name</th>
                     <th>Ledger</th>
                    <th>Invoice No</th>
                    <th>Vehicle Number</th>
                    <th>Driver Number</th>
                    <th>Kilometer</th>
                     <th>Quantity</th>
                          <th>Quantity Liter</th>
                      <th>Quantity Liter Price</th>
                    <th>Total</th>
                 
                  
         
                   
                   
                   
                    <th>Balance Due</th>
                      <th>Payment Mode</th>
                       <th >Payment Status</th>
                 </tr>
                </thead>
                <tbody>
                    @php $i = 1;  $pay_status_final =0; $total=0; $qty=0; $qty_lit=0;$qty_lit_price=0;@endphp
        @foreach ($data as $key => $value) {
           @php if ($value['ledger'] == 'Cashsale') {
                $Cashsale = $value['ledger_value'];
                $DoNo = '-';
            }
            if ($value['ledger'] == 'DoNo') {
                $DoNo = $value['ledger_value'];
                $Cashsale = '-';
            }
            $id = urlencode(base64_encode($value['id']));

            $bill = App\Models\Transaction::where('id', '=', $value['id'])->first();

            $balance = DB::table('transaction_payment')->where('transaction_payment.transaction_id', '=', $value['id'])->sum('transaction_payment.amount');
            $pay_status = round($bill['amount'], 2) - round($balance, 2);
$pay_status_final +=$pay_status;

            if ($pay_status > 0.1) {
                if (auth()->user()->role == 'admin' || auth()->user()->role == 'users') {
                    $payment = 'Due ';
                } else {
                    $payment = '
                   Due
                    ';
                }
            } else {
                if (auth()->user()->role == 'admin' || auth()->user()->role == 'users') {
                    $payment = 'Paid';
                } else {
                    $payment = 'Paid';
                }
            }
            $total +=round($value['total'], 3);
            $qty +=$value['quantity'];
            $qty_lit +=$value['quantity_ltr'];
            $qty_lit_price +=$value['unit_ltr_price'];
                @endphp
            <tr>

              <td>{{ $i}}</td>
                <td>{{ date('d-m-Y', strtotime($value['transaction_date']))}}</td>
                  <td>{{ $value['company_name']}}</td>
                  <td> {{$value['ledger']}}</td>
               <td>{{$value['ledger_value']}}</td>
               <td>{{$value['vehicle_no']}}</td>
               <td> {{ $value['driver_name']}}</td>
               <td>{{$value['kilometer']}}</td>
               
              <td>{{ $value['quantity']}}</td>
              <td>{{ $value['quantity_ltr']}}</td>
              <td>{{ $value['unit_ltr_price']}}</td>
               <td>{{round($value['total'], 3)}}</td>
       
            
             
             
               
               <td>{{round($pay_status)}}</td>
                  <td>{{ $value['payment_mode']}}</td>
                       <td>{{ $payment}}</td>
                </tr>
           @php $i++ @endphp
          @endforeach
               </tbody>
                    <!--<tfoot>-->

              <tr style="background-color:grey" class=" font-17  footer-total">
              <td  ><strong>Total:</strong></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
             
             
              <td>{{$qty}}</td>
               <td>{{$qty_lit}}</td>
              <td>{{$qty_lit_price}}</td>
              <td>{{$total}}</td>
               <td>{{$pay_status_final}}</td>
                <td></td>
 <td></td>
              </tr>
              <!--</tfoot>-->
              </table>




</body>

</html>
