Skip to content
Snippets Groups Projects
view.inc.php 9.27 KiB
Newer Older
  • Learn to ignore specific revisions
  • if(!defined('OSTCLIENTINC') || !$thisclient || !$ticket || !$ticket->checkUserAccess($thisclient)) die('Access Denied!');
    
    
    $info=($_POST && $errors)?Format::htmlchars($_POST):array();
    
    $dept = $ticket->getDept();
    
    
    if ($ticket->isClosed() && !$ticket->isReopenable())
        $warn = __('This ticket is marked as closed and cannot be reopened.');
    
    
    //Making sure we don't leak out internal dept names
    if(!$dept || !$dept->isPublic())
        $dept = $cfg->getDefaultDept();
    
    
    if ($thisclient && $thisclient->isGuest()
        && $cfg->isClientRegistrationEnabled()) { ?>
    
    <div id="msg_info">
        <i class="icon-compass icon-2x pull-left"></i>
    
        <strong><?php echo __('Looking for your other tickets?'); ?></strong></br>
    
        <a href="<?php echo ROOT_PATH; ?>login.php?e=<?php
            echo urlencode($thisclient->getEmail());
    
        ?>" style="text-decoration:underline"><?php echo __('Sign In'); ?></a>
    
        <?php echo sprintf(__('or %s register for an account %s for the best experience on our help desk.'),
            '<a href="account.php?do=create" style="text-decoration:underline">','</a>'); ?>
        </div>
    
    <table width="800" cellpadding="1" cellspacing="0" border="0" id="ticketInfo">
        <tr>
            <td colspan="2" width="100%">
                <h1>
    
                    <b><?php echo $ticket->getSubject(); ?></b>
                    <small>#<?php echo $ticket->getNumber(); ?></small>
    
                    <a href="tickets.php?id=<?php echo $ticket->getId(); ?>" title="<?php echo __('Reload'); ?>"><span class="Icon refresh">&nbsp;</span></a>
    
    <div class="pull-right">
        <a class="action-button" href="tickets.php?a=print&id=<?php
            echo $ticket->getId(); ?>"><i class="icon-print"></i> <?php echo __('Print'); ?></a>
    
    <?php if ($ticket->hasClientEditableFields()
    
            // Only ticket owners can edit the ticket details (and other forms)
            && $thisclient->getId() == $ticket->getUserId()) { ?>
    
                    <a class="action-button" href="tickets.php?a=edit&id=<?php
    
                         echo $ticket->getId(); ?>"><i class="icon-edit"></i> <?php echo __('Edit'); ?></a>
    
    <?php } ?>
    
        </tr>
    
            <td width="50%">
    
                <table class="infoTable" cellspacing="1" cellpadding="3" width="100%" border="0">
    
                    <thead>
                        <tr><td class="headline" colspan="2">
                            <?php echo __('Basic Ticket Information'); ?>
                        </td></tr>
                    </thead>
    
                        <th width="100"><?php echo __('Ticket Status');?>:</th>
    
                        <td><?php echo ($S = $ticket->getStatus()) ? $S->getLocalName() : ''; ?></td>
    
                        <th><?php echo __('Department');?>:</th>
    
                        <td><?php echo Format::htmlchars($dept instanceof Dept ? $dept->getName() : ''); ?></td>
    
                        <th><?php echo __('Create Date');?>:</th>
    
                        <td><?php echo Format::datetime($ticket->getCreateDate()); ?></td>
    
                    </tr>
               </table>
           </td>
           <td width="50%">
               <table class="infoTable" cellspacing="1" cellpadding="3" width="100%" border="0">
    
                    <thead>
                        <tr><td class="headline" colspan="2">
                            <?php echo __('User Information'); ?>
                        </td></tr>
                    </thead>
    
                       <th width="100"><?php echo __('Name');?>:</th>
                       <td><?php echo mb_convert_case(Format::htmlchars($ticket->getName()), MB_CASE_TITLE); ?></td>
    
                       <th width="100"><?php echo __('Email');?>:</th>
    
                       <td><?php echo Format::htmlchars($ticket->getEmail()); ?></td>
                   </tr>
                   <tr>
    
                       <th><?php echo __('Phone');?>:</th>
    
                       <td><?php echo $ticket->getPhoneNumber(); ?></td>
                   </tr>
                </table>
           </td>
        </tr>
    
    Jared Hancock's avatar
    Jared Hancock committed
        <tr>
    
            <td colspan="2">
    <!-- Custom Data -->
    
    Jared Hancock's avatar
    Jared Hancock committed
    <?php
    
    foreach (DynamicFormEntry::forTicket($ticket->getId()) as $form) {
        // Skip core fields shown earlier in the ticket view
        $answers = $form->getAnswers()->exclude(Q::any(array(
            'field__flags__hasbit' => DynamicFormField::FLAG_EXT_STORED,
            'field__name__in' => array('subject', 'priority'),
            Q::not(array('field__flags__hasbit' => DynamicFormField::FLAG_CLIENT_VIEW)),
        )));
        if (count($answers) == 0)
            continue;
        ?>
            <table class="custom-data" cellspacing="0" cellpadding="4" width="100%" border="0">
            <tr><td colspan="2" class="headline flush-left"><?php echo $form->getTitle(); ?></th></tr>
            <?php foreach($answers as $a) {
                if (!($v = $a->display())) continue; ?>
                <tr>
                    <th><?php
        echo $a->getField()->get('label');
                    ?>:</th>
                    <td><?php
        echo $v;
                    ?></td>
                </tr>
                <?php } ?>
            </table>
        <?php
        $idx++;
    } ?>
        </td>
    
    Jared Hancock's avatar
    Jared Hancock committed
    </tr>
    
    </table>
    <br>
    <div id="ticketThread">
    
    <?php
    
    if($ticket->getThreadCount() && ($thread=$ticket->getClientThread())) {
        $threadType=array('M' => 'message', 'R' => 'response');
        foreach($thread as $entry) {
    
            //Making sure internal notes are not displayed due to backend MISTAKES!
    
            if(!$threadType[$entry->type]) continue;
            $poster = $entry->poster;
            if($entry->type=='R' && ($cfg->hideStaffName() || !$entry->staff_id))
    
            <table class="thread-entry <?php echo $threadType[$entry->type]; ?>" cellspacing="0" cellpadding="1" width="800" border="0">
    
    <?php echo Format::datetime($entry->created); ?>
    
                    &nbsp;&nbsp;<span class="textra"></span>
                    <span><?php echo $poster; ?></span>
                </div>
                </th></tr>
    
                <tr><td class="thread-body"><div><?php echo Format::clickableurls($entry->getBody()->toHtml()); ?></div></td></tr>
    
                $urls = null;
                if ($entry->has_attachments
                    && ($urls = $entry->getAttachmentUrls())) { ?>
                <tr>
                    <td class="info"><?php
                        foreach ($entry->attachments as $A) {
                            if ($A->inline) continue;
                            $size = '';
                            if ($A->file->size)
                                $size = sprintf('<em>(%s)</em>',
                                    Format::file_size($A->file->size));
    ?>
                    &nbsp; <i class="icon-paperclip"></i>
                    <a class="no-pjax" href="<?php echo $A->file->getDownloadUrl();
                        ?>" download="<?php echo Format::htmlchars($A->file->name); ?>"
                            target="_blank">
                    <?php echo Format::htmlchars($A->file->name);
                    ?></a><?php echo $size;?>&nbsp;
    <?php               } ?>
                    </td>
                </tr>
    
        }
    }
    ?>
    </div>
    <div class="clear" style="padding-bottom:10px;"></div>
    <?php if($errors['err']) { ?>
        <div id="msg_error"><?php echo $errors['err']; ?></div>
    <?php }elseif($msg) { ?>
        <div id="msg_notice"><?php echo $msg; ?></div>
    <?php }elseif($warn) { ?>
        <div id="msg_warning"><?php echo $warn; ?></div>
    
    
    if (!$ticket->isClosed() || $ticket->isReopenable()) { ?>
    
    <form id="reply" action="tickets.php?id=<?php echo $ticket->getId();
    ?>#reply" name="reply" method="post" enctype="multipart/form-data">
    
        <?php csrf_token(); ?>
    
        <h2><?php echo __('Post a Reply');?></h2>
    
        <input type="hidden" name="id" value="<?php echo $ticket->getId(); ?>">
    
        <input type="hidden" name="a" value="reply">
    
        <div>
            <p><em><?php
             echo __('To best assist you, we request that you be specific and detailed'); ?></em>
            <font class="error">*&nbsp;<?php echo $errors['message']; ?></font>
            </p>
            <textarea name="message" id="message" cols="50" rows="9" wrap="soft"
                class="<?php if ($cfg->isHtmlThreadEnabled()) echo 'richtext';
                    ?> draft" <?php
    list($draft, $attrs) = Draft::getDraftAndDataAttrs('ticket.client', $ticket->getId(), $info['message']);
    echo $attrs; ?>><?php echo $draft ?: $info['message'];
                ?></textarea>
        <?php
        if ($messageField->isAttachmentsEnabled()) {
            print $attachments->render(array('client'=>true));
        } ?>
        </div>
    <?php if ($ticket->isClosed()) { ?>
        <div class="warning-banner">
            <?php echo __('Ticket will be reopened on message post'); ?>
        </div>
    <?php } ?>
        <p style="text-align:center">
    
            <input type="submit" value="<?php echo __('Post Reply');?>">
            <input type="reset" value="<?php echo __('Reset');?>">
            <input type="button" value="<?php echo __('Cancel');?>" onClick="history.go(-1)">
    
    <script type="text/javascript">
    <?php
    // Hover support for all inline images
    $urls = array();
    foreach (AttachmentFile::objects()->filter(array(
        'attachments__thread_entry__thread__id' => $ticket->getThreadId(),
        'attachments__inline' => true,
    )) as $file) {
        $urls[strtolower($file->getKey())] = array(
            'download_url' => $file->getDownloadUrl(),
            'filename' => $file->name,
        );
    } ?>
    showImagesInline(<?php echo JsonDataEncoder::encode($urls); ?>);
    </script>