0

我正在尝试将几个 PHP 页面放在一起作为 OTRS 的仪表板。想法是将其输出到办公室的显示器上,以显示接近第一响应和更新升级的工单。到目前为止,我还不是一个为此苦苦挣扎的开发人员。我已经设法让它只输出设置了升级时间的票......太棒了!但是我想显示升级之前的时间。这是我完全无能为力的地方。我试过在没有太多运气的情况下通过 php/mysql 指南混淆我的方式。

到目前为止,我已经包含了我的代码......不仅希望有人可以指出我在升级列中添加时间的方向(我猜这涉及根据当前日期操作 escalation_update_time (Unix) /时间?),但它也可以帮助某人做我想要实现的同样的事情......这将非常有用!(obv 更改了 IP/用户名/密码)。

所以总结一下;理想情况下,我想添加到以下脚本的内容是:

能够以标准日期/时间格式(而不是 Unix)显示升级时间 能够显示升级前的倒计时,例如每张工单的 3 小时 15 分钟或 2 天 3 小时 14 分钟等

我猜这不是 OTRS 特有的,它适用于任何 mySQL/PHP 环境,所以希望那里有一个能理解这些东西的神童!

预先感谢您提供任何指导或帮助,任何人都可以提供:)

<html><head><title>OTRS - First Contact</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head><body>
<?php
$db_host = '192.168.1.254';
$db_user = 'myuser';
$db_pwd = 'mypassword';

$database = 'otrs';
$table = 'users';

if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");

if (!mysql_select_db($database))
die("Can't select database");

// sending query
$result = mysql_query("SELECT  q.name AS queue_name, t.tn, t.customer_id,a .a_from,      t.title, a.create_time, create_time_unix, escalation_update_time
FROM    queue AS q, ticket AS t, article AS a, (
        SELECT  _a.ticket_id, MAX(_a.create_time) AS create_time
        FROM    ticket AS _t, ticket_state AS _t_s, article AS _a
        WHERE   _t_s.name IN ('new', 'open')
        AND     _t.ticket_state_id = _t_s.id
        AND     _a.ticket_id = _t.id            
        GROUP   BY _a.ticket_id
    ) a_max
WHERE   q.id = t.queue_id
AND     t.id = a_max.ticket_id
AND     a.create_time = a_max.create_time
AND     q.name = 'Service Desk'
AND      escalation_response_time >0
GROUP   BY t.id
ORDER   BY a.create_time ASC");
if (!$result) {
die("Query to show fields from table failed");
}

$fields_num = mysql_num_fields($result);

echo "<h1>Ticket Escalations (First Contact)</h1>";
echo "<table border='1'><tr>";
// printing table headers

echo "<td>Queue</td>";
echo "<td>Ticket#</td>";
echo "<td>Store</td>";
echo "<td>Customer</td>";
echo "<td>Subject</td>";
echo "<td>Last Update</td>";
echo "<td>Created Time (Unix)</td>";
echo "<td>Escalation Time</td>";

echo "</tr>\n";
// printing table rows

while($row = mysql_fetch_row($result))
{
echo "<tr>";

// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell)
    echo "<td>$cell</td>";   
echo "</tr>\n";
}
mysql_free_result($result);
?>
</body></html>
4

2 回答 2

0

您应该尝试使用 php date() 和 strtotime() 函数。对于倒计时选项http://keith-wood.name/countdown.html

于 2012-10-12T10:37:57.000 回答
0

我认为你应该改变你的方法:如果你使用 Perl 和OTRS API,你可以使用 TicketSearch 对象,它允许你搜索升级时间:

    # you can use all following escalation options with this four different ways of escalations
    # TicketEscalationTime...
    # TicketEscalationUpdateTime...
    # TicketEscalationResponseTime...
    # TicketEscalationSolutionTime...

    # ticket escalation time of more than 60 minutes ago (optional)
    TicketEscalationTimeOlderMinutes => -60,
    # ticket escalation time of less than 120 minutes ago (optional)
    TicketEscalationTimeNewerMinutes => -120,

    # tickets with escalation time after ... (optional)
    TicketEscalationTimeNewerDate => '2006-01-09 00:00:01',
    # tickets with escalation time before ... (optional)
    TicketEscalationTimeOlderDate => '2006-01-09 23:59:59',
于 2013-03-19T14:46:05.573 回答