connect_error) { die("Connection failed: " . $conn->connect_error); } // Pagination settings from localStorage or defaults $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $limit = isset($_COOKIE['ticketsPerPage']) ? (int)$_COOKIE['ticketsPerPage'] : 15; $defaultSortColumn = isset($_COOKIE['defaultSortColumn']) ? $_COOKIE['defaultSortColumn'] : 'ticket_id'; $sortDirection = isset($_COOKIE['sortDirection']) ? $_COOKIE['sortDirection'] : 'desc'; $offset = ($page - 1) * $limit; // Get total number of tickets based on current filter $status = isset($_GET['status']) ? $_GET['status'] : 'Open'; $statuses = explode(',', $status); $whereClause = ""; if (isset($_GET['status'])) { $statuses = explode(',', $_GET['status']); $whereClause = "WHERE status IN ('" . implode("','", $statuses) . "')"; } else { $whereClause = "WHERE status = 'Open'"; } $totalTicketsQuery = "SELECT COUNT(*) as total FROM tickets $whereClause"; $totalTicketsResult = $conn->query($totalTicketsQuery); $totalTickets = $totalTicketsResult->fetch_assoc()['total']; $totalPages = ceil($totalTickets / $limit); // Modify SQL to use these settings and filter $sql = "SELECT * FROM tickets $whereClause ORDER BY $defaultSortColumn $sortDirection LIMIT $limit OFFSET $offset"; $result = $conn->query($sql); ?>
| Ticket ID | Priority | Title | Category | Type | Status | Created | Updated |
|---|---|---|---|---|---|---|---|
| {$row['ticket_id']} | "; echo "{$row['priority']} | "; echo "{$row['title']} | "; echo "{$row['category']} | "; echo "{$row['type']} | "; echo "{$row['status']} | "; echo "" . date('Y-m-d H:i', strtotime($row['created_at'])) . " | "; echo "" . date('Y-m-d H:i', strtotime($row['updated_at'])) . " | "; echo "
| No tickets found | |||||||