2012-10-12 68 views
0

我正在嘗試放置幾個PHP頁面以充當OTRS的儀表板。這個想法是將它輸出到辦公室的顯示器上,以顯示正在接近第一響應和更新升級的票據。我並不是一個如此苦苦掙扎的開發者。我已經設法讓它只輸出升級時間設置的票...太好了!但是我想顯示時間,直到升級。這是我絕對無能爲力的地方。我試圖通過php/mysql指南來弄糊塗,沒有太多的運氣。PHP/mySQL日期/時間計算(OTRS)

我已經包含了我的代碼到目前爲止......不僅希望有人可以指示我爲增加升級列的時間(我猜測涉及操縱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> 

回答

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',