72 lines
4.0 KiB
PHP
72 lines
4.0 KiB
PHP
<?php
|
|
require_once __DIR__ . '/includes/app.php';
|
|
|
|
$courses = db()->query("SELECT * FROM courses WHERE status = 'active' ORDER BY created_at DESC")->fetchAll();
|
|
|
|
render_head(
|
|
t('Courses', 'الدورات'),
|
|
t('Browse our specialized short courses.', 'تصفح دوراتنا القصيرة المتخصصة.')
|
|
);
|
|
render_nav('courses.php');
|
|
?>
|
|
<main class="py-5 bg-light min-vh-100">
|
|
<div class="container">
|
|
<div class="section-header mb-5 text-center">
|
|
<span class="eyebrow"><?= h(t('All Courses', 'جميع الدورات')) ?></span>
|
|
<h1 class="section-title mb-2 fw-bold"><?= h(t('Accelerate Your Skills', 'سرّع تطوير مهاراتك')) ?></h1>
|
|
<p class="text-secondary mx-auto" style="max-width: 600px;"><?= h(t('Enroll in our specialized short courses designed to help you achieve your goals.', 'سجل في دوراتنا القصيرة المتخصصة المصممة لمساعدتك على تحقيق أهدافك.')) ?></p>
|
|
</div>
|
|
|
|
<?php if (empty($courses)): ?>
|
|
<div class="alert alert-info text-center py-4 rounded-3 shadow-sm border-0">
|
|
<?= h(t('No active courses found at the moment. Please check back later.', 'لم يتم العثور على دورات نشطة في الوقت الحالي. يرجى التحقق مرة أخرى لاحقاً.')) ?>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="row g-4">
|
|
<?php foreach ($courses as $course): ?>
|
|
<div class="col-lg-4 col-md-6">
|
|
<article class="card h-100 border-0 shadow-sm overflow-hidden" style="border-radius: 1rem; transition: transform 0.2s;">
|
|
<?php if (!empty($course['picture'])): ?>
|
|
<img src="<?= h($course['picture']) ?>" class="card-img-top" alt="<?= h(current_lang() === 'ar' ? $course['name_ar'] : $course['name_en']) ?>" style="height: 220px; object-fit: cover;">
|
|
<?php else: ?>
|
|
<div class="card-img-top bg-secondary d-flex align-items-center justify-content-center text-white" style="height: 220px;">
|
|
<i class="bi bi-play-btn fs-1"></i>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div class="card-body d-flex flex-column p-4">
|
|
<div class="d-flex justify-content-between align-items-start mb-3">
|
|
<h3 class="h5 mb-0 fw-bold"><?= h(current_lang() === 'ar' ? $course['name_ar'] : $course['name_en']) ?></h3>
|
|
<span class="badge bg-primary bg-gradient text-white rounded-pill fs-6 px-3 py-2 shadow-sm"><?= h(format_price((float)$course['price'])) ?></span>
|
|
</div>
|
|
<p class="text-secondary mb-4 flex-grow-1" style="font-size: 0.95rem;"><?= h(current_lang() === 'ar' ? $course['description_ar'] : $course['description_en']) ?></p>
|
|
<div class="d-grid mt-auto">
|
|
<?php
|
|
$isFull = false;
|
|
$isClosed = !$course['registration_open'];
|
|
if ($course['max_students'] > 0) {
|
|
$enrolled = db()->query("SELECT COUNT(*) FROM course_students WHERE course_id = " . $course['id'])->fetchColumn();
|
|
if ($enrolled >= $course['max_students']) {
|
|
$isFull = true;
|
|
}
|
|
}
|
|
if ($isClosed || $isFull):
|
|
?>
|
|
<button class="btn btn-outline-secondary rounded-pill py-2" disabled>
|
|
<?= h(t('Registration Closed', 'التسجيل مغلق')) ?>
|
|
</button>
|
|
<?php else: ?>
|
|
<a href="<?= h(app_url('checkout.php', ['course_id' => $course['id']])) ?>" class="btn btn-dark rounded-pill py-2 shadow-sm fw-bold">
|
|
<?= h(t('Enroll Now', 'سجل الآن')) ?>
|
|
</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</article>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</main>
|
|
<?php render_footer(); ?>
|