<table class="table table-striped table-bordered">
  <thead>
    <tr>
      <th>{{ trans('products.id') }}</th>
      <th>{{ trans('sale_history.sku') }}</th>
      <th style="width:20%;">{{ trans('sale_history.name_en')}} </th>
      <th style="width:20%;">{{ trans('sale_history.name_kh')}}</th>
      <th>{{ trans('products.amount')}}</th>
      <th>{{ trans('sale_history.price')}}</th>
      <th>{{ trans('sale_history.category')}}</th>
      <th>{{ trans('reports.user')}}</th>
      <th>{{ trans('invoices.invoice_no')}}</th>
      <th>{{ trans('sale_history.date_sold')}}</th>
    </tr>
  </thead>
  <tbody>
    <?php
      $totalPriceIn = 0;
      $total_price = 0;
      $totalPriceIn = 0;
      $i= 1;
     ?>
    @foreach ($results as $result)
      <?php
        $total_price += (float) $result->price * $result->amount;
        $totalPriceIn += (float) $result->price_in * $result->amount;
       ?>
    <tr>
      <td>{{ $i }}</td>
      <td>{{ $result->sku }}</td>
      <td>{{ $result->name_en }}</td>
      <td>{{ $result->name_kh }}</td>
      <td>{{ $result->amount }}</td>
      <td>{{ money($result->price) }}</td>
      <td>{{ $result->name }}</td>
      <td>{{ $result->first_name }}</td>
      <td>{{ convertInvoiceNumber($result->invoice_no) }}</td>
      <td>{{ $result->created_at }}</td>
    </tr>
    <?php $i++; ?>
    @endforeach
    <tr>
      <td colspan="9" class="text-right">
        {{ trans('reports.total') }}
      </td>
      <td class="text-center price">
        {{ money($total_price)}}
      </td>
    </tr>
    <tr>
      <td colspan="9" class="text-right">
        {{ trans('reports.price_in') }}
      </td>
      <td class="text-center price">
        {{ money($totalPriceIn)}}
      </td>
    </tr>
    <tr>
      <td colspan="9" class="text-right">
        {{ trans('reports.total_income') }}
      </td>
      <td class="text-center price">
        {{ money($total_price - $totalPriceIn)}}
      </td>
    </tr>
  </tbody>
</table>
