diff --git a/inc/ticket_list.inc.php b/inc/ticket_list.inc.php index 32c32b8e..0109dbf6 100644 --- a/inc/ticket_list.inc.php +++ b/inc/ticket_list.inc.php @@ -1,7 +1,7 @@ 0) while ($ticket=hesk_dbFetchAssoc($result)) { + // Are we grouping tickets? if ($group) { require(HESK_PATH . 'inc/print_group.inc.php'); @@ -284,15 +285,7 @@ if ($total > 0) $first_line = $hesklang['taso3'] . ' ' . $admins[$ticket['owner']] . " \n\n"; } - $tagged = ''; - if ($ticket['archive']) - { - $tagged = ' '; - } - - $statusName = hesk_dbFetchAssoc(hesk_dbQuery("SELECT `ShortNameContentKey`, `TextColor` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` WHERE ID = ".$ticket['status'])); - $ticket['status']=''.$hesklang[$statusName['ShortNameContentKey']].''; - + // Prepare ticket priority switch ($ticket['priority']) { case 0: @@ -310,35 +303,151 @@ if ($total > 0) $ticket['priority']=''; } - $ticket['lastchange']=hesk_time_since(strtotime($ticket['lastchange'])); + // Set message (needed for row title) + $ticket['message'] = $first_line . substr(strip_tags($ticket['message']),0,200).'...'; + + // Start ticket row + echo ' + +   + '; - if ($ticket['lastreplier']) + // Print sequential ID and link it to the ticket page + if ( hesk_show_column('id') ) + { + echo ''.$ticket['id'].''; + } + + // Print tracking ID and link it to the ticket page + if ( hesk_show_column('trackid') ) + { + echo ''.$ticket['trackid'].''; + } + + // Print date submitted + if ( hesk_show_column('dt') ) + { + switch ($hesk_settings['updatedformat']) + { + case 1: + $ticket['dt'] = hesk_formatDate($ticket['dt']); + break; + case 2: + $ticket['dt'] = hesk_time_lastchange($ticket['dt']); + break; + default: + $ticket['dt'] = hesk_time_since( strtotime($ticket['dt']) ); + } + echo ''.$ticket['dt'].''; + } + + // Print last modified + if ( hesk_show_column('lastchange') ) { - $ticket['repliername'] = isset($admins[$ticket['replierid']]) ? $admins[$ticket['replierid']] : $hesklang['staff']; + switch ($hesk_settings['updatedformat']) + { + case 1: + $ticket['lastchange'] = hesk_formatDate($ticket['lastchange']); + break; + case 2: + $ticket['lastchange'] = hesk_time_lastchange($ticket['lastchange']); + break; + default: + $ticket['lastchange'] = hesk_time_since( strtotime($ticket['lastchange']) ); + } + echo ''.$ticket['lastchange'].''; } - else + + // Print ticket category + if ( hesk_show_column('category') ) { - $ticket['repliername'] = $ticket['name']; + $ticket['category'] = isset($hesk_settings['categories'][$ticket['category']]) ? $hesk_settings['categories'][$ticket['category']] : $hesklang['catd']; + echo ''.$ticket['category'].''; } - $ticket['archive'] = !($ticket['archive']) ? $hesklang['no'] : $hesklang['yes']; + // Print customer name + if ( hesk_show_column('name') ) + { + echo ''.$ticket['name'].''; + } + + // Print customer email + if ( hesk_show_column('email') ) + { + echo ''.$hesklang['clickemail'].''; + } + + // Print subject and link to the ticket page + if ( hesk_show_column('subject') ) + { + echo ''.($ticket['archive'] ? ''.$hesklang['archived'].' ' : '').$owner.''.$ticket['subject'].''; + } + + // Print ticket status + if ( hesk_show_column('status') ) + { + $statusName = hesk_dbFetchAssoc(hesk_dbQuery("SELECT `ShortNameContentKey`, `TextColor` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` WHERE ID = ".$ticket['status'])); + $ticket['status']=''.$hesklang[$statusName['ShortNameContentKey']].''; + echo ''.$ticket['status'].' '; + } + + // Print ticket owner + if ( hesk_show_column('owner') ) + { + if ($ticket['owner']) + { + $ticket['owner'] = isset($admins[$ticket['owner']]) ? $admins[$ticket['owner']] : $hesklang['unas']; + } + else + { + $ticket['owner'] = $hesklang['unas']; + } + echo ''.$ticket['owner'].''; + } + + // Print number of all replies + if ( hesk_show_column('replies') ) + { + echo ''.$ticket['replies'].''; + } - $ticket['message'] = $first_line . substr(strip_tags($ticket['message']),0,200).'...'; - + // Print number of staff replies + if ( hesk_show_column('staffreplies') ) + { + echo ''.$ticket['staffreplies'].''; + } - echo << -   - $ticket[trackid] - $ticket[lastchange] - $ticket[name] - $tagged$owner$ticket[subject] - $ticket[status]  - $ticket[repliername] - $ticket[priority]  - + // Print last replier + if ( hesk_show_column('lastreplier') ) + { + if ($ticket['lastreplier']) + { + $ticket['repliername'] = isset($admins[$ticket['replierid']]) ? $admins[$ticket['replierid']] : $hesklang['staff']; + } + else + { + $ticket['repliername'] = $ticket['name']; + } + echo ''.$ticket['repliername'].''; + } -EOC; + // Print time worked + if ( hesk_show_column('time_worked') ) + { + echo ''.$ticket['time_worked'].''; + } + + // Print custom fields + foreach ($hesk_settings['custom_fields'] as $key => $value) + { + if ($value['use'] && hesk_show_column($key) ) + echo ''.$ticket[$key].''; + } + + // End ticket row + echo ' + '.$ticket['priority'].'  + '; } // End while ?> @@ -349,7 +458,11 @@ EOC; - - - - - - + ' . $hesk_settings['possible_ticket_list'][$field] . ''; + } + ?> @@ -492,3 +605,50 @@ function hesk_time_since($original) } return $print; } // END hesk_time_since() + + +function hesk_time_lastchange($original) +{ + global $hesk_settings, $hesklang; + + // Save time format setting so we can restore it later + $copy = $hesk_settings['timeformat']; + + // We need this time format for this function + $hesk_settings['timeformat'] = 'Y-m-d H:i:s'; + + // Get HESK time-adjusted start of today if not already + if ( ! defined('HESK_TIME_TODAY') ) + { + // Adjust for HESK time and define constants for alter use + define('HESK_TIME_TODAY', date('Y-m-d 00:00:00', hesk_date(NULL, false, false, false) ) ); + define('HESK_TIME_YESTERDAY', date('Y-m-d 00:00:00', strtotime(HESK_TIME_TODAY)-86400) ) ; + } + + // Adjust HESK time difference and get day name + $ticket_time = hesk_date($original, true); + + if ($ticket_time >= HESK_TIME_TODAY) + { + // For today show HH:MM + $day = substr($ticket_time, 11, 5); + } + elseif ($ticket_time >= HESK_TIME_YESTERDAY) + { + // For yesterday show word "Yesterday" + $day = $hesklang['r2']; + } + else + { + // For other days show DD MMM YY + list($y, $m, $d) = explode('-', substr($ticket_time, 0, 10) ); + $day = '' . $d . ' ' . $hesklang['ms'.$m] . ' ' . substr($y, 2) . ''; + } + + // Restore original time format setting + $hesk_settings['timeformat'] = $copy; + + // Return value to display + return $day; + +} // END hesk_time_lastchange() \ No newline at end of file