Skip to content
Snippets Groups Projects
Commit 9f4ad94d authored by Peter Rotich's avatar Peter Rotich
Browse files

Move ticket preview to a template

Show ticket prview when a ticket number is clicked as opposed to ticket
view.
Add collaborator preview tab on ticket preview tool tip.
parent 1a0a76d1
No related branches found
No related tags found
No related merge requests found
...@@ -335,123 +335,8 @@ class TicketsAjaxAPI extends AjaxController { ...@@ -335,123 +335,8 @@ class TicketsAjaxAPI extends AjaxController {
if(!$thisstaff || !($ticket=Ticket::lookup($tid)) || !$ticket->checkStaffAccess($thisstaff)) if(!$thisstaff || !($ticket=Ticket::lookup($tid)) || !$ticket->checkStaffAccess($thisstaff))
Http::response(404, 'No such ticket'); Http::response(404, 'No such ticket');
$staff=$ticket->getStaff();
$lock=$ticket->getLock();
$error=$msg=$warn=null;
if($lock && $lock->getStaffId()==$thisstaff->getId())
$warn.='&nbsp;<span class="Icon lockedTicket">Ticket is locked by '.$lock->getStaffName().'</span>';
elseif($ticket->isOverdue())
$warn.='&nbsp;<span class="Icon overdueTicket">Marked overdue!</span>';
ob_start(); ob_start();
echo sprintf( include STAFFINC_DIR . 'templates/ticket-preview.tmpl.php';
'<div style="width:500px; padding: 2px 2px 0 5px;">
<h2>%s</h2><br>',Format::htmlchars($ticket->getSubject()));
if($error)
echo sprintf('<div id="msg_error">%s</div>',$error);
elseif($msg)
echo sprintf('<div id="msg_notice">%s</div>',$msg);
elseif($warn)
echo sprintf('<div id="msg_warning">%s</div>',$warn);
echo '<table border="0" cellspacing="" cellpadding="1" width="100%" class="ticket_info">';
$ticket_state=sprintf('<span>%s</span>',ucfirst($ticket->getStatus()));
if($ticket->isOpen()) {
if($ticket->isOverdue())
$ticket_state.=' &mdash; <span>Overdue</span>';
else
$ticket_state.=sprintf(' &mdash; <span>%s</span>',$ticket->getPriority());
}
echo sprintf('
<tr>
<th width="100">Ticket State:</th>
<td>%s</td>
</tr>
<tr>
<th>Create Date:</th>
<td>%s</td>
</tr>',$ticket_state,
Format::db_datetime($ticket->getCreateDate()));
if($ticket->isClosed()) {
echo sprintf('
<tr>
<th>Close Date:</th>
<td>%s <span class="faded">by %s</span></td>
</tr>',
Format::db_datetime($ticket->getCloseDate()),
($staff?$staff->getName():'staff')
);
} elseif($ticket->getEstDueDate()) {
echo sprintf('
<tr>
<th>Due Date:</th>
<td>%s</td>
</tr>',
Format::db_datetime($ticket->getEstDueDate()));
}
echo '</table>';
echo '<hr>
<table border="0" cellspacing="" cellpadding="1" width="100%" class="ticket_info">';
if($ticket->isOpen()) {
echo sprintf('
<tr>
<th width="100">Assigned To:</th>
<td>%s</td>
</tr>',$ticket->isAssigned()?implode('/', $ticket->getAssignees()):' <span class="faded">&mdash; Unassigned &mdash;</span>');
}
echo sprintf(
' <tr>
<th width="100">Department:</th>
<td>%s</td>
</tr>
<tr>
<th>Help Topic:</th>
<td>%s</td>
</tr>
<tr>
<th>From:</th>
<td>%s <span class="faded">%s</span></td>
</tr>',
Format::htmlchars($ticket->getDeptName()),
Format::htmlchars($ticket->getHelpTopic()),
Format::htmlchars($ticket->getName()),
$ticket->getEmail());
echo '
</table>';
$options = array();
$options[]=array('action'=>'Thread ('.$ticket->getThreadCount().')','url'=>"tickets.php?id=$tid");
if($ticket->getNumNotes())
$options[]=array('action'=>'Notes ('.$ticket->getNumNotes().')','url'=>"tickets.php?id=$tid#notes");
if($ticket->isOpen())
$options[]=array('action'=>'Reply','url'=>"tickets.php?id=$tid#reply");
if($thisstaff->canAssignTickets())
$options[]=array('action'=>($ticket->isAssigned()?'Reassign':'Assign'),'url'=>"tickets.php?id=$tid#assign");
if($thisstaff->canTransferTickets())
$options[]=array('action'=>'Transfer','url'=>"tickets.php?id=$tid#transfer");
$options[]=array('action'=>'Post Note','url'=>"tickets.php?id=$tid#note");
if($thisstaff->canEditTickets())
$options[]=array('action'=>'Edit Ticket','url'=>"tickets.php?id=$tid&a=edit");
if($options) {
echo '<ul class="tip_menu">';
foreach($options as $option)
echo sprintf('<li><a href="%s">%s</a></li>',$option['url'],$option['action']);
echo '</ul>';
}
echo '</div>';
$resp = ob_get_contents(); $resp = ob_get_contents();
ob_end_clean(); ob_end_clean();
......
<?php
/*
* Ticket Preview popup template
*
*/
$staff=$ticket->getStaff();
$lock=$ticket->getLock();
$error=$msg=$warn=null;
if($lock && $lock->getStaffId()==$thisstaff->getId())
$warn.='&nbsp;<span class="Icon lockedTicket">Ticket is locked by '.$lock->getStaffName().'</span>';
elseif($ticket->isOverdue())
$warn.='&nbsp;<span class="Icon overdueTicket">Marked overdue!</span>';
echo sprintf(
'<div style="width:600px; padding: 2px 2px 0 5px;" id="t%s">
<h2>Ticket #%s: %s</h2><br>',
$ticket->getNumber(),
$ticket->getNumber(),
Format::htmlchars($ticket->getSubject()));
if($error)
echo sprintf('<div id="msg_error">%s</div>',$error);
elseif($msg)
echo sprintf('<div id="msg_notice">%s</div>',$msg);
elseif($warn)
echo sprintf('<div id="msg_warning">%s</div>',$warn);
echo '<ul class="tabs">';
echo '
<li><a id="preview_tab" href="#preview" class="active"
><i class="icon-list-alt"></i>&nbsp;Ticket Preview</a></li>';
if ($ticket->getNumCollaborators()) {
echo sprintf('
<li><a id="collab_tab" href="#collab"
><i class="icon-fixed-width icon-group
faded"></i>&nbsp;Collaborators (%d)</a></li>',
$ticket->getNumCollaborators());
}
echo '</ul>';
echo '<div class="tab_content" id="preview">';
echo '<table border="0" cellspacing="" cellpadding="1" width="100%" class="ticket_info">';
$ticket_state=sprintf('<span>%s</span>',ucfirst($ticket->getStatus()));
if($ticket->isOpen()) {
if($ticket->isOverdue())
$ticket_state.=' &mdash; <span>Overdue</span>';
else
$ticket_state.=sprintf(' &mdash; <span>%s</span>',$ticket->getPriority());
}
echo sprintf('
<tr>
<th width="100">Ticket State:</th>
<td>%s</td>
</tr>
<tr>
<th>Create Date:</th>
<td>%s</td>
</tr>',$ticket_state,
Format::db_datetime($ticket->getCreateDate()));
if($ticket->isClosed()) {
echo sprintf('
<tr>
<th>Close Date:</th>
<td>%s <span class="faded">by %s</span></td>
</tr>',
Format::db_datetime($ticket->getCloseDate()),
($staff?$staff->getName():'staff')
);
} elseif($ticket->getEstDueDate()) {
echo sprintf('
<tr>
<th>Due Date:</th>
<td>%s</td>
</tr>',
Format::db_datetime($ticket->getEstDueDate()));
}
echo '</table>';
echo '<hr>
<table border="0" cellspacing="" cellpadding="1" width="100%" class="ticket_info">';
if($ticket->isOpen()) {
echo sprintf('
<tr>
<th width="100">Assigned To:</th>
<td>%s</td>
</tr>',$ticket->isAssigned()?implode('/', $ticket->getAssignees()):' <span class="faded">&mdash; Unassigned &mdash;</span>');
}
echo sprintf(
'
<tr>
<th>From:</th>
<td>%s <span class="faded">%s</span></td>
</tr>
<tr>
<th width="100">Department:</th>
<td>%s</td>
</tr>
<tr>
<th>Help Topic:</th>
<td>%s</td>
</tr>',
Format::htmlchars($ticket->getName()),
$ticket->getEmail(),
Format::htmlchars($ticket->getDeptName()),
Format::htmlchars($ticket->getHelpTopic()));
echo '
</table>';
echo '</div>'; // ticket preview content.
?>
<div class="tab_content" id="collab" style="display:none;">
<table border="0" cellspacing="" cellpadding="1">
<colgroup><col style="min-width: 250px;"></col></colgroup>
<?php
if (($users=$ticket->getCollaborators())) {?>
<?php
foreach($users as $user) {
echo sprintf('<tr><td %s><i class="icon-%s"></i> %s <em>&lt;%s&gt;</em></td></tr>',
($user->isActive()? '' : 'class="faded"'),
($user->isActive()? 'comments' : 'comment-alt'),
$user->getName(),
$user->getEmail());
}
} else {
echo "Ticket doesn't have collaborators.";
}?>
</table>
<br>
<?php
echo sprintf('<span><a class="collaborators"
href="#tickets/%d/collaborators">%s</a></span>',
$ticket->getId(),
$ticket->getNumCollaborators()
? 'Manage Collaborators' : 'Add Collaborator'
);
?>
</div>
<?php
$options = array();
$options[]=array('action'=>'Thread ('.$ticket->getThreadCount().')','url'=>"tickets.php?id=$tid");
if($ticket->getNumNotes())
$options[]=array('action'=>'Notes ('.$ticket->getNumNotes().')','url'=>"tickets.php?id=$tid#notes");
if($ticket->isOpen())
$options[]=array('action'=>'Reply','url'=>"tickets.php?id=$tid#reply");
if($thisstaff->canAssignTickets())
$options[]=array('action'=>($ticket->isAssigned()?'Reassign':'Assign'),'url'=>"tickets.php?id=$tid#assign");
if($thisstaff->canTransferTickets())
$options[]=array('action'=>'Transfer','url'=>"tickets.php?id=$tid#transfer");
$options[]=array('action'=>'Post Note','url'=>"tickets.php?id=$tid#note");
if($thisstaff->canEditTickets())
$options[]=array('action'=>'Edit Ticket','url'=>"tickets.php?id=$tid&a=edit");
if($options) {
echo '<ul class="tip_menu">';
foreach($options as $option)
echo sprintf('<li><a href="%s">%s</a></li>',$option['url'],$option['action']);
echo '</ul>';
}
echo '</div>';
?>
...@@ -183,7 +183,7 @@ jQuery(function() { ...@@ -183,7 +183,7 @@ jQuery(function() {
//Ticket preview //Ticket preview
$('.ticketPreview').live('mouseover', function(e) { $('.ticketPreview').live('mouseover click', function(e) {
e.preventDefault(); e.preventDefault();
var elem = $(this); var elem = $(this);
...@@ -192,18 +192,19 @@ jQuery(function() { ...@@ -192,18 +192,19 @@ jQuery(function() {
var id='t'+vars[1]; var id='t'+vars[1];
var xoffset = 80; var xoffset = 80;
elem.data('timer', 0);
elem.data('id',id); if(!elem.data('id')) {
elem.data('timer',0); elem.data('id', id);
if($('.' + id).length == 0) {
if(e.type=='mouseover') { if(e.type=='mouseover') {
/* wait about 1 sec - before showing the tip - mouseout kills the timeout*/ /* wait about 1 sec - before showing the tip - mouseout kills the timeout*/
elem.data('timer',setTimeout(function() { showtip(url,elem,xoffset);},750)) elem.data('timer',setTimeout(function() { showtip(url,elem,xoffset);},750))
}else{ }else{
clearTimeout(elem.data('timer'));
showtip(url,elem,xoffset); showtip(url,elem,xoffset);
} }
} }
}).live('mouseout', function(e) { }).live('mouseout', function(e) {
$(this).data('id', 0);
clearTimeout($(this).data('timer')); clearTimeout($(this).data('timer'));
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment