-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvw_history.php
More file actions
133 lines (115 loc) · 4.19 KB
/
Copy pathvw_history.php
File metadata and controls
133 lines (115 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
global $HELPDESK_CONFIG, $hditem, $isa, $m, $item_id;
// User's specified format for date and time
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
$isa = dPgetSysVal( 'HelpDeskAuditTrail' );
// Get pagination page
if (isset($_GET['page'])) {
$AppUI->setState('HelpDeskLogPage', $_GET['page']);
} else {
$AppUI->setState('HelpDeskLogPage', 0);
}
$page = $AppUI->getState('HelpDeskLogPage') ? $AppUI->getState('HelpDeskLogPage') : 0;
$q = new DBQuery;
$q->addQuery('*,TRIM(CONCAT(co.contact_first_name,\' \',co.contact_last_name)) modified_by,co.contact_email as email');
$q->addTable('helpdesk_item_status','h');
$q->addJoin('users','u','u.user_id = h.status_modified_by');
$q->addJoin('contacts','co','u.user_contact = co.contact_id');
$q->addWhere('h.status_item_id='.$hditem['item_id']);
$q->addOrder('h.status_date');
// Pagination
$status_log_items_per_page = $HELPDESK_CONFIG['status_log_items_per_page'];
// Figure out number of total results, but do not retrieve
$total_logs = db_num_rows($q->exec());
// Now lets do the offset
$offset = $page * $status_log_items_per_page;
$q->setLimit($status_log_items_per_page,$offset);
// Get the actual, paginated results
$status_log = $q->loadList();
?>
<table border="0" cellpadding="4" cellspacing="0" width="100%" >
<tr>
<td><b><?php echo $AppUI->_('Item History')?></b></td>
<td align="right">
<?php
if ($total_logs > $status_log_items_per_page) {
$pages_per_side = $HELPDESK_CONFIG['pages_per_side'];
$pages = ceil($total_logs / $status_log_items_per_page) - 1;
$link = "?m=helpdesk&a=view&item_id=$item_id&page=";
if ($page < $pages_per_side) {
$start = 0;
} else {
$start = $page - $pages_per_side;
}
if ($page > ($pages - $pages_per_side)) {
$end = $pages;
} else {
$end = $page + $pages_per_side;
}
if ($page > 0) {
print "<a href=\"$link".($page - 1)."\">← Previous</a> ";
}
for ($i = $start; $i <= $end; $i++) {
if ($i == $page) {
print " <b>".($i + 1)."</b>";
} else {
print " <a href=\"$link$i\">".($i + 1)."</a>";
}
}
if ($page < $pages) {
print " <a href=\"$link".($page + 1)."\">Next →</a>";
}
}
?></td>
</tr>
</table>
<table cellspacing="1" cellpadding="2" border="0" width="100%" class="std">
<?php
$last_date = "";
if (is_array($status_log)) {
foreach ($status_log as $log) {
$log_date = new CDate($log['status_date']);
$date = $log_date->format( $df );
if($date!=$last_date){
$last_date = $date;
?>
<tr>
<th nowrap="nowrap" colspan="3"><?php echo $date?>:</th>
</tr>
<?php
}
$time = $log_date->format( $tf );
?>
<tr>
<td class="hilite" nowrap="nowrap" width="1%"><?php echo $time?></td>
<td class="hilite" nowrap="nowrap" width="1%"><?php echo ($log['email']?"<a href=\"mailto: {$log['email']}\">{$log['modified_by']}</a>":$log['modified_by'])?></td>
<td class="hilite" width="98%"><?php
if($log['status_code']==0 || $log['status_code']==18){ //ANDY 17 -> 18
// Created or Deleted
print $AppUI->_($isa[$log['status_code']]);
} else if ($log['status_code'] == 16) {
// Comment
print "<a href=\"javascript:void(0);\"
onClick=\"toggle_comment('{$log['status_id']}_short');
toggle_comment('{$log['status_id']}_long');\">"
. dPshowImage (dPfindImage( 'toggle.png', $m ), 16, 16, '')
. "</a>";
print "<span style='display: inline' id='{$log['status_id']}_short'> "
. $AppUI->_($isa[$log['status_code']]) . " "
. htmlspecialchars(substr($log['status_comment'],0,8))
. "</span><span style='display: none' id='{$log['status_id']}_long'> "
. $AppUI->_($isa[$log['status_code']]) . " "
. htmlspecialchars($log['status_comment'])
. "</span>";
} else {
// Everything else
print $AppUI->_($isa[$log['status_code']])." ".$log['status_comment'];
}
?></td>
</tr>
<?php
}
}
?>
</table>