Fixed MAJOR bugs, currently at a semi-stable state

This commit is contained in:
2025-09-05 11:08:56 -04:00
parent 19f436a17c
commit e05434137c
14 changed files with 1559 additions and 1106 deletions

View File

@ -1,6 +1,6 @@
<?php
// This file contains the HTML template for the dashboard
// It receives $tickets, $totalTickets, $totalPages, $page, and $status variables from the controller
// It receives $tickets, $totalTickets, $totalPages, $page, $status, $categories, $types variables from the controller
?>
<!DOCTYPE html>
<html lang="en">
@ -12,10 +12,10 @@
<link rel="stylesheet" href="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/css/dashboard.css">
<script src="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/js/dashboard.js"></script>
</head>
<body>
<body data-categories='<?php echo json_encode($categories); ?>' data-types='<?php echo json_encode($types); ?>'>
<div class="dashboard-header">
<h1>Tinker Tickets</h1>
<button onclick="window.location.href='<?php echo $GLOBALS['config']['BASE_URL']; ?>/ticket/create'" class="btn create-ticket">New Ticket</button>
<button onclick="window.location.href='/ticket/create'" class="btn create-ticket">New Ticket</button>
</div>
<div class="table-controls">
@ -25,20 +25,28 @@
<div class="table-actions">
<div class="pagination">
<?php
$currentParams = $_GET;
// Previous page button
if ($page > 1) {
echo "<button onclick='window.location.href=\"?page=" . ($page - 1) . "&status=$status\"'>«</button>";
$currentParams['page'] = $page - 1;
$prevUrl = '?' . http_build_query($currentParams);
echo "<button onclick='window.location.href=\"$prevUrl\"'>«</button>";
}
// Page number buttons
for ($i = 1; $i <= $totalPages; $i++) {
$activeClass = ($i === $page) ? 'active' : '';
echo "<button class='$activeClass' onclick='window.location.href=\"?page=$i&status=$status\"'>$i</button>";
$currentParams['page'] = $i;
$pageUrl = '?' . http_build_query($currentParams);
echo "<button class='$activeClass' onclick='window.location.href=\"$pageUrl\"'>$i</button>";
}
// Next page button
if ($page < $totalPages) {
echo "<button onclick='window.location.href=\"?page=" . ($page + 1) . "&status=$status\"'>»</button>";
$currentParams['page'] = $page + 1;
$nextUrl = '?' . http_build_query($currentParams);
echo "<button onclick='window.location.href=\"$nextUrl\"'>»</button>";
}
?>
</div>
@ -54,14 +62,30 @@
<table>
<thead>
<tr>
<th>Ticket ID</th>
<th>Priority</th>
<th>Title</th>
<th>Category</th>
<th>Type</th>
<th>Status</th>
<th>Created</th>
<th>Updated</th>
<?php
$currentSort = isset($_GET['sort']) ? $_GET['sort'] : 'ticket_id';
$currentDir = isset($_GET['dir']) ? $_GET['dir'] : 'desc';
$columns = [
'ticket_id' => 'Ticket ID',
'priority' => 'Priority',
'title' => 'Title',
'category' => 'Category',
'type' => 'Type',
'status' => 'Status',
'created_at' => 'Created',
'updated_at' => 'Updated'
];
foreach($columns as $col => $label) {
$newDir = ($currentSort === $col && $currentDir === 'asc') ? 'desc' : 'asc';
$sortClass = ($currentSort === $col) ? "sort-$currentDir" : '';
$sortParams = array_merge($_GET, ['sort' => $col, 'dir' => $newDir]);
$sortUrl = '?' . http_build_query($sortParams);
echo "<th class='$sortClass' onclick='window.location.href=\"$sortUrl\"'>$label</th>";
}
?>
</tr>
</thead>
<tbody>
@ -69,12 +93,12 @@
if (count($tickets) > 0) {
foreach($tickets as $row) {
echo "<tr class='priority-{$row['priority']}'>";
echo "<td><a href='" . $GLOBALS['config']['BASE_URL'] . "/ticket/{$row['ticket_id']}' class='ticket-link'>{$row['ticket_id']}</a></td>";
echo "<td><a href='/ticket/{$row['ticket_id']}' class='ticket-link'>{$row['ticket_id']}</a></td>";
echo "<td><span>{$row['priority']}</span></td>";
echo "<td>" . htmlspecialchars($row['title']) . "</td>";
echo "<td>{$row['category']}</td>";
echo "<td>{$row['type']}</td>";
echo "<td class='status-{$row['status']}'>{$row['status']}</td>";
echo "<td><span class='status-" . str_replace(' ', '-', $row['status']) . "'>{$row['status']}</span></td>";
echo "<td>" . date('Y-m-d H:i', strtotime($row['created_at'])) . "</td>";
echo "<td>" . date('Y-m-d H:i', strtotime($row['updated_at'])) . "</td>";
echo "</tr>";
@ -85,15 +109,5 @@
?>
</tbody>
</table>
<!--<script>
document.addEventListener('DOMContentLoaded', function() {
// Initialize the dashboard
if (document.querySelector('table')) {
initSearch();
initStatusFilter();
}
});
</script>-->
</body>
</html>