From d367a12e21572153857bbb0d4f5f902b4dbd508c Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Mon, 8 Sep 2014 16:06:06 +0000 Subject: [PATCH] Ticket status change Redirect to tickets listing page when a ticket is resolved or closed via status change. --- include/ajax.tickets.php | 14 ++++++++++---- include/staff/templates/status-options.tmpl.php | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index bb5b86c36..bb6274f52 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -789,16 +789,23 @@ class TicketsAjaxAPI extends AjaxController { } } + $state = strtolower($status->getState()); + if (!$errors && $ticket->setStatus($status, $_REQUEST['comments'])) { - if (!strcasecmp($status->getState(), 'deleted')) { + if ($state == 'deleted') { $msg = sprintf('%s %s', sprintf(__('Ticket #%s'), $ticket->getNumber()), __('deleted sucessfully') ); + } elseif ($state != 'open') { + $msg = sprintf(__('%s status changed to %s'), + sprintf(__('Ticket #%s'), $ticket->getNumber()), + $status->getName()); } else { $msg = sprintf( - __('Successfully changed ticket status to %s'), + __('%s status changed to %s'), + __('Ticket'), $status->getName()); } @@ -809,8 +816,7 @@ class TicketsAjaxAPI extends AjaxController { $errors['err'] = __('Error updating ticket status'); } - $state = $status - ? $status->getState() : $ticket->getStatus()->getState(); + $state = $state ?: $ticket->getStatus()->getState(); $info['status_id'] = $status ? $status->getId() : $ticket->getStatusId(); diff --git a/include/staff/templates/status-options.tmpl.php b/include/staff/templates/status-options.tmpl.php index 19235f19b..a0047553c 100644 --- a/include/staff/templates/status-options.tmpl.php +++ b/include/staff/templates/status-options.tmpl.php @@ -4,11 +4,13 @@ global $thisstaff, $ticket; $actions= array( 'closed' => array( 'icon' => 'icon-repeat', - 'action' => 'close' + 'action' => 'close', + 'href' => 'tickets.php' ), 'resolved' => array( 'icon' => 'icon-ok-circle', - 'action' => 'resolve' + 'action' => 'resolve', + 'href' => 'tickets.php' ), 'open' => array( 'icon' => 'icon-undo', @@ -49,7 +51,14 @@ $actions= array( echo sprintf('#%s/status/%s/%d', $ticket ? ('tickets/'.$ticket->getId()) : 'tickets', $actions[$status->getState()]['action'], - $status->getId()); ?>"><i class=" aaa <?php + $status->getId()); ?>" + <?php + if (isset($actions[$status->getState()]['href'])) + echo sprintf('data-href="%s"', + $actions[$status->getState()]['href']); + + ?> + ><i class="<?php echo $actions[$status->getState()]['icon'] ?: 'icon-tag'; ?>"></i> <?php echo __($status->getName()); ?></a> -- GitLab