🤩 File Manager - Mr.X
PHP:
8.2.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:applications.php
<?php require_once '../includes/db.php'; require_once '../includes/auth.php'; checkEmployer(); $emp_id = $_SESSION['employer_id']; // Handle Actions if (isset($_GET['action']) && isset($_GET['id'])) { $action = $_GET['action']; $app_id = $_GET['id']; // Verify this application belongs to this employer's job $check = fetchOne("SELECT ja.id FROM job_applications ja JOIN jobs j ON ja.job_id = j.id WHERE ja.id = ? AND j.employer_id = ?", [$app_id, $emp_id]); if ($check) { if ($action == 'select') { query("UPDATE job_applications SET status = 'selected' WHERE id = ?", [$app_id]); } elseif ($action == 'reject') { query("UPDATE job_applications SET status = 'rejected' WHERE id = ?", [$app_id]); } header("Location: applications.php?status=success"); exit; } } // Handle Rating if (isset($_POST['rate_candidate'])) { $app_id = $_POST['app_id']; $rating = $_POST['rating']; query("UPDATE job_applications SET rating = ? WHERE id = ?", [$rating, $app_id]); header("Location: applications.php?status=rated"); exit; } // Fetch Applications $filter = isset($_GET['filter']) ? $_GET['filter'] : ''; $where = "WHERE j.employer_id = ?"; $params = [$emp_id]; if ($filter == 'selected') { $where .= " AND ja.status = 'selected'"; } elseif ($filter == 'rejected') { $where .= " AND ja.status = 'rejected'"; } elseif ($filter == 'pending') { $where .= " AND ja.status = 'pending'"; } $applications = []; try { $applications = fetchAll("SELECT ja.*, j.title as job_title FROM job_applications ja JOIN jobs j ON ja.job_id = j.id $where ORDER BY ja.created_at DESC", $params); } catch (Exception $e) { // Table might be missing } $page_title = "Job Applications"; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title><?php echo $page_title; ?> | Employer</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.0/font/bootstrap-icons.css"> <link rel="stylesheet" href="../assets/css/style.css"> </head> <body class="bg-light"> <nav class="navbar navbar-expand-lg navbar-dark sticky-top shadow-sm"> <div class="container-fluid px-4"> <a class="navbar-brand fw-bold" href="../index.php">jobly.lk Employer</a> <div class="ms-auto"> <a href="dashboard.php" class="btn btn-sm btn-outline-light me-2">Dashboard</a> <a href="../logout.php" class="btn btn-sm btn-light">Logout</a> </div> </div> </nav> <div class="container-fluid py-4 px-4"> <div class="d-flex justify-content-between align-items-center mb-4"> <h2 class="fw-bold mb-0">Candidate Applications</h2> <div class="btn-group"> <a href="applications.php" class="btn btn-outline-secondary <?php echo $filter == '' ? 'active' : ''; ?>">All</a> <a href="applications.php?filter=pending" class="btn btn-outline-secondary <?php echo $filter == 'pending' ? 'active' : ''; ?>">Pending</a> <a href="applications.php?filter=selected" class="btn btn-outline-secondary <?php echo $filter == 'selected' ? 'active' : ''; ?>">Selected</a> <a href="applications.php?filter=rejected" class="btn btn-outline-secondary <?php echo $filter == 'rejected' ? 'active' : ''; ?>">Rejected</a> </div> </div> <div class="card border-0 shadow-sm"> <div class="card-body p-0"> <div class="table-responsive"> <table class="table table-hover align-middle mb-0"> <thead class="bg-light"> <tr> <th class="ps-4">Candidate</th> <th>Job Title</th> <th>Applied Date</th> <th>Status</th> <th>Rating</th> <th class="text-end pe-4">Actions</th> </tr> </thead> <tbody> <?php if(empty($applications)): ?> <tr><td colspan="6" class="text-center py-5">No applications found.</td></tr> <?php else: ?> <?php foreach($applications as $app): ?> <tr> <td class="ps-4"> <div class="fw-bold"><?php echo $app['candidate_name']; ?></div> <div class="small text-muted"><?php echo $app['candidate_email']; ?> | <?php echo $app['candidate_phone']; ?></div> </td> <td><?php echo $app['job_title']; ?></td> <td><?php echo date('M d, Y', strtotime($app['created_at'])); ?></td> <td> <?php if($app['status'] == 'pending'): ?> <span class="badge bg-warning text-dark">Pending</span> <?php elseif($app['status'] == 'selected'): ?> <span class="badge bg-success">Selected</span> <?php else: ?> <span class="badge bg-danger">Rejected</span> <?php endif; ?> </td> <td> <?php if($app['status'] == 'selected'): ?> <form action="" method="POST" class="d-flex align-items-center"> <input type="hidden" name="app_id" value="<?php echo $app['id']; ?>"> <select name="rating" class="form-select form-select-sm me-2" style="width: 70px;" onchange="this.form.submit()"> <option value="0" <?php echo $app['rating'] == 0 ? 'selected' : ''; ?>>0</option> <option value="1" <?php echo $app['rating'] == 1 ? 'selected' : ''; ?>>1</option> <option value="2" <?php echo $app['rating'] == 2 ? 'selected' : ''; ?>>2</option> <option value="3" <?php echo $app['rating'] == 3 ? 'selected' : ''; ?>>3</option> <option value="4" <?php echo $app['rating'] == 4 ? 'selected' : ''; ?>>4</option> <option value="5" <?php echo $app['rating'] == 5 ? 'selected' : ''; ?>>5</option> </select> <input type="hidden" name="rate_candidate"> </form> <?php else: ?> - <?php endif; ?> </td> <td class="text-end pe-4"> <a href="../uploads/cvs/<?php echo $app['cv_path']; ?>" class="btn btn-sm btn-outline-primary" download> <i class="bi bi-download me-1"></i> CV </a> <button class="btn btn-sm btn-outline-info" data-bs-toggle="modal" data-bs-target="#detailsModal<?php echo $app['id']; ?>"> <i class="bi bi-eye"></i> </button> <?php if($app['status'] == 'pending'): ?> <a href="?action=select&id=<?php echo $app['id']; ?>" class="btn btn-sm btn-success" onclick="return confirm('Select this candidate?')">Select</a> <a href="?action=reject&id=<?php echo $app['id']; ?>" class="btn btn-sm btn-danger" onclick="return confirm('Reject this candidate?')">Reject</a> <?php endif; ?> </td> </tr> <!-- Details Modal --> <div class="modal fade" id="detailsModal<?php echo $app['id']; ?>" tabindex="-1"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Application Details</h5> <button type="button" class="btn-close" data-bs-dismiss="modal"></button> </div> <div class="modal-body"> <h6>Message from Candidate:</h6> <p class="bg-light p-3 rounded"><?php echo nl2br($app['details']); ?></p> </div> </div> </div> </div> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> </div> </div> </div> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> </body> </html>
Save Changes
Cancel
Create New File
Create New Folder