From f3d0d9f782b0726520a8868f313789a3eb950167 Mon Sep 17 00:00:00 2001
From: aydreeihn <adriane@enhancesoft.com>
Date: Thu, 24 Jan 2019 12:33:51 -0600
Subject: [PATCH] Issue: Mass Assign

This commit addresses an issue where a Department might have the Ticket Assignment option set to All Agents, but when trying to mass assign Tickets, only Department Agents were shown in the list.

Note: If mass assign is done on Tickets with different Departments that have different Ticket Assignment rules, Tickets will only be assigned to the Tickets that are allowed the assignment.
---
 include/ajax.tickets.php | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php
index beb0c5613..099d9ecaf 100644
--- a/include/ajax.tickets.php
+++ b/include/ajax.tickets.php
@@ -792,7 +792,15 @@ function refer($tid, $target=null) {
                                 );
 
                     if ($depts) {
-                        $members->filter(Q::any( array(
+                        $all_agent_depts = Dept::objects()->filter(
+                            Q::all( array('id__in' => $depts,
+                            Q::not(array('flags__hasbit'
+                                => Dept::FLAG_ASSIGN_MEMBERS_ONLY)),
+                            Q::not(array('flags__hasbit'
+                                => Dept::FLAG_ASSIGN_PRIMARY_ONLY))
+                            )))->values_flat('id');
+                        if (!count($all_agent_depts)) {
+                            $members->filter(Q::any( array(
                                         'dept_id__in' => $depts,
                                         Q::all(array(
                                             'dept_access__dept__id__in' => $depts,
@@ -802,6 +810,7 @@ function refer($tid, $target=null) {
                                                     => Dept::FLAG_ASSIGN_PRIMARY_ONLY))
                                             ))
                                         )));
+                        }
                     }
 
                     switch ($cfg->getAgentNameFormat()) {
-- 
GitLab