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

Merge pull request #23 from protich/feature/discard-warning

Feature/discard warning + ticket preview enhancements
parents be196701 d75caac8
No related branches found
No related tags found
No related merge requests found
...@@ -126,14 +126,98 @@ class TicketsAjaxAPI extends AjaxController { ...@@ -126,14 +126,98 @@ class TicketsAjaxAPI extends AjaxController {
global $thisstaff; 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( if($lock && $lock->getStaffId()==$thisstaff->getId())
'<div style="width:500px;"> $warn.='&nbsp;<span class="Icon lockedTicket">Ticket is locked by '.$lock->getStaffName().'</span>';
<strong>Ticket #%d Preview</strong><br>INFO HERE!!', elseif($ticket->isOverdue())
$ticket->getExtId()); $warn.='&nbsp;<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.=' &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->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">&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('action'=>'Thread ('.$ticket->getThreadCount().')','url'=>"tickets.php?id=$tid"); $options[]=array('action'=>'Thread ('.$ticket->getThreadCount().')','url'=>"tickets.php?id=$tid");
if($ticket->getNumNotes()) if($ticket->getNumNotes())
$options[]=array('action'=>'Notes ('.$ticket->getNumNotes().')','url'=>"tickets.php?id=$tid#notes"); $options[]=array('action'=>'Notes ('.$ticket->getNumNotes().')','url'=>"tickets.php?id=$tid#notes");
...@@ -150,15 +234,15 @@ class TicketsAjaxAPI extends AjaxController { ...@@ -150,15 +234,15 @@ class TicketsAjaxAPI extends AjaxController {
$options[]=array('action'=>'Post Note','url'=>"tickets.php?id=$tid#note"); $options[]=array('action'=>'Post Note','url'=>"tickets.php?id=$tid#note");
if($options) { if($options) {
$resp.='<ul class="tip_menu">'; echo '<ul class="tip_menu">';
foreach($options as $option) { foreach($options as $option)
$resp.=sprintf('<li><a href="%s">%s</a></li>', echo sprintf('<li><a href="%s">%s</a></li>',$option['url'],$option['action']);
$option['url'],$option['action']); echo '</ul>';
}
$resp.='</ul>';
} }
$resp.='</div>'; echo '</div>';
$resp = ob_get_contents();
ob_end_clean();
return $resp; return $resp;
} }
......
...@@ -926,6 +926,17 @@ h2 .reload { ...@@ -926,6 +926,17 @@ h2 .reload {
width:300px; width:300px;
} }
.tip_content hr {
color: #ddd;
background-color: #ddd;
height: 1px;
border: 0;
padding: 0;
margin: 0.2em 0;
width: 100%;
}
.tip_close { .tip_close {
position:absolute; position:absolute;
left:100%; left:100%;
...@@ -950,7 +961,7 @@ h2 .reload { ...@@ -950,7 +961,7 @@ h2 .reload {
.tip_menu { .tip_menu {
margin:10px 0 0 0; margin:10px 0 0 0;
padding:5px 0; padding:5px 0;
border-top:1px solid #ddd; border-top:1px solid #aaa;
height:16px; height:16px;
font-size:9pt; font-size:9pt;
} }
......
...@@ -87,6 +87,9 @@ $(document).ready(function(){ ...@@ -87,6 +87,9 @@ $(document).ready(function(){
if(!fObj.data('changed')){ if(!fObj.data('changed')){
fObj.data('changed', true); fObj.data('changed', true);
$('input[type=submit]', fObj).css('color', 'red'); $('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(){ ...@@ -97,9 +100,19 @@ $(document).ready(function(){
$('label', fObj).removeAttr('style'); $('label', fObj).removeAttr('style');
$('label', fObj).removeClass('strike'); $('label', fObj).removeClass('strike');
fObj.data('changed', false); 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() { $(".clearrule").live('click',function() {
$(this).closest("tr").find(":input").val(''); $(this).closest("tr").find(":input").val('');
......
...@@ -44,7 +44,7 @@ require(STAFFINC_DIR.'header.inc.php'); ...@@ -44,7 +44,7 @@ require(STAFFINC_DIR.'header.inc.php');
<div style="padding-top:10px;padding-bottom:5px;"> <div style="padding-top:10px;padding-bottom:5px;">
<form method="get" action="settings.php"> <form method="get" action="settings.php">
Setting Option: Setting Option:
<select name="t" style="width:300px;"> <select id="setting_options" name="t" style="width:300px;">
<option value="">&mdash; Select Setting Group &mdash;</option> <option value="">&mdash; Select Setting Group &mdash;</option>
<?php <?php
foreach($SettingOptions as $k=>$v) { foreach($SettingOptions as $k=>$v) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment