fix: unassigned filter not working + null guards on modal selects
- DashboardController: handle assigned_to='unassigned' before validateUserId() which discarded the string, causing the filter to never reach TicketModel; model already correctly converts 'unassigned' to IS NULL in SQL - dashboard.js: add null guards before .value access on dynamically-created modal selects (bulkPriority, bulkStatus, quickStatusSelect) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -686,7 +686,9 @@ function closeBulkPriorityModal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function performBulkPriority() {
|
function performBulkPriority() {
|
||||||
const priority = document.getElementById('bulkPriority').value;
|
const priorityEl = document.getElementById('bulkPriority');
|
||||||
|
if (!priorityEl) return;
|
||||||
|
const priority = priorityEl.value;
|
||||||
const ticketIds = getSelectedTicketIds();
|
const ticketIds = getSelectedTicketIds();
|
||||||
|
|
||||||
if (!priority) {
|
if (!priority) {
|
||||||
@@ -789,7 +791,9 @@ function closeBulkStatusModal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function performBulkStatusChange() {
|
function performBulkStatusChange() {
|
||||||
const status = document.getElementById('bulkStatus').value;
|
const bulkStatusEl = document.getElementById('bulkStatus');
|
||||||
|
if (!bulkStatusEl) return;
|
||||||
|
const status = bulkStatusEl.value;
|
||||||
const ticketIds = getSelectedTicketIds();
|
const ticketIds = getSelectedTicketIds();
|
||||||
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
@@ -986,7 +990,9 @@ function closeQuickStatusModal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function performQuickStatusChange(ticketId) {
|
function performQuickStatusChange(ticketId) {
|
||||||
const newStatus = document.getElementById('quickStatusSelect').value;
|
const quickStatusEl = document.getElementById('quickStatusSelect');
|
||||||
|
if (!quickStatusEl) return;
|
||||||
|
const newStatus = quickStatusEl.value;
|
||||||
|
|
||||||
lt.api.post('/api/update_ticket.php', { ticket_id: ticketId, status: newStatus })
|
lt.api.post('/api/update_ticket.php', { ticket_id: ticketId, status: newStatus })
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
|||||||
@@ -136,10 +136,16 @@ class DashboardController {
|
|||||||
|
|
||||||
// Validate user ID filters
|
// Validate user ID filters
|
||||||
$createdBy = $this->validateUserId($_GET['created_by'] ?? null);
|
$createdBy = $this->validateUserId($_GET['created_by'] ?? null);
|
||||||
$assignedTo = $this->validateUserId($_GET['assigned_to'] ?? null);
|
|
||||||
|
|
||||||
if ($createdBy !== null) $filters['created_by'] = $createdBy;
|
if ($createdBy !== null) $filters['created_by'] = $createdBy;
|
||||||
if ($assignedTo !== null) $filters['assigned_to'] = $assignedTo;
|
|
||||||
|
// assigned_to accepts a numeric user ID or the special string 'unassigned'
|
||||||
|
$assignedToRaw = $_GET['assigned_to'] ?? null;
|
||||||
|
if ($assignedToRaw === 'unassigned') {
|
||||||
|
$filters['assigned_to'] = 'unassigned';
|
||||||
|
} else {
|
||||||
|
$assignedTo = $this->validateUserId($assignedToRaw);
|
||||||
|
if ($assignedTo !== null) $filters['assigned_to'] = $assignedTo;
|
||||||
|
}
|
||||||
|
|
||||||
// Get tickets with pagination, sorting, search, and advanced filters
|
// Get tickets with pagination, sorting, search, and advanced filters
|
||||||
$result = $this->ticketModel->getAllTickets($page, $limit, $status, $sortColumn, $sortDirection, $category, $type, $search, $filters, $GLOBALS['currentUser'] ?? []);
|
$result = $this->ticketModel->getAllTickets($page, $limit, $status, $sortColumn, $sortDirection, $category, $type, $search, $filters, $GLOBALS['currentUser'] ?? []);
|
||||||
|
|||||||
Reference in New Issue
Block a user