
<div class="card style_table shadow-none" style="margin-bottom:0.8rem;">
    <div class="card-header d-flex align-items-center justify-content-between">
            <h6 class="mb-0">Total Receipt Voucher Entries ({!! isset($data['receipt_voucher_entries']) ? count($data['receipt_voucher_entries']) : '0' !!})</h6>
            <?php /*
            @if($page == 0)
            <a href="{!! route('cart-billing') !!}" type="button" class="btn btn-outline-primary" id="checkout" ><i class="bx bx-plus"></i> Add New</a>
            @endif
            */ 
            ?>
        </div>
    <div class="card-body pb-0">
        <div class="table-responsive">
            <table id="example" class="table table-bordered align-middle" style="width:100%">
                <thead class="table-light">
                    <tr>
                        <th class="thbutton">Sr No.</th>
                        <th class="text-start">Account Name</th>
                        <th style="text-align: right;">Amount</th>
                        <th class="thbutton">Delete</th>
                    </tr>
                </thead>
                <tbody>
                    @php 
                    $i = 1;
                    $totalAmount = 0; 
                    @endphp
                    @if(isset($data['receipt_voucher_entries']) && count($data['receipt_voucher_entries']) > 0)
                        @foreach($data['receipt_voucher_entries'] as $key => $list)
                            <tr class="cart-products" data-patient_id="{{$list['account_id']}}">
                                <td class="text-start">{{ $i }}</td>
                                <td class="text-start">{{$list['account_name'] ?? ''}}</td>
                                @if($page == 0)
                                    <td><input type="text" name="amount[]" data-patient_id="{{$list['account_id']}}" class="form-control bg-white" value="{{ isset($list['amount'])&&$list['amount']>0 ? $list['amount'] : 0 }}" style="text-align: right;"></td>
                                @else
                                    <td align="right" >{{$list['amount'] ?? ''}}</td>
                                @endif
                                <td style="text-align: center;">
                                    <a style="line-height:24px;" data-url="{{route('receipt-voucher-entry-remove')}}" data-id="{{$key}}" data-patient_id="{{$list['account_id']}}" class="btn btn-danger deleteDataCustom" href="#" class="text-danger" data-bs-toggle="tooltip" data-bs-placement="left" title="Delete">
                                        <i class="bi bi-trash text-white"></i>
                                    </a>
                                </td>
                                @php 
                                $totalAmount += preg_replace("/[^0-9.]/", "", (int) $list['amount']); 
                                @endphp
                            </tr>
                            @php $i++; @endphp
                        @endforeach
                            <tr style="background-color: #d4e6ff;font-size: 16px;">
                                <td class="text-start"></td>
                                <td class="text-start"></td>
                                <td align="right" id="totalAmount"><strong>TOTAL: {{$totalAmount}}</strong></td>
                                <td class="text-start"></td>
                            </tr>
                    @else
                        <tr>
                            <td colspan="9">No Data Found</td>
                        </tr>
                    @endif
                    
                </tbody>
            </table>
        </div>
        <?php /*
        @if($page == 0)
        <a href="javascript:;" type="button" class="btn btn-outline-primary" id="checkout" ><i class="bx bx-plus"></i> Submit</a>
        @endif
        */ ?>
    </div>
</div>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        /*$('#checkout').html('Total Amount $amount  <i class="bi bi-cart-fill"></i> Checkout')*/
    });
</script>