Skip to content

Commit

Permalink
fix(issue): merge 2 search options
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Aug 3, 2023
1 parent 54543cb commit 6e120c4
Showing 1 changed file with 74 additions and 50 deletions.
124 changes: 74 additions & 50 deletions inc/issue.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
}

use Glpi\RichText\RichText;
use PluginFormcreatorIssue as GlobalPluginFormcreatorIssue;

class PluginFormcreatorIssue extends CommonDBTM {
static $rightname = 'ticket';

Expand Down Expand Up @@ -684,7 +686,7 @@ public function rawSearchOptions() {
'joinparams' => [
'jointype' => 'empty',
'condition' => [
new \QueryExpression(
new QueryExpression(
'1=1'
),
],
Expand Down Expand Up @@ -721,34 +723,36 @@ public function rawSearchOptions() {
}
$tab[] = $newtab;

$newtab = [
'id' => '14',
'table' => User::getTable(),
'field' => 'name',
'name' => __('Technician'),
'datatype' => 'dropdown',
'massiveaction' => false,
'nodisplay' => $hide_technician,
'nosearch' => $hide_technician,
'right' => 'interface',
'joinparams' => [
'beforejoin' => [
'table' => Ticket_User::getTable(),
'joinparams' => [
'condition' => "AND NEWTABLE.`type` = '2'", // Assign
'jointype' => 'child',
'beforejoin' => [
'table' => Ticket::getTable(),
'joinparams' => [
'jointype' => 'itemtype_item_revert',
'specific_itemtype' => Ticket::class,
],
]
]
]
]
];
$tab[] = $newtab;
// $newtab = [
// 'id' => '14',
// 'table' => User::getTable(),
// 'field' => 'name',
// 'name' => __('Technician'),
// 'datatype' => 'dropdown',
// 'massiveaction' => false,
// 'nodisplay' => $hide_technician,
// 'nosearch' => $hide_technician,
// 'right' => 'interface',
// 'joinparams' => [
// 'beforejoin' => [
// 'table' => Ticket_User::getTable(),
// 'joinparams' => [
// 'condition' => [
// 'NEWTABLE.type' => CommonITILActor::ASSIGN, // Assign
// ],
// 'jointype' => 'child',
// 'beforejoin' => [
// 'table' => Ticket::getTable(),
// 'joinparams' => [
// 'jointype' => 'itemtype_item_revert',
// 'specific_itemtype' => Ticket::class,
// ],
// ]
// ]
// ]
// ]
// ];
// $tab[] = $newtab;

if (!Session::isCron() // no filter for cron
&& Session::getCurrentInterface() != 'helpdesk') {
Expand Down Expand Up @@ -920,7 +924,7 @@ public function rawSearchOptions() {
'joinparams' => [
'jointype' => 'empty',
'condition' => [
new \QueryExpression(
new QueryExpression(
'1=1'
),
],
Expand Down Expand Up @@ -951,37 +955,57 @@ public function rawSearchOptions() {
'field' => 'name',
'name' => __('Ticket technician', 'formcreator'),
'massiveaction' => false,
'nosearch' => true,
'nodisplay' => $hide_technician,
'nosearch' => $hide_technician,
'datatype' => 'dropdown',
'forcegroupby' => true,
'joinparams' => [
'jointype' => 'empty',
// 'jointype' => 'empty',
'beforejoin' => [
'table' => Ticket_User::getTable(),
'joinparams' => [
'jointype' => 'child',
'condition' => [
'NEWTABLE.type' => CommonITILActor::ASSIGN,
// glpi_tickets_a89eed976546dbc70964a86fe8724e95 matches the table in the 1st item in before join below
new QueryExpression(
'NEWTABLE.type = ' . CommonITILActor::ASSIGN .
' OR ' . '`glpi_tickets_a89eed976546dbc70964a86fe8724e95`.`id` = `NEWTABLE`.`tickets_id`' .
'AND NEWTABLE.type = ' . CommonITILActor::ASSIGN
),
],
'beforejoin' => [
'table' => Ticket::getTable(),
'joinparams' => [
'jointype' => 'empty',
'condition' => [
new \QueryExpression(
'1=1'
),
[
'table' => Ticket::getTable(),
'joinparams' => [
'jointype' => 'itemtype_item_revert',
'specific_itemtype' => Ticket::class,
'condition' => [
new QueryExpression(
'2=2'
),
],
],
'beforejoin' => [
'table' => Item_Ticket::getTable(),
'joinparams' => [
'jointype' => 'itemtype_item',
'specific_itemtype' => PluginFormcreatorFormAnswer::class,
'beforejoin' => [
'table' => PluginFormcreatorFormAnswer::getTable(),
'joinparams' => [
'jointype' => 'itemtype_item_revert',
'specific_itemtype' => PluginFormcreatorFormAnswer::class,
],
[
'table' => Ticket::getTable(),
'joinparams' => [
'jointype' => 'empty',
'condition' => [
new QueryExpression(
'3=3'
),
],
'beforejoin' => [
'table' => Item_Ticket::getTable(),
'joinparams' => [
'jointype' => 'itemtype_item',
'specific_itemtype' => PluginFormcreatorFormAnswer::class,
'beforejoin' => [
'table' => PluginFormcreatorFormAnswer::getTable(),
'joinparams' => [
'jointype' => 'itemtype_item_revert',
'specific_itemtype' => PluginFormcreatorFormAnswer::class,
],
],
],
],
Expand Down

0 comments on commit 6e120c4

Please sign in to comment.