main.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:15k
- <?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: main.php,v $
- // | $Date: 2004/02/10 01:34:28 $
- // | $Revision: 1.72 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Technician home page.
- // +-------------------------------------------------------------+
- error_reporting(E_ALL ^ E_NOTICE);
- include "./../global.php";
- require_once(INCLUDE_PATH.'functions/calendar_functions.php');
- tech_nav('Home');
- echo '
- <SCRIPT language="JavaScript">
- if (parent.location.href == self.location.href) {
- window.location.href = 'index.php';
- }
- </SCRIPT>
- ';
- $overdue = 0;
- $month = date('m');
- $year = date('Y');
- ############################### GET TICKETS ###############################
- $own_total = 0; $other_total = 0; $new_total = 0;
- $db->query("
- SELECT ticket.id AS id, subject, tech, category, ticket_cat.name AS
- name, user.username AS username
- FROM ticket
- LEFT JOIN user ON ticket.userid = user.id
- LEFT JOIN ticket_cat ON ticket.category = ticket_cat.id
- WHERE is_open
- AND awaiting_tech
- AND !nodisplay
- " . iff($user[cats_admin], " AND category NOT IN ($user[cats_admin]) ") . "
- ORDER BY tech, date_lastreply
- LIMIT 500
- ");
- // there are 500 tickets, we need to say there are missing results
- if ($db->num_rows() == 500) {
- $max_tickets_reached = true;
- }
- $own_tickets[0] = 'Select...';
- $other_tickets[0] = 'Select...';
- $new_tickets[0] = 'Select...';
- while ($res = $db->row_array()) {
-
- if (strlen($res['subject']) > 30) {
- $res['subject'] = substr($res['subject'], 0, 20) . "...";
- }
- if (strlen($res['username']) > 8) {
- $res['username'] = substr($res['username'], 0, 8);
- }
- if (strlen($res['name']) > 8) {
- $res['name'] = substr($res['name'], 0, 8);
- }
-
- if (!$res['category']) {
- $res['name'] = 'None';
- }
- if ($res['tech'] == $user['id']) {
- if ($own_total < 100) {
- $own_tickets["../tickets/ticketsearch.php?Jump=1&actiontype=your_category&your_category[0]=-2&ticketid=$res[id]"] = "#$res[id]: $res[subject] [$res[name]] [$res[username]]";
- $own_total++;
- }
- }
- if (($res['tech']) AND ($res['tech'] != $user['id'])) {
- if ($other_total < 100) {
- $other_tickets["../tickets/ticketsearch.php?Jump=1&actiontype=other_category&other_category[0]=-2&ticketid=$res[id]"] = "#$res[id]: $res[subject] [$res[name]] [$res[username]]";
- $other_total++;
- }
- }
- if (!$res['tech']) {
- if ($new_total < 100) {
- $new_tickets["../tickets/ticketsearch.php?Jump=1&actiontype=category&unassigned_category[0]=-2&ticketid=$res[id]"] = "#$res[id]: $res[subject] [$res[name]] [$res[username]]";
- $new_total++;
- }
- }
- }
- if (!$own_total) {
- $own_tickets = ' <I>None</I><BR>';
- } else {
- $own_tickets = form_select('own_ticket', $own_tickets, NULL, NULL, NULL, NULL, NULL, "onChange="quick_jump(own_ticket)" style='width:325px'")
- . form_submit('Go', 'own_tickets_submit');
- }
- if (!$new_total) {
- $new_tickets = ' <I>None</I><BR>';
- } else {
- $new_tickets = form_select('new_ticket', $new_tickets, NULL, NULL, NULL, NULL, NULL, "onChange="quick_jump(new_ticket)" style='width:325px'")
- . form_submit('Go', 'new_tickets_submit');
- }
- if (!$other_total) {
- $other_tickets = ' <I>None</I><BR>';
- } else {
- $other_tickets = form_select('other_ticket', $other_tickets, NULL, NULL, NULL, NULL, NULL, "onChange="quick_jump(other_ticket)" style='width:325px'")
- . form_submit('Go', 'other_tickets_submit');
- }
- ############################### PRIVATE MESSAGES ###############################
- $db->query("SELECT tech.username AS sender, pm_source.id, title
- FROM tech, pm_source, pm_relations
- WHERE pm_source.fromid = tech.id
- AND pm_relations.pmid = pm_source.id
- AND pm_relations.techid = '$user[id]'
- AND !pm_relations.is_read
- ORDER BY pm_source.timestamp
- ");
- $message_total = $db->num_rows(); $count = 0;
- while ($res = $db->row_array()) {
- $messages["../teamwork/pms.php?do=read&id=$res[id]"] = "[$res[sender]] $res[title]";
- }
- if ($message_total) {
- $messages = form_select('messages', $messages, NULL, NULL, NULL, NULL, NULL, "onChange="quick_jump(messages)" style='width:250px'")
- . form_submit('Go', 'messages_submit');
- } else {
- $messages = NULL;
- }
- ############################### TASKS AND TICKET WATCHES ###############################
- $today = date('Y-m-d');
- $taskdata = cachetasks(NULL, $today, NULL, NULL, NULL, NULL, NULL, NULL);
- $task_count = 0; $tickwatch_count = 0; $task_more = 0; $tickwatch_more = 0; $today_ts = strtotime($today);
- if (is_array($taskdata)) {
- foreach ($taskdata AS $key2 => $val2) {
- foreach ($val2 AS $key => $val) {
- if (!$val[5]) {
- $origdate = $val[3];
- $val[3] = our_date(strtotime($val[3]), NULL, 'M j');
- if ($val[7]) { // If a ticket watch
- if (strlen($val[1]) > 15) {
- $val[1] = substr($val[1], 0, 40) . '...';
- }
- if ($today_ts > strtotime($origdate)) {
- $od_watches["../tickets/ticketview.php?id=$val[0]"] = "$val[1] [$val[3]]";
- $odtickwatch_count++;
- } else {
- $watches["../tickets/ticketview.php?id=$val[0]"] = "$val[1] [$val[3]]";
- $tickwatch_count++;
- }
- } else { // If a calendar task
- if (strlen($val[1]) > 15) {
- $val[1] = substr($val[1], 0, 40) . '...';
- }
- if ($today_ts > strtotime($origdate)) {
- if ($val[6]) {
- $od_tasks["../calendar/viewtask.php?id=$val[0]&date=$val[3]"] = "$val[1] [$val[3]]";
- } else {
- $od_tasks["../calendar/viewtask.php?id=$val[0]"] = "$val[1] [$val[3]]";
- }
- $odtask_count++;
- } else {
- if ($val[6]) {
- $tasks["../calendar/viewtask.php?id=$val[0]&date=$val[3]"] = "$val[1] [$val[3]]";
- } else {
- $tasks["../calendar/viewtask.php?id=$val[0]"] = "$val[1] [$val[3]]";
- }
- $task_count++;
- }
- }
- }
- }
- }
- }
- if (!$tickwatch_count) {
- $watches = ' <I>None</I><BR>';
- } else {
- $watches = form_select('watches', $watches, NULL, NULL, NULL, NULL, NULL, "onChange="quick_jump(watches)" style='width:280px'")
- . form_submit('Go', 'watches_submit');
- }
- if (!$odtickwatch_count) {
- $od_watches = ' <I>None</I><BR>';
- } else {
- $od_watches = form_select('odwatches', $od_watches, NULL, NULL, NULL, NULL, NULL, "onChange="quick_jump(odwatches)" style='width:280px'")
- . form_submit('Go', 'odwatches_submit');
- }
- if (!$task_count) {
- $tasks = ' <I>None</I><BR>';
- } else {
- $tasks = form_select('tasks', $tasks, NULL, NULL, NULL, NULL, NULL, "onChange="quick_jump(tasks)" style='width:280px'")
- . form_submit('Go', 'tasks_submit');
- }
- if (!$odtask_count) {
- $od_tasks = ' <I>None</I><BR>';
- } else {
- $od_tasks = form_select('odtasks', $od_tasks, NULL, NULL, NULL, NULL, NULL, "onChange="quick_jump(odtasks)" style='width:280px'")
- . form_submit('Go', 'odtasks_submit');
- }
- ############################### FAQ ARTICLES/COMMENTS AWAITING VALIDATION ###############################
- $result = $db->query_return("
- SELECT COUNT(*) AS total
- FROM faq_articles
- WHERE to_validate
- ");
- $faq_count = $result['total'];
- $result = $db->query_return("
- SELECT COUNT(*) AS total
- FROM faq_comments
- WHERE new
- ");
- $faq_comment_count = $result['total'];
- ############################### USERS AWAITING VALIDATION ###############################
- if ($user[p_approve_new_registrations]) {
- $validations = $db->query_return('SELECT COUNT(*) AS total FROM user WHERE awaiting_manual_validation AND !awaiting_validation');
- $validations = $validations['total'];
- }
- ############################### GET SAVED SEARCHES ###############################
- $db->query("SELECT id, save_name FROM tech_ticket_search WHERE save_type = 'search' AND techid = '$user[id]' ORDER BY save_name");
- while ($saves = $db->row_array()) {
- $saved_searches["../tickets/ticketsearch.php?saved_search=$saves[id]"] = $saves['save_name'];
- }
- if (is_array($saved_searches)) {
- $savedsearches = form_select('saved_search', $saved_searches, NULL, NULL, NULL, NULL, NULL, "style='width:250px'") . form_submit('Go', 'run_saved') . form_hidden('save_search_op', 'Run');
- } else {
- $savedsearches = 'No searches defined (<a href="./../tickets/ticketsearch.php?searchtype=advanced">create new search</a>)';
- }
- ############################### DISPLAY EVERYTHING ###############################
- echo "<table width="100%" CELLPADDING="10" BORDER="0"><tr><td width="50%" valign="top">nn";
- echo "<FORM NAME="jumps" ID="jumps" ACTION="go.php" METHOD="POST">";
- $db->query("SELECT tech_news.*, tech.username
- FROM tech_news
- LEFT JOIN tech ON (tech_news.techid = tech.id)
- ORDER BY date
- LIMIT 0,5
- ");
- $news_table = "<table>";
- while ($result = $db->row_array()) {
- $news_table .= "<tr><td><IMG SRC="../../images/tech/bul080.gif" BORDER="0"></td><td><a href="./../news/technews.php?do=view&id=$result[id]">$result[title]</a></td>";
- }
- $news_table .= "</tr></table>";
- fancy_table('100%', "Tech News", $news_table);
- $tickets_table = "
- <TABLE BORDER="0" CELLPADDING="3" CELLPADDING="0">
- <TR VALIGN="TOP">
- <TD>";
- if ($max_tickets_reached) {
- $tickets_table .= "<i>Over 500 tickets are awaiting a response, not all tickets have been listed here. Please run a <a href="./../tickets/ticketsearch.php">search</a> to view all tickets awaiting a response.</i><br /><br />";
- }
- $tickets_table .= "<IMG SRC="../../images/tech/bul080.gif" BORDER="0"> Your Tickets ($own_total)<BR>$own_tickets</TD></TR>";
- if ($user['p_tech_view']) {
- $tickets_table .= "</TD><TR><TD COLSPAN="2"><IMG SRC="../../images/tech/bul080.gif" BORDER="0"> Others' Tickets ($other_total)<BR>
- $other_tickets";
- }
- $tickets_table .= "<TR><TD><IMG SRC="../../images/tech/bul080.gif" BORDER="0"> New (Unowned) Tickets ($new_total)<BR>$new_tickets";
- $tickets_table .= "</TD>
- </TR></TABLE>n";
- fancy_table('100%', "Tickets Awaiting a Response", $tickets_table);
- $messages_table = "
- <TABLE BORDER="0" CELLPADDING="3" CELLPADDING="0">
- <TR VALIGN="TOP">
- <TD><IMG SRC="../../images/tech/bul080.gif" BORDER="0"> $message_total New Message(s)<BR>$messages</TD></TR></TABLE>";
- fancy_table('100%', "New Private Messages", $messages_table);
- $faqs_table = "
- <TABLE BORDER="0" CELLPADDING="3" CELLPADDING="0">
- <TR VALIGN="TOP">
- <TD><IMG SRC="../../images/tech/bul080.gif" BORDER="0"> <a href="./../faq/validate.php">$faq_count New FAQ Article(s)</a></TD><TD><IMG SRC="../../images/tech/bul080.gif" BORDER="0"> <a href="./../faq/comments.php">$faq_comment_count New Comment(s)</a><BR>$faq_comments</TD></TR></TABLE>";
- fancy_table('100%', "FAQ Articles and Comments", $faqs_table);
- $savedsearches_table = "
- <TABLE BORDER="0" CELLPADDING="3" CELLPADDING="0">
- <TR VALIGN="TOP">
- <TD><IMG SRC="../../images/tech/bul080.gif" BORDER="0"> $savedsearches<BR></TD></TR></TABLE>";
- fancy_table('100%', "Your Saved Search Queries", $savedsearches_table);
- if ($user[p_approve_new_registrations]) {
- $validations_table = "<TABLE BORDER="0" CELLPADDING="3" CELLPADDING="0">
- <TR VALIGN="TOP">
- <TD><A HREF="../users/index.php"><IMG SRC="../../images/tech/bul080.gif" BORDER="0"> $validations new user(s)</A></TR></TABLE>";
- fancy_table('100%', "New Users", $validations_table);
- }
- echo "</TD><TD WIDTH="50%">";
- $tasks_table = "
- <TABLE BORDER="0" CELLPADDING="3" CELLPADDING="0">
- <TR VALIGN="TOP"><TD><IMG SRC="../../images/tech/bul080.gif" BORDER="0"> To Do Task(s)<BR>$tasks</TD></TR>" .
- iff($odtask_count, "<TR><TD><IMG SRC="../../images/tech/bul080.gif" BORDER="0"> Overdue Task(s)<BR>$od_tasks</td></tr>") .
- "<tr><td><IMG SRC="../../images/tech/bul080.gif" BORDER="0"> Tickets to Visit Today<BR>$watches</TD></tr>" .
- iff($odtickwatch_count, "<tr><td><IMG SRC="../../images/tech/bul080.gif" BORDER="0"> Overdue Ticket Reminders<BR>$od_watches</td></tr>") .
- "</table>";
- fancy_table('100%', "Your Tasks", $tasks_table);
- fancy_table('100%', "Your Calendar", "<br /><center>" . make_month($month, $year) . "</center>");
- $links_table = "<table>";
- if ($user['p_create_users']) {
- $links_table .= "<tr><td><img src="../../images/tech/bul083.gif" border="0"> </td><td><A HREF="../users/new.php">Create a new user</A></td></tr>";
- }
- $links_table .= "<tr><td><img src="../../images/tech/bul083.gif" border="0"> </td><td><A HREF="../tickets/newticket.php">Start a new ticket</A></td></tr>";
- $links_table .= "<tr><td><img src="../../images/tech/bul083.gif" border="0"> </td><td><A HREF="../teamwork/newpm.php">Send a private message</A></td></tr>";
- if ($user['p_add_k']) {
- $links_table .= "<tr><td><img src="../../images/tech/bul083.gif" border="0"> </td><td><A HREF="../faq/view.php?do=add&catid=0">Add a new FAQ entry</A></td></tr>";
- }
- $links_table .= "<tr><td><img src="../../images/tech/bul083.gif" border="0"> </td><td><A HREF="../calendar/new.php">Create a new task</A></td></tr>";
- $links_table .= "</table>";
- echo "</FORM>";
- echo "<FORM NAME="form" ID="form" ACTION="quicksearch.php" METHOD="POST">";
- echo "<TABLE BORDER="0" CELLPADDING="0" CELLPADDING="0">
- <TR VALIGN="TOP">
- <TD width="50%">";
- fancy_table('100%', 'Quick Links', $links_table);
- $search_table .= "
- <table>
- <tr><td><img src="../../images/tech/bul084.gif" border="0"> Users</td></tr>
- <tr><td>" . form_input('user_search', 'username / email', 30, '', '', "onfocus="this.value='';this.form.ticket_search.value='';"")
- . "</td></tr><tr><td><img src="../../images/tech/bul084.gif" border="0"> Tickets</td></tr><tr><td>"
- . form_input('ticket_search', 'id / ref', 30, '', '', "onfocus="this.value='';this.form.user_search.value='';"")
- . "<CENTER>" . form_submit('Search', 'search') . "</CENTER></td></tr></table>";
- echo "</td><td> </td><td width="50%">";
- fancy_table('100%', 'Quick Search', $search_table);
- echo "</FORM></td></tr></table>n";
- echo "</td></tr></table>n";
- ?>
- <SCRIPT LANGUAGE="JavaScript">
- function quick_jump(f){
- var opt = f.selectedIndex;
- var url = f.options[opt].value;
- if (url != 0) {
- self.document.location = url;
- }
- return true;
- }
- </SCRIPT>
- <?php
- tech_footer();
- ?>