|
Server : LiteSpeed System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64 User : outerorb ( 1091) PHP Version : 8.1.34 Disable Function : mail Directory : /home2/outerorb/assetradar.outerorbittech.com/tl/ | |
|
Path: /home2/outerorb/assetradar.outerorbittech.com/tl/ticket_view.php
Size: 2.32 KB
Permissions: 0666
<?php
require_once __DIR__ . '/../inc/auth.php';
require_once __DIR__ . '/../inc/csrf.php';
require_login();
verify_csrf();
$user = current_user();
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['status'])) {
$status = $_POST['status'];
$stmt = $mysqli->prepare('UPDATE tickets SET status=?, updated_at=NOW() WHERE id=?');
$stmt->bind_param('si', $status, $id);
$stmt->execute();
$mysqli->query("INSERT INTO logs (user_id, action, created_at) VALUES (".(int)$_SESSION['user_id'].", 'Updated ticket {$id} to {$status}', NOW())");
header('Location: ticket_view.php?id='.$id.'&msg=Status updated successfully');
exit;
}
$ticket = $mysqli->query('SELECT t.*, i.asset_tag, i.item_name, u.name as reported_by FROM tickets t LEFT JOIN items i ON t.item_id=i.id LEFT JOIN users u ON t.user_id=u.id WHERE t.id=' . $id)->fetch_assoc();
if (!$ticket) { header('Location: dashboard.php'); exit; }
include __DIR__ . '/../inc/header.php';
include 'tl_menu.php';
?>
<div class="card p-3 card-hero">
<h5>Ticket #<?php echo $ticket['id']; ?> — <?php echo esc($ticket['issue_type']); ?></h5>
<p><strong>Item:</strong> <?php echo esc($ticket['item_name'].' ('.$ticket['asset_tag'].')'); ?></p>
<p><strong>Reported by:</strong> <?php echo esc($ticket['reported_by']); ?></p>
<p><strong>Description:</strong><br><?php echo nl2br(esc($ticket['description'])); ?></p>
<p><strong>Status:</strong> <?php echo esc($ticket['status']); ?></p>
<?php if (isset($_GET['msg'])): ?>
<div class="alert alert-success"><?php echo htmlspecialchars($_GET['msg']); ?></div>
<?php endif; ?>
<form method="post" action="">
<?php echo csrf_field(); ?>
<label>Change status</label>
<select name="status" class="form-control mb-2">
<option <?php if ($ticket['status'] === 'Pending') echo 'selected'; ?>>Pending</option>
<option <?php if ($ticket['status'] === 'In Progress') echo 'selected'; ?>>In Progress</option>
<option <?php if ($ticket['status'] === 'Resolved') echo 'selected'; ?>>Resolved</option>
<option <?php if ($ticket['status'] === 'Closed') echo 'selected'; ?>>Closed</option>
</select>
<button class="btn btn-primary">Update Status</button>
</form>
</div>
<?php include __DIR__ . '/../inc/footer.php'; ?>