-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.php
More file actions
executable file
·353 lines (285 loc) · 13.7 KB
/
view.php
File metadata and controls
executable file
·353 lines (285 loc) · 13.7 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
<?php /* $Id: view.php,v 1.29 2006/04/17 10:10:22 cyberhorse Exp $ */
if (!$canRead) {
$AppUI->redirect( "m=public&a=access_denied" );
}
$ticket = dPgetParam( $_GET, 'ticket', '' );
$ticket_type = dPgetParam( $_GET, 'ticket_type', '' );
$type_toggle = dPgetParam( $_POST, 'type_toggle', '' );
$priority_toggle = dPgetParam( $_POST, 'priority_toggle', '' );
$assignment_toggle = dPgetParam( $_POST, 'assignment_toggle', '' );
// setup the title block
$titleBlock = new CTitleBlock( 'View Ticket', 'gconf-app-icon.png', $m, "$m.$a" );
$titleBlock->addCrumb( "?m=ticketsmith", "tickets list" );
$titleBlock->addCrumb( "?m=ticketsmith&type=My", "my tickets" );
$titleBlock->show();
require("./modules/ticketsmith/config.inc.php");
require("./modules/ticketsmith/common.inc.php");
/* Centralize references */
$app_root = dPgetConfig( 'base_url' );
/* initialize fields */
if ($ticket_type == "Staff Followup" || $ticket_type == "Client Followup") {
$title = $AppUI->_($ticket_type)." ".$AppUI->_('to Ticket')." #$ticket_parent";
$fields = array("headings" => array("From", "To", "Subject", "Date", "Cc", "<br />"),
"columns" => array("author", "recipient", "subject", "timestamp", "cc", "body"),
"types" => array("email", "original_author", "normal", "elapsed_date", "email", "body"));
}
elseif ($ticket_type == "Staff Comment") {
$title = $AppUI->_($ticket_type)." ".$AppUI->_('to Ticket')." #$ticket_parent";
$fields = array("headings" => array("From", "Date", "<br />"),
"columns" => array("author", "timestamp", "body"),
"types" => array("email", "elapsed_date", "body"));
}
else {
$title = $AppUI->_('Ticket')." #$ticket";
$fields = array("headings" => array("From", "Subject", "Date", "Cc", "Status",
"Priority", "Owner", "<br />"),
"columns" => array("author", "subject", "timestamp", "cc",
"type", "priority", "assignment", "body"),
"types" => array("email", "normal", "elapsed_date", "email",
"status", "priority_select", "assignment", "body"));
}
/* perform updates */
$orig_assignment = dPgetParam( $_POST, 'orig_assignment', '' );
$author = dPgetParam( $_POST, 'author', '' );
$priority = dPgetParam( $_POST, 'priority', '' );
$subject = dPgetParam( $_POST, 'subject', '' );
if (@$type_toggle || @$priority_toggle || @$assignment_toggle) {
do_query("UPDATE tickets SET type = '$type_toggle', priority = '$priority_toggle', assignment = '$assignment_toggle' WHERE ticket = '$ticket'");
if(@$assignment_toggle != @$orig_assignment)
{
$mailinfo = query2hash("SELECT contact_first_name, contact_last_name, contact_email from users u LEFT JOIN contacts ON u.user_contact = contact_id WHERE user_id = $assignment_toggle");
if (@$mailinfo['user_email']) {
$boundary = "_lkqwkASDHASK89271893712893";
$message = "--$boundary\n";
$message .= "Content-disposition: inline\n";
$message .= "Content-type: text/plain\n\n";
$message .= $AppUI->_('Trouble ticket assigned to you') . ".\n\n";
$message .= "Ticket ID: $ticket\n";
$message .= "Author : $author\n";
$message .= "Subject : $subject\n";
$message .= "View : $app_root/index.php?m=ticketsmith&a=view&ticket=$ticket\n";
$message .= "\n--$boundary\n";
$message .= "Content-disposition: inline\n";
$message .= "Content-type: text/html\n\n";
$message .= "<html>\n";
$message .= "<head>\n";
$message .= "<style>\n";
$message .= ".title {\n";
$message .= " FONT-SIZE: 18pt; SIZE: 18pt;\n";
$message .= "}\n";
$message .= "</style>\n";
$message .= "<title>".$AppUI->_('Trouble ticket assigned to you')."</title>\n";
$message .= "</head>\n";
$message .= "<body>\n";
$message .= "\n";
$message .= "<TABLE border=0 cellpadding=4 cellspacing=1>\n";
$message .= " <TR>\n";
$message .= " <TD valign=top><img src=$app_root/images/icons/ticketsmith.gif alt= border=0 width=42 height=42></td>\n";
$message .= " <TD nowrap><span class=title>".$AppUI->_('Trouble Ticket Management')."</span></td>\n";
$message .= " <TD valign=top align=right width=100%> </td>\n";
$message .= " </tr>\n";
$message .= "</TABLE>\n";
$message .= "<TABLE width=600 border=0 cellpadding=4 cellspacing=1 bgcolor=#878676>\n";
$message .= " <TR>\n";
$message .= " <TD colspan=2><font face=arial,san-serif size=2 color=white>".$AppUI->_('Ticket assigned to you')."</font></TD>\n";
$message .= " </tr>\n";
$message .= " <TR>\n";
$message .= " <TD bgcolor=white nowrap><font face=arial,san-serif size=2>".$AppUI->_('Ticket ID').":</font></TD>\n";
$message .= " <TD bgcolor=white nowrap><font face=arial,san-serif size=2>$ticket</font></TD>\n";
$message .= " </tr>\n";
$message .= " <TR>\n";
$message .= " <TD bgcolor=white><font face=arial,san-serif size=2>".$AppUI->_('Author').":</font></TD>\n";
$message .= " <TD bgcolor=white><font face=arial,san-serif size=2>" . str_replace(">", ">", str_replace("<", "<", str_replace('"', '', $author))) . "</font></TD>\n";
$message .= " </tr>\n";
$message .= " <TR>\n";
$message .= " <TD bgcolor=white><font face=arial,san-serif size=2>".$AppUI->_('Subject').":</font></TD>\n";
$message .= " <TD bgcolor=white><font face=arial,san-serif size=2>$subject</font></TD>\n";
$message .= " </tr>\n";
$message .= " <TR>\n";
$message .= " <TD bgcolor=white nowrap><font face=arial,san-serif size=2>".$AppUI->_('View').":</font></TD>\n";
$message .= " <TD bgcolor=white nowrap><a href=\"$app_root/index.php?m=ticketsmith&a=view&ticket=$ticket\"><font face=arial,sans-serif size=2>$app_root/index.php?m=ticketsmith&a=view&ticket=$ticket</font></a></TD>\n";
$message .= " </tr>\n";
$message .= "</TABLE>\n";
$message .= "</body>\n";
$message .= "</html>\n";
$message .= "\n--$boundary--\n";
mail($mailinfo["user_email"], $AppUI->_('Trouble ticket')." #$ticket ".$AppUI->_('has been assigned to you'), $message, "From: " . $CONFIG['reply_to'] . "\nContent-type: multipart/alternative; boundary=\"$boundary\"\nMime-Version: 1.0");
} // End of check for valid email
} // End of check for toggle of assignee
} // End of check for change in header fields
/* start table */
?>
<table class="std" cellspacing="2" cellpadding="3" border="0" width="100%">
<tr>
<th colspan="2" align="center"><?php echo $title;?></th>
</tr>
<form name="ticketform" action="index.php?m=ticketsmith&a=view&ticket=<?php echo $ticket;?>" method="post">
<input type="hidden" name="ticket" value="$ticket" />
<?php
/* start form */
/* get ticket */
$ticket_info = query2hash("SELECT * FROM tickets WHERE ticket = $ticket");
print("<input type=\"hidden\" name=\"orig_assignment\" value='" . $ticket_info["assignment"] . "' />\n");
print("<input type=\"hidden\" name=\"author\" value='" . $ticket_info["author"] . "' />\n");
print("<input type=\"hidden\" name=\"priority\" value='" . $ticket_info["priority"] . "' />\n");
print("<input type=\"hidden\" name=\"subject\" value='" . $ticket_info["subject"] . "' />\n");
/* output ticket */
for ($loop = 0; $loop < count($fields["headings"]); $loop++) {
print("<tr>\n");
if ( $fields["headings"][$loop] !== "<br />") {
$fields["headings"][$loop] = $AppUI->_($fields["headings"][$loop]);
}
print("<td align=\"right\">" . $fields["headings"][$loop] . "</td>");
print("<td align=\"left\" class=\"hilite\">" . format_field($ticket_info[$fields["columns"][$loop]], $fields["types"][$loop]) . "</td>\n");
print("</tr>\n");
}
$ticket_info["assignment"];
/* output attachment indicator */
$attach_count = query2result("SELECT attachment FROM tickets WHERE ticket = '$ticket'");
if ($attach_count == 1) {
print("<tr>\n");
print("<td align=\"left\"><strong>Attachments</strong></td>");
print("<td align=\"left\">This email had attachments which were removed.</td>\n");
print("</tr>\n");
} else if ($attach_count == 2) {
$result = do_query("SELECT file_id, file_name from files, tickets where ticket = '$ticket'
and file_task = ticket and file_project = 0");
if (number_rows($result)) {
print("<tr>\n");
print("<td align=\"left\"><b>Attachments</b></td>");
print("<td align=\"left\">");
while ($row = result2hash($result)) {
echo "<a href='fileviewer.php?file_id=" . $row["file_id"] . "'>";
echo $row["file_name"];
echo "</a><br>\n";
}
print("</td>\n");
print("</tr>\n");
}
}
/* output followup navigation */
if ($ticket_type != "Staff Followup" && $ticket_type != "Client Followup" && $ticket_type != "Staff Comment") {
/* output followups */
print("<tr>\n");
print("<td align=\"left\" valign=\"top\"><strong>".$AppUI->_('Followups')."</strong></td>\n");
print("<td align=\"left\" valign=\"top\">\n");
/* grab followups */
$query = "SELECT ticket, type, timestamp, author, body FROM tickets WHERE parent = '$ticket' ORDER BY ticket " . $CONFIG["followup_order"];
$result = do_query($query);
if (($num_followups = number_rows($result))) {
/* print followups */
print("<table width=\"100%\" border=\"1\" cellspacing=\"5\" cellpadding=\"5\">\n");
while ($row = result2hash($result)) {
/* determine row color */
$color = (@$number++ % 2 == 0) ? "#d3dce3" : "#dddddd";
/* start row */
print("<tr>\n");
/* do number/author */
print("<td bgcolor=\"$color\">\n");
print("<strong>$number</strong> : \n");
$row["author"] = ereg_replace("\"", "", $row["author"]);
$row["author"] = htmlspecialchars($row["author"]);
print($row["author"] . "\n");
print("</td>\n");
/* do type */
print("<td bgcolor=\"$color\"><a href=\"index.php?m=ticketsmith&a=view&ticket=" . $row["ticket"] . "\">" . $AppUI->_($row["type"]) . "</a></td>\n");
/* do timestamp */
print("<td bgcolor=\"$color\">\n");
print(get_time_ago($row["timestamp"]));
print("</td>\n");
/* end row */
print("</tr>\n");
if ($num_followups < 5)
{
print("<tr>\n");
/* show body/comments */
print("<td colspan=\"3\" bgcolor=\"$color\">\n");
print(stripslashes($row["body"] . "\n"));
print("</td>\n");
/* end row */
print("</tr>\n");
}
}
print("</table>\n");
}
else {
print("<em>".$AppUI->_('none')."</em>\n");
}
print("</td>\n</tr>\n");
}
else {
/* get peer followups */
$results = do_query("SELECT ticket, type FROM tickets WHERE parent = '$ticket_parent' ORDER BY ticket " . $CONFIG["followup_order"]);
/* parse followups */
while ($row = result2hash($results)) {
$peer_tickets[] = $row["ticket"];
}
/* count peers */
$peer_count = count($peer_tickets);
if ($peer_count > 1) {
/* start row */
print("<tr>\n");
print("<td><strong>". $AppUI->_('Followups') . "</strong></td>\n");
/* start cell */
print("<td valign=\"middle\">");
/* form peer links */
for ($loop = 0; $loop < $peer_count; $loop++) {
if ($peer_tickets[$loop] == $ticket) {
$viewed_peer = $loop;
$peer_strings[$loop] = "<strong>" . ($loop + 1) . "</strong>";
}
else {
$peer_strings[$loop] = "<a href=\"index.php?m=ticketsmith&a=view&ticket=$peer_tickets[$loop]\">" . ($loop + 1) . "</a>";
}
}
/* previous navigator */
if ($viewed_peer > 0) {
print("<a href=\"index.php?m=ticketsmith&a=view&ticket=" . $peer_tickets[$viewed_peer - 1] . "\">");
print($CONFIG["followup_order"] == "ASC" ? $AppUI->_("older") : $AppUI->_("newer"));
print("</a> | ");
}
/* ticket list */
print(join(" | ", $peer_strings));
/* next navigator */
if ($peer_count - $viewed_peer > 1) {
print(" | <a href=\"index.php?m=ticketsmith&a=view&ticket=" . $peer_tickets[$viewed_peer + 1] . "\">");
print($CONFIG["followup_order"] == "ASC" ? "newer" : "older");
print("</a>");
}
/* end cell */
print("</td>\n");
/* end row */
print("</tr>\n");
}
}
/* output action links */
print("<tr>\n");
print("<td><br /></td>\n");
print("<td>\n");
print("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n");
if ($ticket_type == "Staff Followup" || $ticket_type == "Client Followup" || $ticket_type == "Staff Comment") {
if ($canEdit) {
print("<tr><td align=\"left\"><a href=index.php?m=ticketsmith&a=followup&ticket=$ticket>".$AppUI->_("Post followup (emails client)")."</a> | ");
print("<a href=index.php?m=ticketsmith&a=comment&ticket=$ticket>".$AppUI->_('Post internal comment')."</a> | ");
print("<a href=index.php?m=ticketsmith&a=view&ticket=$ticket_parent>".$AppUI->_('Return to parent')."</a> | ");
}
else {
print("<tr><td align=\"left\"><a href=index.php?m=ticketsmith&a=view&ticket=$ticket_parent>".$AppUI->_('Return to parent')."</a>");
}
}
else {
if ($canEdit) {
print("<tr><td align=\"left\"><a href=index.php?m=ticketsmith&a=followup&ticket=$ticket>".$AppUI->_("Post followup (emails client)")."</a> | ");
print("<a href=index.php?m=ticketsmith&a=comment&ticket=$ticket>".$AppUI->_('Post internal comment')."</a> | ");
}
}
print("</td>");
print('<td align="right"><a href="index.php?m=ticketsmith&a=view&ticket='.$ticket.'">'.$AppUI->_('Back to top').'</a></td></tr>');
print("</table>\n");
print("</td>");
print("</tr>\n");
/* end table */
print("</table>\n");
/* end form */
print("</form>\n");
?>