@@ -95,18 +95,16 @@ public static function getSyncIssuesRequest() : AbstractQuery {
95
95
new QueryExpression ("CONCAT('f_', ` $ formAnswerTable`.`id`) as `display_id` " ),
96
96
"$ formAnswerTable.id as items_id " ,
97
97
new QueryExpression ("' " . PluginFormcreatorFormAnswer::getType () . "' as `itemtype` " ),
98
- $ formAnswerTable => [
99
- 'status as status ' ,
100
- 'request_date as date_creation ' ,
101
- 'request_date as date_mod ' ,
102
- 'entities_id as entities_d ' ,
103
- 'is_recursive as is_recursive ' ,
104
- 'requester_id as requester_id ' ,
105
- 'users_id_validator as users_id_validator ' ,
106
- 'groups_id_validator as groups_id_validator ' ,
107
- 'comment as comment ' ,
108
- 'requester_id as users_id_recipient '
109
- ],
98
+ $ formAnswerTable . '.status as status ' ,
99
+ $ formAnswerTable . '.request_date as date_creation ' ,
100
+ $ formAnswerTable . '.request_date as date_mod ' ,
101
+ $ formAnswerTable . '.entities_id as entities_d ' ,
102
+ $ formAnswerTable . '.is_recursive as is_recursive ' ,
103
+ $ formAnswerTable . '.requester_id as requester_id ' ,
104
+ new QueryExpression ('0 as users_id_validator ' ),
105
+ new QueryExpression ('0 as groups_id_validator ' ),
106
+ $ formAnswerTable . '.comment as comment ' ,
107
+ $ formAnswerTable . '.requester_id as users_id_recipient ' ,
110
108
],
111
109
'DISTINCT ' => true ,
112
110
'FROM ' => $ formAnswerTable ,
@@ -142,16 +140,13 @@ public static function getSyncIssuesRequest() : AbstractQuery {
142
140
new QueryExpression ("CONCAT('t_', ` $ ticketTable`.`id`) as `display_id` " ),
143
141
"$ ticketTable.id as items_id " ,
144
142
new QueryExpression ("' " . Ticket::getType () . "' as `itemtype` " ),
145
- new QueryExpression ("IF(` $ ticketValidationTable `.`status` IS NULL ,
143
+ new QueryExpression ("IF(` $ ticketTable `.`global_validation` IN (' " . CommonITILValidation:: NONE . " ', ' " . CommonITILValidation:: ACCEPTED . " ') ,
146
144
` $ ticketTable`.`status`,
147
- IF(` $ ticketTable`.`global_validation ` IN (' " . CommonITILValidation:: NONE . "', ' " . CommonITILValidation:: ACCEPTED . "'),
145
+ IF(` $ ticketTable`.`status ` IN (' " . CommonITILObject:: SOLVED . "', ' " . CommonITILObject:: CLOSED . "'),
148
146
` $ ticketTable`.`status`,
149
- IF(` $ ticketTable`.`status` IN (' " . CommonITILObject::SOLVED . "', ' " . CommonITILObject::CLOSED . "'),
150
- ` $ ticketTable`.`status`,
151
- IF(` $ ticketTable`.`global_validation` = ' " . CommonITILValidation::WAITING . "',
152
- ' " . PluginFormcreatorFormAnswer::STATUS_WAITING . "',
153
- ' " . PluginFormcreatorFormAnswer::STATUS_REFUSED . "'
154
- )
147
+ IF(` $ ticketTable`.`global_validation` = ' " . CommonITILValidation::WAITING . "',
148
+ ' " . PluginFormcreatorFormAnswer::STATUS_WAITING . "',
149
+ ' " . PluginFormcreatorFormAnswer::STATUS_REFUSED . "'
155
150
)
156
151
)
157
152
) AS `status` " ),
@@ -161,9 +156,9 @@ public static function getSyncIssuesRequest() : AbstractQuery {
161
156
'entities_id as entities_id '
162
157
],
163
158
new QueryExpression ('0 as is_recursive ' ),
164
- " $ ticketUserTable. users_id as requester_id" ,
165
- new QueryExpression (" IF(` $ ticketValidationTable `.`users_id_validate` IS NULL, 0, ` $ ticketValidationTable `.`users_id_validate`) as users_id_validator" ),
166
- new QueryExpression ('0 as groups_id_validator ' ),
159
+ new QueryExpression ( " COALESCE(` $ ticketUserTable`.` users_id`, 0) as ` requester_id` " ) ,
160
+ new QueryExpression (' 0 as users_id_validator' ),
161
+ new QueryExpression ('0 as groups_id_validator ' ),
167
162
"$ ticketTable.content as comment " ,
168
163
'users_id_recipient as users_id_recipient '
169
164
],
@@ -195,12 +190,12 @@ public static function getSyncIssuesRequest() : AbstractQuery {
195
190
$ ticketUserTable => $ ticketFk ,
196
191
],
197
192
],
198
- $ ticketValidationTable => [
199
- 'FKEY ' => [
200
- $ ticketTable => 'id ' ,
201
- $ ticketValidationTable => $ ticketFk ,
202
- ],
203
- ],
193
+ // $ticketValidationTable => [
194
+ // 'FKEY' => [
195
+ // $ticketTable => 'id',
196
+ // $ticketValidationTable => $ticketFk,
197
+ // ],
198
+ // ],
204
199
],
205
200
'WHERE ' => [
206
201
"$ ticketTable.is_deleted " => 0 ,
@@ -216,7 +211,7 @@ public static function getSyncIssuesRequest() : AbstractQuery {
216
211
'INNER JOIN ' => [$ itemTicketTable => $ query2 ['LEFT JOIN ' ][$ itemTicketTable ]],
217
212
'LEFT JOIN ' => [
218
213
$ query2 ['LEFT JOIN ' ][0 ], // This is the TABLE => [...] subquery
219
- $ ticketValidationTable => $ query2 ['LEFT JOIN ' ][$ ticketValidationTable ],
214
+ // $ticketValidationTable => $query2['LEFT JOIN'][$ticketValidationTable],
220
215
],
221
216
'WHERE ' => $ query2 ['WHERE ' ],
222
217
'GROUPBY ' => ["$ itemTicketTable.items_id " ],
@@ -499,7 +494,6 @@ public function rawSearchOptions() {
499
494
'name ' => __ ('Name ' ),
500
495
'datatype ' => 'itemlink ' ,
501
496
'massiveaction ' => false ,
502
- 'forcegroupby ' => true ,
503
497
'additionalfields ' => [
504
498
'0 ' => 'display_id '
505
499
]
@@ -583,12 +577,21 @@ public function rawSearchOptions() {
583
577
584
578
$ newtab = [
585
579
'id ' => '9 ' ,
586
- 'table ' => ' glpi_users ' ,
580
+ 'table ' => User:: getTable () ,
587
581
'field ' => 'name ' ,
588
582
'linkfield ' => 'users_id_validator ' ,
589
583
'name ' => __ ('Form approver ' , 'formcreator ' ),
590
584
'datatype ' => 'dropdown ' ,
591
- 'massiveaction ' => false
585
+ 'massiveaction ' => false ,
586
+ 'joinparams ' => [
587
+ 'beforejoin ' => [
588
+ 'table ' => PluginFormcreatorFormAnswer::getTable (),
589
+ 'joinparams ' => [
590
+ 'jointype ' => 'itemtype_item_revert ' ,
591
+ 'specific_itemtype ' => PluginFormcreatorFormAnswer::class,
592
+ ]
593
+ ],
594
+ ],
592
595
];
593
596
if (!Session::isCron () // no filter for cron
594
597
&& Session::getCurrentInterface () == 'helpdesk ' ) {
@@ -613,12 +616,12 @@ public function rawSearchOptions() {
613
616
'field ' => 'name ' ,
614
617
'linkfield ' => 'users_id_validate ' ,
615
618
'name ' => __ ('Ticket approver ' , 'formcreator ' ),
616
- 'datatype ' => 'dropdown ' ,
619
+ 'datatype ' => 'itemlink ' ,
617
620
'right ' => [
618
621
'0 ' => 'validate_request ' ,
619
622
'1 ' => 'validate_incident '
620
623
],
621
- 'forcegroupby ' => false ,
624
+ 'forcegroupby ' => true ,
622
625
'massiveaction ' => false ,
623
626
'joinparams ' => [
624
627
'beforejoin ' => [
@@ -636,6 +639,12 @@ public function rawSearchOptions() {
636
639
]
637
640
]
638
641
];
642
+ if (version_compare (GLPI_VERSION , '10.1 ' ) >= 0 ) {
643
+ $ newtab ['linkfield ' ] = 'items_id_target ' ;
644
+ $ newtab ['condition ' ] = [
645
+ 'REFTABLE.itemtype_target ' => User::class,
646
+ ];
647
+ }
639
648
if (!Session::isCron () // no filter for cron
640
649
&& Session::getCurrentInterface () == 'helpdesk ' ) {
641
650
$ newtab ['right ' ] = 'id ' ;
@@ -648,7 +657,6 @@ public function rawSearchOptions() {
648
657
'field ' => 'name ' ,
649
658
'name ' => __ ('Technician ' ),
650
659
'datatype ' => 'dropdown ' ,
651
- 'forcegroupby ' => true ,
652
660
'massiveaction ' => false ,
653
661
'nodisplay ' => $ hide_technician ,
654
662
'nosearch ' => $ hide_technician ,
@@ -685,12 +693,14 @@ public function rawSearchOptions() {
685
693
'massiveaction ' => false ,
686
694
'nodisplay ' => $ hide_technician ,
687
695
'nosearch ' => $ hide_technician ,
696
+ 'condition ' => ['is_assign ' => 1 ],
688
697
'joinparams ' => [
689
- 'temoin ' => true ,
690
698
'beforejoin ' => [
691
699
'table ' => Group_Ticket::getTable (),
692
700
'joinparams ' => [
693
- 'condition ' => "AND NEWTABLE.`type` = '2' " , // Assign
701
+ 'condition ' => [
702
+ 'NEWTABLE.type ' => CommonITILActor::ASSIGN ,
703
+ ],
694
704
'jointype ' => 'child ' ,
695
705
'beforejoin ' => [
696
706
'table ' => Ticket::getTable (),
@@ -706,12 +716,21 @@ public function rawSearchOptions() {
706
716
707
717
$ tab [] = [
708
718
'id ' => '16 ' ,
709
- 'table ' => ' glpi_groups ' ,
719
+ 'table ' => Group:: getTable () ,
710
720
'field ' => 'completename ' ,
721
+ 'linkfield ' => 'groups_id_validator ' ,
711
722
'name ' => __ ('Form approver group ' , 'formcreator ' ),
712
723
'datatype ' => 'itemlink ' ,
713
724
'massiveaction ' => false ,
714
- 'linkfield ' => 'groups_id_validator ' ,
725
+ 'joinparams ' => [
726
+ 'beforejoin ' => [
727
+ 'table ' => PluginFormcreatorFormAnswer::getTable (),
728
+ 'joinparams ' => [
729
+ 'jointype ' => 'itemtype_item_revert ' ,
730
+ 'specific_itemtype ' => PluginFormcreatorFormAnswer::class,
731
+ ]
732
+ ],
733
+ ],
715
734
];
716
735
717
736
return $ tab ;
0 commit comments