<div class="table-responsive">
    <table id="example" class="table table-bordered align-middle" style="width:100%">
        <thead class="table-light">
            <tr>
                <th class="thbutton">Sl No</th>
                <th>Invoice No.</th>
                <th>Reference Invoice No</th>
                <th>Customer Name</th>
                <th class="text-end">Bill Amount</th>
               
                <th class="thbutton">Bill</th>
               
                @if(in_array('sale-return-edit', $authRolePermissions))
                <th class="thbutton">Edit</th>
                @endif
                @if(in_array('sale-return-delete', $authRolePermissions))
                <th class="thbutton">Delete</th>
                @endif
               
            </tr>
        </thead>
        <tbody>
            @php $i=1;@endphp
            @if(count($data)>0)
                @foreach($data as $key=> $list)
                @php $Receive = ReturnTransactionCalculationReceiveAmount($list->id,'SALE_RETURN'); @endphp
                    <tr>
                        <td class="text-center">{{$data->firstItem() + $key}}</td>
                        <td>
                                <b>{{$list->voucher_type_invoice_no}}</b>
                            <br>
                                {{ formatedDateTime($list->invoice_date) }}
                        </td>
                        <td>{{$list->reference_invoice_no??''}}</td>
                        <td>
                            {{$list->getPatient->name ?? ''}}
                            {{-- {{$list->getPatient->account_contact->gender->name ?? ''}}{{ isset($list->getPatient->account_contact->date_of_birth) && isset($list->getPatient->account_contact->gender) ? ', ' : '' }} {{ isset($list->getPatient->account_contact->date_of_birth) ? age($list->getPatient->account_contact->date_of_birth) . ' yrs' : '' }} --}}
                            <br>
                            @if(isset($list->getCreatedBy->prepared_by))
                            <div style="color:#aaa">By: {!! $list->getCreatedBy->prepared_by??'' !!}</div>
                            @endif
                        </td>
                        <td class="text-end">
                            Total: {{ convertDecimelPoint($Receive['totalBilling']) ?? ''}}<br>
                            Received: {{ convertDecimelPoint($Receive['receivedAmount']) ?? ''}}
                            @if($Receive['dueAmount']>0)
                            <br>
                            <span class="badge btn-secondary text-white"> Due: {{ convertDecimelPoint($Receive['dueAmount']) ?? ''}}</span>
                            @endif
                        </td>
                        
                        <td class="text-center">
                            <a class="btn btn-info" href="{!! route('sale-return-invoice', $list->id) !!}">
                            <i class="bi bi-printer text-white"></i>
                            </a>
                        </td>
                       
                       
                        @if(in_array('sale-return-edit', $authRolePermissions))
                        <td class="text-center">
                            <a href="{{route('sale-return.edit', $list->id)}}" class="btn btn-warning" title="Edit">
                                <i class="bi bi-pencil-square text-white"></i>
                            </a>
                        </td>
                        @endif
                       
                        @if(in_array('sale-return-delete', $authRolePermissions))
                        <td class="text-center">
                            <a data-url="{{route('sale-return.destroy')}}" data-id="{{$list->id}}" class="btn btn-danger deleteDataCustom" href="#" class="text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Delete">
                                <i class="bi bi-trash text-white"></i>
                            </a>
                        </td>
                        @endif
                     
                    </tr>
                    @php $i++; @endphp
                @endforeach
            @else
                <tr>
                    <td colspan="18">No Data Found</td>
                </tr>
            @endif
        </tbody>
    </table>
</div>

<nav class="mt-2 row">
    <div class="col-lg-10 col-md-10 col-10 float-start">
        {!! $data->onEachSide(0)->render('sale-returns.pagination') !!}
    </div>
    <div class="col-lg-2 col-md-2 col-2 dataTables_length" id="example_length" style="text-align: right;">
            <i class="bi bi-funnel" style=" top: 11px;left: 20px;"></i>
            <select class="form-select sorting sorting-box" id="" name="example_length" aria-controls="example" style="padding-left: 30px;">
                <option value="10">Show: 10</option>
                <option value="30">Show: 30</option>
                <option value="50">Show: 50</option>
            </select>
    </div>
</nav>
</div>

