Repository navigation
Expand file tree
/
Copy pathadmin_applications.php
More file actions
128 lines (120 loc) · 7.15 KB
/
Copy pathadmin_applications.php
File metadata and controls
128 lines (120 loc) · 7.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
session_start();
if (!isset($_SESSION['admin_id'])) {
header("Location: admin_login.php");
exit;
}
require_once 'includes/Database.php';
require_once 'includes/ApplicationLogic.php';
$db = Database::getConnection();
$adminId = $_SESSION['admin_id'];
$message = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['process_app'])) {
$appId = $_POST['application_id'];
$newStatus = $_POST['new_status'];
$res = ApplicationLogic::updateStatus($appId, $newStatus, $adminId);
if ($res === true) {
$message = "<div style='color:green; padding:10px; border:1px solid green; margin-bottom:15px; background:#e8f5e9;'>Application Status successfully set to <strong style='text-transform:uppercase;'>$newStatus</strong> mapping state machine exactly.</div>";
} else {
$message = "<div style='color:red; padding:10px; border:1px solid red; margin-bottom:15px; background:#ffebee;'>Rule Violation blocked transition: $res</div>";
}
}
$query = "
SELECT a.*, s.Name AS Student_Name, s.CGPA, j.Title, c.Name AS Company_Name
FROM Applications a
JOIN Students s ON a.Student_ID = s.Student_ID
JOIN Jobs j ON a.Job_ID = j.Job_ID
JOIN Companies c ON j.Company_ID = c.Company_ID
ORDER BY a.Application_Status ASC, a.created_at DESC
";
$stmt = $db->query($query);
$apps = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Process Applications</title>
<!-- Basic styling matched from admin -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
body { font-family: 'Inter', sans-serif; background: #2f3640; margin:0; padding:20px; color:#333; }
.container { max-width: 1200px; margin: 0 auto; background: #fff; padding: 25px; border-radius: 8px; }
.header-actions { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #eee; padding-bottom: 15px; margin-bottom: 20px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 20px;}
th, td { border: 1px solid #ddd; padding: 10px; text-align: left; }
th { background: #273c75; color: white; }
.btn-action { color: white; border: none; padding: 5px 10px; border-radius: 4px; font-size: 11px; font-weight: bold; cursor: pointer; }
.btn-select { background-color: #27ae60; }
.btn-reject { background-color: #c0392b; }
.status-badge { padding: 4px 8px; border-radius: 12px; font-weight: bold; font-size: 11px; }
.s-applied { background: #eccc68; color: #2f3542; }
.s-selected { background: #7bed9f; color: #2f3542; }
.s-rejected { background: #ff4757; color: white; }
.s-accepted { background: #1e90ff; color: white; }
.s-declined { background: #ced6e0; color: #2f3542; }
</style>
</head>
<body>
<div class="container">
<div class="header-actions">
<h2 style="color: #273c75;"><i class="fa-solid fa-file-signature"></i> Process Applications Pool</h2>
<a href="admin_dashboard.php" style="color:#273c75; text-decoration:none; font-weight:600;"><i class="fa-solid fa-arrow-left"></i> Back to Dashboard</a>
</div>
<?= $message ?>
<div style="background:#f1f2f6; border-left:4px solid #3742fa; padding:15px; margin-bottom:20px; font-size:13px; border-radius:4px;">
<i class="fa-solid fa-circle-info"></i> <strong>Admin Processing Engine:</strong> Shortlisting an applicant marks them as <code>Selected</code>. Rejecting marks them as <code>Rejected</code>. This strictly respects unidirectional lifecycle states logic and locks down subsequent illegal revisions.
</div>
<table>
<tr>
<th>App Validation ID</th>
<th>Candidate Details</th>
<th>Company & Role</th>
<th>Timestamp</th>
<th>Application Status</th>
<th>Processing Gate</th>
</tr>
<?php foreach ($apps as $app): ?>
<tr>
<td style="font-family:monospace; font-size:11px;"><?= htmlspecialchars($app['Application_ID']) ?></td>
<td>
<?= htmlspecialchars($app['Student_Name']) ?><br>
<span style="font-size:11px; color:#555;"><?= htmlspecialchars($app['Student_ID']) ?> | CGPA: <?= $app['CGPA'] ?></span>
</td>
<td>
<?= htmlspecialchars($app['Company_Name']) ?><br>
<span style="font-size:11px; color:#555;"><?= htmlspecialchars($app['Title']) ?></span>
</td>
<td style="font-size:11px; color:#777;"><?= explode(' ', $app['created_at'])[0] ?></td>
<td>
<?php
$class = 's-applied';
if ($app['Application_Status'] === 'Selected') $class = 's-selected';
elseif ($app['Application_Status'] === 'Rejected') $class = 's-rejected';
elseif (strpos($app['Application_Status'], 'Accepted') !== false) $class = 's-accepted';
elseif (strpos($app['Application_Status'], 'Declined') !== false) $class = 's-declined';
elseif ($app['Application_Status'] === 'Withdrawn') $class = 's-declined';
?>
<span class="status-badge <?= $class ?>">
<?= strtoupper($app['Application_Status']) ?>
</span>
</td>
<td>
<?php if ($app['Application_Status'] === 'Applied'): ?>
<form method="POST" action="admin_applications.php" style="margin:0; display:flex; gap:5px;">
<input type="hidden" name="application_id" value="<?= htmlspecialchars($app['Application_ID']) ?>">
<button type="submit" name="process_app" class="btn-action btn-select" onclick="document.getElementById('ns_<?= $app['Application_ID'] ?>').value='Selected'; return confirm('Shortlist candidate formally?');"><i class="fa-solid fa-check"></i> Select</button>
<button type="submit" name="process_app" class="btn-action btn-reject" onclick="document.getElementById('ns_<?= $app['Application_ID'] ?>').value='Rejected'; return confirm('Reject candidate? This cannot be undone by student.');"><i class="fa-solid fa-xmark"></i> Reject</button>
<input type="hidden" name="new_status" id="ns_<?= $app['Application_ID'] ?>" value="">
</form>
<?php else: ?>
<span style="font-size:11px; color:#999;">Gated - Workflow Locked</span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</body>
</html>