diff --git a/assets/css/dashboard.css b/assets/css/dashboard.css index f5b9ab9..d222915 100644 --- a/assets/css/dashboard.css +++ b/assets/css/dashboard.css @@ -2424,13 +2424,14 @@ body.dark-mode select option { box-shadow: 0 0 30px rgba(0, 255, 65, 0.5); max-width: 800px; width: 100%; - max-height: 85vh; + max-height: calc(90vh - 2rem); overflow-y: auto; overflow-x: hidden; font-family: var(--font-mono); padding: 2rem; animation: settingsSlideIn 0.3s ease; margin: auto; + box-sizing: border-box; } @keyframes settingsSlideIn { diff --git a/assets/js/dashboard.js b/assets/js/dashboard.js index 9d8d2fb..a5ad621 100644 --- a/assets/js/dashboard.js +++ b/assets/js/dashboard.js @@ -742,3 +742,172 @@ document.addEventListener('DOMContentLoaded', function() { }); }); }); + +// Bulk Status Change +function showBulkStatusModal() { + const ticketIds = getSelectedTicketIds(); + + if (ticketIds.length === 0) { + alert('No tickets selected'); + return; + } + + const modalHtml = ` +
+ `; + + document.body.insertAdjacentHTML('beforeend', modalHtml); +} + +function closeBulkStatusModal() { + const modal = document.getElementById('bulkStatusModal'); + if (modal) { + modal.remove(); + } +} + +function performBulkStatusChange() { + const status = document.getElementById('bulkStatus').value; + const ticketIds = getSelectedTicketIds(); + + if (!status) { + alert('Please select a status'); + return; + } + + fetch('/api/bulk_operation.php', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + operation_type: 'bulk_status', + ticket_ids: ticketIds, + parameters: { status: status } + }) + }) + .then(response => response.json()) + .then(data => { + closeBulkStatusModal(); + if (data.success) { + window.location.reload(); + } else { + alert('Error: ' + (data.error || 'Unknown error')); + } + }) + .catch(error => { + console.error('Error performing bulk status change:', error); + alert('Error performing bulk status change: ' + error.message); + }); +} + +// Bulk Delete +function showBulkDeleteModal() { + const ticketIds = getSelectedTicketIds(); + + if (ticketIds.length === 0) { + alert('No tickets selected'); + return; + } + + const modalHtml = ` + + `; + + document.body.insertAdjacentHTML('beforeend', modalHtml); +} + +function closeBulkDeleteModal() { + const modal = document.getElementById('bulkDeleteModal'); + if (modal) { + modal.remove(); + } +} + +function performBulkDelete() { + const ticketIds = getSelectedTicketIds(); + + fetch('/api/bulk_operation.php', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + operation_type: 'bulk_delete', + ticket_ids: ticketIds + }) + }) + .then(response => response.json()) + .then(data => { + closeBulkDeleteModal(); + if (data.success) { + if (typeof toast !== 'undefined') { + toast.success(`Successfully deleted ${ticketIds.length} ticket(s)`); + } + setTimeout(() => window.location.reload(), 1000); + } else { + alert('Error: ' + (data.error || 'Unknown error')); + } + }) + .catch(error => { + console.error('Error performing bulk delete:', error); + alert('Error performing bulk delete: ' + error.message); + }); +} diff --git a/models/BulkOperationsModel.php b/models/BulkOperationsModel.php index ac35ffd..34df0f2 100644 --- a/models/BulkOperationsModel.php +++ b/models/BulkOperationsModel.php @@ -128,6 +128,36 @@ class BulkOperationsModel { } } break; + + case 'bulk_status': + if (isset($parameters['status'])) { + $currentTicket = $ticketModel->getTicketById($ticketId); + if ($currentTicket) { + $success = $ticketModel->updateTicket([ + 'ticket_id' => $ticketId, + 'title' => $currentTicket['title'], + 'description' => $currentTicket['description'], + 'category' => $currentTicket['category'], + 'type' => $currentTicket['type'], + 'status' => $parameters['status'], + 'priority' => $currentTicket['priority'] + ], $operation['performed_by']); + + if ($success) { + $auditLogModel->log($operation['performed_by'], 'update', 'ticket', $ticketId, + ['status' => $parameters['status'], 'bulk_operation_id' => $operationId]); + } + } + } + break; + + case 'bulk_delete': + $success = $ticketModel->deleteTicket($ticketId); + if ($success) { + $auditLogModel->log($operation['performed_by'], 'delete', 'ticket', $ticketId, + ['bulk_operation_id' => $operationId]); + } + break; } if ($success) { diff --git a/views/DashboardView.php b/views/DashboardView.php index c54c9d8..56377c9 100644 --- a/views/DashboardView.php +++ b/views/DashboardView.php @@ -259,9 +259,10 @@