-
-
Notifications
You must be signed in to change notification settings - Fork 126
/
admin_helpdesk.php
147 lines (138 loc) · 4.47 KB
/
admin_helpdesk.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
protect_page();
admin_only($user_data);
// Declare as int
$view = (isset($_GET['view']) && (int)$_GET['view'] > 0) ? (int)$_GET['view'] : false;
if ($view !== false){
if (!empty($_POST['reply_text'])) {
sanitize($_POST['reply_text']);
// Save ticket reply on database
$query = array(
'tid' => $view,
'username'=> getValue($_POST['username']),
'message' => getValue($_POST['reply_text']),
'created' => time(),
);
$fields = '`'. implode('`, `', array_keys($query)) .'`';
$data = '\''. implode('\', \'', $query) .'\'';
mysql_insert("INSERT INTO `znote_tickets_replies` ($fields) VALUES ($data)");
mysql_update("UPDATE `znote_tickets` SET `status`='Staff-Reply' WHERE `id`='$view' LIMIT 1;");
} else if (!empty($_POST['admin_ticket_close'])) {
$ticketId = (int) $_POST['admin_ticket_id'];
mysql_update("UPDATE `znote_tickets` SET `status` = 'CLOSED' WHERE `id` ='$ticketId' LIMIT 1;");
} else if (!empty($_POST['admin_ticket_open'])) {
$ticketId = (int) $_POST['admin_ticket_id'];
mysql_update("UPDATE `znote_tickets` SET `status` = 'Open' WHERE `id` ='$ticketId' LIMIT 1;");
} else if (!empty($_POST['admin_ticket_delete'])) {
$ticketId = (int) $_POST['admin_ticket_id'];
mysql_delete("DELETE FROM `znote_tickets` WHERE `id`='$ticketId' LIMIT 1;");
header("Location: admin_helpdesk.php");
}
$ticketData = mysql_select_single("SELECT * FROM znote_tickets WHERE id='$view' LIMIT 1;");
?>
<h1>View Ticket #<?php echo $ticketData['id']; ?></h1>
<table class="znoteTable ThreadTable table table-striped">
<tr class="yellow">
<th>
<?php
echo getClock($ticketData['creation'], true);
?>
- Created by:
<?php
echo $ticketData['username'];
?>
</th>
</tr>
<tr>
<td>
<p><?php echo nl2br($ticketData['message']); ?></p>
</td>
</tr>
</table>
<?php
$replies = mysql_select_multi("SELECT * FROM znote_tickets_replies WHERE tid='$view' ORDER BY `created`;");
if ($replies !== false) {
foreach($replies as $reply) {
?>
<table class="znoteTable ThreadTable table table-striped">
<tr class="yellow">
<th>
<?php
echo getClock($reply['created'], true);
?>
- Posted by:
<?php
echo $reply['username'];
?>
</th>
</tr>
<tr>
<td>
<p><?php echo nl2br($reply['message']); ?></p>
</td>
</tr>
</table>
<?php
}
}
?>
<!-- Open/Close Ticket -->
<table class="znoteTable ThreadTable table table-striped">
<tr>
<td>
<form action="" method="post" align="center">
<input type="hidden" name="admin_ticket_id" value="<?php echo $ticketData['id']; ?>">
<?php if ($ticketData['status'] !== 'CLOSED') { ?>
<input type="submit" name="admin_ticket_close" value="Close Ticket" class="btn btn-warning">
<?php } else { ?>
<input type="submit" name="admin_ticket_open" value="Open Ticket" class="btn btn-success">
<?php } ?>
</form>
</td>
<td>
<form action="" method="post" align="center" onClick="return confirm('Are you sure you want to delete this ticket?');">
<input type="hidden" name="admin_ticket_id" value="<?php echo $ticketData['id']; ?>">
<input type="submit" name="admin_ticket_delete" value="Delete Ticket" class="btn btn-danger">
</form>
</td>
</tr>
</table>
<?php if ($ticketData['status'] !== 'CLOSED') { ?>
<hr class="bighr">
<form action="" method="post">
<input type="hidden" name="username" value="ADMIN"><br>
<textarea class="forumReply" name="reply_text" style="width: 610px; height: 150px"></textarea><br>
<input name="" type="submit" value="Post Reply" class="btn btn-primary">
</form>
<?php } ?>
<?php
} else {
?>
<h1>Latest Tickets</h1>
<?php
$tickets = mysql_select_multi("SELECT id,subject,creation,status FROM znote_tickets ORDER BY creation DESC");
if ($tickets !== false) {
?>
<table>
<tr class="yellow">
<td>ID:</td>
<td>Subject:</td>
<td>Creation:</td>
<td>Status:</td>
</tr>
<?php
foreach ($tickets as $ticket) {
echo '<tr class="special">';
echo '<td>'. $ticket['id'] .'</td>';
echo '<td><a href="admin_helpdesk.php?view='. $ticket['id'] .'">'. $ticket['subject'] .'</a></td>';
echo '<td>'. getClock($ticket['creation'], true) .'</td>';
echo '<td>'. $ticket['status'] .'</td>';
echo '</tr>';
}
?>
</table>
<?php
} else echo 'No helpdesk tickets has been submitted.';
}
include 'layout/overall/footer.php';
?>