Fixed multiple critical issues reported by user: 1. **API Configuration Errors:** - Fixed all API files to use correct config path (config/config.php instead of config/db.php) - Fixed: get_users.php (bulk assign dropdown now loads users) - Fixed: get_template.php (templates now load correctly) - Fixed: bulk_operation.php (bulk operations now work) - Fixed: assign_ticket.php (manual assignment now works) 2. **Dark Mode Improvements:** - Added dark mode support for Activity tab content - Ensured proper text and background colors in dark mode All APIs now properly: - Load configuration from config/config.php - Use correct session variables ($_SESSION['user']['user_id']) - Create and close database connections properly - Return proper JSON responses 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
<?php
|
|
session_start();
|
|
require_once dirname(__DIR__) . '/config/config.php';
|
|
require_once dirname(__DIR__) . '/models/TicketModel.php';
|
|
require_once dirname(__DIR__) . '/models/AuditLogModel.php';
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
// Check authentication
|
|
if (!isset($_SESSION['user']) || !isset($_SESSION['user']['user_id'])) {
|
|
echo json_encode(['success' => false, 'error' => 'Not authenticated']);
|
|
exit;
|
|
}
|
|
|
|
$userId = $_SESSION['user']['user_id'];
|
|
|
|
// 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;
|
|
}
|
|
|
|
// Create database connection
|
|
$conn = new mysqli(
|
|
$GLOBALS['config']['DB_HOST'],
|
|
$GLOBALS['config']['DB_USER'],
|
|
$GLOBALS['config']['DB_PASS'],
|
|
$GLOBALS['config']['DB_NAME']
|
|
);
|
|
|
|
if ($conn->connect_error) {
|
|
echo json_encode(['success' => false, 'error' => 'Database connection failed']);
|
|
exit;
|
|
}
|
|
|
|
$ticketModel = new TicketModel($conn);
|
|
$auditLogModel = new AuditLogModel($conn);
|
|
|
|
if ($assignedTo === null || $assignedTo === '') {
|
|
// Unassign ticket
|
|
$success = $ticketModel->unassignTicket($ticketId, $userId);
|
|
if ($success) {
|
|
$auditLogModel->log($userId, 'unassign', 'ticket', $ticketId);
|
|
}
|
|
} else {
|
|
// Assign ticket
|
|
$success = $ticketModel->assignTicket($ticketId, $assignedTo, $userId);
|
|
if ($success) {
|
|
$auditLogModel->log($userId, 'assign', 'ticket', $ticketId, ['assigned_to' => $assignedTo]);
|
|
}
|
|
}
|
|
|
|
$conn->close();
|
|
|
|
echo json_encode(['success' => $success]);
|