 <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>Item</th>
                <th>HSN</th>
                <th>Group / Category</th>
                <th>Brand</th>
                <th>Packing</th>
                <th>Tax</th>
                <th style="text-align: right">Pur. Price</th>
                <th style="text-align: right">Sale Price</th>
                @if(isset($SessionCategory) &&  $SessionCategory !=12)
                <th>Test Link</th>
                @endif
                <th class="thbutton">Active</th>
                @if(in_array('product-edit', $authRolePermissions))
                <th class="thbutton">Edit</th>
                @endif
                {{-- @if(auth()->user()->can('product-delete'))
                <th class="thbutton">Delete</th>
                @endif --}}
            </tr>
        </thead>
        <tbody>
            @php $i=1;@endphp
            @if(count($data)>0)
                @foreach($data as $key=> $list)
                    <tr>
                        <td class="text-center">{{$data->firstItem() + $key}}</td>
                        <td
                        style="white-space: unset;"
                        ><a href="{{route('products.show',$list->id)}}?page={!! $data->currentPage()  !!}">
                            <strong>{{ucfirst($list->name)}}</strong></a>
                            @if(isset($SessionCategory) &&  $SessionCategory ==12 || $list->manage_stock=='Yes')
                            @if(getCurrentStock($list->id)>0)
                            <span class="badge bg-info">{!! getCurrentStock($list->id)??0 !!}</span>
                            @endif
                            @endif
                            {!! $list->testName? "<br>" .$list->testName : '' !!}
                            {!! isset($list->batch) && $list->batch!='N/A' ? "<br>" . $list->batch : '' !!}
                        </td>
                        <td>{{$list->hsncode}}</td>
                        <td>{{$list->composition}}
                            {!! $list->category ? '<br>'.$list->category : ' ' !!}
                        </td>
                        <td>{{$list->brand}}</td>
                        <td>{{$list->convertion_factor}} {{ $list->priceasper != 'alternative' ? $list->primary_unit : $list->alternative_unit}}</td>
                        <td>{{$list->tax}}</td>
                        <td style="text-align: right">{{$list->purchase_price}}</td>
                        <td style="text-align: right">
                            <span class="border-bottom">{{$list->sale_price}}</span>
                            <br>
                            MRP: {{$list->mrp}}
                            </td>
                        {{-- <td class="text-center">
                            <a href="{{route('products.test-packages',$list->id)}}" class="btn btn-success" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Linked Test Packages">
                                <i class="bi bi-link text-white"></i>
                            </a>
                        </td> --}}
                        @if(isset($SessionCategory) &&  $SessionCategory !=12)
                        <td class="text-center">
                            @if($list->testName)
                                <a href="{{ route('products.test-packages', $list->id) }}?pages={!! $data->currentPage()  !!}" class="btn btn-success" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Linked Test Packages">
                                    <i class="bi bi-check2 text-white" style="font-size: 16px;"></i>

                                </a>
                            @else
                                <a href="{{ route('products.test-packages', $list->id) }}?pages={!! $data->currentPage()  !!}" class="btn btn-primary" data-bs-toggle="tooltip" data-bs-placement="bottom" title="No Linked Test Packages">
                                    <i class="bi bi-link text-white"></i>
                                </a>
                            @endif
                        </td>
                        @endif
                        <td>
                            <div class="form-check form-check-inline{{ $i }}">
                                <input class="form-check-input{{ $i }} btn-lg changeStatusCustom" type="checkbox" id="inlineCheckbox{{ $i }}" data-url="{{route('products.changeStatus')}}" data-id="{{ $list->id }}" data-status="{{$list->status=='0' ? '1' : '0'}}" {{ $list->status=='1' ? 'checked' : ''}}>
                            </div>
                        </td>
                        @if(in_array('product-edit', $authRolePermissions))
                        <td class="text-center">
                            <a href="{{route('products.edit',$list->id)}}?page={!! $data->currentPage()  !!}" class="btn btn-warning" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Edit">
                                <i class="bi bi-pencil-square text-white"></i>
                            </a>
                        </td>
                        @endif
                        {{-- @if(auth()->user()->can('product-delete'))
                        <td>
                            <a data-url="{{route('products.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="13">No Data Found</td>
            </tr>
            @endif
        </tbody>
    </table>
</div>
<nav class="row align-items-center mt-3">
    <div class="col-md-6">
        {!! $data->onEachSide(0)->render('products.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>

    {{-- @if(auth()->user()->can('product-import')) --}}
        <div class="col-md-4" style="display: flex; justify-content: space-evenly;">
            <div class="btn-group mb-0">
                <a class="btn btn-outline-primary" href="{!! route('products-export') !!}"><i class="bi bi-upload"></i> Export</a>
            </div>
            {{-- @endif --}}
            @if(in_array('product-import', $authRolePermissions))
            <div class="btn-group mb-0">
                <a class="btn btn-outline-primary" href="{!! route('products-import.create') !!}"><i class="bi bi-upload"></i> Bulk Import</a>
            </div>
            @endif
            {{-- @if(auth()->user()->can('product-import')) --}}
            <div class="btn-group mb-0">
                <a class="btn btn-outline-primary" href="{!! route('products-price-list') !!}"><i class="bi bi-cloud-download"></i> Price List Export</a>
            </div>
        </div>
        {{-- @endif --}}

</nav>
</div>

