Changed Client-side Search to Server-side Search

This commit is contained in:
2025-09-05 12:40:38 -04:00
parent e05434137c
commit 38ae4802b8
6 changed files with 117 additions and 22 deletions

View File

@ -76,7 +76,7 @@
<div class="ticket-footer">
<button type="submit" class="btn primary">Create Ticket</button>
<button type="button" onclick="window.location.href='<?php echo $GLOBALS['config']['BASE_URL']; ?>'" class="btn back-btn">Cancel</button>
<button type="button" onclick="window.location.href='<?php echo $GLOBALS['config']['BASE_URL']; ?>/'" class="btn back-btn">Cancel</button>
</div>
</form>
</div>

View File

@ -17,7 +17,45 @@
<h1>Tinker Tickets</h1>
<button onclick="window.location.href='/ticket/create'" class="btn create-ticket">New Ticket</button>
</div>
<div class="search-container">
<form method="GET" action="" class="search-form">
<!-- Preserve existing parameters -->
<?php if (isset($_GET['status'])): ?>
<input type="hidden" name="status" value="<?php echo htmlspecialchars($_GET['status']); ?>">
<?php endif; ?>
<?php if (isset($_GET['show_all'])): ?>
<input type="hidden" name="show_all" value="<?php echo htmlspecialchars($_GET['show_all']); ?>">
<?php endif; ?>
<?php if (isset($_GET['category'])): ?>
<input type="hidden" name="category" value="<?php echo htmlspecialchars($_GET['category']); ?>">
<?php endif; ?>
<?php if (isset($_GET['type'])): ?>
<input type="hidden" name="type" value="<?php echo htmlspecialchars($_GET['type']); ?>">
<?php endif; ?>
<?php if (isset($_GET['sort'])): ?>
<input type="hidden" name="sort" value="<?php echo htmlspecialchars($_GET['sort']); ?>">
<?php endif; ?>
<?php if (isset($_GET['dir'])): ?>
<input type="hidden" name="dir" value="<?php echo htmlspecialchars($_GET['dir']); ?>">
<?php endif; ?>
<input type="text"
name="search"
placeholder="Search tickets..."
class="search-box"
value="<?php echo isset($_GET['search']) ? htmlspecialchars($_GET['search']) : ''; ?>">
<button type="submit" class="search-btn">Search</button>
<?php if (isset($_GET['search']) && !empty($_GET['search'])): ?>
<a href="?" class="clear-search-btn">Clear</a>
<?php endif; ?>
</form>
</div>
<?php if (isset($_GET['search']) && !empty($_GET['search'])): ?>
<div class="search-results-info">
Showing results for: "<strong><?php echo htmlspecialchars($_GET['search']); ?></strong>"
(<?php echo $totalTickets; ?> ticket<?php echo $totalTickets != 1 ? 's' : ''; ?> found)
</div>
<?php endif; ?>
<div class="table-controls">
<div class="ticket-count">
Total Tickets: <?php echo $totalTickets; ?>