Add Activity Timeline feature and database migrations
- Add Activity Timeline tab to ticket view showing chronological history - Create getTicketTimeline() method in AuditLogModel - Update TicketController to load timeline data - Add timeline UI with helper functions for formatting events - Add comprehensive timeline CSS with dark mode support - Create migrations 007-010 for upcoming features: - 007: Ticket assignment functionality - 008: Status workflow transitions - 009: Ticket templates - 010: Bulk operations tracking 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,43 @@
|
||||
<?php
|
||||
// This file contains the HTML template for a ticket
|
||||
// It receives $ticket and $comments variables from the controller
|
||||
// It receives $ticket, $comments, and $timeline variables from the controller
|
||||
|
||||
// Helper functions for timeline display
|
||||
function getEventIcon($actionType) {
|
||||
$icons = [
|
||||
'create' => '✨',
|
||||
'update' => '📝',
|
||||
'comment' => '💬',
|
||||
'view' => '👁️',
|
||||
'assign' => '👤',
|
||||
'status_change' => '🔄'
|
||||
];
|
||||
return $icons[$actionType] ?? '•';
|
||||
}
|
||||
|
||||
function formatAction($event) {
|
||||
$actions = [
|
||||
'create' => 'created this ticket',
|
||||
'update' => 'updated this ticket',
|
||||
'comment' => 'added a comment',
|
||||
'view' => 'viewed this ticket',
|
||||
'assign' => 'assigned this ticket',
|
||||
'status_change' => 'changed the status'
|
||||
];
|
||||
return $actions[$event['action_type']] ?? $event['action_type'];
|
||||
}
|
||||
|
||||
function formatDetails($details, $actionType) {
|
||||
if ($actionType === 'update' && is_array($details)) {
|
||||
$changes = [];
|
||||
foreach ($details as $field => $value) {
|
||||
if ($field === 'old_value' || $field === 'new_value') continue;
|
||||
$changes[] = "<strong>" . htmlspecialchars($field) . ":</strong> " . htmlspecialchars($value);
|
||||
}
|
||||
return implode(', ', $changes);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@@ -144,6 +181,7 @@
|
||||
<div class="ticket-tabs">
|
||||
<button class="tab-btn active" onclick="showTab('description')">Description</button>
|
||||
<button class="tab-btn" onclick="showTab('comments')">Comments</button>
|
||||
<button class="tab-btn" onclick="showTab('activity')">Activity</button>
|
||||
</div>
|
||||
|
||||
<div id="description-tab" class="tab-content active">
|
||||
@@ -204,6 +242,32 @@
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="activity-tab" class="tab-content">
|
||||
<div class="timeline-container">
|
||||
<?php if (empty($timeline)): ?>
|
||||
<p>No activity recorded yet.</p>
|
||||
<?php else: ?>
|
||||
<?php foreach ($timeline as $event): ?>
|
||||
<div class="timeline-event">
|
||||
<div class="timeline-icon"><?php echo getEventIcon($event['action_type']); ?></div>
|
||||
<div class="timeline-content">
|
||||
<div class="timeline-header">
|
||||
<strong><?php echo htmlspecialchars($event['display_name'] ?? $event['username'] ?? 'System'); ?></strong>
|
||||
<span class="timeline-action"><?php echo formatAction($event); ?></span>
|
||||
<span class="timeline-date"><?php echo date('M d, Y H:i', strtotime($event['created_at'])); ?></span>
|
||||
</div>
|
||||
<?php if (!empty($event['details'])): ?>
|
||||
<div class="timeline-details">
|
||||
<?php echo formatDetails($event['details'], $event['action_type']); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
Reference in New Issue
Block a user