{{-- One subscription on one product. The lifecycle bar is the same shared component the generic subscription screen and the BMart screen render. Same routes, same SubscriptionManager, and every action ends in redirect()->back() — which is why pressing Activate here returns here rather than dropping the administrator into a different product's list. --}} @php $value = $subscription->status instanceof \BackedEnum ? $subscription->status->value : (string) $subscription->status; $tones = [ 'trialing' => 'bg-sky-50 text-sky-700 border-sky-200', 'active' => 'bg-emerald-50 text-emerald-700 border-emerald-200', 'past_due' => 'bg-amber-50 text-amber-700 border-amber-200', 'grace' => 'bg-orange-50 text-orange-700 border-orange-200', 'suspended' => 'bg-rose-50 text-rose-700 border-rose-200', 'cancelled' => 'bg-slate-800 text-slate-400 border-slate-700', ]; @endphp
{{-- Login as Customer can be refused — no portal login to enter, a customer who is not active, a session already impersonating — and the refusal comes back as an error this page had no outlet for. Unsaid, a refusal reads as a button that does nothing. --}} @error('impersonation') @enderror

Subscription #{{ $subscription->id }}

{{ $subscription->tenant?->name ?? 'No account' }}

{{ $subscription->plan?->name ?? 'Plan removed' }} · {{ $subscription->currency }} {{ number_format((float) ($subscription->plan?->price ?? 0), 2) }}

{{-- The customer page's own button, here because this is where an administrator is standing when they want to see what this customer sees. It posts to that page's route, so the same rules decide it and the same audit row records it; nothing about who may do it, or as whom, is decided here. Amber, as there: it does not change the subscription, it changes who this session is signed in as. It enters BCP's own customer portal. "Visit as customer" beside it is the other thing — into the product itself — and only for a product that can take an administrator in. --}} @if ($portalCustomer)
@csrf
@endif {{-- Into the product itself, as the account's owner. Up here beside the status because this is where an administrator looks for the way in, and for a POS shop it is the only one: a shop is an account, not a BCP customer, so the button above is never offered for it. Opens in a new tab, so the administrator stays signed in here. --}} @if ($canVisit)
@csrf {{-- The same classes as "Generate Invoice": ones the built stylesheet is known to carry. --}}
@endif @if (! $portalCustomer && ! $canVisit) {{-- No way in at all: nobody has been linked to this account, and its product cannot take an administrator in. Saying so is better than buttons missing without a reason. --}} No customer linked @endif {{ str_replace('_', ' ', $value) }}
{{-- An account the product has removed has nothing left to visit, reset or delete. --}} @php $accountDeleted = $factoryReset['deleted'] ?? null; @endphp @if ($factoryReset && ! $accountDeleted)
@if ($factoryReset && ! $accountDeleted && $factoryReset['canReset']) {{-- The panel itself is kept last on the page; this only takes the administrator to it. A button, not a #link: a #link scrolls the whole shell (which is meant never to move) and leaves the page shifted up with an empty space below. This scrolls only the content area the panel is in. --}} @endif @if ($factoryReset && ! $accountDeleted && $factoryReset['canDeactivate']) @endif @if ($factoryReset && ! $accountDeleted && $factoryReset['canDelete']) {{-- The same: only a way down to the form, which asks for the name typed out. --}} @endif
@endif
Trial ends
{{ $subscription->trial_ends_at?->format('M d, Y') ?? '—' }}
Period ends
{{ $subscription->current_period_ends_at?->format('M d, Y') ?? '—' }}
Grace until
{{ $subscription->grace_period_ends_at?->format('M d, Y') ?? '—' }}

Invoices

All invoices →
@forelse ($subscription->invoices as $invoice) @empty @endforelse
Invoice Status Total Due
{{ $invoice->invoice_number }} {{ $invoice->status instanceof \BackedEnum ? $invoice->status->value : $invoice->status }} {{ $invoice->currency }} {{ number_format((float) $invoice->total, 2) }} {{ $invoice->due_date?->format('M d, Y') ?? '—' }}

No invoices yet

Generate Invoice above raises one against this subscription.

{{-- Factory reset. Kept last and apart from everything above, in its own colour, because it is the one thing on this screen that cannot be undone from here. Present only for a product whose integration supports it and a subscription that pays for an account of it. BCP erases nothing: the form records a request and tells the product, which does the wipe itself and reports back into the list below. --}} @if ($factoryReset) @php $resetIntegration = $factoryReset['integration']; $resetNoun = $resetIntegration->accountNoun(); @endphp {{-- `relative` matters: the table below has a screen-reader-only heading, which is absolutely positioned. Without a positioned ancestor it is placed against the page itself, this far down, and makes the whole page taller than the screen — an empty space to scroll into. --}}

Danger zone

@if ($accountDeleted) This {{ $resetNoun }} has been deleted @elseif ($factoryReset['canReset']) Factory reset @elseif ($factoryReset['canDeactivate']) Deactivate or delete this {{ $resetNoun }} @else Delete this {{ $resetNoun }} @endif

@if ($accountDeleted) {{-- Nothing more can be asked for: the product no longer has the account. --}}

{{ $resetIntegration->name() }} reported this {{ $resetNoun }} {{ $factoryReset['accountId'] }} removed on {{ $accountDeleted->completed_at?->format('M d, Y H:i') }}. Its sign-ins no longer work there.

The subscription above was cancelled at the same moment. Its invoices and payments are kept as the record of what happened.

{{ $resetIntegration->name() }} keeps a recovery snapshot for a limited time; bringing the {{ $resetNoun }} back from it is done on {{ $resetIntegration->name() }}'s server, not from here.

@endif @if (! $accountDeleted && $factoryReset['canReset'])

Asks {{ $resetIntegration->name() }} to erase every record of this {{ $resetNoun }} {{ $factoryReset['accountId'] }} — patients, bills, staff other than the owner, and settings — so that the {{ $resetNoun }} starts again as new.

{{ $resetIntegration->name() }} keeps a recovery snapshot for a limited time. After that the data cannot be brought back.

The subscription and billing in BCP are not affected: the plan, the invoices and the payments above stay exactly as they are.

BCP erases nothing itself. {{ $resetIntegration->name() }} is told at once and does the wipe; a request it has not picked up within {{ $factoryReset['windowHours'] }} hours expires and is never acted on.

@unless ($resetIntegration->notifies()) @endunless
@csrf
@endif {{-- Deleting the account altogether: for one that tried the product and will not stay. The same request, of another kind; the same name typed out. Unlike a reset it does end the subscription, once the product reports the account gone. --}} @if (! $accountDeleted && $factoryReset['canDeactivate'])

Deactivate this {{ $resetNoun }}

Asks {{ $resetIntegration->name() }} to close this {{ $resetNoun }} {{ $factoryReset['accountId'] }}: nobody of it can sign in and its public pages are off. Every record is kept, and it can be opened again.

When {{ $resetIntegration->name() }} reports it done, this subscription is suspended, not cancelled. Its invoices and payments are kept.

BCP changes nothing in {{ $resetIntegration->name() }} itself. A request {{ $resetIntegration->name() }} has not picked up within {{ $factoryReset['windowHours'] }} hours expires and is never acted on.

@unless ($resetIntegration->notifies()) @endunless
@csrf
{{-- The same shape as the two rose buttons on this page and as "Deactivate Brand": the 600 shade as the ground, a literal white label, the 500 shade on hover. It was written as the darkest slate on a lighter amber, which is dark ink where the ramp runs the usual way. This panel inverts the slate ramp, so the darkest slate is near-white here and the label could barely be read. --}}
@endif @if (! $accountDeleted && $factoryReset['canDelete'])
@if ($factoryReset['canReset'] || $factoryReset['canDeactivate'])

Delete this {{ $resetNoun }}

@endif

Asks {{ $resetIntegration->name() }} to remove this {{ $resetNoun }} {{ $factoryReset['accountId'] }} altogether — every record, every staff account and the owner's, and the {{ $resetNoun }} itself. Nobody can sign in to it afterwards.

{{ $resetIntegration->name() }} keeps a recovery snapshot for a limited time. After that it cannot be brought back.

When {{ $resetIntegration->name() }} reports the {{ $resetNoun }} gone, this subscription is cancelled. Its invoices and payments are kept.

BCP removes nothing itself. A request {{ $resetIntegration->name() }} has not picked up within {{ $factoryReset['windowHours'] }} hours expires and is never acted on.

@unless ($resetIntegration->notifies()) @endunless
@csrf
@endif
@forelse ($factoryReset['requests'] as $resetRequest) @php $resetExpired = $resetRequest->hasExpired($factoryReset['windowHours']); @endphp @empty @endforelse
Requested By Status Result Actions
{{-- Which of the two was asked for. --}}

{{ $resetRequest->kindLabel() }}

{{ $resetRequest->requested_at->format('M d, Y H:i') }}
{{ $resetRequest->requester?->name ?? '—' }} @if ($resetExpired) Expired @else {{ $resetRequest->status->label() }} @endif @if ($resetRequest->reason)

Reason: {{ $resetRequest->reason }}

@endif @if ($resetExpired)

Never picked up by {{ $resetIntegration->name() }}; it will not be acted on.

@elseif ($resetRequest->result)

{{ $resetRequest->result }}

@elseif (! $resetRequest->reason) — @endif @if ($resetRequest->completed_at)

{{ $resetRequest->completed_at->format('M d, Y H:i') }}

@endif
@if ($resetRequest->status->isOpen())
@csrf
@endif
Nothing has been requested for this {{ $resetNoun }}.
@endif