diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index f0a88828d99fe27434ecd6391c61fc027d7c1391..a0017b5cf6f32bf44e9ffce29546789dcc8a436f 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -126,14 +126,98 @@ class TicketsAjaxAPI extends AjaxController { global $thisstaff; + if(!$thisstaff || !($ticket=Ticket::lookup($tid)) || !$ticket->checkStaffAccess($thisstaff)) + Http::response(404, 'No such ticket'); - $ticket = new Ticket($tid); + $staff=$ticket->getStaff(); + $lock=$ticket->getLock(); + $error=$msg=$warn=null; - $resp = sprintf( - '<div style="width:500px;"> - <strong>Ticket #%d Preview</strong><br>INFO HERE!!', - $ticket->getExtId()); + if($lock && $lock->getStaffId()==$thisstaff->getId()) + $warn.=' <span class="Icon lockedTicket">Ticket is locked by '.$lock->getStaffName().'</span>'; + elseif($ticket->isOverdue()) + $warn.=' <span class="Icon overdueTicket">Marked overdue!</span>'; + + ob_start(); + echo sprintf( + '<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.=' — <span>Overdue</span>'; + else + $ticket_state.=sprintf(' — <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->getDueDate()) { + echo sprintf(' + <tr> + <th>Due Date:</th> + <td>%s</td> + </tr>', + Format::db_datetime($ticket->getDueDate())); + } + 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()?$ticket->getAssignee():' <span class="faded">— Unassigned —</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('action'=>'Thread ('.$ticket->getThreadCount().')','url'=>"tickets.php?id=$tid"); if($ticket->getNumNotes()) $options[]=array('action'=>'Notes ('.$ticket->getNumNotes().')','url'=>"tickets.php?id=$tid#notes"); @@ -150,15 +234,15 @@ class TicketsAjaxAPI extends AjaxController { $options[]=array('action'=>'Post Note','url'=>"tickets.php?id=$tid#note"); if($options) { - $resp.='<ul class="tip_menu">'; - foreach($options as $option) { - $resp.=sprintf('<li><a href="%s">%s</a></li>', - $option['url'],$option['action']); - } - $resp.='</ul>'; + echo '<ul class="tip_menu">'; + foreach($options as $option) + echo sprintf('<li><a href="%s">%s</a></li>',$option['url'],$option['action']); + echo '</ul>'; } - $resp.='</div>'; + echo '</div>'; + $resp = ob_get_contents(); + ob_end_clean(); return $resp; } diff --git a/scp/css/scp.css b/scp/css/scp.css index 85a4712cdca6d4b928694df2555d125831d9a385..4f028c561cf5eb9f0ead3ccc7c179475d431d3e8 100644 --- a/scp/css/scp.css +++ b/scp/css/scp.css @@ -926,6 +926,16 @@ h2 .reload { width:300px; } +.tip_content hr { + + color: #ddd; + background-color: #ddd; + height: 1px; + border: 0; + padding: 0; + width: 100%; +} + .tip_close { position:absolute; left:100%; @@ -950,7 +960,7 @@ h2 .reload { .tip_menu { margin:10px 0 0 0; padding:5px 0; - border-top:1px solid #ddd; + border-top:1px solid #666; height:16px; font-size:9pt; }