<!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;
   }
   .table{
      align:center;
      margin-left:50px;
   }
</style>
</head>

<body class="abc">

   <div class="logo">
       
            <center> <img src="<?php  echo $pic ?>"   ></center>
        </div>

          <table  class="table table-bordered table-striped">
                <thead >
                 <tr>
                    <th >Sl.no</th>
                   <th>Company Name</th>
                    <th>Date</th>
                    <th>Ledger</th>
                    <th>Invoice No</th>
                    <th>Vehicle Number</th>
                    <th>Driver Number</th>
                    <th>Kilometer</th>
                    <th>Quantity</th>
                    <th>Total</th>
                    <th>Balance Due</th>
            
                  </tr>
                </thead>
                <tbody>
                     @php  $i = 1; $qty=0;$totals=0;$due=0; @endphp
        @foreach ($data as  $value) 
        @php
            if ($value['ledger'] == 'Cashsale') {
                $Cashsale = $value['ledger_value'];
                $DoNo = '-';
            }
            if ($value['ledger'] == 'DoNo') {
                $DoNo = $value['ledger_value'];
                $Cashsale = '-';
            }
   
            $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);
            $company_name=  $value['company_name'];
            $transaction_date=date('d-m-Y', strtotime($value['transaction_date']));
            $ledger=$value['ledger'];
            $ledger_value=$value['ledger_value'];
            $vehicle_no=$value['vehicle_no'];
            $driver_name=$value['driver_name'];
            $kilometer=$value['kilometer'];
            $quantity=$value['quantity'];
            $total=round($value['total'], 3);
            $pay_status=round($pay_status);
            $qty +=$value['quantity'];
             $totals +=$total;
              $due +=round($pay_status);
        @endphp
            @if($pay_status > 0.1)
            <tr>
                <td>{{$i}}</td>
                <td>{{$company_name}}</td>
                <td>{{$transaction_date}}</td>
                <td>{{$ledger}}</td>
                <td>{{$ledger_value}}</td>
                <td>{{$vehicle_no}}</td>
                <td>{{$driver_name}}</td>
                <td>{{$kilometer}}</td>
                <td>{{$quantity}}</td>
                <td>{{$total}}</td>
                <td>{{$pay_status}}</td>
            </tr>
            @endif
               @php  $i++; @endphp
            @endforeach
               </tbody>
                    <tfoot>

              <tr class="bg-gray font-17  footer-total">
              <td  ><strong>Total:</strong></td>
       
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
               <td>{{$due}}</td>
             
              </tr>
              </tfoot>
              </table>




</body>

</html>
