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:
2026-01-01 18:25:19 -05:00
parent 9a12a656aa
commit f9629f60b6
8 changed files with 264 additions and 1 deletions

View File

@@ -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>