footer_tickets.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:13k
源码类别:

电子政务应用

开发平台:

Java

  1. <?php
  2. // +-------------------------------------------------------------+
  3. // | DeskPRO v [2.0.1 Production]
  4. // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
  5. // | Supplied by WTN-WDYL
  6. // | Nullified by WTN-WDYL
  7. // | Distribution via WebForum, ForumRU and associated file dumps
  8. // +-------------------------------------------------------------+
  9. // | DESKPRO IS NOT FREE SOFTWARE
  10. // +-------------------------------------------------------------+
  11. // | License ID : Full Enterprise License =) ...
  12. // | License Owner : WTN-WDYL Team
  13. // +-------------------------------------------------------------+
  14. // | $RCSfile: footer_tickets.php,v $
  15. // | $Date: 2004/02/10 01:34:28 $
  16. // | $Revision: 1.71 $
  17. // +-------------------------------------------------------------+
  18. // | File Details:
  19. // | - Ticket result set navigation footer.
  20. // +-------------------------------------------------------------+
  21. error_reporting(E_ALL ^ E_NOTICE);
  22. // start file
  23. require("./../global.php");
  24. reload_index_nourl();
  25. // globalise variables
  26. $global = array (
  27. array('searchid'), // the searchid
  28. array('id'), // ticketid
  29. array('num', 'number') // number of ticket in search results
  30. );
  31. rg($global);
  32. /*
  33. If we need to make the searchid first:
  34. */
  35. if ($_REQUEST['frontaction'] == 'own_ticket') {
  36. $db->query("
  37. SELECT id FROM ticket 
  38. WHERE tech = '$user[id]'
  39. AND is_open
  40. AND awaiting_tech 
  41. AND !nodisplay 
  42. ORDER BY date_lastreply_user
  43. LIMIT 100
  44. ");
  45. $total = $db->num_rows();
  46. $num = -1;
  47. while ($result = $db->row_array()) {
  48. if (!$stopcounting) {
  49. $num++;
  50. }
  51. if ($result['id'] == $_REQUEST['ticketid']) {
  52. $stopcounting = true;
  53. }
  54. $searchresults .= $result[id] . ',';
  55. }
  56. // $searchresults = substr($searchresults, 0, -1);
  57. $db->query("
  58. INSERT INTO search SET
  59. query = 'something',
  60. results = '$searchresults',
  61. time = '" . mktime() . "',
  62. techid = '$user[id]',
  63. total = '$total'
  64. ");
  65. $searchid = $db->last_id();
  66. }
  67. // if we have a searchid, we need to get the results
  68. if ($searchid) {
  69. $searchresults = $db->query_return("SELECT results FROM search WHERE id = '$searchid'");
  70. $searchresults = $searchresults['results'];
  71. }
  72. // get previous searches
  73. $db->query("
  74. SELECT id, results, time, total 
  75. FROM search 
  76. WHERE techid = '$user[id]' 
  77. ORDER BY time DESC 
  78. LIMIT 0,30
  79. ");
  80. while ($s = $db->row_array()) {
  81. // if we had no searchid, we need to get last one searched from
  82. if (!$searchid) {
  83. $searchid = $s['id'];
  84. $searchresults = $s['results'];
  85. }
  86. // now generate select links to navigate to other search results
  87. $s['time'] = mktime() - $s['time'];
  88. $search[$s['id']] = display_time($s[time]) . " ago (" . $s['total'] . " tickets)";
  89. }
  90. // we now have a search match, either directed to one or the last search to be run
  91. // the ticket matches into an array
  92. $ids = split(',',$searchresults);
  93. asort($ids);
  94. // clean for query
  95. $searchresults = substr($searchresults, 0, -1);
  96. if (!$searchresults) {
  97. $searchresults = 0;
  98. }
  99. // get titles for search results
  100. $db->query("SELECT id, subject FROM ticket WHERE id IN ($searchresults) ORDER BY id");
  101. while ($subject = $db->row_array()) {
  102. $subject['subject'] = trimstring($subject['subject'], 30);
  103. $subjects[$subject['id']] = $subject['subject'] . " (#$subject[id])";
  104. }
  105. // display javascript for jumping through this
  106. $tmp = 0;
  107. echo "<html><head><title></title><script language="javascript">n";
  108. if (count($ids)) {
  109. echo 'var idArray = new Array('.(count($ids) - 1).");n";
  110. } else {
  111. echo "var idArray = new Array(0);n";
  112. }
  113. foreach ($ids AS $key => $val) {
  114. if ($ids[$tmp]) {
  115. echo "idArray[$tmp] = ".$ids[$tmp].";n";
  116. if ($ids[$tmp] == $id) {
  117. $num = $tmp;
  118. }
  119. }
  120. $tmp++;
  121. }
  122. if (!$num) { 
  123. $num = 0; 
  124. }
  125. echo "var current = $num;n";
  126. ?>
  127. var prev = -1;
  128. var next = -1;
  129. var now;
  130. var go;
  131. var advance2;
  132. var searchid;
  133. var e;
  134. function advance() { 
  135. if (current < idArray.length - 1) {
  136. prev = current;
  137. top.center.location.href='../tickets/ticketview.php?id=' + idArray[++current] + '&searchid=' + searchid + '&num=' + (current + 1);
  138. now = current + 1;
  139. 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>");
  140. showticket(idArray[current]);
  141. next = current;
  142. }
  143. current == 0 ? doPrev(false) : doPrev(true)
  144. current >= (idArray.length - 1) ? doNext(false) : doNext(true)
  145. function back() {
  146. if (current >= 0) {
  147. next = current;
  148. top.center.location.href='../tickets/ticketview.php?id=' + idArray[--current] + '&searchid=' + searchid + '&num=' + (current + 1);
  149. prev = current - 1;
  150. now = current + 1;
  151. 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>");
  152. showticket(idArray[current]);
  153. }
  154. current == 0 ? doPrev(false) : doPrev(true)
  155. current >= (idArray.length - 1) ? doNext(false) : doNext(true)
  156. }
  157. function showcurrent(str){
  158. document.getElementById("currentPage").innerHTML=str;
  159. }
  160. function showticket(current) {
  161. list = document.forms.jumpform.ticketjump;
  162. for (i=0;i<list.options.length;i++) {
  163. if (list.options[i].value==current) {
  164. list.selectedIndex = i;
  165. }
  166. }
  167. function doNext(bool) {
  168. bool ? document.getElementById("next").style.display ="block" : document.getElementById("next").style.display ="none"
  169. }
  170. function doPrev(bool) {
  171. bool ? document.getElementById("prev").style.display ="block" : document.getElementById("prev").style.display ="none"
  172. }
  173. function doPrev2(bool) {
  174. bool ? document.getElementById("prev2").style.display ="block" : document.getElementById("prev2").style.display ="none"
  175. }
  176. function doNext2(bool) {
  177. bool ? document.getElementById("next2").style.display ="block" : document.getElementById("next2").style.display ="none"
  178. }
  179. function init() { 
  180. var temp;
  181. searchid = <? if ($searchid) { echo $searchid; } else { echo 0; } ?>;
  182. temp = current + 1;
  183. if (idArray.length == 0) { return; }
  184. 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>";
  185. idArray.length > 1 ? next = idArray[1] : next = -1;
  186. current == 0 ? doPrev(false) : doPrev(true)
  187. current >= (idArray.length - 1) ? doNext(false) : doNext(true)
  188. showticket(idArray[current]);
  189. }
  190.   
  191. <?
  192. echo " </script></head>";
  193. footer_html("init()", $searchid);
  194. echo "<table cellpadding="3" cellspacing="0" width="100%"><tr><td valign="top">";
  195. if (count($subjects)) {
  196. $ticketlist = form_select('ticketjump', $subjects, NULL, iff($id, $id, NULL), NULL, NULL, NULL, "style='width:250px'");
  197. } else {
  198. $ticketlist = "(no tickets)";
  199. }
  200. ?>
  201. <table width="285" border="0" cellspacing="0" cellpadding="0">
  202.               <tr>
  203.                 <td><table width="285" border="0" cellspacing="0" cellpadding="0">
  204.                     <tr>
  205.                       <td width="19" align="center" bgcolor="#BF4343">
  206.   <img src="./../../images/tech/bul041.gif" width="13" height="14" hspace="3" vspace="2" border="0"></td>
  207.                       <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>
  208. <td width="" nowrap bgcolor="#727272" class="selector" align="center"><span id="currentPage"></span></td>
  209.                       <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>
  210.                       <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>
  211.                     </tr>
  212.                   </table></td>
  213.               </tr>
  214.               <tr>
  215.                 <td align="center"> 
  216.                   
  217.                     <table border="0" cellspacing="5" cellpadding="0">
  218.                       <form action="footer_tickets.php" method="post" id="jumpform" name="jumpform"><tr>
  219.                         <td class="txt010"><?php echo $ticketlist?></td>
  220.                         <td>
  221. <a href="javascript:jumpToTicket(document.forms.jumpform)"><img src="./../../images/tech/but035.gif" alt="Go" width="26" height="18" border="0" ></a></td>
  222.                       </tr></form>
  223.                     </table>
  224.                 </td>
  225.               </tr>
  226.             </table></td>
  227. <?
  228. $db->query("SELECT id, save_name FROM tech_ticket_search WHERE save_type = "search" AND techid = '$user[id]' ORDER BY save_name");
  229. $saved_searches = array();
  230. while ($saves = $db->row_array()) {
  231. $saved_searches[$saves['id']] = $saves['save_name'];
  232. }
  233. if (count($saved_searches)) {
  234. $saved_select = form_select('saved_search', $saved_searches, NULL, NULL, NULL, NULL, NULL, "style='width:250px'");
  235. $saved_select_submit = form_submit('Go', 'submit', NULL, '../../images/tech/but035.gif');
  236. } else {
  237. $saved_select = 'None (<A HREF="../tickets/ticketsearch.php?searchtype=advanced" TARGET="center">Create New Search</A>)';
  238. $saved_select_submit = NULL;
  239. }
  240. if (count($search)) {
  241. $search = form_select('searchid', $search, NULL, NULL, NULL, NULL, NULL, "style='width:250px'");
  242. $search_submit = form_submit('Go', 'submit2', NULL, '../../images/tech/but035.gif');
  243. } else {
  244. $search = 'None (<A HREF="../tickets/ticketsearch.php?searchtype=advanced" TARGET="center">Run a New Search</A>)';
  245. $search_submit = NULL;
  246. }
  247. $cats = $db->query_return("SELECT categories FROM tech_folders WHERE techid = '$user[id]'");
  248. $cats = unserialize($cats['categories']);
  249. $cats[0] = "Top Level";
  250. $saved = $db->query("
  251. SELECT ticket.id AS id, 
  252. ticket.subject AS subject, 
  253. tech_ticket_save.category AS category 
  254. FROM tech_ticket_save, 
  255. ticket 
  256. WHERE tech_ticket_save.ticketid = ticket.id 
  257. ORDER BY category, ticket.id
  258. ");
  259. while ($saves = $db->row_array()) {
  260. $saved_tickets[$saves['id']] = $saves['subject'] . ' [' . $cats[$saves['category']] . ']';
  261. }
  262. if (count($saved_tickets)) {
  263. $saved_tickets = form_select('ticket_id', $saved_tickets, NULL, NULL, NULL, NULL, NULL, "style='width:250px'");
  264. $saved_tickets_submit = form_submit('Go', 'submit3', NULL, '../../images/tech/but035.gif');
  265. } else {
  266. $saved_tickets = 'None';
  267. $saved_tickets_submit = NULL;
  268. }
  269. echo "<td align="right" valign="top">";
  270. $jump_table = "
  271. <table cellpadding="1" cellspacing="2">
  272. <form method="post" target="center" action="./../tickets/ticketsearch.php">
  273. <input type="hidden" name="save_search_op" value="Run">
  274. <tr><td><b>Saved Searches</b></td>
  275. <td>$saved_select</td><td>$saved_select_submit</td></tr>
  276. </form>
  277. <form method="post" action="footer_tickets.php">
  278. <tr>
  279. <td><b>Previous Searches</b></td>
  280. <td>$search</td><td>$search_submit</td></tr>
  281. <tr></td>
  282. <td><b>Saved Tickets</b></td>
  283. <td>$saved_tickets</td><td>$saved_tickets_submit</td></tr>
  284. </form>
  285. </table>";
  286. fancy_table('100%', 'Run Previous & Saved Searches', $jump_table);
  287. if ($_REQUEST['submit']) {
  288. $loc = "../tickets/ticketsearch.php?saved_search=$_REQUEST[saved_id]&save_search_op=Run"; 
  289. if ($_REQUEST['submit2']) {
  290. $loc = "../tickets/load_results.php?id=$ids[0]&searchid=$_REQUEST[run_searchid]";
  291. }
  292. if ($_REQUEST['submit3']) {
  293. $loc = "../tickets/ticketview.php?id=$_REQUEST[ticket_id]";
  294. }
  295. if ($loc) { ?>
  296. <SCRIPT LANGUAGE="JavaScript">
  297. top.center.location = "<? echo $loc; ?>";
  298. </SCRIPT>
  299. <?php 
  300. }
  301. ?>
  302. <SCRIPT LANGUAGE="JavaScript">
  303. function jumpToTicket(form) {
  304. if (typeof(form.ticketjump) == 'undefined') return 0;
  305. var idx=form.ticketjump.selectedIndex;
  306. top.center.location = "../tickets/ticketview.php?id=" + form.ticketjump.options[idx].value;
  307. current = idx;
  308. tmp = current + 1;
  309. prev = current - 1;
  310. next = current + 1;
  311. showcurrent("<?php echo $showing_saved; ?>Ticket <B>" + tmp + "</B> of <B>" + idArray.length + "</B>");
  312. current == 0 ? doPrev(false) : doPrev(true)
  313. current >= (idArray.length - 1) ? doNext(false) : doNext(true)
  314. }
  315. </SCRIPT>
  316. <?php
  317. if ($_REQUEST['advance']) {
  318. ?>
  319. <SCRIPT LANGUAGE="JavaScript">
  320. jumpToTicket(document.getElementById('form'));
  321. </SCRIPT>
  322. <?php
  323. }
  324. if ($id) {
  325. ?>
  326. <SCRIPT LANGUAGE="JavaScript">
  327. showticket(<?php echo($id); ?>);
  328. </SCRIPT>
  329. <?php
  330. }
  331. ?>
  332. </body>
  333. </html>
  334. <?php
  335. $folders = $db->query_return("
  336. SELECT * FROM tech_folders 
  337. WHERE techid = '$user[id]'
  338. AND type = 'savedtickets'
  339. ");
  340. $folders = unserialize($folders['categories']);
  341. $folders[0] = 'No Folder';
  342. $db->query("
  343. SELECT ticketid, category 
  344. FROM tech_ticket_save 
  345. WHERE techid = '$user[id]'
  346. ORDER BY category
  347. ");
  348. $ids = array();
  349. while ($res = $db->row_array()) {
  350. $ids[] = $res['ticketid'];
  351. $cats[$res['ticketid']] = $folders[$res['category']];
  352. }
  353. $searchresults = join(',',$ids) . " ";
  354. $num = 0;
  355. $searchresults = 0;
  356. // get titles for search results
  357. $db->query("SELECT id, subject FROM ticket WHERE id IN ($searchresults) ORDER BY id");
  358. while ($saved = $db->row_array()) {
  359. $saved['subject'] = trimstring($saved['subject'], 30);
  360. $saved[$saved['id']] = $saved['subject'] . " (#$subject[id])";
  361. }