Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Displaying individual custom form fields


OSTicket Version: v1.10 (901e5ea)

Hi,

I have added in the option to print off a customer ticket from a thermal printer, which is just a small ticket with company details, ticket number, date created so our customers can call up and inquire about their jobs (if anyone is interested in how we go about this I can put some more detail in). 
We want a custom field to be printed on it as well; in this case an "item" field that we list the type of device eg. laptop, phone etc.
My question is how can I show just one custom field? The code from ticket-vew-inc.php is what I'm using but it lists all custom fields and I need to be able to just show individual fields as required.  

My coding ability isn't up to this task, any help would be greatly appreciated!

The code in question:

<?php
foreach (DynamicFormEntry::forTicket($ticket->getId()) as $form) {
    // Skip core fields shown earlier in the ticket view
    // TODO: Rewrite getAnswers() so that one could write
    //       ->getAnswers()->filter(not(array('field__name__in'=>
    //           array('email', ...))));
    $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;
    ?>
    <table class="ticket_info custom-data" cellspacing="0" cellpadding="0" width="940" border="0">
    <thead>
        <th colspan="2"><?php echo Format::htmlchars($form->getTitle()); ?></th>
    </thead>
    <tbody>
<?php
    foreach ($displayed as $stuff) {
        list($label, $v) = $stuff;
?>
        <tr>
            <td width="200"><?php
echo Format::htmlchars($label);
            ?>:</th>
            <td><?php
echo $v;
            ?></td>
        </tr>
<?php } ?>
    </tbody>
    </table>
<?php } ?>


Comments

Sign In or Register to comment.