<div class="card style_table shadow-none" style="margin-bottom:0.5rem;">
    @if(!isset($print) || $print == 1)
    <div class="card-header d-flex align-items-center justify-content-between mb-0">
        <div style="width:100%" class="accordion-item">
            <div class="accordion-header" id="panelsStayOpen-headingTwo">
                <div class="accordion-button collapsed" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseTwo" aria-expanded="false" aria-controls="panelsStayOpen-collapseTwo">
                    <div class="col-md-3">
                        <h6 class="mb-0">Report Status:</h6>

                    </div>
                    <div class="col-md-8">
                        <p class="pending-alert"></p>
                    </div>
                </div>
                <div class="col-md-12" align="right">
                </div>
            </div>
            <div style="" id="panelsStayOpen-collapseTwo" class="accordion-collapse collapse" aria-labelledby="panelsStayOpen-headingTwo">
                <div class="accordion-body">
                    @endif
                        <div class="card-body">
                            <div class="table-responsive">
                                <table id="example" class="table table-bordered align-middle" style="width:100%">
                                    <thead class="table-light">
                                        <tr>
                                            {{--<th class="text-start">Invoice No</th>
                                            <th>Date</th>--}}
                                            <th>Test Package</th>
                                            <th>Department</th>
                                            <th class="text-center">Sample</th>
                                            <th class="text-center">Result</th>
                                            <th class="text-center">Review</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @php $pendingcollection = $pendingupdates = $pendingreviews = 0; @endphp
                                        @if(isset($sale_invoice_status) && count($sale_invoice_status) > 0)
                                        @foreach($sale_invoice_status as $key => $list)
                                        <tr class="cart-products" data-patient_id="{{$list->id}}">
                                            {{--<td class="text-start">{{$list->main_invoice_no}}</td>
                                            <td class="text-start">{{ formatedDate($list->invoice_date) }}</td>--}}
                                            <td class="text-start">{{$list->test_package_name}}</td>
                                            <td class="text-start">{{$list->department_name}}</td>
                                            <td class="text-center"><span><i class="bi bi-{{$list->sample_collection_status != 0 ? 'check-circle text-success' : 'x-circle text-danger'}}"></i></span></td>
                                            <td class="text-center"><span><i class="bi bi-{{$list->all_tests_updated != 0 ? 'check-circle text-success' : 'x-circle text-danger'}}"></i></span></td>
                                            <td class="text-center"><span><i class="bi bi-{{$list->all_tests_reviewed != 0 ? 'check-circle text-success' : 'x-circle text-danger'}}"></i></span></td>
                                        </tr>
                                            @php if ($list->sample_collection_status == 0 || $list->all_tests_updated == 0 || $list->all_tests_reviewed == 0) { $pendingPackages = 1; } @endphp

                                            @php
                                            if ($list->sample_collection_status == 0) {
                                                 $pendingcollection += 1;
                                            }
                                            if ($list->all_tests_updated == 0) {
                                                 $pendingupdates += 1;
                                            }
                                            if ($list->all_tests_reviewed == 0) {
                                                 $pendingreviews += 1;
                                            }
                                            @endphp
                                        @endforeach
                                        @else
                                        <tr>
                                            <td colspan="9">No Data Found</td>
                                        </tr>
                                        @endif

                                    </tbody>
                                </table>
                            </div>

                        </div>
                    @if(!isset($print) || $print == 1)
                </div>
            </div>
        </div>
    </div>
    @endif
</div>
@if(!isset($print) || $print == 1)
@if($pendingcollection > 0 || $pendingupdates > 0 || $pendingreviews > 0)
<script type="text/javascript">
    $('.pending-alert').html(`<i class="bi bi-exclamation-triangle"></i> Please Note: {!! $pendingcollection > 0 ? $pendingcollection . ' Sample collections' : '' !!} {!! $pendingcollection > 0 && $pendingupdates > 0  && $pendingreviews > 0 ? ', ' : ($pendingcollection > 0 && $pendingupdates > 0 ? ' and' : '') !!} {!! $pendingupdates > 0 ? $pendingupdates . ' Test Result update' : '' !!} {!! $pendingupdates > 0  && $pendingreviews > 0 ? ' And' : '' !!} {!! $pendingreviews > 0 ? $pendingreviews .' Doctor Reviews' : '' !!} Pending!`);
    $('#panelsStayOpen-headingTwo').find('.accordion-button').addClass('alert alert-danger');
</script>
@else
<script type="text/javascript">
    $('.pending-alert').html(`<i class="bi bi-check-circle"></i> All Done. Report is ready for print.`);
    $('#panelsStayOpen-headingTwo').find('.accordion-button').addClass('alert alert-success');
</script>
@endif
@endif