82 lines
4.3 KiB
PHP
82 lines
4.3 KiB
PHP
|
|
<?php
|
||
|
|
$pageTitle = $title ?? 'Ticket';
|
||
|
|
$ticket = is_array($ticket ?? null) ? $ticket : [];
|
||
|
|
$messages = is_array($messages ?? null) ? $messages : [];
|
||
|
|
$saved = (string)($saved ?? '');
|
||
|
|
$error = (string)($error ?? '');
|
||
|
|
ob_start();
|
||
|
|
?>
|
||
|
|
<section class="admin-card">
|
||
|
|
<div class="badge">Support</div>
|
||
|
|
<div style="display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:16px;">
|
||
|
|
<div>
|
||
|
|
<h1 style="font-size:26px; margin:0;"><?= htmlspecialchars((string)($ticket['ticket_no'] ?? ''), ENT_QUOTES, 'UTF-8') ?></h1>
|
||
|
|
<p style="color: var(--muted); margin-top:6px;"><?= htmlspecialchars((string)($ticket['subject'] ?? ''), ENT_QUOTES, 'UTF-8') ?></p>
|
||
|
|
</div>
|
||
|
|
<div style="display:flex; gap:8px;">
|
||
|
|
<form method="post" action="/admin/support/ticket/delete" onsubmit="return confirm('Delete this ticket and all messages? This cannot be undone.');">
|
||
|
|
<input type="hidden" name="ticket_id" value="<?= (int)($ticket['id'] ?? 0) ?>">
|
||
|
|
<button type="submit" class="btn outline danger">Delete Ticket</button>
|
||
|
|
</form>
|
||
|
|
<a href="/admin/support" class="btn outline">Back</a>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<?php if ($saved !== ''): ?>
|
||
|
|
<div style="margin-top:10px; color:#9be7c6; font-size:13px;">Updated.</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
<?php if ($error !== ''): ?>
|
||
|
|
<div style="margin-top:10px; color:#f3b0b0; font-size:13px;"><?= htmlspecialchars($error, ENT_QUOTES, 'UTF-8') ?></div>
|
||
|
|
<?php endif; ?>
|
||
|
|
|
||
|
|
<div class="admin-card" style="margin-top:12px; padding:12px; display:grid; grid-template-columns:1fr auto; gap:10px; align-items:center;">
|
||
|
|
<div style="font-size:13px; color:var(--muted);">
|
||
|
|
<?= htmlspecialchars((string)($ticket['customer_name'] ?? ''), ENT_QUOTES, 'UTF-8') ?> ·
|
||
|
|
<?= htmlspecialchars((string)($ticket['customer_email'] ?? ''), ENT_QUOTES, 'UTF-8') ?> ·
|
||
|
|
<?= htmlspecialchars((string)($ticket['customer_ip'] ?? ''), ENT_QUOTES, 'UTF-8') ?>
|
||
|
|
</div>
|
||
|
|
<form method="post" action="/admin/support/ticket/status" style="display:flex; gap:8px;">
|
||
|
|
<input type="hidden" name="ticket_id" value="<?= (int)($ticket['id'] ?? 0) ?>">
|
||
|
|
<select class="input" name="status" style="width:150px;">
|
||
|
|
<?php $status = (string)($ticket['status'] ?? 'open'); ?>
|
||
|
|
<option value="open" <?= $status === 'open' ? 'selected' : '' ?>>open</option>
|
||
|
|
<option value="pending" <?= $status === 'pending' ? 'selected' : '' ?>>pending</option>
|
||
|
|
<option value="closed" <?= $status === 'closed' ? 'selected' : '' ?>>closed</option>
|
||
|
|
</select>
|
||
|
|
<button class="btn small" type="submit">Set</button>
|
||
|
|
</form>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="admin-card" style="margin-top:12px; padding:12px;">
|
||
|
|
<div class="label" style="margin-bottom:8px;">Thread</div>
|
||
|
|
<?php if (!$messages): ?>
|
||
|
|
<div style="color:var(--muted); font-size:13px;">No messages yet.</div>
|
||
|
|
<?php else: ?>
|
||
|
|
<div style="display:grid; gap:8px;">
|
||
|
|
<?php foreach ($messages as $msg): ?>
|
||
|
|
<?php $isAdmin = (string)($msg['sender_type'] ?? '') === 'admin'; ?>
|
||
|
|
<div class="admin-card" style="padding:10px; border-color:<?= $isAdmin ? 'rgba(34,242,165,.35)' : 'rgba(255,255,255,.1)' ?>;">
|
||
|
|
<div style="display:flex; justify-content:space-between; gap:12px; font-size:12px; color:var(--muted);">
|
||
|
|
<span><?= $isAdmin ? 'Admin' : 'Customer' ?> · <?= htmlspecialchars((string)($msg['sender_email'] ?? ''), ENT_QUOTES, 'UTF-8') ?></span>
|
||
|
|
<span><?= htmlspecialchars((string)($msg['created_at'] ?? ''), ENT_QUOTES, 'UTF-8') ?></span>
|
||
|
|
</div>
|
||
|
|
<div style="margin-top:8px; white-space:pre-wrap; line-height:1.6;"><?= htmlspecialchars((string)($msg['body_text'] ?? ''), ENT_QUOTES, 'UTF-8') ?></div>
|
||
|
|
</div>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<form method="post" action="/admin/support/ticket/reply" style="margin-top:12px; display:grid; gap:10px;">
|
||
|
|
<input type="hidden" name="ticket_id" value="<?= (int)($ticket['id'] ?? 0) ?>">
|
||
|
|
<div class="label">Reply</div>
|
||
|
|
<textarea class="input" name="body" rows="6" style="resize:vertical;" placeholder="Type reply..."></textarea>
|
||
|
|
<div style="display:flex; justify-content:flex-end;">
|
||
|
|
<button class="btn" type="submit">Send Reply</button>
|
||
|
|
</div>
|
||
|
|
</form>
|
||
|
|
</section>
|
||
|
|
<?php
|
||
|
|
$content = ob_get_clean();
|
||
|
|
require __DIR__ . '/../../../../modules/admin/views/layout.php';
|