Username not live updating & css overlap bug
This commit is contained in:
@@ -66,6 +66,11 @@ try {
|
|||||||
$auditLog->logCommentCreate($userId, $result['comment_id'], $ticketId);
|
$auditLog->logCommentCreate($userId, $result['comment_id'], $ticketId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add user display name to result for frontend
|
||||||
|
if ($result['success']) {
|
||||||
|
$result['user_name'] = $currentUser['display_name'] ?? $currentUser['username'];
|
||||||
|
}
|
||||||
|
|
||||||
// Discard any unexpected output
|
// Discard any unexpected output
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,15 @@ class TicketModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getTicketById($id) {
|
public function getTicketById($id) {
|
||||||
$sql = "SELECT * FROM tickets WHERE ticket_id = ?";
|
$sql = "SELECT t.*,
|
||||||
|
u_created.username as creator_username,
|
||||||
|
u_created.display_name as creator_display_name,
|
||||||
|
u_updated.username as updater_username,
|
||||||
|
u_updated.display_name as updater_display_name
|
||||||
|
FROM tickets t
|
||||||
|
LEFT JOIN users u_created ON t.created_by = u_created.user_id
|
||||||
|
LEFT JOIN users u_updated ON t.updated_by = u_updated.user_id
|
||||||
|
WHERE t.ticket_id = ?";
|
||||||
$stmt = $this->conn->prepare($sql);
|
$stmt = $this->conn->prepare($sql);
|
||||||
$stmt->bind_param("i", $id);
|
$stmt->bind_param("i", $id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|||||||
@@ -13,19 +13,60 @@
|
|||||||
<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 data-categories='<?php echo json_encode($categories); ?>' data-types='<?php echo json_encode($types); ?>'>
|
<body data-categories='<?php echo json_encode($categories); ?>' data-types='<?php echo json_encode($types); ?>'>
|
||||||
<div class="user-header" style="background: #2c3e50; padding: 0.75rem 2rem; color: white; display: flex; justify-content: space-between; align-items: center;">
|
<div class="user-header">
|
||||||
<div>
|
<div class="user-header-left">
|
||||||
<span style="font-weight: bold; font-size: 1.1rem;">🎫 Tinker Tickets</span>
|
<span class="app-title">🎫 Tinker Tickets</span>
|
||||||
</div>
|
</div>
|
||||||
<div style="display: flex; align-items: center; gap: 1rem;">
|
<div class="user-header-right">
|
||||||
<?php if (isset($GLOBALS['currentUser'])): ?>
|
<?php if (isset($GLOBALS['currentUser'])): ?>
|
||||||
<span>👤 <?php echo htmlspecialchars($GLOBALS['currentUser']['display_name'] ?? $GLOBALS['currentUser']['username']); ?></span>
|
<span class="user-name">👤 <?php echo htmlspecialchars($GLOBALS['currentUser']['display_name'] ?? $GLOBALS['currentUser']['username']); ?></span>
|
||||||
<?php if ($GLOBALS['currentUser']['is_admin']): ?>
|
<?php if ($GLOBALS['currentUser']['is_admin']): ?>
|
||||||
<span style="background: #e74c3c; padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.85rem;">Admin</span>
|
<span class="admin-badge">Admin</span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<style>
|
||||||
|
.user-header {
|
||||||
|
background: var(--header-bg, #2c3e50);
|
||||||
|
padding: 0.75rem 2rem;
|
||||||
|
color: var(--header-text, white);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
border-bottom: 1px solid var(--border-color, #ddd);
|
||||||
|
}
|
||||||
|
body.light-mode .user-header {
|
||||||
|
--header-bg: #f8f9fa;
|
||||||
|
--header-text: #333;
|
||||||
|
--border-color: #dee2e6;
|
||||||
|
}
|
||||||
|
body.dark-mode .user-header {
|
||||||
|
--header-bg: #2c3e50;
|
||||||
|
--header-text: white;
|
||||||
|
--border-color: #444;
|
||||||
|
}
|
||||||
|
.user-header-left, .user-header-right {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
.app-title {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
color: var(--header-text);
|
||||||
|
}
|
||||||
|
.user-name {
|
||||||
|
color: var(--header-text);
|
||||||
|
}
|
||||||
|
.admin-badge {
|
||||||
|
background: #e74c3c;
|
||||||
|
color: white;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<div class="dashboard-header">
|
<div class="dashboard-header">
|
||||||
<h1>Ticket Dashboard</h1>
|
<h1>Ticket Dashboard</h1>
|
||||||
<button onclick="window.location.href='<?php echo $GLOBALS['config']['BASE_URL']; ?>/ticket/create'" class="btn create-ticket">New Ticket</button> </div>
|
<button onclick="window.location.href='<?php echo $GLOBALS['config']['BASE_URL']; ?>/ticket/create'" class="btn create-ticket">New Ticket</button> </div>
|
||||||
|
|||||||
@@ -27,24 +27,86 @@
|
|||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="user-header" style="background: #2c3e50; padding: 0.75rem 2rem; color: white; display: flex; justify-content: space-between; align-items: center;">
|
<div class="user-header">
|
||||||
<div>
|
<div class="user-header-left">
|
||||||
<a href="/" style="color: white; text-decoration: none; font-weight: bold;">← Dashboard</a>
|
<a href="/" class="back-link">← Dashboard</a>
|
||||||
</div>
|
</div>
|
||||||
<div style="display: flex; align-items: center; gap: 1rem;">
|
<div class="user-header-right">
|
||||||
<?php if (isset($GLOBALS['currentUser'])): ?>
|
<?php if (isset($GLOBALS['currentUser'])): ?>
|
||||||
<span>👤 <?php echo htmlspecialchars($GLOBALS['currentUser']['display_name'] ?? $GLOBALS['currentUser']['username']); ?></span>
|
<span class="user-name">👤 <?php echo htmlspecialchars($GLOBALS['currentUser']['display_name'] ?? $GLOBALS['currentUser']['username']); ?></span>
|
||||||
<?php if ($GLOBALS['currentUser']['is_admin']): ?>
|
<?php if ($GLOBALS['currentUser']['is_admin']): ?>
|
||||||
<span style="background: #e74c3c; padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.85rem;">Admin</span>
|
<span class="admin-badge">Admin</span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<style>
|
||||||
|
.user-header {
|
||||||
|
background: var(--header-bg, #2c3e50);
|
||||||
|
padding: 0.75rem 2rem;
|
||||||
|
color: var(--header-text, white);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
border-bottom: 1px solid var(--border-color, #ddd);
|
||||||
|
}
|
||||||
|
body.light-mode .user-header {
|
||||||
|
--header-bg: #f8f9fa;
|
||||||
|
--header-text: #333;
|
||||||
|
--border-color: #dee2e6;
|
||||||
|
}
|
||||||
|
body.dark-mode .user-header {
|
||||||
|
--header-bg: #2c3e50;
|
||||||
|
--header-text: white;
|
||||||
|
--border-color: #444;
|
||||||
|
}
|
||||||
|
.user-header-left, .user-header-right {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
.back-link {
|
||||||
|
color: var(--header-text);
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.back-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.user-name {
|
||||||
|
color: var(--header-text);
|
||||||
|
}
|
||||||
|
.admin-badge {
|
||||||
|
background: #e74c3c;
|
||||||
|
color: white;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<div class="ticket-container" data-priority="<?php echo $ticket["priority"]; ?>">
|
<div class="ticket-container" data-priority="<?php echo $ticket["priority"]; ?>">
|
||||||
<div class="ticket-header">
|
<div class="ticket-header">
|
||||||
<h2><input type="text" class="editable title-input" value="<?php echo htmlspecialchars($ticket["title"]); ?>" data-field="title" disabled></h2>
|
<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-subheader">
|
||||||
<div class="ticket-id">UUID <?php echo $ticket['ticket_id']; ?></div>
|
<div class="ticket-metadata">
|
||||||
|
<div class="ticket-id">UUID <?php echo $ticket['ticket_id']; ?></div>
|
||||||
|
<div class="ticket-user-info" style="font-size: 0.85rem; color: #666; margin-top: 0.25rem;">
|
||||||
|
<?php
|
||||||
|
$creator = $ticket['creator_display_name'] ?? $ticket['creator_username'] ?? 'System';
|
||||||
|
echo "Created by: <strong>" . htmlspecialchars($creator) . "</strong>";
|
||||||
|
if (!empty($ticket['created_at'])) {
|
||||||
|
echo " on " . date('M d, Y H:i', strtotime($ticket['created_at']));
|
||||||
|
}
|
||||||
|
if (!empty($ticket['updater_display_name']) || !empty($ticket['updater_username'])) {
|
||||||
|
$updater = $ticket['updater_display_name'] ?? $ticket['updater_username'];
|
||||||
|
echo " • Last updated by: <strong>" . htmlspecialchars($updater) . "</strong>";
|
||||||
|
if (!empty($ticket['updated_at'])) {
|
||||||
|
echo " on " . date('M d, Y H:i', strtotime($ticket['updated_at']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</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 str_replace(' ', '-', $ticket["status"]); ?>"><?php echo $ticket["status"]; ?></span>
|
<span id="statusDisplay" class="status-<?php echo str_replace(' ', '-', $ticket["status"]); ?>"><?php echo $ticket["status"]; ?></span>
|
||||||
|
|||||||
Reference in New Issue
Block a user