You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
187 lines
8.6 KiB
187 lines
8.6 KiB
<?php
|
|
session_start();
|
|
|
|
// Check if the user is logged in
|
|
if (!isset($_SESSION['email'])) {
|
|
header("Location: login.php");
|
|
exit();
|
|
}
|
|
|
|
include 'connect.php';
|
|
|
|
// Check if the logged-in user is an employer
|
|
$is_employer = ($_SESSION['user_type'] === 'Employer');
|
|
if (!$is_employer) {
|
|
echo "Access denied. Only employers can view applications.";
|
|
exit();
|
|
}
|
|
|
|
// Get all applications for the employer's job postings
|
|
$employer_id = $_SESSION['employer_id'];
|
|
$sql = "SELECT
|
|
a.*,
|
|
j.job_title,
|
|
j.location,
|
|
j.salary,
|
|
u.firstname,
|
|
u.lastname,
|
|
u.email,
|
|
u.phone
|
|
FROM applications a
|
|
JOIN job_postings j ON a.job_id = j.job_id
|
|
JOIN job_seekers js ON a.seeker_id = js.seeker_id
|
|
JOIN users u ON js.user_id = u.user_id
|
|
WHERE j.employer_id = ?
|
|
ORDER BY a.application_date DESC";
|
|
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->bind_param("i", $employer_id);
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
|
|
// Handle status updates if posted
|
|
if (isset($_POST['update_status']) && isset($_POST['application_id']) && isset($_POST['new_status'])) {
|
|
$application_id = intval($_POST['application_id']);
|
|
$new_status = $_POST['new_status'];
|
|
$allowed_statuses = ['Pending', 'Accepted', 'Rejected'];
|
|
|
|
if (in_array($new_status, $allowed_statuses)) {
|
|
$update_sql = "UPDATE applications SET status = ? WHERE application_id = ?";
|
|
$update_stmt = $conn->prepare($update_sql);
|
|
$update_stmt->bind_param("si", $new_status, $application_id);
|
|
$update_stmt->execute();
|
|
|
|
// Refresh the page to show updated status
|
|
header("Location: ".$_SERVER['PHP_SELF']);
|
|
exit();
|
|
}
|
|
}
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en" data-theme="light">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>View Applications</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/daisyui@4.7.2/dist/full.min.css" rel="stylesheet" type="text/css" />
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
</head>
|
|
<body class="min-h-screen flex flex-col bg-white">
|
|
<?php include 'navbar.php';?>
|
|
|
|
<main class="flex-grow container mx-auto px-4 py-8">
|
|
<div class="text-sm breadcrumbs mb-6">
|
|
<ul>
|
|
<li><a href="index.php">Home</a></li>
|
|
<li class="text-primary">Applications Received</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="bg-white rounded-lg shadow-md p-6">
|
|
<h1 class="text-3xl font-bold mb-6 text-gray-800">Applications Received</h1>
|
|
|
|
<?php if ($result->num_rows > 0): ?>
|
|
<div class="overflow-x-auto">
|
|
<table class="table w-full">
|
|
<thead>
|
|
<tr class="bg-gray-50">
|
|
<th class="text-left px-6 py-3 text-gray-600">Job Title</th>
|
|
<th class="text-left px-6 py-3 text-gray-600">Applicant Name</th>
|
|
<th class="text-left px-6 py-3 text-gray-600">Contact</th>
|
|
<th class="text-left px-6 py-3 text-gray-600">Application Date</th>
|
|
<th class="text-left px-6 py-3 text-gray-600">Status</th>
|
|
<th class="text-left px-6 py-3 text-gray-600">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-200">
|
|
<?php while ($application = $result->fetch_assoc()): ?>
|
|
<tr class="hover:bg-gray-50 transition-colors">
|
|
<td class="px-6 py-4">
|
|
<div class="text-sm font-medium text-gray-900">
|
|
<?= htmlspecialchars($application['job_title']) ?>
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
<div class="text-sm text-gray-900">
|
|
<?= htmlspecialchars($application['firstname'] . ' ' . $application['lastname']) ?>
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
<div class="text-sm text-gray-600">
|
|
<div>Email: <?= htmlspecialchars($application['email']) ?></div>
|
|
<div>Phone: <?= htmlspecialchars($application['phone']) ?></div>
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-4 text-sm text-gray-600">
|
|
<?= date('F j, Y', strtotime($application['application_date'])) ?>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
<?php
|
|
$statusClass = match($application['status']) {
|
|
'Pending' => 'bg-yellow-100 text-yellow-800',
|
|
'Accepted' => 'bg-green-100 text-green-800',
|
|
'Rejected' => 'bg-red-100 text-red-800',
|
|
default => 'bg-gray-100 text-gray-800'
|
|
};
|
|
?>
|
|
<span class="px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full <?= $statusClass ?>">
|
|
<?= htmlspecialchars($application['status']) ?>
|
|
</span>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
<form method="POST" class="inline">
|
|
<input type="hidden" name="application_id" value="<?= $application['application_id'] ?>">
|
|
<select name="new_status" class="select select-bordered select-sm w-32 mr-2">
|
|
<option value="Pending" <?= $application['status'] === 'Pending' ? 'selected' : '' ?>>Pending</option>
|
|
<option value="Accepted" <?= $application['status'] === 'Accepted' ? 'selected' : '' ?>>Accept</option>
|
|
<option value="Rejected" <?= $application['status'] === 'Rejected' ? 'selected' : '' ?>>Reject</option>
|
|
</select>
|
|
<button type="submit" name="update_status" class="btn btn-sm btn-primary">
|
|
Update
|
|
</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<?php endwhile; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="bg-blue-50 border-l-4 border-blue-400 p-4 mb-4">
|
|
<div class="flex">
|
|
<div class="flex-shrink-0">
|
|
<svg class="h-5 w-5 text-blue-400" viewBox="0 0 20 20" fill="currentColor">
|
|
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" />
|
|
</svg>
|
|
</div>
|
|
<div class="ml-3">
|
|
<p class="text-sm text-blue-700">
|
|
No applications have been received yet for your job postings.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</main>
|
|
|
|
<footer class="mt-auto bg-white border-t">
|
|
<?php include 'footer.php';?>
|
|
</footer>
|
|
|
|
<style>
|
|
body {
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
main {
|
|
flex: 1 0 auto;
|
|
}
|
|
footer {
|
|
flex-shrink: 0;
|
|
}
|
|
</style>
|
|
</body>
|
|
</html>
|