From dd9d2608b83a7273b06f61f9763efa815743d4a3 Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Tue, 22 Jun 2021 12:49:02 +0200 Subject: [PATCH] fix(issue): search options 14 ant 15 Signed-off-by: Thierry Bugier --- hook.php | 24 ------------------------ inc/issue.class.php | 31 ++++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/hook.php b/hook.php index aeefb6190..437c773cf 100644 --- a/hook.php +++ b/hook.php @@ -196,30 +196,6 @@ function plugin_formcreator_addLeftJoin($itemtype, $ref_table, $new_table, $link } $join = " LEFT JOIN `$new_table` AS `$AS` ON (`$ref_table`.`tickets_id` = `$AS`.`tickets_id`) "; } - - if ($new_table == 'glpi_groups') { - foreach ($already_link_tables as $table) { - if (strpos($table, $new_table) === 0) { - $ref = explode('.', $table); - $AS = $ref[0]; - $fk = getForeignKeyFieldForTable($ref[0]); - if (count($ref) > 1) { - $AS = $ref[0]; - $fk = $ref[1]; - } - } - } - $join = " LEFT JOIN `$new_table` AS `$AS` ON (`$ref_table`.`$fk` = `$AS`.`id`) "; - } - - if ($new_table == 'glpi_users' && $linkfield == 'users_id') { - foreach ($already_link_tables as $table) { - if (strpos($table, $new_table) === 0) { - $AS = $table; - } - } - $join = " LEFT JOIN `$new_table` AS `$AS` ON (`$ref_table`.`users_id` = `$AS`.`id`) "; - } break; } diff --git a/inc/issue.class.php b/inc/issue.class.php index 9f9e9ceb9..edf36dd2b 100644 --- a/inc/issue.class.php +++ b/inc/issue.class.php @@ -124,7 +124,7 @@ public static function getSyncIssuesRequest() : AbstractQuery { ] ] ], - 'GROUPBY' => ['items_id'], + 'GROUPBY' => ["$formAnswerTable.id"], 'HAVING' => new QueryExpression("COUNT(`$itemTicketTable`.`$ticketFk`) != 1"), ]); @@ -560,19 +560,25 @@ public function rawSearchOptions() { 'id' => '14', 'table' => User::getTable(), 'field' => 'name', - 'linkfield' => 'users_id', 'name' => __('Technician'), 'datatype' => 'dropdown', - 'forcegroupby' => false, + 'forcegroupby' => true, 'massiveaction' => false, 'nodisplay' => $hide_technician, 'nosearch' => $hide_technician, 'joinparams' => [ 'beforejoin' => [ 'table' => Ticket_User::getTable(), - 'linkfield' => 'original_id', 'joinparams' => [ - 'jointype' => 'empty', + 'condition' => "AND NEWTABLE.`type` = '2'", // Assign + 'jointype' => 'child', + 'beforejoin' => [ + 'table' => Ticket::getTable(), + 'joinparams' => [ + 'jointype' => 'itemtype_item_revert', + 'specific_itemtype' => Ticket::class, + ], + ] ] ] ] @@ -587,19 +593,26 @@ public function rawSearchOptions() { 'id' => '15', 'table' => Group::getTable(), 'field' => 'name', - 'linkfield' => 'groups_id', 'name' => __('Technician group'), 'datatype' => 'dropdown', - 'forcegroupby' => false, + 'forcegroupby' => true, 'massiveaction' => false, 'nodisplay' => $hide_technician, 'nosearch' => $hide_technician, 'joinparams' => [ + 'temoin' => true, 'beforejoin' => [ 'table' => Group_Ticket::getTable(), - 'linkfield' => 'original_id', 'joinparams' => [ - 'jointype' => 'empty', + 'condition' => "AND NEWTABLE.`type` = '2'", // Assign + 'jointype' => 'child', + 'beforejoin' => [ + 'table' => Ticket::getTable(), + 'joinparams' => [ + 'jointype' => 'itemtype_item_revert', + 'specific_itemtype' => Ticket::class, + ], + ] ] ] ]