148 lines
5.9 KiB
PHP
148 lines
5.9 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header("Location: login.php");
|
|
exit;
|
|
}
|
|
|
|
$userId = $_SESSION['user_id'];
|
|
$stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
|
|
$stmt->execute([$userId]);
|
|
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if (!$user) {
|
|
session_destroy();
|
|
header("Location: login.php");
|
|
exit;
|
|
}
|
|
|
|
// Fetch all skills
|
|
$skills_by_category = [];
|
|
$stmt = db()->query("SELECT * FROM skills ORDER BY category, title");
|
|
$all_skills = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
foreach ($all_skills as $skill) {
|
|
$skills_by_category[$skill['category']][] = $skill;
|
|
}
|
|
|
|
// Hardcoded enrolled skills for now
|
|
$enrolled_skills = [
|
|
['title' => 'Introduction to Python', 'progress' => 60, 'thumbnail' => 'assets/images/python.png'],
|
|
['title' => 'Web Development Basics', 'progress' => 25, 'thumbnail' => 'assets/images/webdev.png'],
|
|
];
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Dashboard - TAP2SKILL</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
</head>
|
|
<body>
|
|
|
|
<div class="sidebar">
|
|
<a class="navbar-brand" href="index.php">TAP2SKILL</a>
|
|
<hr>
|
|
<ul class="nav flex-column">
|
|
<li class="nav-item">
|
|
<a class="nav-link active" href="dashboard.php">
|
|
<i class="bi bi-grid-1x2-fill"></i>
|
|
Dashboard
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="#">
|
|
<i class="bi bi-person-circle"></i>
|
|
Profile
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="#">
|
|
<i class="bi bi-gear-fill"></i>
|
|
Settings
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
<hr>
|
|
<a href="logout.php" class="btn btn-outline-primary">Logout</a>
|
|
</div>
|
|
|
|
<div class="main-content">
|
|
<div class="container-fluid">
|
|
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
|
<h1 class="h2">Welcome, <?php echo htmlspecialchars($user['username']); ?>!</h1>
|
|
</div>
|
|
|
|
<!-- Quick Access Buttons -->
|
|
<div class="row mb-4">
|
|
<div class="col-md-4">
|
|
<a href="#skill-explorer" class="btn btn-primary btn-lg w-100">Explore Skills</a>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<a href="#enrolled-skills" class="btn btn-success btn-lg w-100">Continue Learning</a>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<a href="#" class="btn btn-info btn-lg w-100">Community</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Enrolled Skills Section -->
|
|
<section id="enrolled-skills" class="mb-5">
|
|
<h2 class="h4">My Enrolled Skills</h2>
|
|
<div class="row">
|
|
<?php if (empty($enrolled_skills)): ?>
|
|
<p>You are not enrolled in any skills yet. Explore the skills below to get started!</p>
|
|
<?php else: ?>
|
|
<?php foreach ($enrolled_skills as $skill): ?>
|
|
<div class="col-md-6 col-lg-4 mb-3">
|
|
<div class="card">
|
|
<img src="<?php echo htmlspecialchars($skill['thumbnail']); ?>" class="card-img-top" alt="<?php echo htmlspecialchars($skill['title']); ?>">
|
|
<div class="card-body">
|
|
<h5 class="card-title"><?php echo htmlspecialchars($skill['title']); ?></h5>
|
|
<div class="progress">
|
|
<div class="progress-bar" role="progressbar" style="width: <?php echo $skill['progress']; ?>%;" aria-valuenow="<?php echo $skill['progress']; ?>" aria-valuemin="0" aria-valuemax="100"><?php echo $skill['progress']; ?>%</div>
|
|
</div>
|
|
<a href="#" class="btn btn-primary mt-3">Continue</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- Skill Explorer Section -->
|
|
<section id="skill-explorer">
|
|
<h2 class="h4">Skill Explorer</h2>
|
|
<?php foreach ($skills_by_category as $category => $skills): ?>
|
|
<h3 class="h5 mt-4"><?php echo htmlspecialchars($category); ?></h3>
|
|
<div class="row">
|
|
<?php foreach ($skills as $skill): ?>
|
|
<div class="col-md-6 col-lg-3 mb-3">
|
|
<div class="card h-100">
|
|
<img src="<?php echo htmlspecialchars($skill['thumbnail']); ?>" class="card-img-top" alt="<?php echo htmlspecialchars($skill['title']); ?>">
|
|
<div class="card-body d-flex flex-column">
|
|
<h5 class="card-title"><?php echo htmlspecialchars($skill['title']); ?></h5>
|
|
<p class="card-text flex-grow-1"><?php echo htmlspecialchars($skill['description']); ?></p>
|
|
<a href="#" class="btn btn-outline-primary mt-auto">Enroll</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|