Fixed MAJOR bugs, currently at a semi-stable state
This commit is contained in:
@ -20,6 +20,20 @@ try {
|
|||||||
require_once $configPath;
|
require_once $configPath;
|
||||||
debug_log("Config loaded successfully");
|
debug_log("Config loaded successfully");
|
||||||
|
|
||||||
|
// Load environment variables (for Discord webhook)
|
||||||
|
$envPath = dirname(__DIR__) . '/.env';
|
||||||
|
$envVars = [];
|
||||||
|
if (file_exists($envPath)) {
|
||||||
|
$lines = file($envPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
if (strpos($line, '=') !== false && strpos($line, '#') !== 0) {
|
||||||
|
list($key, $value) = explode('=', $line, 2);
|
||||||
|
$envVars[trim($key)] = trim($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
debug_log("Environment variables loaded");
|
||||||
|
}
|
||||||
|
|
||||||
// Load models directly with absolute paths
|
// Load models directly with absolute paths
|
||||||
$ticketModelPath = dirname(__DIR__) . '/models/TicketModel.php';
|
$ticketModelPath = dirname(__DIR__) . '/models/TicketModel.php';
|
||||||
$commentModelPath = dirname(__DIR__) . '/models/CommentModel.php';
|
$commentModelPath = dirname(__DIR__) . '/models/CommentModel.php';
|
||||||
@ -29,49 +43,180 @@ try {
|
|||||||
require_once $commentModelPath;
|
require_once $commentModelPath;
|
||||||
debug_log("Models loaded successfully");
|
debug_log("Models loaded successfully");
|
||||||
|
|
||||||
// Now load the controller with a modified approach
|
// Updated controller class that handles partial updates
|
||||||
$controllerPath = dirname(__DIR__) . '/controllers/TicketController.php';
|
|
||||||
debug_log("Loading controller from: $controllerPath");
|
|
||||||
|
|
||||||
// Instead of directly including the controller file, we'll define a new controller class
|
|
||||||
// that extends the functionality we need without the problematic require_once statements
|
|
||||||
|
|
||||||
class ApiTicketController {
|
class ApiTicketController {
|
||||||
private $ticketModel;
|
private $ticketModel;
|
||||||
private $commentModel;
|
private $commentModel;
|
||||||
|
private $envVars;
|
||||||
|
|
||||||
public function __construct($conn) {
|
public function __construct($conn, $envVars = []) {
|
||||||
$this->ticketModel = new TicketModel($conn);
|
$this->ticketModel = new TicketModel($conn);
|
||||||
$this->commentModel = new CommentModel($conn);
|
$this->commentModel = new CommentModel($conn);
|
||||||
|
$this->envVars = $envVars;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($id, $data) {
|
public function update($id, $data) {
|
||||||
// Add ticket_id to the data
|
debug_log("ApiTicketController->update called with ID: $id and data: " . json_encode($data));
|
||||||
$data['ticket_id'] = $id;
|
|
||||||
|
|
||||||
// Validate input data
|
// First, get the current ticket data to fill in missing fields
|
||||||
if (empty($data['title'])) {
|
$currentTicket = $this->ticketModel->getTicketById($id);
|
||||||
|
if (!$currentTicket) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'error' => 'Ticket not found'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
debug_log("Current ticket data: " . json_encode($currentTicket));
|
||||||
|
|
||||||
|
// Merge current data with updates, keeping existing values for missing fields
|
||||||
|
$updateData = [
|
||||||
|
'ticket_id' => $id,
|
||||||
|
'title' => $data['title'] ?? $currentTicket['title'],
|
||||||
|
'description' => $data['description'] ?? $currentTicket['description'],
|
||||||
|
'category' => $data['category'] ?? $currentTicket['category'],
|
||||||
|
'type' => $data['type'] ?? $currentTicket['type'],
|
||||||
|
'status' => $data['status'] ?? $currentTicket['status'],
|
||||||
|
'priority' => isset($data['priority']) ? (int)$data['priority'] : (int)$currentTicket['priority']
|
||||||
|
];
|
||||||
|
|
||||||
|
debug_log("Merged update data: " . json_encode($updateData));
|
||||||
|
|
||||||
|
// Validate required fields
|
||||||
|
if (empty($updateData['title'])) {
|
||||||
return [
|
return [
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'error' => 'Title cannot be empty'
|
'error' => 'Title cannot be empty'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate priority range
|
||||||
|
if ($updateData['priority'] < 1 || $updateData['priority'] > 5) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'error' => 'Priority must be between 1 and 5'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate status
|
||||||
|
$validStatuses = ['Open', 'Closed', 'In Progress', 'Pending'];
|
||||||
|
if (!in_array($updateData['status'], $validStatuses)) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'error' => 'Invalid status value'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
debug_log("Validation passed, calling ticketModel->updateTicket");
|
||||||
|
|
||||||
// Update ticket
|
// Update ticket
|
||||||
$result = $this->ticketModel->updateTicket($data);
|
$result = $this->ticketModel->updateTicket($updateData);
|
||||||
|
|
||||||
|
debug_log("TicketModel->updateTicket returned: " . ($result ? 'true' : 'false'));
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
|
// Send Discord webhook notification
|
||||||
|
$this->sendDiscordWebhook($id, $currentTicket, $updateData, $data);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'status' => $data['status']
|
'status' => $updateData['status'],
|
||||||
|
'priority' => $updateData['priority'],
|
||||||
|
'message' => 'Ticket updated successfully'
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'error' => 'Failed to update ticket'
|
'error' => 'Failed to update ticket in database'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function sendDiscordWebhook($ticketId, $oldData, $newData, $changedFields) {
|
||||||
|
if (!isset($this->envVars['DISCORD_WEBHOOK_URL']) || empty($this->envVars['DISCORD_WEBHOOK_URL'])) {
|
||||||
|
debug_log("Discord webhook URL not configured, skipping webhook");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$webhookUrl = $this->envVars['DISCORD_WEBHOOK_URL'];
|
||||||
|
debug_log("Sending Discord webhook to: $webhookUrl");
|
||||||
|
|
||||||
|
// Determine what fields actually changed
|
||||||
|
$changes = [];
|
||||||
|
foreach ($changedFields as $field => $newValue) {
|
||||||
|
if ($field === 'ticket_id') continue; // Skip ticket_id
|
||||||
|
|
||||||
|
$oldValue = $oldData[$field] ?? 'N/A';
|
||||||
|
if ($oldValue != $newValue) {
|
||||||
|
$changes[] = [
|
||||||
|
'name' => ucfirst($field),
|
||||||
|
'value' => "$oldValue → $newValue",
|
||||||
|
'inline' => true
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($changes)) {
|
||||||
|
debug_log("No actual changes detected, skipping webhook");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create ticket URL
|
||||||
|
$ticketUrl = "http://t.lotusguild.org/ticket/$ticketId";
|
||||||
|
|
||||||
|
// Determine embed color based on priority
|
||||||
|
$colors = [
|
||||||
|
1 => 0xff4d4d, // Red
|
||||||
|
2 => 0xffa726, // Orange
|
||||||
|
3 => 0x42a5f5, // Blue
|
||||||
|
4 => 0x66bb6a, // Green
|
||||||
|
5 => 0x9e9e9e // Gray
|
||||||
|
];
|
||||||
|
$color = $colors[$newData['priority']] ?? 0x3498db;
|
||||||
|
|
||||||
|
$embed = [
|
||||||
|
'title' => '🔄 Ticket Updated',
|
||||||
|
'description' => "**#{$ticketId}** - " . $newData['title'],
|
||||||
|
'color' => $color,
|
||||||
|
'fields' => array_merge($changes, [
|
||||||
|
[
|
||||||
|
'name' => '🔗 View Ticket',
|
||||||
|
'value' => "[Click here to view]($ticketUrl)",
|
||||||
|
'inline' => false
|
||||||
|
]
|
||||||
|
]),
|
||||||
|
'footer' => [
|
||||||
|
'text' => 'Tinker Tickets'
|
||||||
|
],
|
||||||
|
'timestamp' => date('c')
|
||||||
|
];
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'embeds' => [$embed]
|
||||||
|
];
|
||||||
|
|
||||||
|
debug_log("Discord payload: " . json_encode($payload));
|
||||||
|
|
||||||
|
// Send webhook
|
||||||
|
$ch = curl_init($webhookUrl);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
|
||||||
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||||
|
|
||||||
|
$webhookResult = curl_exec($ch);
|
||||||
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
$curlError = curl_error($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
if ($curlError) {
|
||||||
|
debug_log("Discord webhook cURL error: $curlError");
|
||||||
|
} else {
|
||||||
|
debug_log("Discord webhook sent. HTTP Code: $httpCode, Response: $webhookResult");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_log("Controller defined successfully");
|
debug_log("Controller defined successfully");
|
||||||
@ -90,10 +235,16 @@ try {
|
|||||||
}
|
}
|
||||||
debug_log("Database connection successful");
|
debug_log("Database connection successful");
|
||||||
|
|
||||||
|
// Check request method
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
|
throw new Exception("Method not allowed. Expected POST, got " . $_SERVER['REQUEST_METHOD']);
|
||||||
|
}
|
||||||
|
|
||||||
// Get POST data
|
// Get POST data
|
||||||
$input = file_get_contents('php://input');
|
$input = file_get_contents('php://input');
|
||||||
$data = json_decode($input, true);
|
$data = json_decode($input, true);
|
||||||
debug_log("Received data: " . json_encode($data));
|
debug_log("Received raw input: " . $input);
|
||||||
|
debug_log("Decoded data: " . json_encode($data));
|
||||||
|
|
||||||
if (!$data) {
|
if (!$data) {
|
||||||
throw new Exception("Invalid JSON data received: " . $input);
|
throw new Exception("Invalid JSON data received: " . $input);
|
||||||
@ -103,12 +254,12 @@ try {
|
|||||||
throw new Exception("Missing ticket_id parameter");
|
throw new Exception("Missing ticket_id parameter");
|
||||||
}
|
}
|
||||||
|
|
||||||
$ticketId = $data['ticket_id'];
|
$ticketId = (int)$data['ticket_id'];
|
||||||
debug_log("Processing ticket ID: $ticketId");
|
debug_log("Processing ticket ID: $ticketId");
|
||||||
|
|
||||||
// Initialize controller
|
// Initialize controller
|
||||||
debug_log("Initializing controller");
|
debug_log("Initializing controller");
|
||||||
$controller = new ApiTicketController($conn);
|
$controller = new ApiTicketController($conn, $envVars);
|
||||||
debug_log("Controller initialized");
|
debug_log("Controller initialized");
|
||||||
|
|
||||||
// Update ticket
|
// Update ticket
|
||||||
@ -116,13 +267,16 @@ try {
|
|||||||
$result = $controller->update($ticketId, $data);
|
$result = $controller->update($ticketId, $data);
|
||||||
debug_log("Update completed with result: " . json_encode($result));
|
debug_log("Update completed with result: " . json_encode($result));
|
||||||
|
|
||||||
|
// Close database connection
|
||||||
|
$conn->close();
|
||||||
|
|
||||||
// Discard any output that might have been generated
|
// Discard any output that might have been generated
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
// Return response
|
// Return response
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode($result);
|
echo json_encode($result);
|
||||||
debug_log("Response sent");
|
debug_log("Response sent successfully");
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
debug_log("Error: " . $e->getMessage());
|
debug_log("Error: " . $e->getMessage());
|
||||||
@ -133,9 +287,11 @@ try {
|
|||||||
|
|
||||||
// Return error response
|
// Return error response
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
http_response_code(500);
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'error' => $e->getMessage()
|
'error' => $e->getMessage()
|
||||||
]);
|
]);
|
||||||
debug_log("Error response sent");
|
debug_log("Error response sent");
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
@ -1,4 +1,4 @@
|
|||||||
/* Variables */
|
/* ===== CSS VARIABLES ===== */
|
||||||
:root {
|
:root {
|
||||||
--bg-primary: #f5f7fa;
|
--bg-primary: #f5f7fa;
|
||||||
--bg-secondary: #ffffff;
|
--bg-secondary: #ffffff;
|
||||||
@ -11,6 +11,12 @@
|
|||||||
--priority-2: #ffa726;
|
--priority-2: #ffa726;
|
||||||
--priority-3: #42a5f5;
|
--priority-3: #42a5f5;
|
||||||
--priority-4: #66bb6a;
|
--priority-4: #66bb6a;
|
||||||
|
--priority-5: #9e9e9e;
|
||||||
|
|
||||||
|
/* Status Colors */
|
||||||
|
--status-open: #28a745;
|
||||||
|
--status-in-progress: #ffc107;
|
||||||
|
--status-closed: #dc3545;
|
||||||
|
|
||||||
/* Spacing */
|
/* Spacing */
|
||||||
--spacing-xs: 0.5rem;
|
--spacing-xs: 0.5rem;
|
||||||
@ -31,13 +37,9 @@
|
|||||||
--border-color: #4a5568;
|
--border-color: #4a5568;
|
||||||
--shadow: 0 2px 4px rgba(0,0,0,0.3);
|
--shadow: 0 2px 4px rgba(0,0,0,0.3);
|
||||||
--hover-bg: #374151;
|
--hover-bg: #374151;
|
||||||
--priority-1: #7f1d1d;
|
|
||||||
--priority-2: #854d0e;
|
|
||||||
--priority-3: #075985;
|
|
||||||
--priority-4: #166534;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Base Elements */
|
/* ===== BASE ELEMENTS ===== */
|
||||||
body {
|
body {
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -47,14 +49,47 @@ body {
|
|||||||
transition: var(--transition-default);
|
transition: var(--transition-default);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reusable Components */
|
body.menu-open {
|
||||||
.card-base {
|
padding-left: 260px;
|
||||||
background: var(--bg-secondary);
|
|
||||||
border-radius: 12px;
|
|
||||||
box-shadow: var(--shadow);
|
|
||||||
padding: var(--spacing-md);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: var(--text-primary);
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== LAYOUT COMPONENTS ===== */
|
||||||
|
.dashboard-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: var(--spacing-md);
|
||||||
|
margin-left: 3.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-controls {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
padding: 10px;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: var(--shadow);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ticket-count {
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 15px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== BUTTON STYLES ===== */
|
||||||
.btn-base {
|
.btn-base {
|
||||||
padding: var(--spacing-sm) var(--spacing-md);
|
padding: var(--spacing-sm) var(--spacing-md);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
@ -68,81 +103,140 @@ body {
|
|||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Layout Components */
|
.create-ticket {
|
||||||
.dashboard-header {
|
background: #3b82f6;
|
||||||
display: flex;
|
color: white;
|
||||||
justify-content: space-between;
|
padding: 0.625rem 1.25rem;
|
||||||
align-items: center;
|
border-radius: 0.375rem;
|
||||||
margin-bottom: var(--spacing-md);
|
border: none;
|
||||||
margin-left: 3.75rem;
|
cursor: pointer;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: background-color 0.3s ease;
|
||||||
|
margin-right: 3.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ticket-container {
|
.create-ticket:hover {
|
||||||
max-width: 800px;
|
background: #2563eb;
|
||||||
margin: var(--spacing-lg) auto;
|
|
||||||
border-left: 6px solid;
|
|
||||||
transition: var(--transition-default);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.flex-row {
|
/* ===== TABLE STYLES ===== */
|
||||||
display: flex;
|
table {
|
||||||
gap: var(--spacing-sm);
|
|
||||||
}
|
|
||||||
|
|
||||||
.flex-between {
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Table Styles */
|
|
||||||
.table-base {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: separate;
|
border-collapse: separate;
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
border-radius: 12px;
|
||||||
|
box-shadow: var(--shadow);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-cell {
|
th, td {
|
||||||
padding: var(--spacing-md);
|
padding: 16px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
border-bottom: 1px solid var(--border-color);
|
border-bottom: 1px solid var(--border-color);
|
||||||
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Priority Styles */
|
th {
|
||||||
.priority-indicator {
|
background-color: var(--bg-secondary);
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 0.9em;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
position: relative;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr:hover {
|
||||||
|
background-color: var(--hover-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody tr td:first-child {
|
||||||
|
border-left: 6px solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Priority row colors */
|
||||||
|
tbody tr.priority-1 td:first-child { border-left-color: var(--priority-1); }
|
||||||
|
tbody tr.priority-2 td:first-child { border-left-color: var(--priority-2); }
|
||||||
|
tbody tr.priority-3 td:first-child { border-left-color: var(--priority-3); }
|
||||||
|
tbody tr.priority-4 td:first-child { border-left-color: var(--priority-4); }
|
||||||
|
tbody tr.priority-5 td:first-child { border-left-color: var(--priority-5); }
|
||||||
|
|
||||||
|
/* Priority number styling */
|
||||||
|
td:nth-child(2) {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
td:nth-child(2) span {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-family: 'Courier New', monospace;
|
font-family: 'Courier New', monospace;
|
||||||
padding: var(--spacing-xs) var(--spacing-sm);
|
padding: 4px 8px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
background: var(--hover-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.priority-1 { color: var(--priority-1); }
|
.priority-1 td:nth-child(2) { color: var(--priority-1); }
|
||||||
.priority-2 { color: var(--priority-2); }
|
.priority-2 td:nth-child(2) { color: var(--priority-2); }
|
||||||
.priority-3 { color: var(--priority-3); }
|
.priority-3 td:nth-child(2) { color: var(--priority-3); }
|
||||||
.priority-4 { color: var(--priority-4); }
|
.priority-4 td:nth-child(2) { color: var(--priority-4); }
|
||||||
|
.priority-5 td:nth-child(2) { color: var(--priority-5); }
|
||||||
/* Status Styles */
|
|
||||||
.status-base {
|
|
||||||
font-weight: bold;
|
|
||||||
padding: var(--spacing-xs) var(--spacing-sm);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* ===== STATUS STYLES ===== */
|
||||||
.status-Open {
|
.status-Open {
|
||||||
color: #10b981;
|
background-color: var(--status-open) !important;
|
||||||
background: rgba(16, 185, 129, 0.1);
|
color: white !important;
|
||||||
|
padding: 4px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-In-Progress {
|
||||||
|
background-color: var(--status-in-progress) !important;
|
||||||
|
color: #212529 !important;
|
||||||
|
padding: 4px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-Closed {
|
.status-Closed {
|
||||||
color: #ef4444;
|
background-color: var(--status-closed) !important;
|
||||||
background: rgba(239, 68, 68, 0.1);
|
color: white !important;
|
||||||
|
padding: 4px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== SEARCH AND FILTER STYLES ===== */
|
||||||
|
.search-box {
|
||||||
|
padding: 0.5rem 0.75rem;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 0.375rem;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
color: var(--text-primary);
|
||||||
|
margin-left: 1.25rem;
|
||||||
|
width: 40%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #3b82f6;
|
||||||
|
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Status Filter Dropdown */
|
||||||
|
.status-filter-container {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-dropdown {
|
.status-dropdown {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-right: 15px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-header {
|
.dropdown-header {
|
||||||
@ -194,118 +288,149 @@ body {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*UNCHECKED BELOW*/
|
/* ===== HAMBURGER MENU STYLES ===== */
|
||||||
|
.hamburger-menu {
|
||||||
body.menu-open {
|
position: absolute;
|
||||||
padding-left: 260px;
|
top: 20px;
|
||||||
|
left: 20px;
|
||||||
|
z-index: 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
.create-ticket {
|
.hamburger-icon {
|
||||||
background: #3b82f6;
|
|
||||||
color: white;
|
|
||||||
padding: 0.625rem 1.25rem;
|
|
||||||
border-radius: 0.375rem;
|
|
||||||
border: none;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-weight: 500;
|
font-size: 24px;
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
margin-right: 3.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.create-ticket:hover {
|
|
||||||
background: #2563eb;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
color: var(--text-primary);
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: separate;
|
|
||||||
border-spacing: 0;
|
|
||||||
background: var(--bg-secondary);
|
background: var(--bg-secondary);
|
||||||
border-radius: 12px;
|
padding: 10px;
|
||||||
|
border-radius: 4px;
|
||||||
box-shadow: var(--shadow);
|
box-shadow: var(--shadow);
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
th, td {
|
.hamburger-content {
|
||||||
padding: 16px;
|
position: fixed;
|
||||||
text-align: left;
|
top: 0;
|
||||||
border-bottom: 1px solid var(--border-color);
|
left: -250px;
|
||||||
color: var(--text-primary);
|
width: 200px;
|
||||||
|
height: 100%;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
box-shadow: 2px 0 5px rgba(0,0,0,0.1);
|
||||||
|
transition: left 0.3s ease;
|
||||||
|
padding: 40px 20px 20px;
|
||||||
|
overflow-y: auto;
|
||||||
|
z-index: 99;
|
||||||
}
|
}
|
||||||
|
|
||||||
th {
|
.hamburger-content.open {
|
||||||
background-color: var(--bg-secondary);
|
left: 0;
|
||||||
font-weight: 600;
|
|
||||||
text-transform: uppercase;
|
|
||||||
font-size: 0.9em;
|
|
||||||
letter-spacing: 0.05em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tr:hover {
|
.close-hamburger {
|
||||||
background-color: var(--hover-bg);
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
right: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 24px;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-shadow: var(--shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
tbody tr td:first-child {
|
/* Hamburger menu inline editing styles */
|
||||||
border-left: 6px solid;
|
.ticket-info-editable {
|
||||||
|
padding: 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tbody tr.priority-1 td:first-child { border-left-color: var(--priority-1); }
|
.editable-field, .info-field {
|
||||||
tbody tr.priority-2 td:first-child { border-left-color: var(--priority-2); }
|
display: flex;
|
||||||
tbody tr.priority-3 td:first-child { border-left-color: var(--priority-3); }
|
justify-content: space-between;
|
||||||
tbody tr.priority-4 td:first-child { border-left-color: var(--priority-4); }
|
align-items: center;
|
||||||
|
margin-bottom: 12px;
|
||||||
/* Priority number styling */
|
position: relative;
|
||||||
td:nth-child(2) {
|
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
td:nth-child(2) span {
|
.editable-field label, .info-field label {
|
||||||
font-weight: bold;
|
flex: 0 0 auto;
|
||||||
font-family: 'Courier New', monospace;
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editable-value {
|
||||||
|
flex: 1;
|
||||||
|
text-align: right;
|
||||||
|
min-height: 20px;
|
||||||
|
display: inline-block;
|
||||||
|
cursor: pointer;
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
display: inline-block;
|
transition: background-color 0.2s;
|
||||||
background: var(--hover-bg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.priority-1 td:nth-child(2) { color: var(--priority-1); }
|
.editable-value:hover {
|
||||||
.priority-2 td:nth-child(2) { color: var(--priority-2); }
|
background-color: var(--hover-bg) !important;
|
||||||
.priority-3 td:nth-child(2) { color: var(--priority-3); }
|
|
||||||
.priority-4 td:nth-child(2) { color: var(--priority-4); }
|
|
||||||
|
|
||||||
.search-box {
|
|
||||||
padding: 0.5rem 0.75rem;
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: 0.375rem;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
color: var(--text-primary);
|
|
||||||
margin-left: 1.25rem;
|
|
||||||
width: 40%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-filter {
|
.edit-dropdown {
|
||||||
padding: 0.5rem 0.75rem;
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
right: 0;
|
||||||
|
background: var(--bg-primary);
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
border-radius: 0.375rem;
|
border-radius: 4px;
|
||||||
background: var(--bg-secondary);
|
padding: 8px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
||||||
|
z-index: 1000;
|
||||||
|
min-width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-select {
|
||||||
|
width: 100%;
|
||||||
|
padding: 4px 8px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
background: var(--bg-primary);
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.save-btn, .cancel-btn {
|
||||||
|
padding: 4px 8px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 3px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
min-width: 120px;
|
font-size: 12px;
|
||||||
margin-right: 1rem;
|
min-width: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-box:focus,
|
.save-btn {
|
||||||
.status-filter:focus {
|
background: #28a745;
|
||||||
outline: none;
|
color: white;
|
||||||
border-color: #3b82f6;
|
|
||||||
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.save-btn:hover {
|
||||||
|
background: #218838;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cancel-btn {
|
||||||
|
background: #dc3545;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cancel-btn:hover {
|
||||||
|
background: #c82333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-field span {
|
||||||
|
flex: 1;
|
||||||
|
text-align: right;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== UTILITY STYLES ===== */
|
||||||
.theme-toggle {
|
.theme-toggle {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 20px;
|
top: 20px;
|
||||||
@ -325,27 +450,22 @@ td:nth-child(2) span {
|
|||||||
transform: scale(1.1);
|
transform: scale(1.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-controls {
|
.ticket-link {
|
||||||
display: flex;
|
font-family: 'Courier New', monospace;
|
||||||
justify-content: space-between;
|
font-weight: bold;
|
||||||
align-items: center;
|
color: var(--text-primary) !important;
|
||||||
margin-bottom: 15px;
|
text-decoration: none;
|
||||||
padding: 10px;
|
background: var(--hover-bg);
|
||||||
background: var(--bg-secondary);
|
padding: 4px 8px;
|
||||||
border-radius: 8px;
|
border-radius: 4px;
|
||||||
box-shadow: var(--shadow);
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ticket-count {
|
.ticket-link:hover {
|
||||||
font-weight: 500;
|
background: var(--border-color);
|
||||||
color: var(--text-secondary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-actions {
|
/* ===== PAGINATION STYLES ===== */
|
||||||
display: flex;
|
|
||||||
gap: 15px;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.pagination {
|
.pagination {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
@ -372,18 +492,31 @@ td:nth-child(2) span {
|
|||||||
border-color: #3b82f6;
|
border-color: #3b82f6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-icon {
|
/* ===== SORTING STYLES ===== */
|
||||||
cursor: pointer;
|
th::after {
|
||||||
padding: 8px;
|
content: '';
|
||||||
border-radius: 4px;
|
position: absolute;
|
||||||
transition: background-color 0.2s;
|
right: 8px;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-left: 5px solid transparent;
|
||||||
|
border-right: 5px solid transparent;
|
||||||
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-icon:hover {
|
th.sort-asc::after {
|
||||||
background: var(--hover-bg);
|
border-bottom: 7px solid var(--text-primary);
|
||||||
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Settings Modal Styles */
|
th.sort-desc::after {
|
||||||
|
border-top: 7px solid var(--text-primary);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== SETTINGS MODAL STYLES ===== */
|
||||||
.settings-modal-backdrop {
|
.settings-modal-backdrop {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
@ -471,186 +604,4 @@ td:nth-child(2) span {
|
|||||||
.cancel-settings {
|
.cancel-settings {
|
||||||
background: var(--hover-bg);
|
background: var(--hover-bg);
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
}
|
|
||||||
|
|
||||||
/* Sorting indicator styles */
|
|
||||||
th {
|
|
||||||
position: relative; /* Ensure proper positioning of arrows */
|
|
||||||
cursor: pointer; /* Show it's clickable */
|
|
||||||
}
|
|
||||||
|
|
||||||
th::after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
right: 8px;
|
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
border-left: 5px solid transparent;
|
|
||||||
border-right: 5px solid transparent;
|
|
||||||
opacity: 0.5; /* Make arrows less prominent when not active */
|
|
||||||
}
|
|
||||||
|
|
||||||
th.sort-asc::after {
|
|
||||||
border-bottom: 7px solid var(--text-primary);
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
th.sort-desc::after {
|
|
||||||
border-top: 7px solid var(--text-primary);
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
/* Column toggle styles */
|
|
||||||
.column-toggles {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(2, 1fr);
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.column-toggles label {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hamburger-menu {
|
|
||||||
position: absolute;
|
|
||||||
top: 20px;
|
|
||||||
left: 20px;
|
|
||||||
z-index: 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hamburger-icon {
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 24px;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 4px;
|
|
||||||
box-shadow: var(--shadow);
|
|
||||||
}
|
|
||||||
|
|
||||||
.hamburger-content {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: -250px;
|
|
||||||
width: 200px;
|
|
||||||
height: 100%;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
box-shadow: 2px 0 5px rgba(0,0,0,0.1);
|
|
||||||
transition: left 0.3s ease, margin-left 0.3s ease;
|
|
||||||
padding: 40px 20px 20px;
|
|
||||||
overflow-y: auto;
|
|
||||||
z-index: 99;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hamburger-content.open {
|
|
||||||
left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-hamburger {
|
|
||||||
position: absolute;
|
|
||||||
top: 10px;
|
|
||||||
right: 10px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 24px;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 4px;
|
|
||||||
box-shadow: var(--shadow);
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-section {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-section label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-actions button {
|
|
||||||
flex: 1;
|
|
||||||
padding: 10px;
|
|
||||||
border: none;
|
|
||||||
border-radius: 4px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
#apply-filters {
|
|
||||||
background: #3b82f6;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
#clear-filters {
|
|
||||||
background: var(--hover-bg);
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ticket-link {
|
|
||||||
font-family: 'Courier New', monospace;
|
|
||||||
font-weight: bold;
|
|
||||||
color: var(--text-primary) !important;
|
|
||||||
text-decoration: none;
|
|
||||||
background: var(--hover-bg);
|
|
||||||
padding: 4px 8px;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ticket-link:hover {
|
|
||||||
background: var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Hamburger Menu Styles */
|
|
||||||
|
|
||||||
.menu-group {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
padding: 15px;
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-group label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-group select {
|
|
||||||
width: 100%;
|
|
||||||
padding: 10px;
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: 6px;
|
|
||||||
background: var(--bg-primary);
|
|
||||||
color: var(--text-primary);
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-actions {
|
|
||||||
padding: 15px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-actions .btn.primary {
|
|
||||||
width: 100%;
|
|
||||||
padding: 12px;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-controls {
|
|
||||||
padding: 15px;
|
|
||||||
text-align: center;
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-controls .btn {
|
|
||||||
width: 100%;
|
|
||||||
padding: 12px;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
}
|
||||||
@ -1,3 +1,42 @@
|
|||||||
|
/* ===== TICKET PAGE SPECIFIC STYLES ===== */
|
||||||
|
|
||||||
|
/* Status colors for ticket page */
|
||||||
|
.status-Open,
|
||||||
|
[id="statusDisplay"].status-Open {
|
||||||
|
background-color: var(--status-open) !important;
|
||||||
|
color: white !important;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-weight: 500;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 0.9em;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-In-Progress,
|
||||||
|
[id="statusDisplay"].status-In-Progress {
|
||||||
|
background-color: var(--status-in-progress) !important;
|
||||||
|
color: #212529 !important;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-weight: 500;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 0.9em;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-Closed,
|
||||||
|
[id="statusDisplay"].status-Closed {
|
||||||
|
background-color: var(--status-closed) !important;
|
||||||
|
color: white !important;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-weight: 500;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 0.9em;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
/* Base Layout Components */
|
/* Base Layout Components */
|
||||||
.ticket-container {
|
.ticket-container {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
@ -14,9 +53,13 @@
|
|||||||
transition: border-color 0.3s ease;
|
transition: border-color 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.full-width {
|
/* Priority border colors */
|
||||||
grid-column: 1 / -1;
|
[data-priority="1"] { border-color: var(--priority-1); }
|
||||||
}
|
[data-priority="2"] { border-color: var(--priority-2); }
|
||||||
|
[data-priority="3"] { border-color: var(--priority-3); }
|
||||||
|
[data-priority="4"] { border-color: var(--priority-4); }
|
||||||
|
[data-priority="5"] { border-color: var(--priority-5); }
|
||||||
|
|
||||||
/* Header Components */
|
/* Header Components */
|
||||||
.ticket-header {
|
.ticket-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -51,11 +94,17 @@
|
|||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
.status-priority-group {
|
||||||
margin: 0;
|
display: flex;
|
||||||
padding: 0;
|
gap: 10px;
|
||||||
width: 100%;
|
align-items: center;
|
||||||
display: block;
|
margin-right: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.priority-indicator {
|
||||||
|
padding: 4px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Title Input Styles */
|
/* Title Input Styles */
|
||||||
@ -74,7 +123,9 @@ h1 {
|
|||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
min-height: fit-content;
|
min-height: fit-content;
|
||||||
height: auto;
|
height: auto;
|
||||||
}.title-input:not(:disabled) {
|
}
|
||||||
|
|
||||||
|
.title-input:not(:disabled) {
|
||||||
border-color: var(--border-color);
|
border-color: var(--border-color);
|
||||||
background: var(--bg-primary);
|
background: var(--bg-primary);
|
||||||
}
|
}
|
||||||
@ -102,13 +153,8 @@ h1 {
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
#statusDisplay {
|
.full-width {
|
||||||
padding: 8px 16px;
|
grid-column: 1 / -1;
|
||||||
border-radius: 6px;
|
|
||||||
font-weight: 500;
|
|
||||||
text-transform: uppercase;
|
|
||||||
font-size: 0.9em;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.editable {
|
.editable {
|
||||||
@ -128,17 +174,17 @@ input.editable {
|
|||||||
textarea.editable {
|
textarea.editable {
|
||||||
width: calc(100% - 20px);
|
width: calc(100% - 20px);
|
||||||
min-height: 800px !important;
|
min-height: 800px !important;
|
||||||
height: auto !important; /* Allow it to grow with content */
|
height: auto !important;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
white-space: pre; /* Preserve formatting */
|
white-space: pre;
|
||||||
font-family: monospace; /* Better for ASCII art */
|
font-family: monospace;
|
||||||
line-height: 1.2; /* Tighter line spacing for ASCII art */
|
line-height: 1.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#description-tab {
|
#description-tab {
|
||||||
min-height: 850px !important; /* Slightly larger than the textarea */
|
min-height: 850px !important;
|
||||||
height: auto !important;
|
height: auto !important;
|
||||||
padding-bottom: 20px; /* Add some padding at the bottom */
|
padding-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.editable:disabled {
|
.editable:disabled {
|
||||||
@ -174,89 +220,6 @@ textarea.editable {
|
|||||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Status and Priority Styles */
|
|
||||||
.status-priority-row {
|
|
||||||
display: flex;
|
|
||||||
gap: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.detail-half {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-priority-group {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
align-items: center;
|
|
||||||
margin-right: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.priority-indicator {
|
|
||||||
padding: 4px 8px;
|
|
||||||
border-radius: 4px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Priority Select Styles */
|
|
||||||
select[data-field="priority"] {
|
|
||||||
border-left: 4px solid;
|
|
||||||
}
|
|
||||||
|
|
||||||
select[data-field="priority"] option {
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
select[data-field="priority"] option[value="1"] {
|
|
||||||
background-color: var(--priority-1);
|
|
||||||
}
|
|
||||||
select[data-field="priority"] option[value="2"] {
|
|
||||||
background-color: var(--priority-2);
|
|
||||||
}
|
|
||||||
select[data-field="priority"] option[value="3"] {
|
|
||||||
background-color: var(--priority-3);
|
|
||||||
}
|
|
||||||
select[data-field="priority"] option[value="4"] {
|
|
||||||
background-color: var(--priority-4);
|
|
||||||
}
|
|
||||||
|
|
||||||
select[data-field="priority"][value="1"] {
|
|
||||||
border-left-color: var(--priority-1);
|
|
||||||
}
|
|
||||||
select[data-field="priority"][value="2"] {
|
|
||||||
border-left-color: var(--priority-2);
|
|
||||||
}
|
|
||||||
select[data-field="priority"][value="3"] {
|
|
||||||
border-left-color: var(--priority-3);
|
|
||||||
}
|
|
||||||
select[data-field="priority"][value="4"] {
|
|
||||||
border-left-color: var(--priority-4);
|
|
||||||
}
|
|
||||||
|
|
||||||
select[data-field="priority"] option[value="1"]:hover {
|
|
||||||
background-color: #ffc9c9;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
select[data-field="priority"] option[value="2"]:hover {
|
|
||||||
background-color: #ffe0b2;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
select[data-field="priority"] option[value="3"]:hover {
|
|
||||||
background-color: #bbdefb;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
select[data-field="priority"] option[value="4"]:hover {
|
|
||||||
background-color: #c8e6c9;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-priority="1"] { border-color: var(--priority-1); }
|
|
||||||
[data-priority="2"] { border-color: var(--priority-2); }
|
|
||||||
[data-priority="3"] { border-color: var(--priority-3); }
|
|
||||||
[data-priority="4"] { border-color: var(--priority-4); }
|
|
||||||
|
|
||||||
/* Comments Section */
|
/* Comments Section */
|
||||||
.comments-section {
|
.comments-section {
|
||||||
margin-top: 40px;
|
margin-top: 40px;
|
||||||
@ -306,7 +269,23 @@ select[data-field="priority"] option[value="4"]:hover {
|
|||||||
|
|
||||||
.comment-text {
|
.comment-text {
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
line-height: 1.4;
|
line-height: 1.6;
|
||||||
|
word-wrap: break-word;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-text p {
|
||||||
|
margin: 0.5em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-text p:first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-text p:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-controls {
|
.comment-controls {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -25,12 +25,6 @@ function saveTicket() {
|
|||||||
// Use the correct API path
|
// Use the correct API path
|
||||||
const apiUrl = '/api/update_ticket.php';
|
const apiUrl = '/api/update_ticket.php';
|
||||||
|
|
||||||
console.log('Sending request to:', apiUrl);
|
|
||||||
console.log('Sending data:', JSON.stringify({
|
|
||||||
ticket_id: ticketId,
|
|
||||||
...data
|
|
||||||
}));
|
|
||||||
|
|
||||||
fetch(apiUrl, {
|
fetch(apiUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -42,7 +36,6 @@ function saveTicket() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.log('Response status:', response.status);
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
return response.text().then(text => {
|
return response.text().then(text => {
|
||||||
console.error('Server response:', text);
|
console.error('Server response:', text);
|
||||||
@ -52,7 +45,6 @@ function saveTicket() {
|
|||||||
return response.json();
|
return response.json();
|
||||||
})
|
})
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Response data:', data);
|
|
||||||
if(data.success) {
|
if(data.success) {
|
||||||
const statusDisplay = document.getElementById('statusDisplay');
|
const statusDisplay = document.getElementById('statusDisplay');
|
||||||
if (statusDisplay) {
|
if (statusDisplay) {
|
||||||
@ -141,6 +133,22 @@ function addComment() {
|
|||||||
// Clear the comment box
|
// Clear the comment box
|
||||||
document.getElementById('newComment').value = '';
|
document.getElementById('newComment').value = '';
|
||||||
|
|
||||||
|
// Format the comment text for display
|
||||||
|
let displayText;
|
||||||
|
if (isMarkdownEnabled) {
|
||||||
|
// For markdown, use marked.parse
|
||||||
|
displayText = marked.parse(commentText);
|
||||||
|
} else {
|
||||||
|
// For non-markdown, convert line breaks to <br> and escape HTML
|
||||||
|
displayText = commentText
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>')
|
||||||
|
.replace(/"/g, '"')
|
||||||
|
.replace(/'/g, ''')
|
||||||
|
.replace(/\n/g, '<br>');
|
||||||
|
}
|
||||||
|
|
||||||
// Add new comment to the list
|
// Add new comment to the list
|
||||||
const commentsList = document.querySelector('.comments-list');
|
const commentsList = document.querySelector('.comments-list');
|
||||||
const newComment = `
|
const newComment = `
|
||||||
@ -149,9 +157,7 @@ function addComment() {
|
|||||||
<span class="comment-user">${data.user_name}</span>
|
<span class="comment-user">${data.user_name}</span>
|
||||||
<span class="comment-date">${data.created_at}</span>
|
<span class="comment-date">${data.created_at}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="comment-text">
|
<div class="comment-text">${displayText}</div>
|
||||||
${isMarkdownEnabled ? marked.parse(commentText) : commentText}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
commentsList.insertAdjacentHTML('afterbegin', newComment);
|
commentsList.insertAdjacentHTML('afterbegin', newComment);
|
||||||
@ -180,9 +186,17 @@ function togglePreview() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updatePreview() {
|
function updatePreview() {
|
||||||
const preview = document.getElementById('markdownPreview');
|
const commentText = document.getElementById('newComment').value;
|
||||||
const textarea = document.getElementById('newComment');
|
const previewDiv = document.getElementById('markdownPreview');
|
||||||
preview.innerHTML = marked.parse(textarea.value);
|
const isMarkdownEnabled = document.getElementById('markdownMaster').checked;
|
||||||
|
|
||||||
|
if (isMarkdownEnabled && commentText.trim()) {
|
||||||
|
// For markdown preview, use marked.parse which handles line breaks correctly
|
||||||
|
previewDiv.innerHTML = marked.parse(commentText);
|
||||||
|
previewDiv.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
previewDiv.style.display = 'none';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleMarkdownMode() {
|
function toggleMarkdownMode() {
|
||||||
|
|||||||
@ -9,7 +9,8 @@ $GLOBALS['config'] = [
|
|||||||
'DB_USER' => $envVars['DB_USER'] ?? 'root',
|
'DB_USER' => $envVars['DB_USER'] ?? 'root',
|
||||||
'DB_PASS' => $envVars['DB_PASS'] ?? '',
|
'DB_PASS' => $envVars['DB_PASS'] ?? '',
|
||||||
'DB_NAME' => $envVars['DB_NAME'] ?? 'tinkertickets',
|
'DB_NAME' => $envVars['DB_NAME'] ?? 'tinkertickets',
|
||||||
'BASE_URL' => '/tinkertickets', // Application base URL
|
'BASE_URL' => '', // Empty since we're serving from document root
|
||||||
'ASSETS_URL' => '/assets', // Assets URL
|
'ASSETS_URL' => '/assets', // Assets URL
|
||||||
'API_URL' => '/api' // API URL
|
'API_URL' => '/api' // API URL
|
||||||
];
|
];
|
||||||
|
?>
|
||||||
@ -3,8 +3,10 @@ require_once 'models/TicketModel.php';
|
|||||||
|
|
||||||
class DashboardController {
|
class DashboardController {
|
||||||
private $ticketModel;
|
private $ticketModel;
|
||||||
|
private $conn;
|
||||||
|
|
||||||
public function __construct($conn) {
|
public function __construct($conn) {
|
||||||
|
$this->conn = $conn;
|
||||||
$this->ticketModel = new TicketModel($conn);
|
$this->ticketModel = new TicketModel($conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12,12 +14,27 @@ class DashboardController {
|
|||||||
// Get query parameters
|
// Get query parameters
|
||||||
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
||||||
$limit = isset($_COOKIE['ticketsPerPage']) ? (int)$_COOKIE['ticketsPerPage'] : 15;
|
$limit = isset($_COOKIE['ticketsPerPage']) ? (int)$_COOKIE['ticketsPerPage'] : 15;
|
||||||
$status = isset($_GET['status']) ? $_GET['status'] : 'Open';
|
$sortColumn = isset($_GET['sort']) ? $_GET['sort'] : 'ticket_id';
|
||||||
$sortColumn = isset($_COOKIE['defaultSortColumn']) ? $_COOKIE['defaultSortColumn'] : 'ticket_id';
|
$sortDirection = isset($_GET['dir']) ? $_GET['dir'] : 'desc';
|
||||||
$sortDirection = isset($_COOKIE['sortDirection']) ? $_COOKIE['sortDirection'] : 'desc';
|
$category = isset($_GET['category']) ? $_GET['category'] : null;
|
||||||
|
$type = isset($_GET['type']) ? $_GET['type'] : null;
|
||||||
|
|
||||||
// Get tickets with pagination
|
// Handle status filtering
|
||||||
$result = $this->ticketModel->getAllTickets($page, $limit, $status, $sortColumn, $sortDirection);
|
$status = null;
|
||||||
|
if (isset($_GET['status']) && !empty($_GET['status'])) {
|
||||||
|
$status = $_GET['status'];
|
||||||
|
} else if (!isset($_GET['show_all'])) {
|
||||||
|
// Default: show Open and In Progress (exclude Closed)
|
||||||
|
$status = 'Open,In Progress';
|
||||||
|
}
|
||||||
|
// If $_GET['show_all'] exists or no status param with show_all, show all tickets (status = null)
|
||||||
|
|
||||||
|
// Get tickets with pagination and sorting
|
||||||
|
$result = $this->ticketModel->getAllTickets($page, $limit, $status, $sortColumn, $sortDirection, $category, $type);
|
||||||
|
|
||||||
|
// Get categories and types for filters
|
||||||
|
$categories = $this->getCategories();
|
||||||
|
$types = $this->getTypes();
|
||||||
|
|
||||||
// Extract data for the view
|
// Extract data for the view
|
||||||
$tickets = $result['tickets'];
|
$tickets = $result['tickets'];
|
||||||
@ -27,4 +44,25 @@ class DashboardController {
|
|||||||
// Load the dashboard view
|
// Load the dashboard view
|
||||||
include 'views/DashboardView.php';
|
include 'views/DashboardView.php';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private function getCategories() {
|
||||||
|
$sql = "SELECT DISTINCT category FROM tickets WHERE category IS NOT NULL ORDER BY category";
|
||||||
|
$result = $this->conn->query($sql);
|
||||||
|
$categories = [];
|
||||||
|
while($row = $result->fetch_assoc()) {
|
||||||
|
$categories[] = $row['category'];
|
||||||
|
}
|
||||||
|
return $categories;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getTypes() {
|
||||||
|
$sql = "SELECT DISTINCT type FROM tickets WHERE type IS NOT NULL ORDER BY type";
|
||||||
|
$result = $this->conn->query($sql);
|
||||||
|
$types = [];
|
||||||
|
while($row = $result->fetch_assoc()) {
|
||||||
|
$types[] = $row['type'];
|
||||||
|
}
|
||||||
|
return $types;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
@ -6,10 +6,24 @@ require_once dirname(__DIR__) . '/models/CommentModel.php';
|
|||||||
class TicketController {
|
class TicketController {
|
||||||
private $ticketModel;
|
private $ticketModel;
|
||||||
private $commentModel;
|
private $commentModel;
|
||||||
|
private $envVars;
|
||||||
|
|
||||||
public function __construct($conn) {
|
public function __construct($conn) {
|
||||||
$this->ticketModel = new TicketModel($conn);
|
$this->ticketModel = new TicketModel($conn);
|
||||||
$this->commentModel = new CommentModel($conn);
|
$this->commentModel = new CommentModel($conn);
|
||||||
|
|
||||||
|
// Load environment variables for Discord webhook
|
||||||
|
$envPath = dirname(__DIR__) . '/.env';
|
||||||
|
$this->envVars = [];
|
||||||
|
if (file_exists($envPath)) {
|
||||||
|
$lines = file($envPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
if (strpos($line, '=') !== false && strpos($line, '#') !== 0) {
|
||||||
|
list($key, $value) = explode('=', $line, 2);
|
||||||
|
$this->envVars[trim($key)] = trim($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function view($id) {
|
public function view($id) {
|
||||||
@ -22,8 +36,8 @@ class TicketController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get comments for this ticket
|
// Get comments for this ticket using CommentModel
|
||||||
$comments = $this->ticketModel->getTicketComments($id);
|
$comments = $this->commentModel->getCommentsByTicketId($id);
|
||||||
|
|
||||||
// Load the view
|
// Load the view
|
||||||
include dirname(__DIR__) . '/views/TicketView.php';
|
include dirname(__DIR__) . '/views/TicketView.php';
|
||||||
@ -51,8 +65,11 @@ class TicketController {
|
|||||||
$result = $this->ticketModel->createTicket($ticketData);
|
$result = $this->ticketModel->createTicket($ticketData);
|
||||||
|
|
||||||
if ($result['success']) {
|
if ($result['success']) {
|
||||||
|
// Send Discord webhook notification for new ticket
|
||||||
|
$this->sendDiscordWebhook($result['ticket_id'], $ticketData);
|
||||||
|
|
||||||
// Redirect to the new ticket
|
// Redirect to the new ticket
|
||||||
header("Location: /tinkertickets/ticket/" . $result['ticket_id']);
|
header("Location: " . $GLOBALS['config']['BASE_URL'] . "/ticket/" . $result['ticket_id']);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
$error = $result['error'];
|
$error = $result['error'];
|
||||||
@ -66,32 +83,17 @@ class TicketController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function update($id) {
|
public function update($id) {
|
||||||
// Debug function
|
|
||||||
$debug = function($message, $data = null) {
|
|
||||||
$log_message = date('Y-m-d H:i:s') . " - [Controller] " . $message;
|
|
||||||
if ($data !== null) {
|
|
||||||
$log_message .= ": " . (is_string($data) ? $data : json_encode($data));
|
|
||||||
}
|
|
||||||
$log_message .= "\n";
|
|
||||||
file_put_contents('/tmp/api_debug.log', $log_message, FILE_APPEND);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Check if this is an AJAX request
|
// Check if this is an AJAX request
|
||||||
$debug("Request method", $_SERVER['REQUEST_METHOD']);
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
// For AJAX requests, get JSON data
|
// For AJAX requests, get JSON data
|
||||||
$input = file_get_contents('php://input');
|
$input = file_get_contents('php://input');
|
||||||
$debug("Raw input", $input);
|
|
||||||
$data = json_decode($input, true);
|
$data = json_decode($input, true);
|
||||||
$debug("Decoded data", $data);
|
|
||||||
|
|
||||||
// Add ticket_id to the data
|
// Add ticket_id to the data
|
||||||
$data['ticket_id'] = $id;
|
$data['ticket_id'] = $id;
|
||||||
$debug("Added ticket_id to data", $id);
|
|
||||||
|
|
||||||
// Validate input data
|
// Validate input data
|
||||||
if (empty($data['title'])) {
|
if (empty($data['title'])) {
|
||||||
$debug("Title is empty");
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
@ -101,26 +103,16 @@ class TicketController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update ticket
|
// Update ticket
|
||||||
$debug("Calling model updateTicket method");
|
$result = $this->ticketModel->updateTicket($data);
|
||||||
try {
|
|
||||||
$result = $this->ticketModel->updateTicket($data);
|
|
||||||
$debug("Model updateTicket result", $result);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$debug("Exception in model updateTicket", $e->getMessage());
|
|
||||||
$debug("Stack trace", $e->getTraceAsString());
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return JSON response
|
// Return JSON response
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$debug("Update successful, sending success response");
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'status' => $data['status']
|
'status' => $data['status']
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$debug("Update failed, sending error response");
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'error' => 'Failed to update ticket'
|
'error' => 'Failed to update ticket'
|
||||||
@ -128,29 +120,90 @@ class TicketController {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// For direct access, redirect to view
|
// For direct access, redirect to view
|
||||||
$debug("Not a POST request, redirecting");
|
|
||||||
header("Location: " . $GLOBALS['config']['BASE_URL'] . "/ticket/$id");
|
header("Location: " . $GLOBALS['config']['BASE_URL'] . "/ticket/$id");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
private function sendDiscordWebhook($ticketId, $ticketData) {
|
||||||
// Get query parameters
|
if (!isset($this->envVars['DISCORD_WEBHOOK_URL']) || empty($this->envVars['DISCORD_WEBHOOK_URL'])) {
|
||||||
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
error_log("Discord webhook URL not configured, skipping webhook for ticket creation");
|
||||||
$limit = isset($_COOKIE['ticketsPerPage']) ? (int)$_COOKIE['ticketsPerPage'] : 15;
|
return;
|
||||||
$status = isset($_GET['status']) ? $_GET['status'] : 'Open';
|
}
|
||||||
$sortColumn = isset($_COOKIE['defaultSortColumn']) ? $_COOKIE['defaultSortColumn'] : 'ticket_id';
|
|
||||||
$sortDirection = isset($_COOKIE['sortDirection']) ? $_COOKIE['sortDirection'] : 'desc';
|
|
||||||
|
|
||||||
// Get tickets with pagination
|
$webhookUrl = $this->envVars['DISCORD_WEBHOOK_URL'];
|
||||||
$result = $this->ticketModel->getAllTickets($page, $limit, $status, $sortColumn, $sortDirection);
|
|
||||||
|
|
||||||
// Extract data for the view
|
// Create ticket URL
|
||||||
$tickets = $result['tickets'];
|
$ticketUrl = "http://tinkertickets.local/ticket/$ticketId";
|
||||||
$totalTickets = $result['total'];
|
|
||||||
$totalPages = $result['pages'];
|
|
||||||
|
|
||||||
// Load the dashboard view
|
// Map priorities to Discord colors
|
||||||
include 'views/DashboardView.php';
|
$priorityColors = [
|
||||||
|
1 => 0xff4d4d, // Red
|
||||||
|
2 => 0xffa726, // Orange
|
||||||
|
3 => 0x42a5f5, // Blue
|
||||||
|
4 => 0x66bb6a, // Green
|
||||||
|
5 => 0x9e9e9e // Gray
|
||||||
|
];
|
||||||
|
|
||||||
|
$priority = (int)($ticketData['priority'] ?? 4);
|
||||||
|
$color = $priorityColors[$priority] ?? 0x3498db;
|
||||||
|
|
||||||
|
$embed = [
|
||||||
|
'title' => '🎫 New Ticket Created',
|
||||||
|
'description' => "**#{$ticketId}** - " . $ticketData['title'],
|
||||||
|
'url' => $ticketUrl,
|
||||||
|
'color' => $color,
|
||||||
|
'fields' => [
|
||||||
|
[
|
||||||
|
'name' => 'Priority',
|
||||||
|
'value' => 'P' . $priority,
|
||||||
|
'inline' => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'Category',
|
||||||
|
'value' => $ticketData['category'] ?? 'General',
|
||||||
|
'inline' => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'Type',
|
||||||
|
'value' => $ticketData['type'] ?? 'Issue',
|
||||||
|
'inline' => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'Status',
|
||||||
|
'value' => $ticketData['status'] ?? 'Open',
|
||||||
|
'inline' => true
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'footer' => [
|
||||||
|
'text' => 'Tinker Tickets'
|
||||||
|
],
|
||||||
|
'timestamp' => date('c')
|
||||||
|
];
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'embeds' => [$embed]
|
||||||
|
];
|
||||||
|
|
||||||
|
// Send webhook
|
||||||
|
$ch = curl_init($webhookUrl);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
|
||||||
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||||
|
|
||||||
|
$webhookResult = curl_exec($ch);
|
||||||
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
$curlError = curl_error($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
if ($curlError) {
|
||||||
|
error_log("Discord webhook cURL error: $curlError");
|
||||||
|
} else {
|
||||||
|
error_log("Discord webhook sent for new ticket. HTTP Code: $httpCode");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
@ -180,7 +180,7 @@ $discord_data = [
|
|||||||
"embeds" => [[
|
"embeds" => [[
|
||||||
"title" => "New Ticket Created: #" . $ticket_id,
|
"title" => "New Ticket Created: #" . $ticket_id,
|
||||||
"description" => $title,
|
"description" => $title,
|
||||||
"url" => "http://10.10.10.45/ticket.php?id=" . $ticket_id,
|
"url" => "http://tinkertickets.local/ticket/" . $ticket_id,
|
||||||
"color" => $priorityColors[$priority],
|
"color" => $priorityColors[$priority],
|
||||||
"fields" => [
|
"fields" => [
|
||||||
["name" => "Priority", "value" => $priority, "inline" => true],
|
["name" => "Priority", "value" => $priority, "inline" => true],
|
||||||
|
|||||||
62
index.php
62
index.php
@ -2,52 +2,64 @@
|
|||||||
// Main entry point for the application
|
// Main entry point for the application
|
||||||
require_once 'config/config.php';
|
require_once 'config/config.php';
|
||||||
|
|
||||||
// Parse the URL
|
// Parse the URL - no need to remove base path since we're at document root
|
||||||
$request = $_SERVER['REQUEST_URI'];
|
$request = $_SERVER['REQUEST_URI'];
|
||||||
$basePath = '/tinkertickets'; // Adjust based on your installation path
|
|
||||||
$request = str_replace($basePath, '', $request);
|
|
||||||
|
|
||||||
// Create database connection
|
// Remove query string for routing (but keep it available)
|
||||||
$conn = new mysqli(
|
$requestPath = strtok($request, '?');
|
||||||
$GLOBALS['config']['DB_HOST'],
|
|
||||||
$GLOBALS['config']['DB_USER'],
|
// Create database connection for non-API routes
|
||||||
$GLOBALS['config']['DB_PASS'],
|
if (!str_starts_with($requestPath, '/api/')) {
|
||||||
$GLOBALS['config']['DB_NAME']
|
$conn = new mysqli(
|
||||||
);
|
$GLOBALS['config']['DB_HOST'],
|
||||||
|
$GLOBALS['config']['DB_USER'],
|
||||||
|
$GLOBALS['config']['DB_PASS'],
|
||||||
|
$GLOBALS['config']['DB_NAME']
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Simple router
|
// Simple router
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case $request == '/' || $request == '':
|
case $requestPath == '/' || $requestPath == '':
|
||||||
require_once 'controllers/DashboardController.php';
|
require_once 'controllers/DashboardController.php';
|
||||||
$controller = new DashboardController($conn);
|
$controller = new DashboardController($conn);
|
||||||
$controller->index();
|
$controller->index();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case preg_match('/^\/ticket\?id=(\d+)$/', $request, $matches) ||
|
case preg_match('/^\/ticket\/(\d+)$/', $requestPath, $matches):
|
||||||
preg_match('/^\/ticket\/(\d+)$/', $request, $matches):
|
|
||||||
require_once 'controllers/TicketController.php';
|
require_once 'controllers/TicketController.php';
|
||||||
$controller = new TicketController($conn);
|
$controller = new TicketController($conn);
|
||||||
$controller->view($matches[1]);
|
$controller->view($matches[1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case $request == '/ticket/create':
|
case $requestPath == '/ticket/create':
|
||||||
require_once 'controllers/TicketController.php';
|
require_once 'controllers/TicketController.php';
|
||||||
$controller = new TicketController($conn);
|
$controller = new TicketController($conn);
|
||||||
$controller->create();
|
$controller->create();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case preg_match('/^\/ticket\/(\d+)\/update$/', $request, $matches):
|
// API Routes - these handle their own database connections
|
||||||
require_once 'controllers/TicketController.php';
|
case $requestPath == '/api/update_ticket.php':
|
||||||
$controller = new TicketController($conn);
|
require_once 'api/update_ticket.php';
|
||||||
$controller->update($matches[1]);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case preg_match('/^\/ticket\/(\d+)\/comment$/', $request, $matches):
|
case $requestPath == '/api/add_comment.php':
|
||||||
require_once 'controllers/CommentController.php';
|
require_once 'api/add_comment.php';
|
||||||
$controller = new CommentController($conn);
|
|
||||||
$controller->addComment($matches[1]);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Legacy support for old URLs
|
||||||
|
case $requestPath == '/dashboard.php':
|
||||||
|
header("Location: /");
|
||||||
|
exit;
|
||||||
|
|
||||||
|
case preg_match('/^\/ticket\.php/', $requestPath) && isset($_GET['id']):
|
||||||
|
header("Location: /ticket/" . $_GET['id']);
|
||||||
|
exit;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// 404 Not Found
|
// 404 Not Found
|
||||||
header("HTTP/1.0 404 Not Found");
|
header("HTTP/1.0 404 Not Found");
|
||||||
@ -55,4 +67,8 @@ switch (true) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn->close();
|
// Close database connection if it was opened
|
||||||
|
if (isset($conn)) {
|
||||||
|
$conn->close();
|
||||||
|
}
|
||||||
|
?>
|
||||||
@ -9,7 +9,7 @@ class CommentModel {
|
|||||||
public function getCommentsByTicketId($ticketId) {
|
public function getCommentsByTicketId($ticketId) {
|
||||||
$sql = "SELECT * FROM ticket_comments WHERE ticket_id = ? ORDER BY created_at DESC";
|
$sql = "SELECT * FROM ticket_comments WHERE ticket_id = ? ORDER BY created_at DESC";
|
||||||
$stmt = $this->conn->prepare($sql);
|
$stmt = $this->conn->prepare($sql);
|
||||||
$stmt->bind_param("i", $ticketId);
|
$stmt->bind_param("s", $ticketId); // Changed to string since ticket_id is varchar
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
@ -31,11 +31,14 @@ class CommentModel {
|
|||||||
$username = $commentData['user_name'] ?? 'User';
|
$username = $commentData['user_name'] ?? 'User';
|
||||||
$markdownEnabled = isset($commentData['markdown_enabled']) && $commentData['markdown_enabled'] ? 1 : 0;
|
$markdownEnabled = isset($commentData['markdown_enabled']) && $commentData['markdown_enabled'] ? 1 : 0;
|
||||||
|
|
||||||
|
// Preserve line breaks in the comment text
|
||||||
|
$commentText = $commentData['comment_text'];
|
||||||
|
|
||||||
$stmt->bind_param(
|
$stmt->bind_param(
|
||||||
"sssi",
|
"sssi",
|
||||||
$ticketId,
|
$ticketId,
|
||||||
$username,
|
$username,
|
||||||
$commentData['comment_text'],
|
$commentText,
|
||||||
$markdownEnabled
|
$markdownEnabled
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -44,7 +47,8 @@ class CommentModel {
|
|||||||
'success' => true,
|
'success' => true,
|
||||||
'user_name' => $username,
|
'user_name' => $username,
|
||||||
'created_at' => date('M d, Y H:i'),
|
'created_at' => date('M d, Y H:i'),
|
||||||
'markdown_enabled' => $markdownEnabled
|
'markdown_enabled' => $markdownEnabled,
|
||||||
|
'comment_text' => $commentText
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
@ -53,4 +57,5 @@ class CommentModel {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
@ -35,16 +35,45 @@ class TicketModel {
|
|||||||
return $comments;
|
return $comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllTickets($page = 1, $limit = 15, $status = 'Open', $sortColumn = 'ticket_id', $sortDirection = 'desc') {
|
public function getAllTickets($page = 1, $limit = 15, $status = 'Open', $sortColumn = 'ticket_id', $sortDirection = 'desc', $category = null, $type = null) {
|
||||||
// Calculate offset
|
// Calculate offset
|
||||||
$offset = ($page - 1) * $limit;
|
$offset = ($page - 1) * $limit;
|
||||||
|
|
||||||
// Build WHERE clause for status filtering
|
// Build WHERE clause
|
||||||
$whereClause = "";
|
$whereConditions = [];
|
||||||
|
$params = [];
|
||||||
|
$paramTypes = '';
|
||||||
|
|
||||||
|
// Status filtering
|
||||||
if ($status) {
|
if ($status) {
|
||||||
$statuses = explode(',', $status);
|
$statuses = explode(',', $status);
|
||||||
$placeholders = str_repeat('?,', count($statuses) - 1) . '?';
|
$placeholders = str_repeat('?,', count($statuses) - 1) . '?';
|
||||||
$whereClause = "WHERE status IN ($placeholders)";
|
$whereConditions[] = "status IN ($placeholders)";
|
||||||
|
$params = array_merge($params, $statuses);
|
||||||
|
$paramTypes .= str_repeat('s', count($statuses));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Category filtering
|
||||||
|
if ($category) {
|
||||||
|
$categories = explode(',', $category);
|
||||||
|
$placeholders = str_repeat('?,', count($categories) - 1) . '?';
|
||||||
|
$whereConditions[] = "category IN ($placeholders)";
|
||||||
|
$params = array_merge($params, $categories);
|
||||||
|
$paramTypes .= str_repeat('s', count($categories));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type filtering
|
||||||
|
if ($type) {
|
||||||
|
$types = explode(',', $type);
|
||||||
|
$placeholders = str_repeat('?,', count($types) - 1) . '?';
|
||||||
|
$whereConditions[] = "type IN ($placeholders)";
|
||||||
|
$params = array_merge($params, $types);
|
||||||
|
$paramTypes .= str_repeat('s', count($types));
|
||||||
|
}
|
||||||
|
|
||||||
|
$whereClause = '';
|
||||||
|
if (!empty($whereConditions)) {
|
||||||
|
$whereClause = 'WHERE ' . implode(' AND ', $whereConditions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate sort column to prevent SQL injection
|
// Validate sort column to prevent SQL injection
|
||||||
@ -60,8 +89,8 @@ class TicketModel {
|
|||||||
$countSql = "SELECT COUNT(*) as total FROM tickets $whereClause";
|
$countSql = "SELECT COUNT(*) as total FROM tickets $whereClause";
|
||||||
$countStmt = $this->conn->prepare($countSql);
|
$countStmt = $this->conn->prepare($countSql);
|
||||||
|
|
||||||
if ($status) {
|
if (!empty($params)) {
|
||||||
$countStmt->bind_param(str_repeat('s', count($statuses)), ...$statuses);
|
$countStmt->bind_param($paramTypes, ...$params);
|
||||||
}
|
}
|
||||||
|
|
||||||
$countStmt->execute();
|
$countStmt->execute();
|
||||||
@ -72,12 +101,13 @@ class TicketModel {
|
|||||||
$sql = "SELECT * FROM tickets $whereClause ORDER BY $sortColumn $sortDirection LIMIT ? OFFSET ?";
|
$sql = "SELECT * FROM tickets $whereClause ORDER BY $sortColumn $sortDirection LIMIT ? OFFSET ?";
|
||||||
$stmt = $this->conn->prepare($sql);
|
$stmt = $this->conn->prepare($sql);
|
||||||
|
|
||||||
if ($status) {
|
// Add limit and offset parameters
|
||||||
$types = str_repeat('s', count($statuses)) . 'ii';
|
$params[] = $limit;
|
||||||
$params = array_merge($statuses, [$limit, $offset]);
|
$params[] = $offset;
|
||||||
$stmt->bind_param($types, ...$params);
|
$paramTypes .= 'ii';
|
||||||
} else {
|
|
||||||
$stmt->bind_param("ii", $limit, $offset);
|
if (!empty($params)) {
|
||||||
|
$stmt->bind_param($paramTypes, ...$params);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
// This file contains the HTML template for the dashboard
|
// This file contains the HTML template for the dashboard
|
||||||
// It receives $tickets, $totalTickets, $totalPages, $page, and $status variables from the controller
|
// It receives $tickets, $totalTickets, $totalPages, $page, $status, $categories, $types variables from the controller
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@ -12,10 +12,10 @@
|
|||||||
<link rel="stylesheet" href="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/css/dashboard.css">
|
<link rel="stylesheet" href="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/css/dashboard.css">
|
||||||
<script src="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/js/dashboard.js"></script>
|
<script src="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/js/dashboard.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body data-categories='<?php echo json_encode($categories); ?>' data-types='<?php echo json_encode($types); ?>'>
|
||||||
<div class="dashboard-header">
|
<div class="dashboard-header">
|
||||||
<h1>Tinker Tickets</h1>
|
<h1>Tinker Tickets</h1>
|
||||||
<button onclick="window.location.href='<?php echo $GLOBALS['config']['BASE_URL']; ?>/ticket/create'" class="btn create-ticket">New Ticket</button>
|
<button onclick="window.location.href='/ticket/create'" class="btn create-ticket">New Ticket</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="table-controls">
|
<div class="table-controls">
|
||||||
@ -25,20 +25,28 @@
|
|||||||
<div class="table-actions">
|
<div class="table-actions">
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
<?php
|
<?php
|
||||||
|
$currentParams = $_GET;
|
||||||
|
|
||||||
// Previous page button
|
// Previous page button
|
||||||
if ($page > 1) {
|
if ($page > 1) {
|
||||||
echo "<button onclick='window.location.href=\"?page=" . ($page - 1) . "&status=$status\"'>«</button>";
|
$currentParams['page'] = $page - 1;
|
||||||
|
$prevUrl = '?' . http_build_query($currentParams);
|
||||||
|
echo "<button onclick='window.location.href=\"$prevUrl\"'>«</button>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Page number buttons
|
// Page number buttons
|
||||||
for ($i = 1; $i <= $totalPages; $i++) {
|
for ($i = 1; $i <= $totalPages; $i++) {
|
||||||
$activeClass = ($i === $page) ? 'active' : '';
|
$activeClass = ($i === $page) ? 'active' : '';
|
||||||
echo "<button class='$activeClass' onclick='window.location.href=\"?page=$i&status=$status\"'>$i</button>";
|
$currentParams['page'] = $i;
|
||||||
|
$pageUrl = '?' . http_build_query($currentParams);
|
||||||
|
echo "<button class='$activeClass' onclick='window.location.href=\"$pageUrl\"'>$i</button>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next page button
|
// Next page button
|
||||||
if ($page < $totalPages) {
|
if ($page < $totalPages) {
|
||||||
echo "<button onclick='window.location.href=\"?page=" . ($page + 1) . "&status=$status\"'>»</button>";
|
$currentParams['page'] = $page + 1;
|
||||||
|
$nextUrl = '?' . http_build_query($currentParams);
|
||||||
|
echo "<button onclick='window.location.href=\"$nextUrl\"'>»</button>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
@ -54,14 +62,30 @@
|
|||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Ticket ID</th>
|
<?php
|
||||||
<th>Priority</th>
|
$currentSort = isset($_GET['sort']) ? $_GET['sort'] : 'ticket_id';
|
||||||
<th>Title</th>
|
$currentDir = isset($_GET['dir']) ? $_GET['dir'] : 'desc';
|
||||||
<th>Category</th>
|
|
||||||
<th>Type</th>
|
$columns = [
|
||||||
<th>Status</th>
|
'ticket_id' => 'Ticket ID',
|
||||||
<th>Created</th>
|
'priority' => 'Priority',
|
||||||
<th>Updated</th>
|
'title' => 'Title',
|
||||||
|
'category' => 'Category',
|
||||||
|
'type' => 'Type',
|
||||||
|
'status' => 'Status',
|
||||||
|
'created_at' => 'Created',
|
||||||
|
'updated_at' => 'Updated'
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($columns as $col => $label) {
|
||||||
|
$newDir = ($currentSort === $col && $currentDir === 'asc') ? 'desc' : 'asc';
|
||||||
|
$sortClass = ($currentSort === $col) ? "sort-$currentDir" : '';
|
||||||
|
$sortParams = array_merge($_GET, ['sort' => $col, 'dir' => $newDir]);
|
||||||
|
$sortUrl = '?' . http_build_query($sortParams);
|
||||||
|
|
||||||
|
echo "<th class='$sortClass' onclick='window.location.href=\"$sortUrl\"'>$label</th>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -69,12 +93,12 @@
|
|||||||
if (count($tickets) > 0) {
|
if (count($tickets) > 0) {
|
||||||
foreach($tickets as $row) {
|
foreach($tickets as $row) {
|
||||||
echo "<tr class='priority-{$row['priority']}'>";
|
echo "<tr class='priority-{$row['priority']}'>";
|
||||||
echo "<td><a href='" . $GLOBALS['config']['BASE_URL'] . "/ticket/{$row['ticket_id']}' class='ticket-link'>{$row['ticket_id']}</a></td>";
|
echo "<td><a href='/ticket/{$row['ticket_id']}' class='ticket-link'>{$row['ticket_id']}</a></td>";
|
||||||
echo "<td><span>{$row['priority']}</span></td>";
|
echo "<td><span>{$row['priority']}</span></td>";
|
||||||
echo "<td>" . htmlspecialchars($row['title']) . "</td>";
|
echo "<td>" . htmlspecialchars($row['title']) . "</td>";
|
||||||
echo "<td>{$row['category']}</td>";
|
echo "<td>{$row['category']}</td>";
|
||||||
echo "<td>{$row['type']}</td>";
|
echo "<td>{$row['type']}</td>";
|
||||||
echo "<td class='status-{$row['status']}'>{$row['status']}</td>";
|
echo "<td><span class='status-" . str_replace(' ', '-', $row['status']) . "'>{$row['status']}</span></td>";
|
||||||
echo "<td>" . date('Y-m-d H:i', strtotime($row['created_at'])) . "</td>";
|
echo "<td>" . date('Y-m-d H:i', strtotime($row['created_at'])) . "</td>";
|
||||||
echo "<td>" . date('Y-m-d H:i', strtotime($row['updated_at'])) . "</td>";
|
echo "<td>" . date('Y-m-d H:i', strtotime($row['updated_at'])) . "</td>";
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
@ -85,15 +109,5 @@
|
|||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<!--<script>
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
// Initialize the dashboard
|
|
||||||
if (document.querySelector('table')) {
|
|
||||||
initSearch();
|
|
||||||
initStatusFilter();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>-->
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -34,7 +34,7 @@
|
|||||||
<div class="ticket-id">UUID <?php echo $ticket['ticket_id']; ?></div>
|
<div class="ticket-id">UUID <?php echo $ticket['ticket_id']; ?></div>
|
||||||
<div class="header-controls">
|
<div class="header-controls">
|
||||||
<div class="status-priority-group">
|
<div class="status-priority-group">
|
||||||
<span id="statusDisplay" class="status-<?php echo $ticket["status"]; ?>"><?php echo $ticket["status"]; ?></span>
|
<span id="statusDisplay" class="status-<?php echo str_replace(' ', '-', $ticket["status"]); ?>"><?php echo $ticket["status"]; ?></span>
|
||||||
<span class="priority-indicator priority-<?php echo $ticket["priority"]; ?>">P<?php echo $ticket["priority"]; ?></span>
|
<span class="priority-indicator priority-<?php echo $ticket["priority"]; ?>">P<?php echo $ticket["priority"]; ?></span>
|
||||||
</div>
|
</div>
|
||||||
<button id="editButton" class="btn" onclick="toggleEditMode()">Edit Ticket</button>
|
<button id="editButton" class="btn" onclick="toggleEditMode()">Edit Ticket</button>
|
||||||
@ -86,14 +86,16 @@
|
|||||||
foreach ($comments as $comment) {
|
foreach ($comments as $comment) {
|
||||||
echo "<div class='comment'>";
|
echo "<div class='comment'>";
|
||||||
echo "<div class='comment-header'>";
|
echo "<div class='comment-header'>";
|
||||||
echo "<span class='comment-user'>{$comment['user_name']}</span>";
|
echo "<span class='comment-user'>" . htmlspecialchars($comment['user_name']) . "</span>";
|
||||||
echo "<span class='comment-date'>" . date('M d, Y H:i', strtotime($comment['created_at'])) . "</span>";
|
echo "<span class='comment-date'>" . date('M d, Y H:i', strtotime($comment['created_at'])) . "</span>";
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
echo "<div class='comment-text'>";
|
echo "<div class='comment-text'>";
|
||||||
if ($comment['markdown_enabled']) {
|
if ($comment['markdown_enabled']) {
|
||||||
|
// For markdown comments, use JavaScript to render
|
||||||
echo "<script>document.write(marked.parse(" . json_encode($comment['comment_text']) . "))</script>";
|
echo "<script>document.write(marked.parse(" . json_encode($comment['comment_text']) . "))</script>";
|
||||||
} else {
|
} else {
|
||||||
echo htmlspecialchars($comment['comment_text']);
|
// For non-markdown comments, convert line breaks to <br> and escape HTML
|
||||||
|
echo nl2br(htmlspecialchars($comment['comment_text']));
|
||||||
}
|
}
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
@ -103,7 +105,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ticket-footer">
|
<div class="ticket-footer">
|
||||||
<button onclick="window.location.href='<?php echo $GLOBALS['config']['BASE_URL']; ?>'" class="btn back-btn">Back to Dashboard</button>
|
<button onclick="window.location.href='/'" class="btn back-btn">Back to Dashboard</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
@ -116,5 +118,17 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<script>
|
||||||
|
// Make ticket data available to JavaScript
|
||||||
|
window.ticketData = {
|
||||||
|
id: <?php echo json_encode($ticket['ticket_id']); ?>,
|
||||||
|
status: <?php echo json_encode($ticket['status']); ?>,
|
||||||
|
priority: <?php echo json_encode($ticket['priority']); ?>,
|
||||||
|
category: <?php echo json_encode($ticket['category']); ?>,
|
||||||
|
type: <?php echo json_encode($ticket['type']); ?>,
|
||||||
|
title: <?php echo json_encode($ticket['title']); ?>
|
||||||
|
};
|
||||||
|
console.log('Ticket data loaded:', window.ticketData);
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user