📁 File Manager
Editing:
/home/wvl7mof7402e/public_html/remindyourdata.live/admin/emigration_list.php
<?php include "dbconnect.php"; // Pagination Setup $limit = 10; $page = isset($_GET['page']) ? (int) $_GET['page'] : 1; $start = ($page - 1) * $limit; $search = isset($_GET['search']) ? $_GET['search'] : ''; $searchEscaped = $con->real_escape_string($search); $searchQuery = $search ? "WHERE name LIKE '%$searchEscaped%' OR passport_no LIKE '%$searchEscaped%' OR agency_name LIKE '%$searchEscaped%'" : ""; // Total Records $total_result = $con->query("SELECT COUNT(*) as total FROM emigrations $searchQuery"); $total_rows = $total_result->fetch_assoc()['total']; $total_pages = ceil($total_rows / $limit); // Fetch Paginated Data $sql = "SELECT * FROM emigrations $searchQuery ORDER BY created_at DESC LIMIT $start, $limit"; $result = $con->query($sql); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>All Emigration Applications</title> <!-- 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" /> <!-- jQuery --> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <!-- jsPDF & SheetJS for Export --> <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.28/jspdf.plugin.autotable.min.js"></script> <style> /* Animated background gradient */ body { min-height: 100vh; background: linear-gradient(135deg, #11998e, #38ef7d, #11998e, #38ef7d); background-size: 400% 400%; animation: gradientBG 15s ease infinite; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; color: #333; padding: 20px 0; } @keyframes gradientBG { 0% {background-position: 0% 50%;} 50% {background-position: 100% 50%;} 100% {background-position: 0% 50%;} } .container { background: #fff; border-radius: 12px; padding: 25px 20px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); max-width: 1000px; } h2 { color: #117a65; font-weight: 700; margin-bottom: 20px; text-align: center; } /* Search input with icon */ .input-group .form-control { border-radius: 25px 0 0 25px; border-right: none; font-size: 1rem; } .input-group-text { background-color: #38ef7d; border-radius: 0 25px 25px 0; color: #fff; font-size: 1.2rem; cursor: pointer; border-left: none; } /* Buttons styling */ .btn { border-radius: 25px; font-weight: 600; font-size: 0.9rem; display: flex; align-items: center; gap: 6px; } .btn-success { background-color: #11998e; border-color: #11998e; transition: background-color 0.3s ease; } .btn-success:hover { background-color: #0e8079; border-color: #0e8079; } .btn-outline-primary { color: #11998e; border-color: #11998e; transition: all 0.3s ease; } .btn-outline-primary:hover { background-color: #11998e; color: white; } .btn-outline-danger { color: #e74a3b; border-color: #e74a3b; transition: all 0.3s ease; } .btn-outline-danger:hover { background-color: #e74a3b; color: white; } /* Table responsive & styling */ .table-responsive { overflow-x: auto; } table { min-width: 800px; } th, td { vertical-align: middle !important; } /* Pagination */ .pagination { justify-content: center; margin-top: 15px; } /* Responsive tweaks */ @media (max-width: 768px) { .btn { font-size: 0.85rem; padding: 7px 12px; } h2 { font-size: 1.5rem; } table { min-width: 600px; } } @media (max-width: 480px) { .btn { font-size: 0.75rem; padding: 6px 10px; } .input-group .form-control { font-size: 0.9rem; } } </style> </head> <body> <div class="container shadow-sm"> <h2><i class="bi bi-people-fill"></i> All Emigration Applications</h2> <div class="d-flex flex-column flex-md-row justify-content-between align-items-center mb-4 gap-3"> <a href="emigration_form.php" class="btn btn-success"> <i class="bi bi-plus-lg"></i> Add New </a> <div class="input-group" style="max-width: 350px; flex-grow: 1;"> <input type="text" id="searchBox" class="form-control" placeholder="Search by name, passport, agency..." value="<?= htmlspecialchars($search) ?>" aria-label="Search applications" /> <span class="input-group-text" role="button" id="searchBtn"><i class="bi bi-search"></i></span> </div> <div class="d-flex gap-2 align-items-center"> <button class="btn btn-outline-primary" type="button" onClick="exportTableToExcel('emigrationTable')"> <i class="bi bi-file-earmark-excel-fill"></i> Excel </button> <button class="btn btn-outline-danger" type="button" onClick="exportTableToPDF()"> <i class="bi bi-file-earmark-pdf-fill"></i> PDF </button> <a href="logout.php" class="btn btn-outline-danger" title="Logout"> <i class="bi bi-box-arrow-right"></i> Logout </a> </div> </div> <div class="table-responsive"> <table class="table table-bordered table-hover align-middle" id="emigrationTable"> <thead class="table-success"> <tr> <th>ID</th> <th>Name</th> <th>Phone</th> <th>Passport No</th> <th>Country</th> <th>Position</th> <th>Agency</th> <th>Applied On</th> <th style="min-width: 130px;">Action</th> </tr> </thead> <tbody> <?php if ($result->num_rows > 0): ?> <?php while ($row = $result->fetch_assoc()): ?> <tr> <td><?= $row['id'] ?></td> <td><?= htmlspecialchars($row['name']) ?></td> <td><?= htmlspecialchars($row['phone']) ?></td> <td><?= htmlspecialchars($row['passport_no']) ?></td> <td><?= htmlspecialchars($row['country_applied']) ?></td> <td><?= htmlspecialchars($row['job_position']) ?></td> <td><?= htmlspecialchars($row['agency_name']) ?></td> <td><?= $row['created_at'] ?></td> <td> <a href="emigration_edit.php?id=<?= $row['id'] ?>" class="btn btn-warning btn-sm" title="Edit"> <i class="bi bi-pencil-fill"></i> </a> <a href="emigration_delete.php?id=<?= $row['id'] ?>" class="btn btn-danger btn-sm" title="Delete" onClick="return confirm('Are you sure to delete?')"> <i class="bi bi-trash-fill"></i> </a> </td> </tr> <?php endwhile; ?> <?php else: ?> <tr><td colspan="9" class="text-center py-4">No records found.</td></tr> <?php endif; ?> </tbody> </table> </div> <!-- Pagination --> <nav aria-label="Page navigation"> <ul class="pagination"> <?php for ($i = 1; $i <= $total_pages; $i++): ?> <li class="page-item <?= ($page == $i) ? 'active' : '' ?>"> <a class="page-link" href="?page=<?= $i ?>&search=<?= urlencode($search) ?>"><?= $i ?></a> </li> <?php endfor; ?> </ul> </nav> </div> <script> // Search on Enter or Search icon click $('#searchBox').on('keypress', function(e) { if (e.key === 'Enter') { e.preventDefault(); searchApplications(); } }); $('#searchBtn').on('click', function() { searchApplications(); }); function searchApplications() { const value = $('#searchBox').val().trim(); window.location.href = '?search=' + encodeURIComponent(value); } // Export Table to Excel function exportTableToExcel(tableID) { var wb = XLSX.utils.table_to_book(document.getElementById(tableID), { sheet: "Sheet1" }); XLSX.writeFile(wb, 'Emigration_Applications.xlsx'); } // Export Table to PDF function exportTableToPDF() { import('jspdf').then(jsPDF => { const { jsPDF: PDF } = jsPDF; const doc = new PDF(); doc.setFontSize(18); doc.text("Emigration Applications", 14, 15); doc.autoTable({ html: '#emigrationTable', startY: 25, theme: 'grid' }); doc.save('Emigration_Applications.pdf'); }); } </script> <!-- Bootstrap JS Bundle --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> </body> </html>
Save
Cancel