@extends('central.super.layout') @section('title', __('super.subscriptions.show_title')) @section('content') @php $tenant = $subscription->tenant; $tenantDisplayName = $tenant->company_name ?? ($tenant->domains->first()->domain ?? $tenant->id); $tenantEmail = $tenant->admin_email ?? null; $tenantDomain = $tenant->domains->first()->domain ?? null; $colors = ['purple', 'blue', 'green', 'amber', 'rose']; $color = $colors[crc32($subscription->tenant_id) % count($colors)]; $initial = strtoupper(mb_substr($tenantDisplayName, 0, 2)); $badgeClass = match($subscription->status) { 'active' => 'active', 'trial' => 'trial', 'pending' => 'pending', 'cancelled' => 'cancelled', 'suspended' => 'suspended', 'expired' => 'expired', 'failed' => 'failed', default => 'secondary', }; @endphp
{{-- Main info --}}
{{-- Subscription details card --}}

{{ __('super.subscriptions.sub_details') }}

{{ __('super.status.' . $subscription->status) }}
{{-- Plan & Amount highlight --}}
{{ __('super.subscriptions.plan') }}
{{ $subscription->plan->name ?? '—' }}
@if($subscription->amount)
{{ $subscription->currency ?? 'USD' }} ${{ number_format($subscription->amount, 2) }} / {{ $subscription->billing_cycle }}
@endif
{{ ucfirst($subscription->billing_cycle ?? '—') }}
{{ __('super.subscriptions.show_billing_cycle') }}
{{-- Key dates --}}
{{ __('super.subscriptions.show_starts_at') }}
{{ ($subscription->starts_at ?? $subscription->created_at)->format('M d, Y') }}
{{ __('super.subscriptions.ends_at') }}
@if($subscription->ends_at) {{ $subscription->ends_at->format('M d, Y') }} @if($subscription->ends_at->isFuture()) {{ $subscription->ends_at->diffForHumans() }} @else {{ __('super.status.expired') }} @endif @elseif($subscription->status === 'pending') {{ __('super.subscriptions.awaiting_activation') }} @else {{ __('super.status.ongoing') }} @endif
@if($subscription->trial_ends_at || $subscription->cancelled_at)
@if($subscription->trial_ends_at)
{{ __('super.subscriptions.trial_ends_at') }}
{{ $subscription->trial_ends_at->format('M d, Y') }} @if($subscription->trial_ends_at->isFuture()) {{ $subscription->trial_ends_at->diffForHumans() }} @else {{ __('super.status.expired') }} @endif
@endif @if($subscription->cancelled_at)
{{ __('super.subscriptions.show_cancelled_at') }}
{{ $subscription->cancelled_at->format('M d, Y \a\t h:i A') }}
@endif
@endif {{-- Timestamps --}}
{{ __('super.payments.created') }}
{{ $subscription->created_at->format('M d, Y') }}
{{ $subscription->created_at->format('h:i A') }}
{{ __('super.payments.updated') }}
{{ $subscription->updated_at->format('M d, Y') }}
{{ $subscription->updated_at->format('h:i A') }}
@if($subscription->ends_at)
{{ __('super.subscriptions.show_days_remaining') }}
{{ $subscription->daysRemaining() }} {{ __('super.subscriptions.show_days') }}
@endif
{{-- Payment history --}}

{{ __('super.subscriptions.show_payment_history') }}

{{ $subscription->payments->count() }} {{ __('super.subscriptions.show_payments_count') }}
@if($subscription->payments->count())
@foreach($subscription->payments as $payment) @php $payBadge = match($payment->status) { 'paid' => 'yes', 'failed' => 'no', 'refunded' => 'info', default => 'pending', }; @endphp @endforeach
{{ __('super.payments.invoice') }} {{ __('super.common.amount') }} {{ __('super.payments.gateway') }} {{ __('super.common.status') }} {{ __('super.common.date') }}
{{ $payment->invoice_number }} {{ $currencySymbol }}{{ number_format($payment->amount, 2) }} {{ $payment->gateway_label }} {{ ucfirst($payment->status) }} {{ $payment->created_at->format('M d, Y') }}
@else

{{ __('super.subscriptions.show_no_payments') }}

{{ __('super.subscriptions.show_no_payments_desc') }}

@endif
{{-- Sidebar --}}
{{-- Tenant info --}}

{{ __('super.subscriptions.tenant') }}

{{ $initial }}

{{ $tenantDisplayName }}

@if($tenantDomain)

{{ $tenantDomain }}

@endif @if($tenantEmail)

{{ $tenantEmail }}

@endif
{{ __('super.payments.view_tenant') }}
{{-- Plan info --}} @if($subscription->plan)

{{ __('super.subscriptions.plan') }}

{{ $subscription->plan->name }}

{{ $currencySymbol }}{{ number_format($subscription->plan->price, 2) }}/{{ __('super.plans.mo') }} · {{ $currencySymbol }}{{ number_format($subscription->plan->yearly_price, 2) }}/{{ __('super.plans.yr') }}

@if($subscription->plan->is_private) {{ __('super.plans.private') }} @endif
@endif {{-- Allowed transitions --}} @php $allowedTransitions = \App\Models\Central\TenantSubscription::ALLOWED_TRANSITIONS[$subscription->status] ?? []; $hasPaidPayment = $subscription->payments->where('status', 'paid')->isNotEmpty(); $pendingPayment = $subscription->payments->where('status', 'pending')->first(); $isPendingNeedsPayment = $subscription->status === 'pending' && !$hasPaidPayment; @endphp {{-- Actions --}}

{{ __('super.common.actions') }}

@if($isPendingNeedsPayment && $pendingPayment) {{-- Pending subscription with unpaid payment — direct admin to approve payment first --}} {{ __('super.subscriptions.approve_payment_btn') }}
{{ __('super.subscriptions.payment_required_hint') }}
@elseif($isPendingNeedsPayment && !$pendingPayment) {{-- Pending subscription with no payment at all --}}
{{ __('super.subscriptions.no_payment_hint') }}
@elseif(in_array('active', $allowedTransitions))
@csrf
@endif @if(in_array('suspended', $allowedTransitions))
@csrf
@endif @if(in_array('cancelled', $allowedTransitions))
@csrf
@endif {{ __('super.subscriptions.edit_sub') }}
{{-- Notes --}}

{{ __('super.subscriptions.show_status_info') }}

@push('scripts') @endpush @endsection