Add premium My Case MVP

This commit is contained in:
2026-05-23 10:17:34 +02:00
parent e0aeefc73e
commit 83fc71414f
33 changed files with 1275 additions and 148 deletions
+10 -10
View File
@@ -18,9 +18,11 @@ $detail = $userId > 0 ? FreeTier::balanceDetail($userId) : [
'balance' => 0, 'bonus_balance' => 0, 'tier' => 'caveau',
'storage_used_bytes' => 0, 'storage_quota_bytes' => 0,
'survey_completed_at' => null, 'subscription_period_end' => null,
'trial_active' => false, 'trial_days_remaining' => 0, 'trial_expires_at' => null,
];
$tier = (string)$detail['tier'];
$isPaidTier = in_array($tier, ['plus', 'pro'], true);
$effective = (int)$detail['balance'] + (int)$detail['bonus_balance'];
$storageMb = round($detail['storage_used_bytes'] / 1048576, 1);
$quotaMb = $detail['storage_quota_bytes'] > 0 ? round($detail['storage_quota_bytes'] / 1048576, 0) : 0;
@@ -28,9 +30,8 @@ $storagePct = $quotaMb > 0 ? min(100, round(($storageMb / $quotaMb) * 100)) : 0;
$tierLabels = [
'free' => 'Gratis',
'light' => 'Light',
'pro' => 'Pro',
'pro_plus' => 'Pro+ Familie',
'plus' => 'Plus',
'pro' => 'Pro Familie',
'caveau' => 'CaveauAI',
];
@@ -66,9 +67,8 @@ $status = (string)($_GET['status'] ?? '');
.billing-card h2 { margin: 0 0 0.5rem; font-size: 1.1rem; color: #374151; }
.tier-badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; }
.tier-free { background: #f3f4f6; color: #374151; }
.tier-light { background: #ddd6fe; color: #5b21b6; }
.tier-plus { background: #ddd6fe; color: #5b21b6; }
.tier-pro { background: #bfdbfe; color: #1e40af; }
.tier-pro_plus { background: #fde68a; color: #92400e; }
.tier-caveau { background: #d1fae5; color: #065f46; }
.balance-big { font-size: 2.6rem; font-weight: 700; color: #00205B; margin: 0.5rem 0; }
.balance-break { color: #6b7280; font-size: 0.9rem; }
@@ -104,13 +104,16 @@ $status = (string)($_GET['status'] ?? '');
<p style="margin:0.5rem 0 1rem;">
<span class="tier-badge tier-<?= htmlspecialchars($tier) ?>"><?= htmlspecialchars($tierLabels[$tier] ?? $tier) ?></span>
</p>
<?php if (!empty($detail['trial_active'])): ?>
<p class="balance-break" style="color:#92400e;">Plus prøveperiode: <?= (int)$detail['trial_days_remaining'] ?> dager igjen. Kortet belastes automatisk etter prøveperioden hvis du ikke kansellerer.</p>
<?php endif; ?>
<?php if (!empty($detail['subscription_period_end'])): ?>
<p class="balance-break">Fornyes <?= htmlspecialchars(date('j. F Y', strtotime((string)$detail['subscription_period_end']))) ?></p>
<?php elseif ($tier === 'free'): ?>
<p class="balance-break">Ingen aktiv abonnement. <a href="/pricing.php">Se planer</a></p>
<?php endif; ?>
<div class="billing-actions" style="margin: 1.25rem 0 0;">
<?php if (in_array($tier, ['light','pro','pro_plus'], true)): ?>
<?php if ($isPaidTier): ?>
<button type="button" id="portalBtn" class="btn btn-secondary">Administrer abonnement</button>
<?php endif; ?>
<a class="btn btn-primary" href="/pricing.php">Se alle planer</a>
@@ -123,12 +126,9 @@ $status = (string)($_GET['status'] ?? '');
<p class="balance-break">
<?= (int)$detail['balance'] ?> månedlige · <?= (int)$detail['bonus_balance'] ?> bonus
</p>
<?php if ($tier === 'pro_plus'): ?>
<p style="margin-top:0.5rem; color:#059669; font-size:0.9rem;">✓ Pro+ har ubegrenset bruk (50 kall/time)</p>
<?php endif; ?>
</div>
<?php if (in_array($tier, ['light','pro','pro_plus'], true)): ?>
<?php if ($isPaidTier): ?>
<div class="billing-card">
<h2>Sak-lagring</h2>
<p class="balance-big" style="font-size:1.8rem;"><?= $storageMb ?> MB <span style="color:#6b7280; font-size:1rem;">/ <?= $quotaMb ?> MB</span></p>