39496-vm/dashboard.php
2026-04-06 04:21:26 +00:00

121 lines
7.8 KiB
PHP

<?php
require_once __DIR__ . '/includes/app.php';
$subscription = current_subscription();
$history = [];
if ($subscription) {
$history = fetch_subscriptions_by_email((string) $subscription['email']);
}
render_head(
t('Student dashboard', 'لوحة الطالب'),
t('Review the active subscription, upcoming live classes, and access to subject detail pages.', 'راجع الاشتراك النشط والفصول المباشرة القادمة والوصول إلى صفحات تفاصيل المواد.')
);
render_nav('dashboard.php');
?>
<main class="py-5">
<div class="container">
<?php if (!$subscription): ?>
<div class="panel-card text-center">
<span class="eyebrow"><?= h(t('Student dashboard', 'لوحة الطالب')) ?></span>
<h1 class="section-title mb-2"><?= h(t('No active subscription yet', 'لا يوجد اشتراك نشط بعد')) ?></h1>
<p class="text-secondary mb-4"><?= h(t('Start with pricing, complete the checkout form, and your personalized classroom dashboard will appear here.', 'ابدأ بالتسعير وأكمل نموذج الدفع وستظهر هنا لوحة الفصول الشخصية الخاصة بك.')) ?></p>
<div class="d-flex justify-content-center flex-wrap gap-2">
<a class="btn btn-dark" href="<?= h(app_url('pricing.php')) ?>"><?= h(t('Choose a plan', 'اختر خطة')) ?></a>
<a class="btn btn-outline-dark" href="<?= h(app_url('catalog.php')) ?>"><?= h(t('Browse catalog', 'تصفح الكتالوج')) ?></a>
</div>
</div>
<?php else: ?>
<?php $plan = get_plan($subscription['plan_key']) ?? get_plan('plus'); ?>
<div class="row g-4">
<div class="col-lg-8">
<div class="panel-card mb-4">
<div class="d-flex flex-wrap justify-content-between gap-3 align-items-start">
<div>
<span class="eyebrow"><?= h(t('Active subscription', 'الاشتراك النشط')) ?></span>
<h1 class="section-title mb-2"><?= h(t('Welcome back, ', 'مرحباً بعودتك، ') . $subscription['full_name']) ?></h1>
<p class="text-secondary mb-0"><?= h(t('Your plan is active and your next live classrooms are listed below.', 'خطتك نشطة وتم إدراج الفصول المباشرة القادمة أدناه.')) ?></p>
</div>
<span class="badge bg-success-subtle text-success-emphasis border border-success-subtle px-3 py-2"><?= h(plan_name($plan)) ?></span>
</div>
</div>
<div class="row g-3 mb-4">
<?php $unlocked = array_slice(subjects_catalog(), 0, $plan['subjects_limit'] >= 999 ? 4 : $plan['subjects_limit']); ?>
<?php foreach ($unlocked as $subject): ?>
<?php
$modules = subject_modules($subject);
$totalModules = count($modules);
$completed = count(get_completed_modules((int) $subscription['id'], $subject['slug']));
$progress = $totalModules > 0 ? round(($completed / $totalModules) * 100) : 0;
?>
<div class="col-md-6">
<article class="subject-card h-100 d-flex flex-column">
<div class="d-flex justify-content-between align-items-start gap-3 mb-2">
<div>
<h2 class="h6 mb-1"><?= h(subject_title($subject)) ?></h2>
<p class="small text-secondary mb-0"><?= h(subject_teacher($subject)) ?></p>
</div>
<span class="mini-tag"><?= h(t('Unlocked', 'مفتوحة')) ?></span>
</div>
<div class="mb-3">
<p class="text-secondary small mb-1"><?= h(t('Progress:', 'التقدم:')) ?> <?= h((string) $progress) ?>%</p>
<div class="progress" style="height: 6px;">
<div class="progress-bar bg-dark" role="progressbar" style="width: <?= h((string) $progress) ?>%;" aria-valuenow="<?= h((string) $progress) ?>" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
<p class="text-secondary small mb-3 flex-grow-1"><?= h(t('Next live:', 'الجلسة المباشرة القادمة:')) ?> <?= h(subject_next_live($subject)) ?></p>
<div class="d-flex gap-2">
<a class="btn btn-sm btn-dark" href="<?= h($subject['meet_url']) ?>" target="_blank" rel="noreferrer"><?= h(t('Meet', 'ميت')) ?></a>
<a class="btn btn-sm btn-outline-dark" href="<?= h(app_url('subject.php', ['slug' => $subject['slug']])) ?>"><?= h(t('Details', 'التفاصيل')) ?></a>
</div>
</article>
</div>
<?php endforeach; ?>
</div>
<div class="panel-card">
<div class="d-flex justify-content-between align-items-center mb-3">
<h2 class="h5 mb-0"><?= h(t('Subscription history', 'سجل الاشتراكات')) ?></h2>
<a class="link-dark text-decoration-none fw-semibold" href="<?= h(app_url('subscription.php', ['id' => (int) $subscription['id']])) ?>"><?= h(t('Open current detail', 'افتح التفاصيل الحالية')) ?></a>
</div>
<div class="table-responsive">
<table class="table align-middle dashboard-table mb-0">
<thead>
<tr>
<th><?= h(t('Reference', 'المرجع')) ?></th>
<th><?= h(t('Plan', 'الخطة')) ?></th>
<th><?= h(t('Created', 'تاريخ الإنشاء')) ?></th>
<th><?= h(t('Action', 'الإجراء')) ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($history as $item): ?>
<?php $historyPlan = get_plan($item['plan_key']) ?? get_plan('plus'); ?>
<tr>
<td><?= h($item['thawani_reference']) ?></td>
<td><?= h(plan_name($historyPlan)) ?></td>
<td><?= h((string) $item['created_at']) ?></td>
<td><a class="btn btn-sm btn-outline-dark" href="<?= h(app_url('subscription.php', ['id' => (int) $item['id']])) ?>"><?= h(t('View', 'عرض')) ?></a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-lg-4">
<aside class="panel-card sticky-card">
<h2 class="h5 mb-3"><?= h(t('Student profile', 'ملف الطالب')) ?></h2>
<div class="summary-row"><span><?= h(t('Preferred language', 'اللغة المفضلة')) ?></span><strong><?= h($subscription['preferred_language'] === 'ar' ? 'العربية' : 'English') ?></strong></div>
<div class="summary-row"><span><?= h(t('WhatsApp reminders', 'تذكيرات واتساب')) ?></span><strong><?= h((int) $subscription['wablas_opt_in'] === 1 ? t('Enabled', 'مفعلة') : t('Off', 'متوقفة')) ?></strong></div>
<div class="summary-row"><span><?= h(t('Payment gateway', 'بوابة الدفع')) ?></span><strong><?= h($subscription['payment_gateway']) ?></strong></div>
<div class="summary-row"><span><?= h(t('Live classroom', 'الفصل المباشر')) ?></span><strong>Google Meet</strong></div>
<hr>
<div class="d-grid gap-2">
<a class="btn btn-dark" href="<?= h(app_url('catalog.php')) ?>"><?= h(t('Explore more subjects', 'استكشف المزيد من المواد')) ?></a>
<a class="btn btn-outline-dark" href="<?= h(app_url('teacher.php')) ?>"><?= h(t('Open teacher view', 'افتح عرض المعلم')) ?></a>
</div>
</aside>
</div>
</div>
<?php endif; ?>
</div>
</main>
<?php render_footer(); ?>