⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 footer_tickets.php

📁 本代码是为客户联系管理而做的系统
💻 PHP
字号:
<?php
// +-------------------------------------------------------------+
// | DeskPRO v [2.0.1 Production]
// | Copyright (C) 2001 - 2004 Headstart Solutions Limited
// | Supplied by WTN-WDYL
// | Nullified by WTN-WDYL
// | Distribution via WebForum, ForumRU and associated file dumps
// +-------------------------------------------------------------+
// | DESKPRO IS NOT FREE SOFTWARE
// +-------------------------------------------------------------+
// | License ID : Full Enterprise License =) ...
// | License Owner : WTN-WDYL Team
// +-------------------------------------------------------------+
// | $RCSfile: footer_tickets.php,v $
// | $Date: 2004/02/10 01:34:28 $
// | $Revision: 1.71 $
// +-------------------------------------------------------------+
// | File Details:
// | - Ticket result set navigation footer.
// +-------------------------------------------------------------+

error_reporting(E_ALL ^ E_NOTICE);
// start file
require("./../global.php");
reload_index_nourl();

// globalise variables
$global = array	(
			array('searchid'),			// the searchid
			array('id'),				// ticketid
			array('num', 'number')		// number of ticket in search results
);
rg($global);

/*
	If we need to make the searchid first:
*/

if ($_REQUEST['frontaction'] == 'own_ticket') {

	$db->query("
		SELECT id FROM ticket 
		WHERE tech = '$user[id]'
			AND is_open
			AND awaiting_tech 
			AND !nodisplay 
		ORDER BY date_lastreply_user
		LIMIT 100
	");

	$total = $db->num_rows();
	
	$num = -1;
	while ($result = $db->row_array()) {
		if (!$stopcounting) {
			$num++;
		}
		if ($result['id'] == $_REQUEST['ticketid']) {
			$stopcounting = true;
		}
		$searchresults .= $result[id] . ',';
	}
	
	// $searchresults = substr($searchresults, 0, -1);
	
	$db->query("
		INSERT INTO search SET
		query = 'something',
		results = '$searchresults',
		time = '" . mktime() . "',
		techid = '$user[id]',
		total = '$total'
	");

	$searchid = $db->last_id();

}

// if we have a searchid, we need to get the results
if ($searchid) {
	$searchresults = $db->query_return("SELECT results FROM search WHERE id = '$searchid'");
	$searchresults = $searchresults['results'];
}

// get previous searches
$db->query("
	SELECT id, results, time, total 
	FROM search 
	WHERE techid = '$user[id]' 
	ORDER BY time DESC 
	LIMIT 0,30
");

while ($s = $db->row_array()) {

	// if we had no searchid, we need to get last one searched from
	if (!$searchid) {
		$searchid = $s['id'];
		$searchresults = $s['results'];
	}

	// now generate select links to navigate to other search results
	$s['time'] = mktime() - $s['time'];
	$search[$s['id']] = display_time($s[time]) . " ago (" . $s['total'] . " tickets)";
}

// we now have a search match, either directed to one or the last search to be run
// the ticket matches into an array
$ids = split(',',$searchresults);
asort($ids);

// clean for query
$searchresults = substr($searchresults, 0, -1);
if (!$searchresults) {
	$searchresults = 0;
}

// get titles for search results
$db->query("SELECT id, subject FROM ticket WHERE id IN ($searchresults) ORDER BY id");
while ($subject = $db->row_array()) {
	$subject['subject'] = trimstring($subject['subject'], 30);
	$subjects[$subject['id']] = $subject['subject'] . " (#$subject[id])";
}

// display javascript for jumping through this
$tmp = 0;
echo "<html><head><title></title><script language=\"javascript\">\n";
if (count($ids)) {
	echo 'var idArray = new Array('.(count($ids) - 1).");\n";
} else {
	echo "var idArray = new Array(0);\n";
}

foreach ($ids AS $key => $val) {
	if ($ids[$tmp]) {
		echo "idArray[$tmp] = ".$ids[$tmp].";\n";
		if ($ids[$tmp] == $id) {
			$num = $tmp;
		}
	}
	$tmp++;
}
if (!$num) { 
	$num = 0; 
}
echo "var current = $num;\n";

?>

var prev = -1;
var next = -1;
var now;
var go;
var advance2;
var searchid;
var e;

function advance() { 
	if (current < idArray.length - 1) {
		prev = current;
		top.center.location.href='../tickets/ticketview.php?id=' + idArray[++current] + '&searchid=' + searchid + '&num=' + (current + 1);
		now = current + 1;
		showcurrent("<?php echo $showing_saved; ?>Ticket <b><a class='selector' href='./../tickets/ticketview.php?id=" + idArray[current] + "' target='center'>" + now + "</b></a> of <B>" + idArray.length + "</B>");
		showticket(idArray[current]);
		next = current;
	}
	current == 0 ? doPrev(false) : doPrev(true)
	current >= (idArray.length - 1) ? doNext(false) : doNext(true)
} 

function back() {
	if (current >= 0) {
		next = current;
		top.center.location.href='../tickets/ticketview.php?id=' + idArray[--current] + '&searchid=' + searchid + '&num=' + (current + 1);
		prev = current - 1;
		now = current + 1;
		showcurrent("<?php echo $showing_saved; ?>Ticket <b><a class='selector' href='./../tickets/ticketview.php?id=" + idArray[current] + "' target='center'>" + now + "</b></a> of <b>" + idArray.length + "</b>");
		showticket(idArray[current]);
	}
	current == 0 ? doPrev(false) : doPrev(true)
	current >= (idArray.length - 1) ? doNext(false) : doNext(true)
}

function showcurrent(str){
	document.getElementById("currentPage").innerHTML=str;
}

function showticket(current) {
	list = document.forms.jumpform.ticketjump;
	for (i=0;i<list.options.length;i++) {
		if (list.options[i].value==current) {
			list.selectedIndex = i;
		} 
	}
}

function doNext(bool) {
	bool ? document.getElementById("next").style.display ="block" : document.getElementById("next").style.display ="none"
}

function doPrev(bool) {
	bool ? document.getElementById("prev").style.display ="block" : document.getElementById("prev").style.display ="none"
}

function doPrev2(bool) {
	bool ? document.getElementById("prev2").style.display ="block" : document.getElementById("prev2").style.display ="none"
}

function doNext2(bool) {
	bool ? document.getElementById("next2").style.display ="block" : document.getElementById("next2").style.display ="none"
}

function init() { 
	var temp;
	searchid = <? if ($searchid) { echo $searchid; } else { echo 0; } ?>;
	temp = current + 1;
	if (idArray.length == 0) { return; }
	document.getElementById("currentPage").innerHTML=" <? echo $showing_saved; ?>Ticket <b><a class='selector' href='./../tickets/ticketview.php?id=" + idArray[current] + "' target='center'>" + temp + "</b></a> of <b>" + idArray.length + "</b>";
	idArray.length > 1 ? next = idArray[1] : next = -1;
	current == 0 ? doPrev(false) : doPrev(true)
	current >= (idArray.length - 1) ? doNext(false) : doNext(true)
	showticket(idArray[current]);
}
	  
<?

echo " </script></head>";

footer_html("init()", $searchid);

echo "<table cellpadding=\"3\" cellspacing=\"0\" width=\"100%\"><tr><td valign=\"top\">";

if (count($subjects)) {
	$ticketlist = form_select('ticketjump', $subjects, NULL, iff($id, $id, NULL), NULL, NULL, NULL, "style='width:250px'");
} else {
	$ticketlist = "(no tickets)";
}

?>

	<table width="285" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><table width="285" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="19" align="center" bgcolor="#BF4343">
					  <img src="./../../images/tech/bul041.gif" width="13" height="14" hspace="3" vspace="2" border="0"></td>
                      <td width="65" align="center" bgcolor="#A4A4A4" class="txt012"><strong><span id="prev" style="display:none"><a href="#" class="selector"  onClick="back()">previous</a></strong></td>
					<td width="" nowrap bgcolor="#727272" class="selector" align="center"><span id="currentPage"></span></td>
                      <td width="61" align="center" bgcolor="#A4A4A4" class="txt012"><strong><span id="next" style="display:none"><a href="#" class="selector" onClick="advance()">next</a></strong></td>
                      <td width="19" align="center" bgcolor="#BF4343"><img src="./../../images/tech/bul040.gif" width="13" height="14" hspace="3" vspace="2" border="0"></td></span>
                    </tr>
                  </table></td>
              </tr>
              <tr>
                <td align="center"> 
                  
                    <table border="0" cellspacing="5" cellpadding="0">
                      <form action="footer_tickets.php" method="post" id="jumpform" name="jumpform"><tr>
                        <td class="txt010"><?php echo $ticketlist?></td>
                        <td>
						<a href="javascript:jumpToTicket(document.forms.jumpform)"><img src="./../../images/tech/but035.gif" alt="Go" width="26" height="18" border="0" ></a></td>
                      </tr></form>
                    </table>
                </td>
              </tr>
            </table></td>

<?	

$db->query("SELECT id, save_name FROM tech_ticket_search WHERE save_type = \"search\" AND techid = '$user[id]' ORDER BY save_name");
$saved_searches = array();
while ($saves = $db->row_array()) {
	$saved_searches[$saves['id']] = $saves['save_name'];
}

if (count($saved_searches)) {
	$saved_select = form_select('saved_search', $saved_searches, NULL, NULL, NULL, NULL, NULL, "style='width:250px'");
	$saved_select_submit = form_submit('Go', 'submit', NULL, '../../images/tech/but035.gif');
} else {
	$saved_select = 'None (<A HREF="../tickets/ticketsearch.php?searchtype=advanced" TARGET="center">Create New Search</A>)';
	$saved_select_submit = NULL;
}

if (count($search)) {
	$search = form_select('searchid', $search, NULL, NULL, NULL, NULL, NULL, "style='width:250px'");
	$search_submit = form_submit('Go', 'submit2', NULL, '../../images/tech/but035.gif');
} else {
	$search = 'None (<A HREF="../tickets/ticketsearch.php?searchtype=advanced" TARGET="center">Run a New Search</A>)';
	$search_submit = NULL;
}

$cats = $db->query_return("SELECT categories FROM tech_folders WHERE techid = '$user[id]'");
$cats = unserialize($cats['categories']);
$cats[0] = "Top Level";
$saved = $db->query("
	SELECT ticket.id AS id, 
		ticket.subject AS subject, 
		tech_ticket_save.category AS category 
	FROM tech_ticket_save, 
		ticket 
	WHERE tech_ticket_save.ticketid = ticket.id 
	ORDER BY category, ticket.id
");

while ($saves = $db->row_array()) {
	$saved_tickets[$saves['id']] = $saves['subject'] . ' [' . $cats[$saves['category']] . ']';
}

if (count($saved_tickets)) {
	$saved_tickets = form_select('ticket_id', $saved_tickets, NULL, NULL, NULL, NULL, NULL, "style='width:250px'");
	$saved_tickets_submit = form_submit('Go', 'submit3', NULL, '../../images/tech/but035.gif');
} else {
	$saved_tickets = 'None';
	$saved_tickets_submit = NULL;
}

echo "<td align=\"right\" valign=\"top\">";

$jump_table = "
<table cellpadding=\"1\" cellspacing=\"2\">
<form method=\"post\" target=\"center\" action=\"./../tickets/ticketsearch.php\">
<input type=\"hidden\" name=\"save_search_op\" value=\"Run\">
<tr><td><b>Saved Searches</b></td>
<td>$saved_select</td><td>$saved_select_submit</td></tr>
</form>
<form method=\"post\" action=\"footer_tickets.php\">
<tr>
<td><b>Previous Searches</b></td>
<td>$search</td><td>$search_submit</td></tr>
<tr></td>
<td><b>Saved Tickets</b></td>
<td>$saved_tickets</td><td>$saved_tickets_submit</td></tr>
</form>

</table>";

fancy_table('100%', 'Run Previous & Saved Searches', $jump_table);

if ($_REQUEST['submit']) {
	$loc = "../tickets/ticketsearch.php?saved_search=$_REQUEST[saved_id]&save_search_op=Run"; 
} 

if ($_REQUEST['submit2']) {
	$loc = "../tickets/load_results.php?id=$ids[0]&searchid=$_REQUEST[run_searchid]";

}

if ($_REQUEST['submit3']) {
	$loc = "../tickets/ticketview.php?id=$_REQUEST[ticket_id]";
}

if ($loc) { ?>
<SCRIPT LANGUAGE="JavaScript">
	top.center.location = "<? echo $loc; ?>";
</SCRIPT>

<?php 
}

?>

<SCRIPT LANGUAGE="JavaScript">
function jumpToTicket(form) {

	if (typeof(form.ticketjump) == 'undefined') return 0;

	var idx=form.ticketjump.selectedIndex;
	top.center.location = "../tickets/ticketview.php?id=" + form.ticketjump.options[idx].value;
	current = idx;
	tmp = current + 1;
	prev = current - 1;
	next = current + 1;
	showcurrent("<?php echo $showing_saved; ?>Ticket <B>" + tmp + "</B> of <B>" + idArray.length + "</B>");
	current == 0 ? doPrev(false) : doPrev(true)
	current >= (idArray.length - 1) ? doNext(false) : doNext(true)
}
</SCRIPT>

<?php

if ($_REQUEST['advance']) {

?>
<SCRIPT LANGUAGE="JavaScript">
jumpToTicket(document.getElementById('form'));
</SCRIPT>
<?php
}

if ($id) {
	?>
<SCRIPT LANGUAGE="JavaScript">
showticket(<?php echo($id); ?>);
</SCRIPT>
<?php
}

?>

</body>
</html>


<?php


$folders = $db->query_return("
	SELECT * FROM tech_folders 
	WHERE techid = '$user[id]'
	AND type = 'savedtickets'
");

$folders = unserialize($folders['categories']);
$folders[0] = 'No Folder';

$db->query("
	SELECT ticketid, category 
	FROM tech_ticket_save 
	WHERE techid = '$user[id]'
	ORDER BY category
");
	
$ids = array();
while ($res = $db->row_array()) {
	$ids[] = $res['ticketid'];
	$cats[$res['ticketid']] = $folders[$res['category']];
}
$searchresults = join(',',$ids) . " ";
$num = 0;
$searchresults = 0;

// get titles for search results
$db->query("SELECT id, subject FROM ticket WHERE id IN ($searchresults) ORDER BY id");
while ($saved = $db->row_array()) {
	$saved['subject'] = trimstring($saved['subject'], 30);
	$saved[$saved['id']] = $saved['subject'] . " (#$subject[id])";
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -