Files
tinker_tickets/api/assign_ticket.php
Jared Vititoe 99e60795c9 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>
2026-01-01 18:36:34 -05:00

43 lines
1.2 KiB
PHP

<?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]);