📁 File Manager
Editing:
/home/wvl7mof7402e/public_html/remindyourdata.live/admin/visalist.php
<?php session_start(); include "dbconnect.php"; // Pagination $limit = 10; $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $offset = ($page - 1) * $limit; // Search $search = isset($_POST['search']) ? $_POST['search'] : (isset($_GET['search']) ? $_GET['search'] : ''); $search_query = !empty($search) ? "AND ja.passport_no LIKE '%$search%'" : ''; // Fetch data $sql = "SELECT vm.id, vm.visa_status, ja.name AS applicant_name, ja.passport_no, vm.visa_type, vm.visa_issue_date, vm.visa_expiry_date, vm.visa_upload, ja.job_country, ja.reference FROM visa_management vm JOIN job_applicants ja ON vm.applicant_id = ja.id WHERE 1=1 $search_query LIMIT $limit OFFSET $offset"; $result = $con->query($sql); // Count total for pagination $count_sql = "SELECT COUNT(vm.id) AS total FROM visa_management vm JOIN job_applicants ja ON vm.applicant_id = ja.id WHERE 1=1 $search_query"; $count_result = $con->query($count_sql); $total_rows = $count_result->fetch_assoc()['total']; $total_pages = ceil($total_rows / $limit); ?> <!DOCTYPE html> <html lang="en"> <?php $today = date('Y-m-d'); $notify_sql = "SELECT ja.name, ja.passport_no, vm.visa_expiry_date FROM visa_management vm JOIN job_applicants ja ON vm.applicant_id = ja.id WHERE vm.visa_expiry_date IS NOT NULL AND DATEDIFF(vm.visa_expiry_date, '$today') BETWEEN 0 AND 20 ORDER BY vm.visa_expiry_date ASC"; $notify_result = $con->query($notify_sql); $visa_notification = ''; while ($row = $notify_result->fetch_assoc()) { $visa_notification .= "{$row['name']} (Passport: {$row['passport_no']}) expiring on {$row['visa_expiry_date']} | "; } ?> <head> <meta charset="UTF-8" /> <title>Visa List</title> <meta name="viewport" content="width=device-width, initial-scale=1" /> <!-- Bootstrap CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> <!-- Bootstrap Icons --> <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet" /> <style> body { background: linear-gradient(135deg, #d1e7dd 0%, #f8f9fa 100%); font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; color: #212529; min-height: 100vh; } .logout-btn { position: fixed; top: 15px; right: 15px; z-index: 1050; background-color: #dc3545; color: #fff; padding: 8px 14px; border: none; border-radius: 6px; font-weight: 600; display: flex; align-items: center; gap: 6px; transition: background-color 0.3s ease; cursor: pointer; } .logout-btn:hover { background-color: #b02a37; } h3 { font-size: 2.2rem; font-weight: 700; color: #198754; /* greenish */ text-align: center; margin-bottom: 2rem; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); } .form-control { border-radius: 0.5rem; box-shadow: none !important; } .btn-primary, .btn-success, .btn-info, .btn-danger { border-radius: 0.5rem; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; transition: background-color 0.3s ease; } .btn-primary:hover { background-color: #0b5ed7; } .btn-success:hover { background-color: #157347; } .btn-info:hover { background-color: #0b7285; } .btn-danger:hover { background-color: #b02a37; } .table th, .table td { vertical-align: middle; text-align: center; } .table thead { background-color: #198754; color: white; } .table-striped tbody tr:nth-of-type(odd) { background-color: rgba(25, 135, 84, 0.1); } .table-responsive { overflow-x: auto; border-radius: 0.5rem; box-shadow: 0 0 10px rgb(0 0 0 / 0.05); } .pagination { justify-content: center; margin-top: 1.5rem; user-select: none; } .pagination .page-link { border-radius: 0.5rem; color: #198754; font-weight: 600; } .pagination .page-item.active .page-link { background-color: #198754; color: white; border: none; } .pagination .page-link:hover { background-color: #157347; color: white; } /* Add New Visa Button */ .add-btn { position: absolute; top: 20px; right: 80px; background-color: #198754; color: white; border-radius: 6px; font-weight: 600; padding: 8px 14px; display: flex; align-items: center; gap: 6px; transition: background-color 0.3s ease; border: none; cursor: pointer; z-index: 1050; text-decoration: none; } .add-btn:hover { background-color: #157347; color: white; } @media (max-width: 768px) { h3 { font-size: 1.75rem; } .logout-btn { top: 10px; right: 10px; padding: 6px 12px; font-size: 14px; } .add-btn { top: 60px; right: 15px; width: calc(100% - 30px); justify-content: center; position: static; margin-bottom: 1rem; } .btn { width: 100%; margin-bottom: 10px; justify-content: center; } .table th, .table td { font-size: 13px; padding: 0.5rem; white-space: nowrap; } .table-responsive { overflow-x: scroll; } @media (max-width: 480px) { .table th, .table td { font-size: 11px; padding: 6px 4px; } .btn-sm { font-size: 12px; padding: 4px 6px; } .logout-btn, .add-btn { font-size: 13px; padding: 6px 10px; } marquee { font-size: 13px; } h3 { font-size: 1.5rem; } } } </style> </head> <body> <marquee behavior="scroll" direction="left" style="background-color: #ffc107; color: #000; padding: 10px; font-weight: bold;"> <?= !empty($visa_notification) ? $visa_notification : "No visa records expiring in the next 20 days." ?> </marquee> <!-- Logout Button --> <form action="logout.php" method="post" class="position-fixed" style="z-index:1050;"> <button type="submit" class="logout-btn" aria-label="Logout"> <i class="bi bi-box-arrow-right"></i> Logout </button> </form> <!-- Add New Visa Button --> <div class="container mt-5 mb-5 position-relative"> <h3>Visa Management List</h3> <!-- Search Form --> <form method="POST" class="d-flex justify-content-center gap-2 mb-4 flex-wrap"> <input type="text" name="search" class="form-control" placeholder="Search by Passport No" value="<?= htmlspecialchars($search) ?>" style="max-width: 320px;" aria-label="Search by Passport Number" /> <button type="submit" class="btn btn-primary"> <i class="bi bi-search"></i> Search </button> </form> <!-- Export & Print Buttons --> <div class="d-flex justify-content-end gap-2 flex-wrap mb-3"> <button onclick="exportToExcel()" class="btn btn-success" aria-label="Export to Excel"> <i class="bi bi-file-earmark-spreadsheet"></i> Export to Excel </button> <button onclick="window.print()" class="btn btn-info" aria-label="Print Page"> <i class="bi bi-printer"></i> Print </button> </div> <!-- Visa List Table --> <div class="table-responsive"> <table class="table table-striped table-bordered align-middle"> <thead> <tr> <th>#</th> <!-- Serial Number --> <th>ID</th> <!-- DB ID --> <th>Name</th> <th>Passport No</th> <th>Visa Type</th> <th>Issue Date</th> <th>Expiry Date</th> <th>Job Country</th> <th>Agent</th> <th>Document</th> <th>Action</th> </tr> </thead> <tbody> <?php if ($result->num_rows > 0): $serial = $offset + 1; // Serial number starting for current page while ($row = $result->fetch_assoc()): ?> <tr> <td><?= $serial ?></td> <!-- Serial Number --> <td><?= $row['id'] ?></td> <!-- DB ID --> <td><?= htmlspecialchars($row['applicant_name']) ?></td> <td><?= htmlspecialchars($row['passport_no']) ?></td> <td><?= htmlspecialchars($row['visa_type']) ?></td> <td><?= htmlspecialchars($row['visa_issue_date']) ?></td> <td><?= htmlspecialchars($row['visa_expiry_date']) ?></td> <td><?= htmlspecialchars($row['job_country']) ?></td> <td><?= htmlspecialchars($row['reference']) ?></td> <td> <?php if ($row['visa_upload']): ?> <a href="<?= htmlspecialchars($row['visa_upload']) ?>" class="btn btn-primary btn-sm" download aria-label="Download Visa Document for <?= htmlspecialchars($row['applicant_name']) ?>"> <i class="bi bi-download"></i> Download </a> <?php else: ?> <span class="text-muted">No File</span> <?php endif; ?> </td> <td class="d-flex justify-content-center gap-2 flex-wrap"> <a href="visaedit.php?id=<?= $row['id'] ?>" class="btn btn-info btn-sm" aria-label="Edit Visa Record for <?= htmlspecialchars($row['applicant_name']) ?>"> <i class="bi bi-pencil"></i> Edit </a> <a href="visadelete.php?id=<?= $row['id'] ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure to delete this record?')" aria-label="Delete Visa Record for <?= htmlspecialchars($row['applicant_name']) ?>"> <i class="bi bi-trash"></i> Delete </a> </td> </tr> <?php $serial++; endwhile; else: ?> <tr><td colspan="11" class="text-center fw-semibold">No records found.</td></tr> <?php endif; ?> </tbody> </table> </div> <!-- Pagination --> <nav aria-label="Visa Management Pagination"> <ul class="pagination"> <?php for ($i = 1; $i <= $total_pages; $i++): ?> <li class="page-item <?= ($i == $page) ? 'active' : '' ?>"> <a class="page-link" href="?page=<?= $i ?>&search=<?= urlencode($search) ?>" aria-current="<?= ($i == $page) ? 'page' : '' ?>"><?= $i ?></a> </li> <?php endfor; ?> </ul> </nav> </div> <!-- Bootstrap JS Bundle --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> <script> // Export table data to CSV (Excel) function exportToExcel() { const table = document.querySelector("table"); const rows = table.querySelectorAll("tr"); let csv = []; rows.forEach(row => { const cells = row.querySelectorAll("th, td"); let rowData = []; cells.forEach(cell => { // Escape double quotes and commas inside cells let cellText = cell.innerText.replace(/"/g, '""'); if(cellText.includes(',') || cellText.includes('\n')){ cellText = `"${cellText}"`; } rowData.push(cellText); }); csv.push(rowData.join(",")); }); const csvFile = new Blob([csv.join("\n")], { type: "text/csv" }); const downloadLink = document.createElement("a"); downloadLink.href = URL.createObjectURL(csvFile); downloadLink.download = "visa_management_list.csv"; downloadLink.click(); } </script> </body> </html>
Save
Cancel