📁 File Manager
Editing:
/home/wvl7mof7402e/www/remindyourdata.live/emply/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'] : ''; $searchQuery = $search ? "WHERE name LIKE '%$search%' OR passport_no LIKE '%$search%' OR agency_name LIKE '%$search%'" : ""; // 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"> <title>All Emigration Applications</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Bootstrap + jQuery + Export Libraries --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <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> body { background: linear-gradient(135deg, #e0f7fa, #e1bee7); font-family: 'Segoe UI', sans-serif; color: #333; } h2 { color: #3f51b5; font-weight: 700; margin-bottom: 30px; text-align: center; } .btn { border-radius: 8px; font-weight: 600; } .btn-success { background-color: #43a047; } .btn-outline-primary { border-color: #1e88e5; color: #1e88e5; } .btn-outline-primary:hover { background-color: #1e88e5; color: white; } .btn-outline-danger { border-color: #e53935; color: #e53935; } .btn-outline-danger:hover { background-color: #e53935; color: white; } #searchBox { border-radius: 8px; max-width: 300px; } table { background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 5px 20px rgba(0,0,0,0.1); } thead th { background: linear-gradient(to right, #3f51b5, #5c6bc0); color: white; font-size: 0.95rem; text-align: center; } tbody td { text-align: center; vertical-align: middle; font-size: 0.9rem; } .table-hover tbody tr:hover { background-color: #f1f8ff; } .pagination .page-link { border-radius: 6px; margin: 0 3px; color: #3f51b5; font-weight: 600; } .pagination .active .page-link { background-color: #3f51b5; color: white; border: none; } @media (max-width: 768px) { .d-flex.flex-wrap.gap-2 { flex-direction: column !important; align-items: center; } #searchBox { width: 100% !important; } } </style> </head> <body> <body> <!-- Logout Button --> <form action="logout.php" method="post" class="position-absolute top-0 end-0 m-3"> <button class="btn btn-danger">🚪 Logout</button> </form> <div class="container mt-5"> <h2>📋 All Emigration Applications</h2> <div class="d-flex justify-content-between align-items-center mb-3 flex-wrap gap-2"> <a href="emigration_form.php" class="btn btn-success">➕ Add New</a> <input type="text" id="searchBox" class="form-control" placeholder="Search by name/passport/agency..." value="<?= htmlspecialchars($search) ?>"> <div> <button class="btn btn-outline-primary me-2" onClick="exportTableToExcel('emigrationTable')">📁 Excel</button> <button class="btn btn-outline-danger" onClick="exportTableToPDF()">📄 PDF</button> </div> </div> <div class="table-responsive"> <table class="table table-bordered table-hover" id="emigrationTable"> <thead> <tr> <th>#</th> <th>👤 Name</th> <th>📞 Phone</th> <th>🛂 Passport</th> <th>🌍 Country</th> <th>💼 Position</th> <th>🏢 Agency</th> <th>📅 Applied On</th> <th>✏️ 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">Edit</a> <!-- Delete Button Removed --> </td> </tr> <?php endwhile; ?> <?php else: ?> <tr><td colspan="9" class="text-center">No records found.</td></tr> <?php endif; ?> </tbody> </table> </div> <!-- Pagination --> <nav> <ul class="pagination justify-content-center mt-4"> <?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> // Auto search submit $('#searchBox').on('change', function() { const value = $(this).val(); window.location.href = '?search=' + encodeURIComponent(value); }); // Excel Export function exportTableToExcel(tableID) { const wb = XLSX.utils.table_to_book(document.getElementById(tableID), { sheet: "Sheet1" }); XLSX.writeFile(wb, 'Emigration_Applications.xlsx'); } // PDF Export function exportTableToPDF() { import('jspdf').then(jsPDF => { const { jsPDF: PDF } = jsPDF; const doc = new PDF(); doc.text("Emigration Applications", 14, 10); doc.autoTable({ html: '#emigrationTable' }); doc.save('Emigration_Applications.pdf'); }); } </script> </body> </html>
Save
Cancel