📄 ticketsearch.php
字号:
// results search
$query = "
SELECT id
FROM ticket
WHERE id = id
$reply_search
$where
";
$db->query($query);
$total = $db->num_rows();
while ($result = $db->row_array()) {
if (!$first) {
$first = $result['id'];
}
// we only want to save 500 tickets here
if ($y < 500) {
$linkcode .= $result[id] . ",";
$y++;
}
}
if ($y) {
$db->query("INSERT INTO search SET
query = '" . mysql_escape_string($query) . "',
results = '".mysql_escape_string($linkcode)."',
time = '".mktime()."',
techid = '$user[id]',
total = '$total'
");
$searchid = $db->last_id();
}
if ($_REQUEST['Jump'] AND $y) {
if ($_REQUEST['ticketid']) {
$first = $_REQUEST['ticketid'];
}
echo "<SCRIPT LANGUAGE=\"JavaScript\">top.center.location.href=\"load_results.php?id=$first&searchid=$searchid&num=0\";</SCRIPT>\n";
echo "<a href=\"load_results.php?id=$first&searchid=$searchid&num=0\">Click here to proceed to the ticket list if you aren't automatically directed.</a>";
exit;
}
/*******************************************************
PART 5.5: SOME PROCESSING IF THERE IS A RESULT
*******************************************************/
if ($y) { // we have results
if (!$_REQUEST['sortby']) {
$_REQUEST['sortby'] = 'category';
}
// build quick reply
$db->query("SELECT quickreply.id, quickreply.name, quickreply_cat.name AS catname FROM quickreply
LEFT JOIN quickreply_cat ON (quickreply_cat.id = quickreply.category)
WHERE quickreply.techid = '$user[id]' OR quickreply_cat.global
ORDER BY $_REQUEST[sortby]
");
while ($result = $db->row_array()) {
if (!$result[catname]) {
$result[catname] = addslashes_js($result[catname]);
$html .= "new Array(true,'quickreply|Pick Message','0|UNCATEGORIZED'),\n";
}
if ($result[catname] != $lastcatname) {
$result[catname] = addslashes_js($result[catname]);
$html .= "new Array(true,'quickreply|Pick Message','0|CATEGORY: $result[catname]'),\n";
}
$result[name] = addslashes_js($result[name]);
$html .= "new Array(true,'quickreply|Pick Message','$result[id]|- $result[name]'),\n";
$lastcatname = $result[catname];
}
// build javascript for drop down menus
echo get_javascript('dropdown.js');
?>
<SCRIPT language=JavaScript type=text/javascript>
var Arr = new Array(
new Array("form","OPT","SO"),
<?php echo $html; ?>
new Array(true,"close|Close Ticket","1|Email User"),
new Array(true,"close|Close Ticket","2|Do not email user"),
new Array(true,"awaiting_tech|Set as awaiting a tech response",""),
new Array(true,"awaiting_user|Set as awaiting a user response",""),
new Array(true,"open|Open Ticket",""),
new Array(true,"selectone|Select One",""),
new Array(false,"delete|Delete",""),
new Array(false,"nuke|Nuke",""),
new Array(false,"spam|Spam",""),
new Array(false,"nospam|Not Spam","")
);
</SCRIPT>
<?
}
/*******************************************************
PART 6: LOOP THROUGH TICKETS (1. COLUMNS)
*******************************************************/
$user_fields = $db->query_return("
SELECT * FROM user_def WHERE tech_viewable ORDER by displayorder DESC
");
if (is_array($user_fields)) {
foreach ($user_fields AS $val) {
$val['disp_name'] = unserialize($val[display_name]);
}
}
$db->query($select . $reply_search . $where . $limit);
$this_total = $db->num_rows();
$i=0;
while ($ticket = $db->row_array()) {
$ticket_array[$i] = $ticket[id];
// awaiting tech / user
if (in_array('awaitingtu', $fields['default'])) {
if ($ticket[awaiting_tech] == 1) {
$table[$i][] = "<b>Tech</b>";
} else {
$table[$i][] = "User</b>";
}
}
// open / closed
if (in_array('openclosed', $fields['default'])) {
if ($ticket[is_open] == 1) {
$table[$i][] = "<b>Open</b>";
} else {
$table[$i][] = "Closed";
}
}
// priority
if (in_array('priority', $fields['default'])) {
if ($ticket[priname] == "") {
$table[$i][] = "<i>none</i>";
} else {
$table[$i][] = $ticket[priname];
}
}
// category
if (in_array('category', $fields['default'])) {
if ($ticket[catname] == "") {
$table[$i][] = "<i>none</i>";
} else {
$table[$i][] = $ticket[catname];
}
}
if (in_array('email', $fields['default'])) {
$table[$i][] = "<a href=\"../users/view.php?id=$ticket[userid]&do=view\">$ticket[username]</a>";
}
if (in_array('techowner', $fields['default'])) {
if ($ticket[techname] != "") {
$table[$i][] = $ticket[techname];
} else {
$table[$i][] = "<i>Unassigned</i>";
}
}
$ticket[since_started] = mktime() - $ticket[date_opened];
$ticket[date_opened] = our_date($ticket[date_opened]);
if (in_array('timestart', $fields['default'])) {
$table[$i][] = display_time($ticket[since_started]) . ' ' . html_image('bul042.gif', "Opened: $ticket[date_opened]");
}
if (in_array('timetech', $fields['default'])) {
if ($ticket[date_lastreply] != "0") {
if (!$ticket[date_awaiting_toggled]) {
$ticket[date_awaiting_toggled] = $ticket[date_lastreply];
}
$ticket[since_reply] = mktime() - $ticket[date_awaiting_toggled];
$ticket[date_lastreply] = "Last replied: " . our_date($ticket[date_lastreply], 'Full');
$table[$i][] = display_time($ticket[since_reply]) . html_image('bul042.gif', $ticket['date_lastreply']);
} else {
$table[$i][] = "No replies";
}
}
$num = $start + $i;
// show custom fields selected to view
if (is_array($showfield)) {
foreach ($showfield AS $key => $var) {
$table[$i][] = field_display($tfields[$var], $ticket[$var], 1);
}
}
// parse admin options
if (is_array($admincols)) {
foreach ($admincols AS $key => $var) {
eval("\$table[$i][] = \"" . addslashes($var) . "\";");
}
}
/*******************************************************
PART 7: LOOP THROUGH TICKETS (2.ICONS, SUBJECT AND ACTIONS)
*******************************************************/
/******
* ICONS
******/
// awaiting reply
if ($ticket['awaiting_tech'] == "1") {
$icons = html_image('tech/bul095.gif', 'Awaiting tech reply');
} else {
$icons = html_image('tech/bul096.gif', 'Awaiting user reply');
}
$icons .= ' ';
// locked
if ($ticket[is_open] == "0") {
$icons .= html_image('tech/bul097.gif', 'Closed');
}
// attachments
if ($ticket[attachments] > "0") {
$icons .= ' ';
if ($ticket[attachments] == "1") {
$icons .= html_image('tech/bul099.gif', "$ticket[attachments] attachment");
} else {
$icons .= html_image('tech/bul099.gif', "$ticket[attachments] attachments");
}
}
if ($ticket['nodisplay'] == 1) {
$icons .= '[spam]';
}
if (!$ticket['subject']) {
$ticket['subject'] = 'No subject';
}
/******
* SUBJECT
******/
$subject_icons = "<table width=\"100%\"><tr valign=\"top\"><td width=\"45\">$icons</td><td valign=\"top\"><b>ID:</b> <a href=\"load_results.php?id=$ticket[id]&searchid=$searchid&num=$num\">$ticket[id]</a> <b>REF:</b> <a href=\"load_results.php?id=$ticket[id]&searchid=$searchid&num=$num\">$ticket[ref]</a> <b>Subject:</b> <a href=\"load_results.php?id=$ticket[id]&searchid=$searchid&num=$num\">$ticket[subject]</a></td><td align=\"right\">";
unset($icons);
/******
* TICKET OPTIONS
******/
// create ticket dos
$extra[$i] .= "<table><tr valign=\"top\"><td>
<select onchange=\"update(this,Arr,$ticket[id])\" size=\"1\" name=\"OPT$ticket[id]\">\n
<option value=\"selectone\" selected>===== Select one =====</option>\n";
// delete ticket
if (p_ticket('delete')) {
$extra[$i] .= "<option value=\"delete\">Delete ticket</option>\n";
}
if (p_ticket('delete') AND ($user['p_delete_users'] OR $user['admin'])) {
$extra[$i] .= "<option value=\"nuke\">Delete Ticket, Delete User, and Ban E-mail</option>\n";
}
// assign ticket to another tech
if (p_ticket('edit')) {
$extra[$i] .= "<option value=\"tech\">Assign to tech</option>\n";
$has_option = 1;
}
// mark ticket completed
if (p_ticket('close') AND $ticket[is_open] == '1') {
$extra[$i] .= "<option value=\"close\">Close Ticket</option>\n";
$has_option = 1;
}
// mark ticket as in progress
if (p_ticket('close') AND $ticket[is_open] == '0') {
$extra[$i] .= "<option value=\"open\">Open Ticket</option>\n";
$has_option = 1;
}
// mark ticket awaiting a user response
if (p_ticket('edit') AND $ticket['awaiting_tech'] == '1') {
$extra[$i] .= "<option value=\"awaiting_user\">Set as awaiting a user response</option>\n";
$has_option = 1;
}
// mark ticket awaiting a tech response
if (p_ticket('edit') AND $ticket['awaiting_tech'] == '0') {
$extra[$i] .= "<option value=\"awaiting_tech\">Set as awaiting a tech response</option>\n";
$has_option = 1;
}
// quick replies
if (p_ticket('edit')) {
$extra[$i] .= "<option value=\"quickreply\">Reply with quick reply</option>\n";
$has_option = 1;
}
// edit priority / category
if (p_ticket('edit')) {
$extra[$i] .= "<option value=\"priority\">Change priority</option><option value=\"category\">Change category</option>\n";
$has_option = 1;
}
if (p_ticket('edit') AND $ticket['nodisplay']) {
$extra[$i] .= "<option value=\"nospam\">Remove \"Spam\" flag from this ticket</option>\n";
$has_option = 1;
}
if (p_ticket('edit') AND !$ticket['nodisplay']) {
$extra[$i] .= "<option value=\"spam\">Set \"Spam\" flag for this ticket</option>\n";
$has_option = 1;
}
if ($has_option) {
$extra[$i] .= "</select></td><td>
<div id=\"Layer$ticket[id]\" style=\"visibility: hidden\">
<select onchange=\"update(this,Arr,$ticket[id]);\" size=\"1\" name=\"SO$ticket[id]\">
<option selected>Sub OPT</option>
</select>
</div></td><td>" . thelp('Tickets - Searching', 'Search Results') . "</td>
</tr></table></td></tr></table>";
unset($has_option);
} else {
$extra[$i] = '</td></tr></table>';
}
if ($noact) {
$extra[$i] = $subject_icons . '</td></tr></table>';
} else {
$extra[$i] = $subject_icons . $extra[$i];
}
$i++;
}
/*******************************************************
PART 8: LOOP THROUGH TICKETS (3. 1st MESSAGE)
*******************************************************/
$i = 0;
$db->query("SELECT id, message, ticketid
FROM ticket_message
WHERE ticketid IN " . array2sql($ticket_array, '0') . "
GROUP BY ticketid
ORDER BY date DESC
");
while ($result = $db->row_array()) {
$message_log[$result[ticketid]] = "
<table width=\"100%\" class=\"table_midheader\"><tr><td><b>Last Message:</b> " . trimstring(htmlspecialchars_uni($result[message]), 400, 1) . "</td></tr></table>";
}
if (is_array($ticket_array)) {
foreach ($ticket_array AS $key => $var) {
$extra2[$i] = iff($message_log[$var], $message_log[$var], ' ');
$i++;
}
}
/*******************************************************
PART 9: DISPLAY PAGE
*******************************************************/
if (is_array($table)) {
if ($total < $perpage) {
if ($total == 1) {
$message = "The following ticket matched your search criteria";
} else {
$message = "The following $total tickets matched your search criteria";
}
} else {
$pages = ceil($total / $perpage);
if ($page == 1) {
$t_start = 1;
} else {
$t_start = $perpage * ($page - 1) + 1;
}
$t_end = ($perpage * ($page -1)) + $this_total;
$message = "$total tickets matched your search criteria. Showing page $page of $pages / Showing tickets $t_start to $t_end";
}
table_header("$message [ <a href=./../settings/ticketdisplay.php?saved_search=$searchid>edit column display</a> ]", 'ticketactions.php', array('searchtype' => iff($_REQUEST['searchtype'], $_REQUEST['searchtype'], 'simple'), 'do' => 'process', 'variables' => serialize($_REQUEST)), '', 'form', '', 'onsubmit="return ValidateSelection()"');
table_content($columns, $table, $extra, '', '', $extra2);
table_footer('Process Tickets');
////////////////////////// BUILD NEXT AND PREV LINKS //////////////////////////
$variables = serialize($_REQUEST);
echo "<form action=\"ticketsearch.php\" method=\"post\" name=\"frm\">";
echo form_hidden('variables', $variables) . form_hidden('do', 'search');
echo pagenav($total, $perpage, $page, '', 'frm', 'select', 'page');
echo "<span id=\"hiddenbit\"></span></form>";
////////////////////////// BUILD KEY //////////////////////////
} else {
echo "<b><center>No tickets matched the specified criteria</center></b>";
}
}
tech_footer();
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -