escalate.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:3k
- <?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: escalate.php,v $
- // | $Date: 2004/02/10 01:34:25 $
- // | $Revision: 1.7 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Ticket auto-escalation
- // +-------------------------------------------------------------+
- error_reporting(E_ALL ^ E_NOTICE);
- cron_check();
- //////////////////// RUN ESCALATIONS ////////////////////
- $db->query("SELECT * FROM escalate");
- while ($result = $db->row_array()) {
- if (!$result[dayswaiting] AND !$result[daysopen]) {
- // If it's a nonsensical escalation, don't continue
- continue;
- }
- // category change
- if ($result[category]) {
- $sql = " category = $result[category]";
- $i = 1;
- }
- // priority change
- if ($result[priority]) {
- $sql .= iff($i, ', ') . " priority = $result[priority]";
- $i = 1;
- }
- // tech owner
- if ($result[tech]) {
- $sql .= iff($i, ', ') . " tech = $result[tech]";
- }
- if ($sql) {
- if ($result[dayswaiting]) {
- $waiting_time = mktime() - (60 * 60 * 24 * $result[dayswaiting]);
- }
- if ($result[daysopen]) {
- $open_time = mktime() - (60 * 60 * 24 * $result[daysopen]);
- }
- if ($sql) {
- // First find all affected tickets
- $tickets = $db2->query_return_array("SELECT * FROM ticket WHERE
- " . iff($result[dayswaiting], " date_lastreply_tech > $waiting_time ") . "
- " . iff($result[daysopen], " date_opened > $open_time "));
- if ($db2->num_rows()) {
- // If there are tickets to escalate, log the changes and notify
- // technicians if needed.
- foreach ($tickets AS $ticket) {
- $userdata = $db2->query_return("SELECT * FROM tech WHERE id = '$ticket[tech]'");
- ticketlog($ticket[id], "escalate");
- if ($result[category]) {
- ticketlog($ticket[id], "category", $ticket[category], $result[category]);
- }
- if ($result[priority]) {
- ticketlog($ticket[id], "priority", $ticket[priority], $result[priority]);
- }
- if ($result[tech]) {
- ticketlog($ticket[id], "tech", $ticket[tech], $result[tech]);
- notify_technicians('assigned', $ticket, $userdata);
- }
- }
- $db2->query("
- UPDATE ticket SET $sql WHERE
- " . iff($result[dayswaiting], " date_lastreply_tech > $waiting_time ") . "
- " . iff($result[daysopen], " date_opened > $open_time ") . "
- ");
- }
- }
- }
- }