<!-- Show active services -->
<div class="card card-dark">
	<div class="card-header">
		<h3 class="card-title">Active Services</h3>
	</div>

	<div class="card-body">
		@if ($o->services->count())
			<table class="table table-striped table-hover" id="services_active">
				<thead>
				<tr>
					<th>ID</th>
					<th>Category</th>
					<th>Service</th>
					<th>Product</th>
					<th>Next Invoice</th>
				</tr>
				</thead>

				<tbody>
				@foreach ($o->services as $oo)
				<tr>
					<td><a href="{{ url('u/service',[$oo->id]) }}">{{ $oo->sid }}</a></td>
					<td>{{ $oo->product_category }}</td>
					<td>{{ $oo->name_short }}</td>
					<td>{{ $oo->product_name }}</td>
					<td>{{ $oo->external_billing ? '-' : $oo->next_invoice->format('Y-m-d') }}</td>
				</tr>
				@endforeach
				</tbody>
				<tfoot>
				<tr>
					<th>Count {{ $o->services->count() }}</th>
					<th colspan="4">&nbsp;</th>
				</tr>
				</tfoot>
			</table>

		@else
			<p>No services active</p>
		@endif
	</div>
</div>

@section('page-scripts')
	@css('//cdn.datatables.net/1.10.25/css/dataTables.bootstrap4.min.css','jq-dt-css')
	@js('//cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js','jq-dt-js')
	@js('//cdn.datatables.net/1.10.25/js/dataTables.bootstrap4.min.js','jq-dt-bs5-js','jq-dt-js')
	@js('//cdn.datatables.net/rowgroup/1.1.3/js/dataTables.rowGroup.min.js','jq-dt-rowgroup-js','jq-dt-js')
	@css('//cdn.datatables.net/rowgroup/1.1.3/css/rowGroup.bootstrap4.min.css','jq-dt-rowgroup-css','jq-dt-jss')

	<style>
		table.dataTable tr.dtrg-group.dtrg-end.dtrg-level-0 {
			font-size: 75%;
			background-color: #eeeeee !important;
		}
		table.dataTable tr.dtrg-group.dtrg-end.dtrg-level-0 td {
			background-color: #fefefe !important;
		}
	</style>

	<script type="text/javascript">
		$(document).ready(function() {
			$('#services_active').DataTable( {
				order: [4,'asc'],
				rowGroup: {
					dataSrc: 1,
					endRender: function ( rows, group ) {
						return rows.count()+' x ' + group;
					},
				},
			});

			$('#services_active tbody').on('click','tr', function () {
				$(this).toggleClass('selected');
			});
		});
	</script>
@append