From b70c60a0455214d7e5cdd5e1a356f2a70b1cc5ba Mon Sep 17 00:00:00 2001 From: JediKev <kevin@enhancesoft.com> Date: Thu, 19 Oct 2017 11:55:21 -0500 Subject: [PATCH] issue: Ticket Preview Custom Fields This enhances the Ticket Preview window to include Custom Fields and their data. A field will only appear in the window if it has a value. Fields are grouped by Forms and each Form is separated by a horizontal line for better visibility. --- .../staff/templates/ticket-preview.tmpl.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/include/staff/templates/ticket-preview.tmpl.php b/include/staff/templates/ticket-preview.tmpl.php index 3533c8af7..d69053f51 100644 --- a/include/staff/templates/ticket-preview.tmpl.php +++ b/include/staff/templates/ticket-preview.tmpl.php @@ -116,6 +116,38 @@ echo sprintf( echo ' </table>'; +?> +<?php +foreach (DynamicFormEntry::forTicket($ticket->getId()) as $form) { + // Skip core fields shown earlier in the ticket preview + $answers = $form->getAnswers()->exclude(Q::any(array( + 'field__flags__hasbit' => DynamicFormField::FLAG_EXT_STORED, + 'field__name__in' => array('subject', 'priority') + ))); + $displayed = array(); + foreach($answers as $a) { + if (!($v = $a->display())) + continue; + $displayed[] = array($a->getLocal('label'), $v); + } + if (count($displayed) == 0) + continue; + + echo '<hr>'; + echo '<table border="0" cellspacing="" cellpadding="1" width="100%" style="margin-bottom:0px;" class="ticket_info">'; + echo '<tbody>'; + + foreach ($displayed as $stuff) { + list($label, $v) = $stuff; + echo '<tr>'; + echo '<th width="20%">'.Format::htmlchars($label).':</th>'; + echo '<td>'.$v.'</td>'; + echo '</tr>'; + } + + echo '</tbody>'; + echo '</table>'; +} echo '</div>'; // ticket preview content. ?> <div class="hidden tab_content" id="collab"> -- GitLab