diff --git a/hook.php b/hook.php index d463ad7f3..7fe39c81b 100644 --- a/hook.php +++ b/hook.php @@ -151,6 +151,24 @@ 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) { + $AS = $table; + } + } + $join = " LEFT JOIN `$new_table` AS `$AS` ON (`glpi_groups_tickets_original_id`.`groups_id` = `$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 (`glpi_tickets_users_original_id`.`users_id` = `$AS`.`id`) "; + } break; } diff --git a/inc/issue.class.php b/inc/issue.class.php index 03df9df7e..5883d1637 100644 --- a/inc/issue.class.php +++ b/inc/issue.class.php @@ -428,6 +428,46 @@ public function rawSearchOptions() { ] ]; + $tab[] = [ + 'id' => '14', + 'table' => User::getTable(), + 'field' => 'name', + 'linkfield' => 'users_id', + 'name' => __('Technician'), + 'datatype' => 'dropdown', + 'forcegroupby' => false, + 'massiveaction' => false, + 'joinparams' => [ + 'beforejoin' => [ + 'table' => Ticket_User::getTable(), + 'linkfield' => 'original_id', + 'joinparams' => [ + 'jointype' => 'empty', + ] + ] + ] + ]; + + $tab[] = [ + 'id' => '15', + 'table' => Group::getTable(), + 'field' => 'name', + 'linkfield' => 'groups_id', + 'name' => __('Technician group'), + 'datatype' => 'dropdown', + 'forcegroupby' => false, + 'massiveaction' => false, + 'joinparams' => [ + 'beforejoin' => [ + 'table' => Group_Ticket::getTable(), + 'linkfield' => 'original_id', + 'joinparams' => [ + 'jointype' => 'empty', + ] + ] + ] + ]; + return $tab; }