From 9040db682757499cbf70f4bc5c8f49e6f0ca0e5c Mon Sep 17 00:00:00 2001
From: JediKev <kevin@enhancesoft.com>
Date: Wed, 9 Jan 2019 12:25:15 -0600
Subject: [PATCH] profile: Reply Redirect

This pull adds a Profile Setting for Agents to choose where to redirect
after replying to ticket. The two options are Queue (redirect to queue to
work on other tickets) or Ticket (redirect back to same ticket to continue
working) with the latter being the default. The setting is configurable for
each Agent in the helpdesk.
---
 include/class.staff.php       |  6 ++++++
 include/staff/profile.inc.php | 17 +++++++++++++++++
 scp/tickets.php               |  2 +-
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/include/class.staff.php b/include/class.staff.php
index 3833c6353..c9aa07dac 100644
--- a/include/class.staff.php
+++ b/include/class.staff.php
@@ -91,6 +91,7 @@ implements AuthenticatedUser, EmailContact, TemplateVariable, Searchable {
                         'datetime_format'   => '',
                         'thread_view_order' => '',
                         'default_ticket_queue_id' => 0,
+                        'reply_redirect' => 'Ticket',
                         ));
             $this->_config = $_config->getInfo();
         }
@@ -347,6 +348,10 @@ implements AuthenticatedUser, EmailContact, TemplateVariable, Searchable {
         return $this->default_paper_size;
     }
 
+    function getReplyRedirect() {
+        return $this->reply_redirect;
+    }
+
     function forcePasswdChange() {
         return $this->change_passwd;
     }
@@ -744,6 +749,7 @@ implements AuthenticatedUser, EmailContact, TemplateVariable, Searchable {
                     'default_from_name' => $vars['default_from_name'],
                     'thread_view_order' => $vars['thread_view_order'],
                     'default_ticket_queue_id' => $vars['default_ticket_queue_id'],
+                    'reply_redirect' => ($vars['reply_redirect'] == 'Queue') ? 'Queue' : 'Ticket',
                     )
                 );
         $this->_config = $_config->getInfo();
diff --git a/include/staff/profile.inc.php b/include/staff/profile.inc.php
index 78bab30bf..1acb99a26 100644
--- a/include/staff/profile.inc.php
+++ b/include/staff/profile.inc.php
@@ -300,6 +300,23 @@ if ($avatar->isChangeable()) { ?>
                 <div class="error"><?php echo $errors['default_paper_size']; ?></div>
             </td>
         </tr>
+        <tr>
+            <td><?php echo __('Reply Redirect'); ?>:
+                <div class="faded"><?php echo __('Redirect URL used after replying to a ticket.');?></div>
+            </td>
+            <td>
+                <select name="reply_redirect">
+                  <?php
+                  $options=array('Queue'=>__('Queue'),'Ticket'=>__('Ticket'));
+                  foreach($options as $key=>$opt) {
+                      echo sprintf('<option value="%s" %s>%s</option>',
+                                $key,($staff->reply_redirect==$key)?'selected="selected"':'',$opt);
+                  }
+                  ?>
+                </select>
+                <div class="error"><?php echo $errors['reply_redirect']; ?></div>
+            </td>
+        </tr>
       </tbody>
       <tbody>
         <tr class="header">
diff --git a/scp/tickets.php b/scp/tickets.php
index 8881874e8..27179c0be 100644
--- a/scp/tickets.php
+++ b/scp/tickets.php
@@ -214,7 +214,7 @@ if($_POST && !$errors):
                     $ticket = null;
 
                 $redirect = 'tickets.php';
-                if ($ticket)
+                if ($ticket && $thisstaff->getReplyRedirect() == 'Ticket')
                     $redirect = 'tickets.php?id='.$ticket->getId();
 
             } elseif (!$errors['err']) {
-- 
GitLab