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..5ccdbe543b0030b0fe910fc2382102bd997a4acc 100644 --- a/scp/css/scp.css +++ b/scp/css/scp.css @@ -926,6 +926,17 @@ h2 .reload { width:300px; } +.tip_content hr { + + color: #ddd; + background-color: #ddd; + height: 1px; + border: 0; + padding: 0; + margin: 0.2em 0; + width: 100%; +} + .tip_close { position:absolute; left:100%; @@ -950,7 +961,7 @@ h2 .reload { .tip_menu { margin:10px 0 0 0; padding:5px 0; - border-top:1px solid #ddd; + border-top:1px solid #aaa; height:16px; font-size:9pt; } diff --git a/scp/js/scp.js b/scp/js/scp.js index 10b8d733121107ce95840054cd6024d08bba9d54..f993a5a468ea7e6d96eb3ec903b89dc4d99f2ade 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -87,6 +87,9 @@ $(document).ready(function(){ if(!fObj.data('changed')){ fObj.data('changed', true); $('input[type=submit]', fObj).css('color', 'red'); + $(window).bind('beforeunload', function(e) { + return 'Are you sure you want to leave? Any changes or info you\'ve entered will be discarded!'; + }); } }); @@ -97,9 +100,19 @@ $(document).ready(function(){ $('label', fObj).removeAttr('style'); $('label', fObj).removeClass('strike'); fObj.data('changed', false); + $(window).unbind('beforeunload'); } }); + $('form#save').submit(function() { + $(window).unbind('beforeunload'); + + return true; + }); + + $('select#setting_options').change(function() { + $(this).closest('form').submit(); + }); $(".clearrule").live('click',function() { $(this).closest("tr").find(":input").val(''); diff --git a/scp/settings.php b/scp/settings.php index 162ea816c844ec9702a2723a2ba672f391def96b..d7809d63751039c61639efd448c5718a888cb7ac 100644 --- a/scp/settings.php +++ b/scp/settings.php @@ -44,7 +44,7 @@ require(STAFFINC_DIR.'header.inc.php'); <div style="padding-top:10px;padding-bottom:5px;"> <form method="get" action="settings.php"> Setting Option: - <select name="t" style="width:300px;"> + <select id="setting_options" name="t" style="width:300px;"> <option value="">— Select Setting Group —</option> <?php foreach($SettingOptions as $k=>$v) {