@extends('layouts.app') @section('content')

{{ __('billing.title') }}

{{ __('billing.current_plan') }} {{ __('billing.subtitle') }}

@if($activeSubscription)

{{ Lang::has('billing.plans_names.' . $activeSubscription->plan->slug) ? __('billing.plans_names.' . $activeSubscription->plan->slug) : $activeSubscription->plan->name }}

{{ __('billing.status') }}: @if($activeSubscription->status === 'active') {{ __('billing.active') }} @elseif($activeSubscription->status === 'trialling') {{ __('billing.trialling') }} @elseif($activeSubscription->status === 'cancelled') {{ __('billing.cancelled') }} @else {{ __('billing.expired') }} @endif
@if($activeSubscription->status === 'trialling')
{{ __('billing.trial_ends_at') }}
{{ $activeSubscription->trial_ends_at ? $activeSubscription->trial_ends_at->translatedFormat('d F Y H:i') : '-' }}
@else
{{ __('billing.ends_at') }}
{{ $activeSubscription->ends_at ? $activeSubscription->ends_at->translatedFormat('d F Y H:i') : '-' }}
@endif
@else

{{ __('billing.expired') }}

{{ __('billing.no_active_subscription') }}
@endif
@if($activeSubscription && in_array($activeSubscription->status, ['active', 'trialling']))
@csrf
@endif

{{ __('billing.usage_limits') }}

@foreach(['customers' => 'customers_limit', 'orders' => 'orders_limit', 'measurements' => 'measurements_limit', 'emails' => 'emails_limit'] as $key => $transKey)
{{ __('billing.' . $transKey) }}
{{ $usage[$key]['count'] }} / {{ $usage[$key]['limit'] ?? __('billing.unlimited') }}
@if($usage[$key]['limit']) @php $pct = min(100, round(($usage[$key]['count'] / $usage[$key]['limit']) * 100)); $barClass = 'bg-primary'; if($pct >= 90) { $barClass = 'bg-danger'; } elseif($pct >= 75) { $barClass = 'bg-warning'; } @endphp
{{ __('billing.usage_occupancy', ['pct' => $pct]) }}
@else
{{ __('billing.unlimited_usage') }}
@endif
@endforeach

{{ __('billing.plans') }}

{{ __('billing.plans_subtitle') }}
@foreach($plans as $plan) @php $isCurrentPlan = $activeSubscription && $activeSubscription->plan->id === $plan->id && $activeSubscription->isActive(); $colorClass = $plan->slug === 'yearly-premium' ? 'border-primary border-dashed' : 'border-gray-200'; $badgeText = $plan->slug === 'yearly-premium' ? __('billing.popular') : ''; @endphp
@if($badgeText) {{ $badgeText }} @endif

{{ Lang::has('billing.plans_names.' . $plan->slug) ? __('billing.plans_names.' . $plan->slug) : $plan->name }}

{{ Lang::has('billing.plans_descriptions.' . $plan->slug) ? __('billing.plans_descriptions.' . $plan->slug) : ($plan->description ?? __('billing.plan_default_description')) }}

@money($plan->price) / {{ $plan->billing_interval === 'month' ? __('billing.monthly') : __('billing.yearly') }}
  • {{ __('billing.unlimited') }} {{ __('common.customers') }}
  • {{ __('billing.unlimited') }} {{ __('common.orders') }}
  • {{ __('billing.unlimited') }} {{ __('common.measurements') }}
  • {{ __('billing.auto_renew_with_card') }}
@if($isCurrentPlan) @else {{ __('billing.subscribe') }} @endif
@endforeach

{{ __('billing.payment_history') }} {{ __('billing.payment_history_desc') }}

@forelse($payments as $payment) @empty @endforelse
{{ __('billing.plan_name') }} {{ __('billing.transaction_ref') }} {{ __('billing.amount') }} {{ __('billing.status') }} {{ __('billing.payment_date') }}
{{ Lang::has('billing.plans_names.' . $payment->subscription->plan->slug) ? __('billing.plans_names.' . $payment->subscription->plan->slug) : $payment->subscription->plan->name }} {{ $payment->transaction_id ?? '-' }} @money($payment->amount) @if($payment->status === 'success') {{ __('billing.payment_success') }} @else {{ __('billing.payment_failed') }} @endif {{ $payment->payment_date ? $payment->payment_date->translatedFormat('d F Y H:i') : '-' }}
{{ __('billing.no_payment_history') }}
@endsection