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

📄 index.php

📁 本代码是为客户联系管理而做的系统
💻 PHP
📖 第 1 页 / 共 2 页
字号:

if (!$pris) {
	$awaiting_response_priority[] = 'None';
} elseif ($graphing) {
	$awaiting_response_priority[] = "<img src=\"graph.php?type=priority\">";
}

/*****************************************************
	TICKETS CLOSED BY THIS TECH
*****************************************************/

// CATEGORY

$stats = $db->query_return_array("
	SELECT COUNT(*) AS total, 
		ticket_cat.name AS category
	FROM ticket
	LEFT JOIN ticket_cat ON ticket_cat.id = ticket.category
	WHERE tech = '$user[id]'
	GROUP BY category
");

$stat_tot = 0;
if (is_array($stats)) {
	foreach ($stats AS $stat) {
		if (!$stat['category']) {
			$stat['category'] = '<I>Uncategorized</I>';
		}
		$your_close_category[] = array($stat[category], $stat[total]);
		$stat_tot += $stat['total'];
	}
}

if ($stat_tot) {
	$your_close_category[] = array('<b>Total</b>', '<b>' . $stat_tot . '</b>');
} else {
	$your_close_category[] = 'No tickets closed';
}

// PRIORITY

if ($stat_tot) {
	$stats = $db->query_return_array("
		SELECT COUNT(*) AS total, 
			ticket_pri.name AS priority
		FROM ticket
		LEFT JOIN ticket_pri ON ticket_pri.id = ticket.priority
		WHERE tech = '$user[id]'
		GROUP BY priority
	");

	foreach ($stats AS $stat) {
		if (!$stat['priority']) {
			$stat['priority'] = '<I>Unprioritized</I>';
		}
		$your_close_priority[] = array($stat[priority], $stat[total]);
	}

	$your_close_priority[] = array('<b>Total</b>', '<b>' . $stat_tot . '</b>');
} else {
	$your_close_priority[] = 'No tickets closed';
}

/************************************
*	TECH RANKING
************************************/

// TECHS 

$db->query("
	SELECT COUNT(ticket_log.id) AS total, tech.username 
	FROM ticket_log, tech
	WHERE ticket_log.techid = tech.id 
	GROUP BY techid 
	ORDER BY 'total' 
	DESC LIMIT 5
");

while ($result = $db->row_array()) {
	$techscount += $result[total];
	$top_tech_ticket_closed[] = array($result[username], $result[total]);
}

// totals
$top_tech_ticket_closed[] = array('<b>Total</b>', '<b>' . $techscount . '</b>');

// no results
if (!is_array($top_tech_ticket_closed)) {
	$top_tech_ticket_closed[] = "No closed tickets";
}

// MOST CUSTOMERS HELPED

$custs = $db->query_return_array("
	SELECT COUNT(ticket.id) AS total, 
		user.username 
	FROM ticket, 
		user 
	WHERE tech = '$user[id]' 
		AND !is_open 
		AND ticket.userid = user.id 
	GROUP BY userid 
	ORDER BY total DESC LIMIT 10
");

if (is_array($custs)) {
	foreach ($custs AS $cust) {
		$top_tech_customer_helped[] = array($cust[username], $cust[total]);
		$cust_total += $cust[total];
	}
	$top_tech_customer_helped[] = array('Total', '<b>'  . $cust_total . '</b>');
} else {
	$top_tech_customer_helped[] = 'None';
}

/************************************
*	USER RANKING
************************************/

$topusers = $db->query_return_array("
	SELECT COUNT(ticket.id) AS total, user.username, user.id AS userid 
	FROM ticket 
	LEFT JOIN user ON (ticket.userid = user.id)
	GROUP BY ticket.userid 
	ORDER BY 'total' 
	DESC LIMIT 5
");


if ($db->num_rows()) {
	foreach ($topusers AS $val) {
		$users++;
		$top_users_tickets[] = array($val[username], $val[total]);
	}
}

/************************************
*	TECH TIME ACTIVITY
************************************/

$from = strtotime(date('Y-n-d') . ' -2 weeks');

if ($_REQUEST['all']) {
	$techlog = $db->query_return_array("SELECT * FROM tech_timelog WHERE techid = '$user[id]' ORDER BY stamp");
	$time_link = "Total Logged Time (all logged events) <A HREF=\"index.php\">View Last Two Weeks</A></CENTER>";
} else {
	$techlog = $db->query_return_array("SELECT * FROM tech_timelog WHERE techid = '$user[id]' AND stamp >= '$from' ORDER BY stamp");
	$time_link = "Total Logged Time (past two weeks) <A HREF=\"index.php?all=1\">View All Entries</A>";
}

foreach ($techlog AS $val) {
	if ($last) {
		if (($diff = $val['stamp'] - $last) <= $settings['max_log_duration']) {
			$techtime[date('Y-m-d', $val['stamp'])] += $diff;
			$total += $diff;
		}
	}
	$last = $val['stamp'];
}

if (is_array($techtime)) {
	foreach ($techtime AS $key => $data) {
		$time_log[] = array(date('D, M jS Y', strtotime($key)), clean_time($data));
	}
}

$time_log[] = array('<b>Total</b>', '<b>' . clean_time($total) . '</b>');

/************************************
*		LETS DISPLAY EVERYTHING
************************************/

// basic stats
echo table_list("Since $first_entry you have:", $simple_stats, '95%');

echo "<br /><br />";

// open tickets awaiting response (category / priority)
echo "<table cellpadding=\"3\" align=\"center\" width=\"95%\" cellspacing=\"0\"><tr><td valign=\"top\" width=\"50%\">";

echo table_list("Your Open Tickets Awaiting Your Response (by Category):", $awaiting_response_category, '100%');

echo "</td><td><td width=\"40\">&nbsp;</td><td valign=\"top\" width=\"50%\">";

echo table_list("Your Open Tickets Awaiting Your Response (by Priority):", $awaiting_response_priority, '100%');

echo "</td></tr></table>";

echo "<br /><br />";

// avg response times
echo "<table cellpadding=\"3\" align=\"center\" width=\"95%\" cellspacing=\"0\"><tr><td valign=\"top\" width=\"50%\">";

echo table_list("Your Avg. Response Time</B> (by Category):", $avg_response_category, '100%');

echo "</td><td><td width=\"40\">&nbsp;</td><td valign=\"top\" width=\"50%\">";

echo table_list("Your Avg. Response Time</B> (by Priority)", $avg_response_pri, '100%');

echo "</td></tr></table>";

echo "<br /><br />";

echo "<table cellpadding=\"3\" align=\"center\" width=\"95%\" cellspacing=\"0\"><tr><td valign=\"top\" width=\"50%\">";

echo table_list("Others' Avg. Response Time (Today)", $avg_resp_tech_today, '100%');

echo "</td><td><td width=\"40\">&nbsp;</td><td valign=\"top\" width=\"50%\">";

echo table_list("Others' Avg. Response Time (Week)", $avg_resp_tech_week, '100%');

echo "</td></tr></table>";

echo "<br /><br />";

// tickets you have closed (category / priority)
echo "<table cellpadding=\"3\" align=\"center\" width=\"95%\" cellspacing=\"0\"><tr><td valign=\"top\" width=\"50%\">";

echo table_list("Your Closed Tickets (by Category):", $your_close_category, '100%');

echo "</td><td><td width=\"40\">&nbsp;</td><td valign=\"top\" width=\"50%\">";

echo table_list("Your Closed Tickets (by Priority):", $your_close_priority, '100%');

echo "</td></tr></table>";

echo "<br /><br />";

// list of techs by number of tickets closed and number of customers helped
echo "<table cellpadding=\"3\" align=\"center\" width=\"95%\" cellspacing=\"0\"><tr><td valign=\"top\" width=\"50%\">";

echo table_list("Top Techs</B> (by tickets closed):", $top_tech_ticket_closed, '100%');

echo "</td><td><td width=\"40\">&nbsp;</td><td valign=\"top\" width=\"50%\">";

echo table_list("Customers Most Helped</B> (Tickets Closed):", $top_tech_customer_helped, '100%');

echo "</td></tr></table>";

echo "<br /><br />";

// users by number of tickets created
echo "<table cellpadding=\"3\" align=\"center\" width=\"95%\" cellspacing=\"0\"><tr><td valign=\"top\" width=\"50%\">";

echo table_list("Top User Ticket Submitters</B> (by tickets opened)", $top_users_tickets, '100%');

echo "</td><td><td width=\"40\">&nbsp;</td><td valign=\"top\" width=\"50%\">";

echo "</td></tr></table>";

echo "<br /><br />";

// basic stats
echo table_list($time_link, $time_log, '95%');

tech_footer();
?>

⌨️ 快捷键说明

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