<!-- $o=Service::class -->
<div class="card">
	@if($o->external_billing)
		<div class="ribbon-wrapper ribbon-lg">
			<div class="ribbon bg-danger">
				EXTERNAL BILLING
			</div>
		</div>
	@endif

	<div class="card-header bg-light p-2">
		<h3 class="card-title">Service Information</h3>
	</div>

	<div class="card-body p-2">
		<table class="table table-sm">
			<tr>
				<th>Account</th>
				<td><a href="{{url('u/home',$o->account->user_id)}}">{{ $o->account->sid }}</a></td>
			</tr>
			<tr>
				<th>Status</th>
				<td><x-button.status :status="$o->status" :substatus="$o->order_status"/></td>
			</tr>
			@if($o->is_pending_cancel)
				<tr>
					<th>Cancel Date</th>
					<td>{{ $o->stop_at->format('Y-m-d') }}</td>
				</tr>
			@endif
			@if($o->order_status == 'ORDER-SENT')
				<tr>
					<th>Order Reference</th>
					<td>{{ $o->order_info_reference ?? '' }}</td>
				</tr>
			@endif
			@if($o->start_at && $o->is_pending_active)
				<tr>
					<th>Pending Connection</th>
					<td>{{ $o->start_at->format('Y-m-d') }}</td>
				</tr>
			@endif
			@if(($o->active || $o->is_pending_active) && (! $o->external_billing))
				<tr>
					<th>Billed</th>
					<td>{{ $o->billing_interval_name }}</td>
				</tr>
				<tr>
					<th>Amount</th>
					@if($o->is_charge_overridden)
						<td>@if($o->billing_charge < $o->billing_charge_orig)<del>${{ number_format($o->billing_charge_orig_taxed,2) }}</del> @endif${{ number_format($o->billing_charge_taxed,2) }}</td>
					@else
						<td>${{ number_format($o->billing_charge_taxed,2) }}</td>
					@endif
				</tr>
				@if($o->is_active && $o->invoiced_to)
					<tr>
						<th>Invoiced To</th>
						<td>{{ $o->invoiced_to->format('Y-m-d') }}</td>
					</tr>
					@if($o->paid_to)
						<tr>
							<th>Paid Until</th>
							<td>{{ $o->paid_to->format('Y-m-d') }}</td>
						</tr>
					@endif
				@endif

				<tr>
					<th>Next Invoice</th>
					<td>@if($o->suspend_billing)<del>@endif{{ $o->invoice_next?->format('Y-m-d') }}@if($o->suspend_billing)</del> <strong>SUSPENDED</strong>@endif</td>
				</tr>

				@if($o->invoice_next)
					<tr>
						<th>Next Estimated Invoice</th>
						<td>${{ number_format($o->next_invoice_items()->sum('total'),2) }} <sup>*</sup></td>
					</tr>
				@endif

				<tr>
					<th>Payment Method</th>
					<td>@if($o->billing)Direct Debit @else Invoice @endif</td>
				</tr>

			@elseif($o->is_cancelled)
				<tr>
					<th>Cancelled</th>
					<td>{{ ($o->stop_at ?: $o->paid_to)?->format('Y-m-d') }}</td>
				</tr>
			@endif
		</table>
	</div>

	@if($o->active || $o->is_pending_active)
		<div class="card-footer sm">
			<strong><sup>*</sup>NOTE:</strong> Estimated Invoice does not include any setup, connection nor all current billing cycle usage charges.
		</div>
	@endif
</div>