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

📄 ticketview.php

📁 jsp程序开发系统
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?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: ticketview.php,v $
// | $Date: 2004/02/10 01:34:31 $
// | $Revision: 1.201 $
// +-------------------------------------------------------------+
// | File Details:
// | - Ticket details and history viewer.
// +-------------------------------------------------------------+

error_reporting(E_ALL ^ E_NOTICE);

// start file
require("./../global.php");

// globalise variables
$global = array	(
			array('id') 
);
rg($global);

if (!$id) {
	mistake("No ticket was specified");	
	exit();
}

############################### GET TICKET DATA ###############################

$id = mysql_escape_string($id);
$query = "
SELECT 
ticket.*,
tech.username AS techusername,
ticket_cat.name AS catname,
tech.id AS techid,
ticket_pri.name AS priname,
user.id AS userid,
user.email AS email
FROM ticket
LEFT JOIN ticket_cat ON (ticket.category = ticket_cat.id)
LEFT JOIN ticket_pri ON (ticket.priority = ticket_pri.id)
LEFT JOIN user ON (ticket.userid = user.id)
LEFT JOIN tech ON (ticket.tech = tech.id)
";

$ticket = $db->query_return($query . " WHERE ticket.id = '$id'");
if (!$db->num_rows()) {
	$ticket = $db->query_return($query . " WHERE ticket.ref = '$id'");
	if (is_array($ticket)) {
		$id = $ticket['id'];
	}
}

if (!$db->num_rows()) { // Try checking in ticket_merge too
	$ticket = $db->query_return("SELECT * FROM ticket_merge WHERE old_id = '$id'");
	if (!$db->num_rows()) {
		$ticket = $db->query_return("SELECT * FROM ticket_merge WHERE old_ref = '$id'");
	}
}

if ($ticket['new_id']) {
	$ticket = $db->query_return($query . " WHERE ticket.id = '$ticket[new_id]'");
	$id = $ticket['id'];
}

############################### PERMISSIONS ###############################

if (!$db->num_rows()) {
	mistake("Ticket Not Found. Either an invalid ID or REF ('$id') was specified, or the ticket has been deleted");
}

tech_nav('Tickets', 'View Ticket');

if ($_REQUEST['do'] == 'delnote' AND $_REQUEST['noteid']) {
	if (p_ticket('edit')) {
		$note = $db->query_return("SELECT * FROM ticket_notes WHERE id = '$_REQUEST[noteid]'");
		ticketlog($id, 'note_deleted', 0, 0, $note['note'], NULL, NULL);
		$db->query("DELETE FROM ticket_notes WHERE techid = '$user[id]' AND id = '$_REQUEST[noteid]'");
	}
}

// permission to view
if (!p_ticket('view')) {
	nopermission('to view this ticket');
}

// locked?
if (($ticket[is_locked]) && ($ticket[lock_id] != $user[id])) {

	$lock_html = '<table cellpadding="3" cellspacing="0"><tr><td>' . html_image('tech/bul074.gif') . "</td><td><b>THIS TICKED IS CURRENTLY LOCKED</b></td><td>" . html_image('tech/bul074.gif') . "</td></tr></table><br /> (since " . our_date($ticket[date_locked]);
	
	if (p_ticket('edit')) {
		$lock_html .= "<br /><a href=\"ticketactions.php?do=unlock&id=$id\"><b>Remove lock status</b></a></center>";
	} else {
		$lock_html .= "<br />You cannot make changes to this ticket until the technician assigned to it has unlocked it.</center>";
	}
	
	echo table_border($lock_html);

}

############################### CACHE SOME DATA ###############################

$techname[0] = 'Unassigned';
$priority[0] = '';
$category[0] = '';

// techs
$db->query("SELECT id, username FROM tech");
while ($tech = $db->row_array()) {
	$techname[$tech[id]] = $tech['username'];
	$techlist[$tech[id]] = $tech['username']; // This list doesn't include "Unassigned"
}

// categories
$db->query("SELECT id, name FROM ticket_cat");
while ($cat = $db->row_array()) {
	$category[$cat[id]] = $cat[name];
}

// priorities
$db->query("SELECT id, name FROM ticket_pri");
while ($pri = $db->row_array()) {
	$priority[$pri[id]] = $pri[name];
}

#################### TECHNICIANS SAVED TICKETS ##########################

$db->query("SELECT ticketid FROM tech_ticket_save WHERE techid = '$user[id]'");
while ($save = $db->row_array()) {
	$saved[] = $save[ticketid];
}

############################### TICKET ACTIONS ###############################

if (p_ticket('edit')) {

	// lock
	if ($ticket[is_locked] != '1') {
		$top_links[] = jprompt(
				'This will lock the ticket, preventing other techs from changing or replying to it.',
				"ticketactions.php?do=lock&id=$id",
				"Lock Ticket"
			) . ' ' . thelp('Tickets - Viewing and Responding', 'Lock/Unlock Ticket');
	}

	if ($ticket[is_locked] == '1') {
		$top_links[] = jprompt(
				'This will unlock the ticket, there may already be a tech working on this ticket',
				"ticketactions.php?do=unlock&id=$id",
				"Unlock Ticket"
			) . ' ' . thelp('Tickets - Viewing and Responding', 'Lock/Unlock Ticket');
	}


	// awaiting user
	if ($ticket[awaiting_tech] == "1" AND $ticket[is_open] == "1") {
		$top_links[] = jprompt(
				"This will mark the ticket Awaiting User Response.",
				"ticketactions.php?do=awaiting_user&id=$id",
				"Mark Awaiting User Response"
			) . ' ' . thelp('Tickets - Viewing and Responding', 'Awaiting Status');
	}

	// awaiting tech
	if ($ticket[awaiting_tech] == "0" AND $ticket[is_open] == "1") {
		$top_links[] = jprompt(
				"This will mark the ticket Awaiting Technician Response.",
				"ticketactions.php?do=awaiting_tech&id=$id",
				"Mark Awaiting Tech Response"
			) . ' ' . thelp('Tickets - Viewing and Responding', 'Awaiting Status');
	}

	// remove ownership
	if ($ticket[tech] == $user[id]) {
		$top_links[] = jprompt(
				"This will remove your ownership and mark the ticket Unassigned.",
				"ticketactions.php?do=remove_ownership&id=$id",
				'Remove Your Ownership'
			) . ' ' . thelp('Tickets - Viewing and Responding', 'Ticket Ownership');

	// take ownership
	} elseif (p_ticket('edit')) {
		$top_links[] = "<a href=\"ticketactions.php?do=take_ownership&id=$id\">Take Ticket Ownership</a>";
	}

	if ($ticket['nodisplay'] == 1) {
		$top_links[] = jprompt(
			'This will mark the ticket as non-spam. It will appear in normal ticket lists.',
			"ticketactions.php?do=nospam&id=$id",
			'Mark as Non-Spam'
		) . ' ' . thelp('Tickets - Viewing and Responding', 'Handling "Spam"');
	} else {
		$top_links[] = jprompt(
			'This will mark the ticket as spam. It will not appear in normal ticket lists (but you can still search for it in Ticket Search).',
			"ticketactions.php?do=spam&id=$id",
			'Mark as Spam'
		) . ' ' . thelp('Tickets - Viewing and Responding', 'Handling "Spam"');
	}
}

// delete
if (p_ticket('delete')) {
			$top_links[] = jprompt(
				'This will delete the ticket.',
				"ticketactions.php?do=delete&id=$id",
				"Delete Ticket"
			) . ' ' . thelp('Tickets - Viewing and Responding', 'Deleting a Ticket');
}

// close // reopen
if (p_ticket('close')) {
	if ($ticket[is_open] == "1") {
		$top_links[] = jprompt_multi(
			'This will close the ticket.',
			'Select [OK] to send an e-mail notification to the user, or [CANCEL] to close the ticket without mailing notification.',
			"ticketactions.php?do=close&id=$id&email=1",
			"ticketactions.php?do=close&id=$id",
			"Close"
		) . ' ' . thelp('Tickets - Viewing and Responding', 'Closing a Ticket');
	} else {
		$top_links[] = jprompt_multi(
			'This will re-open the ticket.',
			'Select [OK] to send an e-mail notification to the user, or [CANCEL] to re-open the ticket without mailing notification.',
			"ticketactions.php?do=open&id=$id&email=1",
			"ticketactions.php?do=open&id=$id",
			"Re-open"
		) . ' ' . thelp('Tickets - Viewing and Responding', 'Re-opening a Ticket');
	}
}

if (@in_array($id, $saved)) {
	$top_links[] = "<A HREF=\"ticketactions.php?do=unstore&id=$id\">Remove Ticket from Saved Tickets</A>" . ' ' . thelp('Tickets - Viewing and Responding', 'Saving Tickets');
} else {
	$top_links[] = "<A HREF=\"ticketactions.php?do=store&id=$id\">Add Ticket to Saved Tickets</A> (<A HREF=\"javascript:openWindow('popupactions.php?do=store&id=$id', '', '')\">pick cat</A>)" . ' ' . thelp('Tickets - Viewing and Responding', 'Saving Tickets');
}



if ($user['p_delete_users']) {

	$top_links[] = jprompt('This will prevent tickets being submitted by ' .
		htmlspecialchars($ticket['email']). '!',
		"ticketactions.php?id=$id&do=banmail&email=".urlencode($ticket['email']), 
		'Ban this e-mail address'
	) . ' ' . thelp('Tickets - Viewing and Responding', 'Handling "Spam"');

	$top_links[] = jprompt('This will delete this user, all tickets created by this user, and ban the e-mail address ' .
	htmlspecialchars($ticket['email']) . '!',
		"ticketactions.php?id=$id&do=nuke", 
		'Ban user/delete user & tickets'
	) . ' ' . thelp('Tickets - Viewing and Responding', 'Handling "Spam"');
}

foreach ($top_links AS $key => $var) {
	$top_links_html .= "<tr><td>" . html_image('tech/blue.gif', 4, 4) . "</td><td>$var</td></tr>";
}
$top_links = "<table cellpadding=\"2\" cellspacing=\"0\">$top_links_html</table>";

############################### TICKET STATUS ###############################

$ticket_status = "<table>";

// open / closed
if ($ticket[is_open] == 1) {
	$message = 'Ticket is Open';
} else {
	$message = 'Ticket is Closed';
}
$ticket_status .= "<tr><td>" . html_image('tech/bul070.gif') . '</td><td>' . table_thelp($message, 'Tickets - Viewing and Responding', 'Open/Closed') . '</td></tr>';

// awaiting user/tech
if ($ticket[awaiting_tech] == 1) {
	$message = 'Ticket is awaiting Tech';
} else {
	$message = 'Ticket is awaiting User';
}
$ticket_status .= "<tr><td>" . html_image('tech/bul072.gif') . '</td><td>' . table_thelp($message, 'Tickets - Viewing and Responding', 'Awaiting Status') . '</td></tr>';

// ticket locked
if ($ticket[is_locked] == 1) {
	$ticket_status .= "<tr><td>" . html_image('tech/bul074.gif') . '</td><td>' . table_thelp('Ticket is Locked', 'Tickets - Viewing and Responding', 'Locked') . '</td></tr>';
}

// who is ticket owned by
if ($ticket[tech] == $user[id]) {
	$message = 'Ticket is assigned to you';
} elseif ($ticket[tech] == 0) {
	$message = "Ticket is unassigned";
} else {
	$message = "Ticket is assigned to <a href=\"./../teamwork/techs.php\">$ticket[techusername]</a>";
}
$ticket_status .= "<tr><td>" . html_image('tech/bul077.gif') . '</td><td>' . table_thelp($message, 'Tickets - Viewing and Responding', 'Ticket Ownership') . '</td></tr>';

$ticket_status .= "</table>";

############################### TICKET FIELDS ###############################

// Admin fields
$fields = unserialize($user['fielddisplay']);
$sql = array2sql($fields['admin']);
if ($sql) {
	$db->query("SELECT * FROM ticket_fielddisplay WHERE id IN $sql");
	while ($fielddisplay = $db->row_array()) {
		$admincols[$fielddisplay['name']] = $fielddisplay['code'];
	}
}

// Calculate time-since-started and show it
if ($ticket[is_open]) {
	$since_started = mktime() - $ticket[date_opened];
} else {
	$since_started = $ticket[date_closed] - $ticket[date_opened];
}
$since_started = clean_time($since_started);

// generic
give_default($ticket['techusername'], '<i>Unassigned</i>');
give_default($ticket['catname'], '<i>None</i>');
give_default($ticket['priname'], '<i>None</i>');

if ($ticket[is_open]) {
	$table_ticket_fields[] = array(table_thelp('<b>Time Since Opened</B>', 'Tickets - Viewing and Responding', 'Time Since Opened'), $since_started);
	if ((($ticket[date_lastreply] > $ticket[date_lastreply_tech]) OR !$ticket[date_lastreply_tech]) AND $ticket[awaiting_tech]) {
		if (!$ticket[date_awaiting_toggled]) {
			$tmp_time = mktime() - $ticket[date_opened];
		} else {
			$tmp_time = mktime() - $ticket[date_awaiting_toggled];
		}
		$table_ticket_fields[] = array(table_thelp('<b>Time Since User Response</b>', 'Tickets - Viewing and Responding', 'Time Since User Response'), clean_time($tmp_time));
	}
} else {
	$table_ticket_fields[] = array(table_thelp('<b>Time to Close</B>', 'Tickets - Viewing and Responding', 'Time to Close'), $since_started);
}

$table_ticket_fields[] = array('<b>Ticket Subject</b>', $ticket['subject']);
$table_ticket_fields[] = array('<b>Tech Owner</b>', $ticket['techusername']);
$table_ticket_fields[] = array('<b>Category</b>', $ticket['catname']);
$table_ticket_fields[] = array('<b>Priority</b>', $ticket['priname']);

// custom fields
$db->query("
	SELECT * 
	FROM ticket_def 
	WHERE tech_viewable
	ORDER by displayorder
");

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

	$ticket_data[display_name] = unserialize($ticket_data[display_name]);
	$ticket_data[display_name] = $ticket_data[display_name][$settings[default_language]];

	$ticket_data[description] = unserialize($ticket_data[description]);
	$ticket_data[description] = $ticket_data[description][$settings[default_language]];

	$ticket_custom[$ticket_data[name]] = field_display($ticket_data, $ticket[$ticket_data[name]], 1);

	// normal display
	if ($ticket[$ticket_data[name]]) {
		$table_ticket_fields[] = array("<B>$ticket_data[display_name]</B>", $ticket_custom[$ticket_data[name]]);
	}

	// edit display
	if ($ticket_data['tech_editable']) {
		$table_ticket_fields2[] = array("
			<b>$ticket_data[display_name]</b><br />$ticket_data[description]", 
			field_def(
				$ticket_data, 
				'edit', 
				'', 
				'', 
				$ticket[$ticket_data[name]])
			);
	} else {

⌨️ 快捷键说明

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