Skip to content
Snippets Groups Projects
Commit 49b9658f authored by Jared Hancock's avatar Jared Hancock
Browse files

tickets: Use post-redirect-get when posting and editing

parent d2af0eb6
No related branches found
No related tags found
No related merge requests found
...@@ -587,7 +587,7 @@ $(function() { ...@@ -587,7 +587,7 @@ $(function() {
+'?count='+count +'?count='+count
+'&_uid='+new Date().getTime(); +'&_uid='+new Date().getTime();
$.dialog(url, [201], function (xhr) { $.dialog(url, [201], function (xhr) {
$.pjax.reload('#pjax-container'); $.pjax({url: 'tickets.php', container: '#pjax-container'});
}); });
} }
return false; return false;
......
...@@ -25,6 +25,7 @@ require_once(INCLUDE_DIR.'class.export.php'); // For paper sizes ...@@ -25,6 +25,7 @@ require_once(INCLUDE_DIR.'class.export.php'); // For paper sizes
$page=''; $page='';
$ticket = $user = null; //clean start. $ticket = $user = null; //clean start.
$redirect = false;
//LOCKDOWN...See if the id provided is actually valid and if the user has access. //LOCKDOWN...See if the id provided is actually valid and if the user has access.
if($_REQUEST['id']) { if($_REQUEST['id']) {
if(!($ticket=Ticket::lookup($_REQUEST['id']))) if(!($ticket=Ticket::lookup($_REQUEST['id'])))
...@@ -131,6 +132,7 @@ if($_POST && !$errors): ...@@ -131,6 +132,7 @@ if($_POST && !$errors):
// Go back to the ticket listing page on reply // Go back to the ticket listing page on reply
$ticket = null; $ticket = null;
$redirect = 'tickets.php';
} elseif(!$errors['err']) { } elseif(!$errors['err']) {
$errors['err']=__('Unable to post the reply. Correct the errors below and try again!'); $errors['err']=__('Unable to post the reply. Correct the errors below and try again!');
...@@ -173,6 +175,7 @@ if($_POST && !$errors): ...@@ -173,6 +175,7 @@ if($_POST && !$errors):
Draft::deleteForNamespace('ticket.note.'.$ticket->getId(), Draft::deleteForNamespace('ticket.note.'.$ticket->getId(),
$thisstaff->getId()); $thisstaff->getId());
$redirect = 'tickets.php';
} else { } else {
if(!$errors['err']) if(!$errors['err'])
...@@ -187,6 +190,7 @@ if($_POST && !$errors): ...@@ -187,6 +190,7 @@ if($_POST && !$errors):
$errors['err']=__('Permission Denied. You are not allowed to edit tickets'); $errors['err']=__('Permission Denied. You are not allowed to edit tickets');
elseif($ticket->update($_POST,$errors)) { elseif($ticket->update($_POST,$errors)) {
$msg=__('Ticket updated successfully'); $msg=__('Ticket updated successfully');
$redirect = 'tickets.php?id='.$ticket->getId();
$_REQUEST['a'] = null; //Clear edit action - going back to view. $_REQUEST['a'] = null; //Clear edit action - going back to view.
//Check to make sure the staff STILL has access post-update (e.g dept change). //Check to make sure the staff STILL has access post-update (e.g dept change).
if(!$ticket->checkStaffPerm($thisstaff)) if(!$ticket->checkStaffPerm($thisstaff))
...@@ -335,6 +339,12 @@ if($_POST && !$errors): ...@@ -335,6 +339,12 @@ if($_POST && !$errors):
$thisstaff ->resetStats(); //We'll need to reflect any changes just made! $thisstaff ->resetStats(); //We'll need to reflect any changes just made!
endif; endif;
if ($redirect) {
if ($msg)
Messages::success($msg);
Http::redirect($redirect);
}
/*... Quick stats ...*/ /*... Quick stats ...*/
$stats= $thisstaff->getTicketsStats(); $stats= $thisstaff->getTicketsStats();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment