67 lines
2.5 KiB
PHP
67 lines
2.5 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
// If the user is not logged in, redirect to the login page.
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: /login.php');
|
|
exit;
|
|
}
|
|
|
|
require_once __DIR__ . '/includes/header.php';
|
|
|
|
// Check for and display error messages
|
|
if (isset($_SESSION['error_message'])) {
|
|
echo '<div class="error-banner"><p>' . htmlspecialchars($_SESSION['error_message']) . '</p></div>';
|
|
unset($_SESSION['error_message']); // Clear the message after displaying
|
|
}
|
|
|
|
// Check for and display success messages
|
|
if (isset($_SESSION['success_message'])) {
|
|
echo '<div class="success-banner"><p>' . htmlspecialchars($_SESSION['success_message']) . '</p></div>';
|
|
unset($_SESSION['success_message']); // Clear the message after displaying
|
|
}
|
|
?>
|
|
|
|
<div class="dashboard-container">
|
|
<h2>Welcome to Your Dashboard</h2>
|
|
<p>Your role: <strong><?php echo htmlspecialchars($_SESSION['role']); ?></strong></p>
|
|
|
|
<div class="cv-management">
|
|
<h3>Your CVs</h3>
|
|
<?php
|
|
require_once __DIR__ . '/db/config.php';
|
|
$pdoconn = db();
|
|
$stmt = $pdoconn->prepare('SELECT id, title, updated_at FROM cvs WHERE user_id = :user_id ORDER BY updated_at DESC');
|
|
$stmt->execute(['user_id' => $_SESSION['user_id']]);
|
|
$cvs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if ($cvs):
|
|
?>
|
|
<ul class="cv-list">
|
|
<?php foreach ($cvs as $cv): ?>
|
|
<li>
|
|
<div class="cv-item">
|
|
<strong><?php echo htmlspecialchars($cv['title']); ?></strong>
|
|
<span>Last updated: <?php echo date('F j, Y', strtotime($cv['updated_at'])); ?></span>
|
|
</div>
|
|
<div class="cv-actions">
|
|
<a href="view_cv.php?id=<?php echo $cv['id']; ?>" class="button-sm">View</a>
|
|
<a href="cv_editor.php?id=<?php echo $cv['id']; ?>" class="button-sm">Edit</a>
|
|
<a href="delete_cv.php?id=<?php echo $cv['id']; ?>" class="button-sm button-danger" onclick="return confirm('Are you sure you want to delete this CV?');">Delete</a>
|
|
</div>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php else: ?>
|
|
<p>You don't have any CVs yet. Let's create one!</p>
|
|
<?php endif; ?>
|
|
<a href="/cv_editor.php" class="button">Create a New CV</a>
|
|
</div>
|
|
|
|
<a href="/logout.php">Logout</a>
|
|
</div>
|
|
|
|
<?php
|
|
require_once __DIR__ . '/includes/footer.php';
|
|
?>
|