<div class="card card-dark">
	<div class="card-header p-2">
		<h4 class="card-title">Accounts</h4>
	</div>

	<div class="card-body p-2">
		@if($x=$o->accounts_all->count())
			<table class="table table-sm table-striped table-hover" id="accounts">
				<thead>
				<tr>
					<th style="width: 10%;">Profile</th>
					<th>Name</th>
					<th class="text-right" style="width: 10%;">Services</th>
				</tr>
				</thead>
				<tbody>
				@foreach($o->accounts_all as $ao)
					@php
						$ao->load(['services:id,active,account_id']);
					@endphp
					<tr>
						<td><a href="{{ url('switch/start',$ao->user_id) }}"><i class="fas fa-external-link-alt"></i></a></td>
						<td><a href="{{ url('u/home',$ao->user_id) }}">{{ $ao->name }}</a></td>
						<td class="text-right">{{ $ao->services->where('active',TRUE)->count() }} <small>/{{ $ao->services->count() }}</small></td>
					</tr>
				@endforeach
				</tbody>

				<tfoot>
				<tr>
					<th>Count {{ $x }}</th>
					<th colspan="2">&nbsp;</th>
				</tr>
				</tfoot>
			</table>

		@else
			<p>No Accounts Active</p>
		@endif
	</div>
</div>

@pa(datatables,rowgroup|conditionalpaging)

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