@extends('adminlte::layouts.app')

@section('htmlheader_title')
	Web Hosting
@endsection
@section('page_title')
	Web Hosting
@endsection

@section('contentheader_title')
	Web Hosting
@endsection
@section('contentheader_description')
	Web Hosting currently managed.
@endsection

@section('main-content')
	<div class="row">
		<div class="col-12">
			<div class="card card-dark">
				<div class="card-body">
					<table class="table table-hover" id="services">
						<thead>
						<tr>
							<th>Service ID</tH>
							<th>Account</th>
							<th>Product</th>
							<th>Domain</th>
							<th>Expires</th>
							<th>Supplier</th>
							<th>Next Billed</th>
							<th>Price</th>
							<th>Term</th>
						</tr>
						</thead>

						<tbody>
						@foreach ($o as $oo)
							<tr @if ($oo->has_expired) class="table-danger" @endif>
								<td><a href="{{ url('u/service',[$oo->service_id]) }}">{{ $oo->service->sid }}</td>
								<td>{{ $oo->service->account->name }}</td>
								<td>{{ $oo->service->product->name }}</td>
								<td>{{ $oo->service->name }}</td>
								<td>{{ $oo->service_expire ? $oo->service_expire->format('Y-m-d') : '-' }}</td>
								<td>{{ $oo->service->product->supplier->name }}</td>
								<td>@if ($oo->service->is_billed) {{ $oo->service->invoice_next->format('Y-m-d') }}@else - @endif</td>
								<td>@if (! $oo->service->external_billing)${{ number_format($oo->service->next_invoice_items()->sum('total'),2) }}@else - @endif</td>
								<td>{{ $oo->service->billing_interval_name }}</td>
							</tr>
						@endforeach
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
@endsection

@pa(datatables,rowgroup)

@section('page-scripts')
	<script type="text/javascript">
		$(document).ready(function() {
			$('#services').DataTable({
				order: [[5,'asc'],[1,'asc'],[2,'desc']],
				rowGroup: {
					dataSrc: 5,
				},
				columnDefs: [
					{
						targets: [5],
						visible: false,
					}
				],
			});
		});
	</script>
@append