Newer
Older
<?php
//Note that ticket obj is initiated in tickets.php.
if(!defined('OSTSCPINC') || !$thisstaff || !is_object($ticket) || !$ticket->getId()) die('Invalid path');
//Make sure the staff is allowed to access the page.
if(!@$thisstaff->isStaff() || !$ticket->checkStaffAccess($thisstaff)) die('Access Denied');
//Re-use the post info on error...savekeyboards.org (Why keyboard? -> some people care about objects than users!!)
$info=($_POST && $errors)?Format::input($_POST):array();
//Auto-lock the ticket if locking is enabled.. If already locked by the user then it simply renews.
if($cfg->getLockTime() && !$ticket->acquireLock($thisstaff->getId(),$cfg->getLockTime()))
$warn.='Unable to obtain a lock on the ticket';
//Get the goodies.
$dept = $ticket->getDept(); //Dept
$staff = $ticket->getStaff(); //Assigned or closed by..
$user = $ticket->getOwner(); //Ticket User (EndUser)
$team = $ticket->getTeam(); //Assigned team.
$lock = $ticket->getLock(); //Ticket lock obj
$id = $ticket->getId(); //Ticket ID.
//Useful warnings and errors the user might want to know!
if($ticket->isAssigned() && (
($staff && $staff->getId()!=$thisstaff->getId())
|| ($team && !$team->hasMember($thisstaff))
))
$warn.=' <span class="Icon assignedTicket">Ticket is assigned to '.implode('/', $ticket->getAssignees()).'</span>';
if(!$errors['err'] && ($lock && $lock->getStaffId()!=$thisstaff->getId()))
$errors['err']='This ticket is currently locked by '.$lock->getStaffName();
if(!$errors['err'] && ($emailBanned=TicketFilter::isBanned($ticket->getEmail())))
$errors['err']='Email is in banlist! Must be removed before any reply/response';
$unbannable=($emailBanned) ? BanList::includes($ticket->getEmail()) : false;
if($ticket->isOverdue())
$warn.=' <span class="Icon overdueTicket">Marked overdue!</span>';
?>
<table width="940" cellpadding="2" cellspacing="0" border="0">
<tr>
<td width="50%" class="has_bottom_border">
<h2><a href="tickets.php?id=<?php echo $ticket->getId(); ?>"
title="Reload"><i class="icon-refresh"></i> Ticket #<?php echo $ticket->getNumber(); ?></a></h2>
</td>
<td width="50%" class="right_align has_bottom_border">
<?php
if ($thisstaff->canBanEmails()
|| $thisstaff->canEditTickets()
|| ($dept && $dept->isManager($thisstaff))) { ?>
<span class="action-button" data-dropdown="#action-dropdown-more">
<span ><i class="icon-cog"></i> More</span>
<i class="icon-caret-down"></i>
</span>
<?php
} ?>
<?php if($thisstaff->canDeleteTickets()) { ?>
<a id="ticket-delete" class="action-button" href="#delete"><i class="icon-trash"></i> Delete</a>
<?php } ?>
if($thisstaff->canCloseTickets()) {
if($ticket->isOpen()) {?>
<a id="ticket-close" class="action-button" href="#close"><i class="icon-remove-circle"></i> Close</a>
<?php
} else { ?>
<a id="ticket-reopen" class="action-button" href="#reopen"><i class="icon-undo"></i> Reopen</a>
<?php
} ?>
} ?>
if($thisstaff->canEditTickets()) { ?>
<a class="action-button" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=edit"><i class="icon-edit"></i> Edit</a>
} ?>
<?php
if($ticket->isOpen() && !$ticket->isAssigned() && $thisstaff->canAssignTickets()) {?>
<a id="ticket-claim" class="action-button" href="#claim"><i class="icon-user"></i> Claim</a>
<?php
}?>
<span class="action-button" data-dropdown="#action-dropdown-print">
<a id="ticket-print" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=print"><i class="icon-print"></i> Print</a>
<i class="icon-caret-down"></i>
</span>
<div id="action-dropdown-print" class="action-dropdown anchor-right">
<ul>
<li><a target="_blank" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=print¬es=0"><i
class="icon-file-alt"></i> Ticket Thread</a>
<li><a target="_blank" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=print¬es=1"><i
class="icon-file-text-alt"></i> Thread + Internal Notes</a>
</ul>
</div>
<div id="action-dropdown-more" class="action-dropdown anchor-right">
<ul>
if($thisstaff->canEditTickets()) { ?>
<li><a class="change-user" href="#tickets/<?php echo $ticket->getId(); ?>/change-user"><i class="icon-user"></i> Change Ticket Owner</a></li>
<?php
}
if($ticket->isOpen() && ($dept && $dept->isManager($thisstaff))) {
if($ticket->isAssigned()) { ?>
<li><a id="ticket-release" href="#release"><i class="icon-user"></i> Release (unassign) Ticket</a></li>
<?php
}
if(!$ticket->isOverdue()) { ?>
<li><a id="ticket-overdue" href="#overdue"><i class="icon-bell"></i> Mark as Overdue</a></li>
<?php
}
if($ticket->isAnswered()) { ?>
<li><a id="ticket-unanswered" href="#unanswered"><i class="icon-circle-arrow-left"></i> Mark as Unanswered</a></li>
<?php
} else { ?>
<li><a id="ticket-answered" href="#answered"><i class="icon-circle-arrow-right"></i> Mark as Answered</a></li>
<?php
}
}
if(!$emailBanned) {?>
<li><a id="ticket-banemail" href="#banemail"><i class="icon-ban-circle"></i> Ban Email (<?php echo $ticket->getEmail(); ?>)</a></li>
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
} elseif($unbannable) { ?>
<li><a id="ticket-banemail" href="#unbanemail"><i class="icon-undo"></i> Unban Email (<?php echo $ticket->getEmail(); ?>)</a></li>
<?php
}
}?>
</ul>
</div>
</td>
</tr>
</table>
<table class="ticket_info" cellspacing="0" cellpadding="0" width="940" border="0">
<tr>
<td width="50">
<table border="0" cellspacing="" cellpadding="4" width="100%">
<tr>
<th width="100">Status:</th>
<td><?php echo ucfirst($ticket->getStatus()); ?></td>
</tr>
<tr>
<th>Priority:</th>
<td><?php echo $ticket->getPriority(); ?></td>
</tr>
<tr>
<th>Department:</th>
<td><?php echo Format::htmlchars($ticket->getDeptName()); ?></td>
</tr>
<tr>
<th>Create Date:</th>
<td><?php echo Format::db_datetime($ticket->getCreateDate()); ?></td>
</tr>
</table>
</td>
<td width="50%" style="vertical-align:top">
<table border="0" cellspacing="" cellpadding="4" width="100%">
<tr>
<th width="100">Client:</th>
<td><a href="#tickets/<?php echo $ticket->getId(); ?>/user"
$.userLookup('ajax.php/tickets/<?php echo $ticket->getId(); ?>/user',
function (user) {
$('#user-'+user.id+'-name').text(user.name);
$('#user-'+user.id+'-email').text(user.email);
$('#user-'+user.id+'-phone').text(user.phone);
$('select#emailreply option[value=1]').text(user.name+' <'+user.email+'>');
"><i class="icon-user"></i> <span id="user-<?php echo $ticket->getOwnerId(); ?>-name"
><?php echo Format::htmlchars($ticket->getName());
?></span></a>
echo sprintf(' <a href="tickets.php?a=search&uid=%d" title="Related Tickets" data-dropdown="#action-dropdown-stats">(<b>%d</b>)</a>',
urlencode($user->getId()), $user->getNumTickets());
?>
<div id="action-dropdown-stats" class="action-dropdown anchor-right">
<ul>
<?php
echo sprintf('<li><a href="tickets.php?a=search&status=open&uid=%s"><i class="icon-folder-open-alt"></i> %d Open Tickets</a></li>',
$user->getId(), $open);
if(($closed=$user->getNumClosedTickets()))
echo sprintf('<li><a href="tickets.php?a=search&status=closed&uid=%d"><i class="icon-folder-close-alt"></i> %d Closed Tickets</a></li>',
<li><a href="tickets.php?a=search&uid=<?php echo $ticket->getOwnerId(); ?>"><i class="icon-double-angle-right"></i> All Tickets</a></li>
</u>
</div>
<?php
}
?>
</td>
</tr>
<span id="user-<?php echo $ticket->getOwnerId(); ?>-email"><?php echo $ticket->getEmail(); ?></span>
<td>
<span id="user-<?php echo $ticket->getOwnerId(); ?>-phone"><?php echo $ticket->getPhoneNumber(); ?></span>
</td>
<tr>
<th>Source:</th>
echo Format::htmlchars($ticket->getSource());
if($ticket->getIP())
echo ' <span class="faded">('.$ticket->getIP().')</span>';
?>
</td>
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
</tr>
</table>
</td>
</tr>
</table>
<br>
<table class="ticket_info" cellspacing="0" cellpadding="0" width="940" border="0">
<tr>
<td width="50%">
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<?php
if($ticket->isOpen()) { ?>
<tr>
<th width="100">Assigned To:</th>
<td>
<?php
if($ticket->isAssigned())
echo Format::htmlchars(implode('/', $ticket->getAssignees()));
else
echo '<span class="faded">— Unassigned —</span>';
?>
</td>
</tr>
<?php
} else { ?>
<tr>
<th width="100">Closed By:</th>
<td>
<?php
if(($staff = $ticket->getStaff()))
echo Format::htmlchars($staff->getName());
else
echo '<span class="faded">— Unknown —</span>';
?>
</td>
</tr>
<?php
} ?>
<tr>
<th>SLA Plan:</th>
<td><?php echo $sla?Format::htmlchars($sla->getName()):'<span class="faded">— none —</span>'; ?></td>
</tr>
<?php
if($ticket->isOpen()){ ?>
<tr>
<th>Due Date:</th>
<td><?php echo Format::db_datetime($ticket->getEstDueDate()); ?></td>
</tr>
<?php
}else { ?>
<tr>
<th>Close Date:</th>
<td><?php echo Format::db_datetime($ticket->getCloseDate()); ?></td>
</tr>
<?php
}
?>
</table>
</td>
<td width="50%">
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
<td><?php echo Format::htmlchars($ticket->getHelpTopic()); ?></td>
</tr>
<tr>
<th nowrap>Last Message:</th>
<td><?php echo Format::db_datetime($ticket->getLastMsgDate()); ?></td>
</tr>
<tr>
<th nowrap>Last Response:</th>
<td><?php echo Format::db_datetime($ticket->getLastRespDate()); ?></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<table class="ticket_info" cellspacing="0" cellpadding="0" width="940" border="0">
<?php
$idx = 0;
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 = array_filter($form->getAnswers(), function ($a) {
return !in_array($a->getField()->get('name'),
array('email','subject','name','priority'));
});
if (count($answers) == 0)
continue;
?>
</tr><tr>
<td colspan="2">
<table cellspacing="0" cellpadding="4" width="100%" border="0">
if (!($v = $a->display())) continue; ?>
<tr>
<th width="100"><?php
echo $a->getField()->get('label');
?>:</th>
<td><?php
?></td>
</tr>
<?php } ?>
</table>
</td>
<?php
$idx++;
} ?>
</tr>
</table>
<div class="clear"></div>
<h2 style="padding:10px 0 5px 0; font-size:11pt;"><?php echo Format::htmlchars($ticket->getSubject()); ?></h2>
<?php
$tcount = $ticket->getThreadCount();
$tcount+= $ticket->getNumNotes();
?>
<ul id="threads">
<li><a class="active" id="toggle_ticket_thread" href="#">Ticket Thread (<?php echo $tcount; ?>)</a></li>
</ul>
<div id="ticket_thread">
<?php
$threadTypes=array('M'=>'message','R'=>'response', 'N'=>'note');
/* -------- Messages & Responses & Notes (if inline)-------------*/
$types = array('M', 'R', 'N');
if(($thread=$ticket->getThreadEntries($types))) {
foreach($thread as $entry) {
?>
<table class="thread-entry <?php echo $threadTypes[$entry['thread_type']]; ?>" cellspacing="0" cellpadding="1" width="940" border="0">
<tr>
<th colspan="4" width="100%">
<div>
<span style="display:inline-block"><?php
echo Format::db_datetime($entry['created']);?></span>
<span style="display:inline-block;padding-left:1em" class="faded title"><?php
echo Format::truncate($entry['title'], 100); ?></span>
<span style="float:right;white-space:no-wrap;display:inline-block">
<span style="vertical-align:middle;" class="textra"></span>
<span style="vertical-align:middle;"
class="tmeta faded title"><?php
Peter Rotich
committed
echo Format::htmlchars($entry['name'] ?: $entry['poster']); ?></span>
</span>
</div>
</th>
</tr>
<tr><td colspan="4" class="thread-body" id="thread-id-<?php
echo $entry['id']; ?>"><div><?php
echo Format::viewableImages(Format::display($entry['body'])); ?></div></td></tr>
<?php
&& ($tentry=$ticket->getThreadEntry($entry['id']))
&& ($urls = $tentry->getAttachmentUrls())
&& ($links=$tentry->getAttachmentsLinks())) {?>
<tr>
<td class="info" colspan="4"><?php echo $links; ?></td>
<script type="text/javascript">
$(function() { showImagesInline(<?php echo
JsonDataEncoder::encode($urls); ?>); });
</script>
</tr>
<?php
}?>
</table>
<?php
if($entry['thread_type']=='M')
$msgId=$entry['id'];
}
} else {
echo '<p>Error fetching ticket thread - get technical help.</p>';
}?>
</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>
<?php } ?>
<div id="response_options">
<?php
if($thisstaff->canPostReply()) { ?>
<li><a id="reply_tab" href="#reply">Post Reply</a></li>
<li><a id="note_tab" href="#note">Post Internal Note</a></li>
<?php
if($thisstaff->canTransferTickets()) { ?>
<li><a id="transfer_tab" href="#transfer">Dept. Transfer</a></li>
<?php
}
if($thisstaff->canAssignTickets()) { ?>
<li><a id="assign_tab" href="#assign"><?php echo $ticket->isAssigned()?'Reassign Ticket':'Assign Ticket'; ?></a></li>
<?php
} ?>
</ul>
<?php
if($thisstaff->canPostReply()) { ?>
<form id="reply" action="tickets.php?id=<?php echo $ticket->getId(); ?>#reply" name="reply" method="post" enctype="multipart/form-data">
<?php csrf_token(); ?>
<input type="hidden" name="id" value="<?php echo $ticket->getId(); ?>">
<input type="hidden" name="msgId" value="<?php echo $msgId; ?>">
<input type="hidden" name="a" value="reply">
<span class="error"></span>
<table style="width:100%" border="0" cellspacing="0" cellpadding="3">
<tbody id="to_sec">
<tr>
</td>
# XXX: Add user-to-name and user-to-email HTML ID#s
$to =sprintf('%s <%s>', $ticket->getName(), $ticket->getReplyToEmail());
$emailReply = (!isset($info['emailreply']) || $info['emailreply']);
<select id="emailreply" name="emailreply">
<option value="1" <?php echo $emailReply ? 'selected="selected"' : ''; ?>><?php echo $to; ?></option>
<option value="0" <?php echo !$emailReply ? 'selected="selected"' : ''; ?>
>—Do Not Email Reply—</option>
</select>
</td>
</tr>
</tbody>
<?php
<tbody id="cc_sec"
style="display:<?php echo $emailReply? 'table-row-group':'none'; ?>;">
<tr>
<label><strong>Collaborators:</strong></label>
Peter Rotich
committed
<input type='checkbox' value='1' name="emailcollab" id="emailcollab"
<?php echo ((!$info['emailcollab'] && !$errors) || isset($info['emailcollab']))?'checked="checked"':''; ?>
style="display:<?php echo $ticket->getNumCollaborators() ? 'inline-block': 'none'; ?>;"
>
$recipients = 'Add Recipients';
if ($ticket->getNumCollaborators())
$recipients = sprintf('Recipients (%d of %d)',
$ticket->getNumActiveCollaborators(),
$ticket->getNumCollaborators());
echo sprintf('<span><a class="collaborators preview"
href="#tickets/%d/collaborators"><span id="recipients">%s</span></a></span>',
</tbody>
<?php
} ?>
<tbody id="resp_sec">
<?php
<tr><td width="120"> </td><td class="error"><?php echo $errors['response']; ?> </td></tr>
}?>
<tr>
<td width="120" style="vertical-align:top">
<label><strong>Response:</strong></label>
</td>
<?php
if(($cannedResponses=Canned::responsesByDeptId($ticket->getDeptId()))) {?>
<select id="cannedResp" name="cannedResp">
<option value="0" selected="selected">Select a canned response</option>
<?php
foreach($cannedResponses as $id =>$title) {
echo sprintf('<option value="%d">%s</option>',$id,$title);
}
?>
</select>
<label><input type='checkbox' value='1' name="append" id="append" checked="checked"> Append</label>
<br>
<?php
}
$signature = '';
switch ($thisstaff->getDefaultSignatureType()) {
case 'dept':
if ($dept && $dept->canAppendSignature())
$signature = $dept->getSignature();
break;
case 'mine':
$signature = $thisstaff->getSignature();
break;
} ?>
<input type="hidden" name="draft_id" value=""/>
<textarea name="response" id="response" cols="50"
data-draft-namespace="ticket.response"
data-signature-field="signature" data-dept-id="<?php echo $dept->getId(); ?>"
data-signature="<?php
echo Format::htmlchars(Format::viewableImages($signature)); ?>"
placeholder="Start writing your response here. Use canned responses from the drop-down above"
data-draft-object-id="<?php echo $ticket->getId(); ?>"
rows="9" wrap="soft"
class="richtext ifhtml draft"><?php
echo $info['response']; ?></textarea>
</td>
</tr>
<?php
if($cfg->allowAttachments()) { ?>
<tr>
<td width="120" style="vertical-align:top">
Loading
Loading full blame...