<!-- $o=Service::class -->
<table class="table table-sm table-striped" id="svc_bill_hist">
	<thead>
		<tr>
			<th>Invoice</th>
			<th>Start</th>
			<th>Stop</th>
			<th>Service</th>
			<th>Extras</th>
			<th class="text-right">Total</th>
		</tr>
	</thead>

	<tbody>
	@foreach($o->invoiced_items_active->groupBy('invoice_id') as $oo)
		<tr>
			<td><a href="{{ url('u/invoice',($x=$oo->first())->invoice_id) }}">{{ $x->invoice_id }}</a></td>
			<td>{{ ($y=$oo->where('item_type',0))->min('start_at')->format('Y-m-d') }}</td>
			<td>{{ $y->max('stop_at')->format('Y-m-d') }}</td>
			<th>{{ number_format($y->sum('total'),2) }}</th>
			<th>{{ number_format($oo->where('item_type','<>',0)->sum('total'),2) }}</th>
			<td class="text-right">{{ number_format($oo->sum('total'),2) }}</td>
		</tr>
	@endforeach
	</tbody>
</table>

@pa(datatables,conditionalpaging)

@section('page-scripts')
	<script type="text/javascript">
		$(document).ready(function() {
			$('#svc_bill_hist').DataTable({
				conditionalPaging: true,
				language: {
					emptyTable: "No Invoices"
				},
				order: [1,'desc'],
				pageLength: 10
			});
		});
	</script>
@append