📁 File Manager
Editing:
/home/wvl7mof7402e/public_html/remindyourdata.live/admin/ticketlist.php
<?php session_start(); include "dbconnect.php"; // Database Connection // Pagination setup $limit = 10; $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $offset = ($page - 1) * $limit; // Search $search = isset($_POST['search']) ? $_POST['search'] : ''; $search_query = !empty($search) ? "AND (ja.name LIKE '%$search%' OR ja.passport_no LIKE '%$search%')" : ''; // Data Query $sql = "SELECT t.ticket_id, ja.name AS applicant_name, ja.passport_no, t.from_location, t.to_location, t.distance, t.ticket_date, t.amount, t.boarding_pass_upload FROM Ticketing t JOIN job_applicants ja ON t.job_applicant_id = ja.id WHERE 1=1 $search_query ORDER BY t.ticket_id DESC LIMIT $limit OFFSET $offset"; $result = $con->query($sql); // Total count $count_sql = "SELECT COUNT(t.ticket_id) AS total FROM Ticketing t JOIN job_applicants ja ON t.job_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"> <head> <meta charset="UTF-8"> <title>Ticket List</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Bootstrap & Icons --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet"> <style> body { background: linear-gradient(145deg, #f1f5ff, #e2ecff); font-family: 'Segoe UI', sans-serif; color: #333; min-height: 100vh; } .container { padding-top: 50px; padding-bottom: 60px; } h3 { font-size: 2rem; font-weight: 700; color: #007bff; text-align: center; margin-bottom: 30px; } .table { border-radius: 12px; overflow: hidden; } .table th { background-color: #007bff; color: white; vertical-align: middle; } .table-striped tbody tr:nth-of-type(odd) { background-color: #f2f8ff; } .table-bordered td, .table-bordered th { border: 1px solid #dee2e6; text-align: center; vertical-align: middle; } .form-control { border-radius: 8px; } .btn { border-radius: 8px; } .logout-btn { position: absolute; top: 20px; right: 20px; } .logout-btn a { background-color: #dc3545; color: white; padding: 8px 16px; border-radius: 20px; text-decoration: none; font-weight: 600; } .logout-btn a:hover { background-color: #c82333; color: white; } .pagination { justify-content: center; } .pagination .page-link { border-radius: 6px; } .pagination .active .page-link { background-color: #007bff; color: white; } @media (max-width: 576px) { .form-control { width: 100% !important; } .logout-btn { position: static; margin-top: 10px; text-align: right; } } </style> </head> <body> <div class="container"> <div class="logout-btn"> <a href="logout.php"><i class="bi bi-box-arrow-right"></i> Logout</a> </div> <h3><i class="bi bi-card-list"></i> Ticket Management List</h3> <!-- Search --> <form method="POST" class="d-flex flex-wrap justify-content-center mb-4 gap-2"> <input type="text" name="search" class="form-control" placeholder="Search by Name or Passport No" value="<?= htmlspecialchars($search); ?>" style="max-width: 300px;"> <button type="submit" class="btn btn-primary"><i class="bi bi-search"></i> Search</button> </form> <!-- Table --> <div class="table-responsive"> <table class="table table-striped table-bordered align-middle"> <thead> <tr> <th><i class="bi bi-hash"></i> ID</th> <th><i class="bi bi-person-fill"></i> Applicant</th> <th><i class="bi bi-passport"></i> Passport No</th> <th><i class="bi bi-geo-alt-fill"></i> From</th> <th><i class="bi bi-geo-fill"></i> To</th> <th><i class="bi bi-signpost-2-fill"></i> Distance</th> <th><i class="bi bi-calendar-event-fill"></i> Date</th> <th><i class="bi bi-currency-rupee"></i> Amount</th> <th><i class="bi bi-file-earmark-arrow-down-fill"></i> Boarding Pass</th> <th><i class="bi bi-gear-fill"></i> Actions</th> </tr> </thead> <tbody> <?php if ($result->num_rows > 0): ?> <?php while ($row = $result->fetch_assoc()): ?> <tr> <td><?= $row['ticket_id'] ?></td> <td><?= htmlspecialchars($row['applicant_name']) ?></td> <td><?= htmlspecialchars($row['passport_no']) ?></td> <td><?= htmlspecialchars($row['from_location']) ?></td> <td><?= htmlspecialchars($row['to_location']) ?></td> <td><?= htmlspecialchars($row['distance']) ?> km</td> <td><?= htmlspecialchars($row['ticket_date']) ?></td> <td>₹ <?= number_format($row['amount'], 2) ?></td> <td> <?php if (!empty($row['boarding_pass_upload'])): ?> <a href="<?= $row['boarding_pass_upload'] ?>" target="_blank" class="btn btn-outline-primary btn-sm"> <i class="bi bi-eye-fill"></i> View </a> <?php else: ?> N/A <?php endif; ?> </td> <td> <a href="ticketedit.php?id=<?= $row['ticket_id'] ?>" class="btn btn-primary btn-sm"> <i class="bi bi-pencil-square"></i> Edit </a> <a href="ticketdelete.php?id=<?= $row['ticket_id'] ?>" class="btn btn-danger btn-sm ms-1" onclick="return confirm('Are you sure you want to delete this ticket?');"> <i class="bi bi-trash-fill"></i> Delete </a> </td> </tr> <?php endwhile; ?> <?php else: ?> <tr><td colspan="10" class="text-center text-danger">No records found.</td></tr> <?php endif; ?> </tbody> </table> </div> <!-- Pagination --> <nav aria-label="Page navigation"> <ul class="pagination"> <li class="page-item <?= ($page == 1) ? 'disabled' : '' ?>"> <a class="page-link" href="?page=1" title="First">«</a> </li> <li class="page-item <?= ($page <= 1) ? 'disabled' : '' ?>"> <a class="page-link" href="?page=<?= max($page - 1, 1) ?>" title="Previous">‹</a> </li> <?php for ($i = 1; $i <= $total_pages; $i++): ?> <li class="page-item <?= ($i == $page) ? 'active' : '' ?>"> <a class="page-link" href="?page=<?= $i ?>"><?= $i ?></a> </li> <?php endfor; ?> <li class="page-item <?= ($page >= $total_pages) ? 'disabled' : '' ?>"> <a class="page-link" href="?page=<?= min($page + 1, $total_pages) ?>" title="Next">›</a> </li> <li class="page-item <?= ($page == $total_pages) ? 'disabled' : '' ?>"> <a class="page-link" href="?page=<?= $total_pages ?>" title="Last">»</a> </li> </ul> </nav> </div> <!-- Bootstrap JS --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> </body> </html>
Save
Cancel