 <div class="table-responsive">
  <table id="example" class="table table-bordered align-middle" style="width:100%">
    <thead class="table-light">
      <tr>
        <th>Sl No</th>
        <th>Date</th>
        <th>Doctor Name (Dr. Code)</th>
        <th>INV NO</th>
        <th>Patient NAME (Patient Code)</th>
        <th>Category</th>
        <th>ITEM</th>
        <th style="text-align: right;">Basic Amount</th>
        <th style="text-align: right;">Com. %</th>
        <th style="text-align: right;">Per unit</th>
        <th style="text-align: right;">Total Amount</th>
    </tr>
</thead>
<tbody>
    @php $auth_format = \Session::get('company_data')['date_format'] ?? ''; @endphp
    @php $i=1; @endphp
    @if(count($data)>0)
        @foreach($data as $key=> $row)
            <tr>
                <td>{{ 1 + $key}}</td>
                <td>{{ formatedDate($row['sale_invoice_details']->created_at) }}</td>
                <td>
                    {{ $row['sale_invoice_details']->doctor }}
                    ({!! $row['sale_invoice_details']->doctor_code !!})
                </td>
                <td>{{ $row['sale_invoice_details']->main_invoice_no }}</td>
                <td>
                    {{ $row['sale_invoice_details']->patient_name }}
                    ({{ $row['sale_invoice_details']->patient_code }})
                </td>
                <td>{{ $row['sale_invoice_details']->brand }}</td>
                <td>{{ $row['sale_invoice_details']->product }}</td>
                <td style="text-align: right;">{{ $row['sale_invoice_details']->basic_amount }}</td>
                @php
                    $amount     = $row['sale_invoice_details']->basic_amount ?? 0 ;

                    $type       = isset($row['incentive_slab_details']) &&
                        isset($row['incentive_slab_details']->calculation_type)
                        ? $row['incentive_slab_details']->calculation_type : 0 ;

                    $percentage       = isset($row['incentive_slab_details']) &&
                        isset($row['incentive_slab_details']->percentage)
                        ? $row['incentive_slab_details']->percentage : 0 ;

                    $price       = isset($row['incentive_slab_details']) &&
                        isset($row['incentive_slab_details']->price)
                        ? $row['incentive_slab_details']->price : 0 ;

                    $commission = 0 ;

                    if ($type == 'quantity') {
                        $commission = $price;
                    } else if ($type == 'percentage') {
                        $commission = ($percentage / 100) * $price;
                    }
                @endphp
                <td style="text-align: right;">{{ $percentage }}</td>
                <td style="text-align: right;">{{ $price }}</td>
                <td style="text-align: right;">{{ $commission }}</td>
            </tr>
            @php $i++; @endphp
        @endforeach
    @else
        <tr>
            <td colspan="10">No Data Found</td>
        </tr>
    @endif
</tbody>
</table>
</div>
<nav class="float-start mt-2">
    <ul class="pagination">
        {{-- {!! $data->onEachSide(0)->render('financialyear.pagination') !!} --}}
    </ul>
</nav>
</div>

