Add Ticket Assignment feature (Feature 2)
- Add assigned_to column support in TicketModel with assignTicket() and unassignTicket() methods - Create assign_ticket.php API endpoint for assignment operations - Update TicketController to load user list from UserModel - Add assignment dropdown UI in TicketView - Add JavaScript handler for assignment changes - Integrate with audit log for assignment tracking Users can now assign tickets to team members via dropdown selector. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
42
api/assign_ticket.php
Normal file
42
api/assign_ticket.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once '../config/db.php';
|
||||
require_once '../models/TicketModel.php';
|
||||
require_once '../models/AuditLogModel.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Check authentication
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
echo json_encode(['success' => false, 'error' => 'Not authenticated']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get request data
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$ticketId = $data['ticket_id'] ?? null;
|
||||
$assignedTo = $data['assigned_to'] ?? null;
|
||||
|
||||
if (!$ticketId) {
|
||||
echo json_encode(['success' => false, 'error' => 'Ticket ID required']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$ticketModel = new TicketModel($conn);
|
||||
$auditLogModel = new AuditLogModel($conn);
|
||||
|
||||
if ($assignedTo === null || $assignedTo === '') {
|
||||
// Unassign ticket
|
||||
$success = $ticketModel->unassignTicket($ticketId, $_SESSION['user_id']);
|
||||
if ($success) {
|
||||
$auditLogModel->log($_SESSION['user_id'], 'unassign', 'ticket', $ticketId);
|
||||
}
|
||||
} else {
|
||||
// Assign ticket
|
||||
$success = $ticketModel->assignTicket($ticketId, $assignedTo, $_SESSION['user_id']);
|
||||
if ($success) {
|
||||
$auditLogModel->log($_SESSION['user_id'], 'assign', 'ticket', $ticketId, ['assigned_to' => $assignedTo]);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode(['success' => $success]);
|
||||
Reference in New Issue
Block a user