📁 File Manager
Editing:
/home/wvl7mof7402e/public_html/remindyourdata.live/admin/agentlist.php
<?php include "dbconnect.php"; // Pagination settings $limit = 10; $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; if ($page < 1) $page = 1; $offset = ($page - 1) * $limit; // Search & date filters $searchQuery = ""; $dateFilter = ""; if (isset($_GET['search']) && $_GET['search'] !== "") { $search = $con->real_escape_string($_GET['search']); $searchQuery = " AND (mobile_no LIKE '%$search%' OR adharno LIKE '%$search%')"; } if (!empty($_GET['start_date']) && !empty($_GET['end_date'])) { $start_date = $con->real_escape_string($_GET['start_date']); $end_date = $con->real_escape_string($_GET['end_date']); $dateFilter = " AND created_at BETWEEN '$start_date' AND '$end_date'"; } // Count total records $totalSql = "SELECT COUNT(*) as cnt FROM agents WHERE 1 $searchQuery $dateFilter"; $totalResult = $con->query($totalSql); $totalRow = $totalResult->fetch_assoc(); $totalRecords = $totalRow['cnt']; $totalPages = ceil($totalRecords / $limit); // Fetch page data $sql = "SELECT * FROM agents WHERE 1 $searchQuery $dateFilter ORDER BY created_at DESC LIMIT $limit OFFSET $offset"; $result = $con->query($sql); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Agent List</title> <!-- Bootstrap & DataTables & Font Awesome --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdn.datatables.net/1.13.4/css/jquery.dataTables.min.css"> <link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.3.6/css/buttons.dataTables.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <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> <script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/buttons/2.3.6/js/dataTables.buttons.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script> <script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.html5.min.js"></script> <script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.print.min.js"></script> <style> body { background: linear-gradient(135deg, #4e54c8, #8f94fb); font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; color: #333; } .container { margin-top: 30px; } h3 { color: #f8f9fa; margin-bottom: 20px; } .filter-form { gap: 10px; flex-wrap: wrap; } .filter-form input[type="date"], .filter-form input[type="text"] { width: 180px; } .filter-form .btn { white-space: nowrap; } .logout-btn { position: fixed; top: 15px; right: 15px; background-color: #dc3545; color: white; border-radius: 25px; padding: 10px 20px; font-size: 14px; text-decoration: none; z-index: 999; } .logout-btn:hover { background-color: #c82333; } .table thead th { background-color: #343a40; color: white; text-align: center; } .table tbody td { vertical-align: middle; text-align: center; } .action-btns a { margin: 0 2px; } @media (max-width: 768px) { .filter-form input[type="date"], .filter-form input[type="text"] { width: 100%; } .logout-btn { top: 10px; right: 10px; padding: 8px 16px; } } </style> </head> <body> <a href="logout.php" class="logout-btn"><i class="fas fa-sign-out-alt"></i> Logout</a> <div class="container"> <h3 class="text-center text-light">Agent List</h3> <form method="GET" class="mb-3 d-flex filter-form"> <input type="date" name="start_date" class="form-control" value="<?= isset($_GET['start_date']) ? $_GET['start_date'] : '' ?>" required> <input type="date" name="end_date" class="form-control" value="<?= isset($_GET['end_date']) ? $_GET['end_date'] : '' ?>" required> <input type="text" name="search" class="form-control" placeholder="Search Mobile / Aadhar" value="<?= isset($_GET['search']) ? htmlspecialchars($_GET['search']) : '' ?>"> <button type="submit" class="btn btn-success"><i class="fas fa-filter"></i> Filter</button> </form> <div class="table-responsive bg-white rounded shadow-sm"> <table id="agentTable" class="table table-striped table-bordered mb-0"> <thead> <tr> <th><i class="fas fa-hashtag"></i></th> <th><i class="fas fa-user"></i> Name</th> <th><i class="fas fa-user-tie"></i> Father</th> <th><i class="fas fa-graduation-cap"></i> Qualif.</th> <th><i class="fas fa-phone"></i> Mobile</th> <th><i class="fas fa-envelope"></i> Email</th> <th><i class="fas fa-id-card-alt"></i> Aadhar</th> <th><i class="fas fa-id-badge"></i> PAN</th> <th><i class="fas fa-comment-dots"></i> Message</th> <th><i class="fas fa-file-alt"></i> Document</th> <th><i class="fas fa-cogs"></i> Actions</th> </tr> </thead> <tbody> <?php $sr = $offset + 1; while ($row = $result->fetch_assoc()) { ?> <tr> <td><?= $sr++ ?></td> <td><?= htmlspecialchars($row['name']) ?></td> <td><?= htmlspecialchars($row['father_name']) ?></td> <td><?= htmlspecialchars($row['qualification']) ?></td> <td><?= htmlspecialchars($row['mobile_no']) ?></td> <td><?= htmlspecialchars($row['email_id']) ?></td> <td><?= htmlspecialchars($row['adharno']) ?></td> <td><?= htmlspecialchars($row['pancard']) ?></td> <td><?= htmlspecialchars($row['message']) ?></td> <td> <?php if (!empty($row['document_upload'])) { ?> <a href="uploads/<?= htmlspecialchars($row['document_upload']) ?>" target="_blank" class="btn btn-sm btn-info"><i class="fas fa-eye"></i></a> <a href="uploads/<?= htmlspecialchars($row['document_upload']) ?>" download class="btn btn-sm btn-success"><i class="fas fa-download"></i></a> <?php } else { echo "N/A"; } ?> </td> <td class="action-btns"> <a href="#" class="btn btn-sm btn-warning" onclick="verifyCode('edit_agent.php?id=<?= $row['id'] ?>')"><i class="fas fa-edit"></i></a> <a href="#" class="btn btn-sm btn-danger" onclick="verifyCode('delete_agent.php?id=<?= $row['id'] ?>')"><i class="fas fa-trash-alt"></i></a> </td> </tr> <?php } ?> </tbody> </table> </div> <!-- Optional: Pagination links (manual) --> <nav class="mt-3"> <ul class="pagination justify-content-center"> <?php if ($page > 1): ?> <li class="page-item"> <a class="page-link" href="?page=<?= $page-1 ?>&<?= http_build_query($_GET) ?>">« Prev</a> </li> <?php endif; ?> <?php for ($p = 1; $p <= $totalPages; $p++): ?> <li class="page-item <?= ($p == $page ? 'active' : '') ?>"> <a class="page-link" href="?page=<?= $p ?>&<?= http_build_query($_GET) ?>"><?= $p ?></a> </li> <?php endfor; ?> <?php if ($page < $totalPages): ?> <li class="page-item"> <a class="page-link" href="?page=<?= $page+1 ?>&<?= http_build_query($_GET) ?>">Next »</a> </li> <?php endif; ?> </ul> </nav> </div> <script> $(document).ready(function() { $('#agentTable').DataTable({ dom: 'Bfrtip', buttons: [ { extend: 'excelHtml5', text: '<i class="fas fa-file-excel"></i> Excel' }, { extend: 'csvHtml5', text: '<i class="fas fa-file-csv"></i> CSV' }, { extend: 'pdfHtml5', text: '<i class="fas fa-file-pdf"></i> PDF' }, { extend: 'print', text: '<i class="fas fa-print"></i> Print' } ], pageLength: 10, order: [] // disable initial ordering, or set default }); }); function verifyCode(url) { let code = prompt("Enter Security Code:"); if (code === "1234") { window.location.href = url; } else { alert("Invalid Security Code!"); } } </script> </body> </html>
Save
Cancel