134 lines
6.8 KiB
PHP
134 lines
6.8 KiB
PHP
<?php
|
|
// This file contains the HTML template for a ticket
|
|
// It receives $ticket and $comments variables from the controller
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Ticket #<?php echo $ticket['ticket_id']; ?></title>
|
|
<link rel="icon" type="image/png" href="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/images/favicon.png">
|
|
<link rel="stylesheet" href="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/css/dashboard.css">
|
|
<link rel="stylesheet" href="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/css/ticket.css">
|
|
<script src="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/js/dashboard.js"></script>
|
|
<script src="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/js/ticket.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
<script>
|
|
// Store ticket data in a global variable
|
|
window.ticketData = {
|
|
ticket_id: "<?php echo $ticket['ticket_id']; ?>",
|
|
title: "<?php echo htmlspecialchars($ticket['title']); ?>",
|
|
status: "<?php echo $ticket['status']; ?>",
|
|
priority: "<?php echo $ticket['priority']; ?>",
|
|
category: "<?php echo $ticket['category']; ?>",
|
|
type: "<?php echo $ticket['type']; ?>"
|
|
};
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div class="ticket-container" data-priority="<?php echo $ticket["priority"]; ?>">
|
|
<div class="ticket-header">
|
|
<h2><input type="text" class="editable title-input" value="<?php echo htmlspecialchars($ticket["title"]); ?>" data-field="title" disabled></h2>
|
|
<div class="ticket-subheader">
|
|
<div class="ticket-id">UUID <?php echo $ticket['ticket_id']; ?></div>
|
|
<div class="header-controls">
|
|
<div class="status-priority-group">
|
|
<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>
|
|
</div>
|
|
<button id="editButton" class="btn" onclick="toggleEditMode()">Edit Ticket</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="ticket-details">
|
|
<div class="ticket-tabs">
|
|
<button class="tab-btn active" onclick="showTab('description')">Description</button>
|
|
<button class="tab-btn" onclick="showTab('comments')">Comments</button>
|
|
</div>
|
|
|
|
<div id="description-tab" class="tab-content active">
|
|
<div class="detail-group full-width">
|
|
<label>Description</label>
|
|
<textarea class="editable" data-field="description" disabled><?php echo $ticket["description"]; ?></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="comments-tab" class="tab-content">
|
|
<div class="comments-section">
|
|
<h2>Comments</h2>
|
|
<div class="comment-form">
|
|
<textarea id="newComment" placeholder="Add a comment..."></textarea>
|
|
<div class="comment-controls">
|
|
<div class="markdown-toggles">
|
|
<div class="preview-toggle">
|
|
<label class="switch">
|
|
<input type="checkbox" id="markdownMaster" onchange="toggleMarkdownMode()">
|
|
<span class="slider round"></span>
|
|
</label>
|
|
<span class="toggle-label">Enable Markdown</span>
|
|
</div>
|
|
<div class="preview-toggle">
|
|
<label class="switch">
|
|
<input type="checkbox" id="markdownToggle" onchange="togglePreview()" disabled>
|
|
<span class="slider round"></span>
|
|
</label>
|
|
<span class="toggle-label">Preview Markdown</span>
|
|
</div>
|
|
</div>
|
|
<button onclick="addComment()" class="btn">Add Comment</button>
|
|
</div>
|
|
<div id="markdownPreview" class="markdown-preview" style="display: none;"></div>
|
|
</div>
|
|
</div>
|
|
<div class="comments-list">
|
|
<?php
|
|
foreach ($comments as $comment) {
|
|
echo "<div class='comment'>";
|
|
echo "<div class='comment-header'>";
|
|
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 "</div>";
|
|
echo "<div class='comment-text'>";
|
|
if ($comment['markdown_enabled']) {
|
|
// For markdown comments, use JavaScript to render
|
|
echo "<script>document.write(marked.parse(" . json_encode($comment['comment_text']) . "))</script>";
|
|
} else {
|
|
// For non-markdown comments, convert line breaks to <br> and escape HTML
|
|
echo nl2br(htmlspecialchars($comment['comment_text']));
|
|
}
|
|
echo "</div>";
|
|
echo "</div>";
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="ticket-footer">
|
|
<button onclick="window.location.href='/'" class="btn back-btn">Back to Dashboard</button>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
// Initialize the ticket view
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
if (typeof showTab === 'function') {
|
|
showTab('description');
|
|
} else {
|
|
console.error('showTab function not defined');
|
|
}
|
|
});
|
|
</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>
|
|
</html>
|