129 lines
5.2 KiB
PHP
129 lines
5.2 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_SESSION['client_id'])) {
|
|
header("Location: login-client.php");
|
|
exit;
|
|
}
|
|
|
|
$client_id = $_SESSION['client_id'];
|
|
|
|
// Fetch jobs posted by the client
|
|
$sql_jobs = "SELECT * FROM jobs WHERE client_id = ? ORDER BY created_at DESC";
|
|
$stmt_jobs = db()->prepare($sql_jobs);
|
|
$stmt_jobs->execute([$client_id]);
|
|
$jobs = $stmt_jobs->fetchAll();
|
|
|
|
// Fetch applications for the client's jobs
|
|
$sql_apps = "SELECT ja.*, j.title, w.name AS worker_name, w.email AS worker_email
|
|
FROM job_applications ja
|
|
JOIN jobs j ON ja.job_id = j.id
|
|
JOIN workers w ON ja.worker_id = w.id
|
|
WHERE j.client_id = ?
|
|
ORDER BY ja.created_at DESC";
|
|
$stmt_apps = db()->prepare($sql_apps);
|
|
$stmt_apps->execute([$client_id]);
|
|
$applications = $stmt_apps->fetchAll();
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Client Dashboard - SkillRunner</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="index.php">SkillRunner</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav ms-auto">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="post-job.php">Post a New Job</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="logout.php">Logout</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="container mt-5">
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h1>Client Dashboard</h1>
|
|
<p class="lead">Welcome, <?php echo htmlspecialchars($_SESSION['client_name']); ?>!</p>
|
|
</div>
|
|
|
|
<section class="mb-5">
|
|
<h2>Your Posted Jobs</h2>
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<?php if (empty($jobs)): ?>
|
|
<p>You have not posted any jobs yet. <a href="post-job.php">Post one now!</a></p>
|
|
<?php else: ?>
|
|
<ul class="list-group list-group-flush">
|
|
<?php foreach ($jobs as $job): ?>
|
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
|
<a href="job-detail.php?id=<?php echo $job['id']; ?>"><?php echo htmlspecialchars($job['title']); ?></a>
|
|
<span class="badge bg-secondary"><?php echo date("M d, Y", strtotime($job['created_at'])); ?></span>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section>
|
|
<h2>Recent Job Applications</h2>
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<?php if (empty($applications)): ?>
|
|
<p>No applications received yet.</p>
|
|
<?php else: ?>
|
|
<div class="table-responsive">
|
|
<table class="table table-striped table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Job Title</th>
|
|
<th>Applicant</th>
|
|
<th>Applicant Email</th>
|
|
<th>Applied On</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($applications as $app): ?>
|
|
<tr>
|
|
<td><a href="job-detail.php?id=<?php echo $app['job_id']; ?>"><?php echo htmlspecialchars($app['title']); ?></a></td>
|
|
<td><?php echo htmlspecialchars($app['worker_name']); ?></td>
|
|
<td><a href="mailto:<?php echo htmlspecialchars($app['worker_email']); ?>"><?php echo htmlspecialchars($app['worker_email']); ?></a></td>
|
|
<td><?php echo date("M d, Y H:i", strtotime($app['created_at'])); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
</main>
|
|
|
|
<footer class="text-center mt-5 py-3 bg-light">
|
|
<p>© <?php echo date("Y"); ?> SkillRunner. All rights reserved.</p>
|
|
</footer>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|