Skip to content

Commit

Permalink
fix(issue): search options 14 ant 15
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <[email protected]>
  • Loading branch information
btry committed Jul 5, 2021
1 parent f793115 commit dd9d260
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 33 deletions.
24 changes: 0 additions & 24 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
31 changes: 22 additions & 9 deletions inc/issue.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static function getSyncIssuesRequest() : AbstractQuery {
]
]
],
'GROUPBY' => ['items_id'],
'GROUPBY' => ["$formAnswerTable.id"],
'HAVING' => new QueryExpression("COUNT(`$itemTicketTable`.`$ticketFk`) != 1"),
]);

Expand Down Expand Up @@ -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,
],
]
]
]
]
Expand All @@ -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,
],
]
]
]
]
Expand Down

0 comments on commit dd9d260

Please sign in to comment.