@@ -105,8 +105,6 @@ public static function getSyncIssuesRequest() : AbstractQuery {
105
105
'entities_id as entities_d ' ,
106
106
'is_recursive as is_recursive ' ,
107
107
'requester_id as requester_id ' ,
108
- 'users_id_validator as users_id_validator ' ,
109
- 'groups_id_validator as groups_id_validator ' ,
110
108
'comment as comment ' ,
111
109
'requester_id as users_id_recipient '
112
110
],
@@ -145,16 +143,13 @@ public static function getSyncIssuesRequest() : AbstractQuery {
145
143
new QueryExpression ("CONCAT('t_', ` $ ticketTable`.`id`) as `display_id` " ),
146
144
"$ ticketTable.id as items_id " ,
147
145
new QueryExpression ("' " . Ticket::getType () . "' as `itemtype` " ),
148
- new QueryExpression ("IF(` $ ticketValidationTable `.`status` IS NULL ,
146
+ new QueryExpression ("IF(` $ ticketTable `.`global_validation` IN (' " . CommonITILValidation:: NONE . " ', ' " . CommonITILValidation:: ACCEPTED . " ') ,
149
147
` $ ticketTable`.`status`,
150
- IF(` $ ticketTable`.`global_validation ` IN (' " . CommonITILValidation:: NONE . "', ' " . CommonITILValidation:: ACCEPTED . "'),
148
+ IF(` $ ticketTable`.`status ` IN (' " . CommonITILObject:: SOLVED . "', ' " . CommonITILObject:: CLOSED . "'),
151
149
` $ ticketTable`.`status`,
152
- IF(` $ ticketTable`.`status` IN (' " . CommonITILObject::SOLVED . "', ' " . CommonITILObject::CLOSED . "'),
153
- ` $ ticketTable`.`status`,
154
- IF(` $ ticketTable`.`global_validation` = ' " . CommonITILValidation::WAITING . "',
155
- ' " . PluginFormcreatorFormAnswer::STATUS_WAITING . "',
156
- ' " . PluginFormcreatorFormAnswer::STATUS_REFUSED . "'
157
- )
150
+ IF(` $ ticketTable`.`global_validation` = ' " . CommonITILValidation::WAITING . "',
151
+ ' " . PluginFormcreatorFormAnswer::STATUS_WAITING . "',
152
+ ' " . PluginFormcreatorFormAnswer::STATUS_REFUSED . "'
158
153
)
159
154
)
160
155
) AS `status` " ),
@@ -165,8 +160,6 @@ public static function getSyncIssuesRequest() : AbstractQuery {
165
160
],
166
161
new QueryExpression ('0 as is_recursive ' ),
167
162
new QueryExpression ("COALESCE(` $ ticketUserTable`.`users_id`, 0) as `requester_id` " ),
168
- new QueryExpression ("COALESCE(` $ ticketValidationTable`.`users_id_validate`, 0) as `users_id_validator` " ),
169
- new QueryExpression ('0 as groups_id_validator ' ),
170
163
"$ ticketTable.content as comment " ,
171
164
'users_id_recipient as users_id_recipient '
172
165
],
@@ -198,12 +191,6 @@ public static function getSyncIssuesRequest() : AbstractQuery {
198
191
$ ticketUserTable => $ ticketFk ,
199
192
],
200
193
],
201
- $ ticketValidationTable => [
202
- 'FKEY ' => [
203
- $ ticketTable => 'id ' ,
204
- $ ticketValidationTable => $ ticketFk ,
205
- ],
206
- ],
207
194
],
208
195
'WHERE ' => [
209
196
"$ ticketTable.is_deleted " => 0 ,
@@ -219,7 +206,7 @@ public static function getSyncIssuesRequest() : AbstractQuery {
219
206
'INNER JOIN ' => [$ itemTicketTable => $ query2 ['LEFT JOIN ' ][$ itemTicketTable ]],
220
207
'LEFT JOIN ' => [
221
208
$ query2 ['LEFT JOIN ' ][0 ], // This is the TABLE => [...] subquery
222
- $ ticketValidationTable => $ query2 ['LEFT JOIN ' ][$ ticketValidationTable ],
209
+ // $ticketValidationTable => $query2['LEFT JOIN'][$ticketValidationTable],
223
210
],
224
211
'WHERE ' => $ query2 ['WHERE ' ],
225
212
'GROUPBY ' => ["$ itemTicketTable.items_id " ],
@@ -521,7 +508,6 @@ public function rawSearchOptions() {
521
508
'name ' => __ ('Name ' ),
522
509
'datatype ' => 'itemlink ' ,
523
510
'massiveaction ' => false ,
524
- 'forcegroupby ' => true ,
525
511
'additionalfields ' => [
526
512
'0 ' => 'display_id '
527
513
]
@@ -608,14 +594,22 @@ public function rawSearchOptions() {
608
594
} else {
609
595
$ newtab = [
610
596
'id ' => '9 ' ,
611
- 'table ' => ' glpi_users ' ,
597
+ 'table ' => User:: getTable () ,
612
598
'field ' => 'name ' ,
613
599
'linkfield ' => 'users_id_validator ' ,
614
600
'name ' => __ ('Form approver ' , 'formcreator ' ),
615
601
'datatype ' => 'dropdown ' ,
616
- 'massiveaction ' => false
602
+ 'massiveaction ' => false ,
603
+ 'joinparams ' => [
604
+ 'beforejoin ' => [
605
+ 'table ' => PluginFormcreatorFormAnswer::getTable (),
606
+ 'joinparams ' => [
607
+ 'jointype ' => 'itemtype_item_revert ' ,
608
+ 'specific_itemtype ' => PluginFormcreatorFormAnswer::class,
609
+ ]
610
+ ],
611
+ ],
617
612
];
618
-
619
613
}
620
614
if (!Session::isCron () // no filter for cron
621
615
&& Session::getCurrentInterface () == 'helpdesk ' ) {
@@ -640,12 +634,12 @@ public function rawSearchOptions() {
640
634
'field ' => 'name ' ,
641
635
'linkfield ' => 'users_id_validate ' ,
642
636
'name ' => __ ('Ticket approver ' , 'formcreator ' ),
643
- 'datatype ' => 'dropdown ' ,
637
+ 'datatype ' => 'itemlink ' ,
644
638
'right ' => [
645
639
'0 ' => 'validate_request ' ,
646
640
'1 ' => 'validate_incident '
647
641
],
648
- 'forcegroupby ' => false ,
642
+ 'forcegroupby ' => true ,
649
643
'massiveaction ' => false ,
650
644
'joinparams ' => [
651
645
'beforejoin ' => [
@@ -663,6 +657,12 @@ public function rawSearchOptions() {
663
657
],
664
658
]
665
659
];
660
+ if (version_compare (GLPI_VERSION , '10.1 ' ) >= 0 ) {
661
+ $ newtab ['linkfield ' ] = 'items_id_target ' ;
662
+ $ newtab ['condition ' ] = [
663
+ 'REFTABLE.itemtype_target ' => User::class,
664
+ ];
665
+ }
666
666
if (!Session::isCron () // no filter for cron
667
667
&& Session::getCurrentInterface () == 'helpdesk ' ) {
668
668
$ newtab ['right ' ] = 'id ' ;
@@ -675,7 +675,6 @@ public function rawSearchOptions() {
675
675
'field ' => 'name ' ,
676
676
'name ' => __ ('Technician ' ),
677
677
'datatype ' => 'dropdown ' ,
678
- 'forcegroupby ' => true ,
679
678
'massiveaction ' => false ,
680
679
'nodisplay ' => $ hide_technician ,
681
680
'nosearch ' => $ hide_technician ,
@@ -716,7 +715,9 @@ public function rawSearchOptions() {
716
715
'beforejoin ' => [
717
716
'table ' => Group_Ticket::getTable (),
718
717
'joinparams ' => [
719
- 'condition ' => "AND NEWTABLE.`type` = '2' " , // Assign
718
+ 'condition ' => [
719
+ 'NEWTABLE.type ' => CommonITILActor::ASSIGN ,
720
+ ],
720
721
'jointype ' => 'child ' ,
721
722
'beforejoin ' => [
722
723
'table ' => Ticket::getTable (),
@@ -732,17 +733,63 @@ public function rawSearchOptions() {
732
733
}
733
734
734
735
if (Plugin::isPluginActive (PLUGIN_FORMCREATOR_ADVANCED_VALIDATION )) {
735
- $ tab [] = PluginAdvformIssue::rawSearchOptionFormApproverGroup ();
736
+ $ newtab = PluginAdvformIssue::rawSearchOptionFormApproverGroup ();
736
737
} else {
737
- $ tab [] = [
738
+ $ newtab = [
738
739
'id ' => '16 ' ,
739
- 'table ' => ' glpi_groups ' ,
740
+ 'table ' => Group:: getTable () ,
740
741
'field ' => 'completename ' ,
742
+ 'linkfield ' => 'groups_id_validator ' ,
741
743
'name ' => __ ('Form approver group ' , 'formcreator ' ),
742
744
'datatype ' => 'itemlink ' ,
743
745
'massiveaction ' => false ,
744
- 'linkfield ' => 'groups_id_validator ' ,
746
+ 'joinparams ' => [
747
+ 'beforejoin ' => [
748
+ 'table ' => PluginFormcreatorFormAnswer::getTable (),
749
+ 'joinparams ' => [
750
+ 'jointype ' => 'itemtype_item_revert ' ,
751
+ 'specific_itemtype ' => PluginFormcreatorFormAnswer::class,
752
+ ]
753
+ ],
754
+ ],
755
+ ];
756
+ }
757
+ $ tab [] = $ newtab ;
758
+
759
+ if (version_compare (GLPI_VERSION , '10.1 ' ) >= 0 ) {
760
+ $ newtab = [
761
+ 'id ' => '17 ' ,
762
+ 'table ' => Group::getTable (),
763
+ 'field ' => 'name ' ,
764
+ 'linkfield ' => 'items_id_target ' ,
765
+ 'name ' => __ ('Ticket approver group ' , 'formcreator ' ),
766
+ 'datatype ' => 'itemlink ' ,
767
+ 'condition ' => [
768
+ 'REFTABLE.itemtype_target ' => User::class,
769
+ ],
770
+ 'right ' => [
771
+ '0 ' => 'validate_request ' ,
772
+ '1 ' => 'validate_incident '
773
+ ],
774
+ 'forcegroupby ' => true ,
775
+ 'massiveaction ' => false ,
776
+ 'joinparams ' => [
777
+ 'beforejoin ' => [
778
+ 'table ' => TicketValidation::getTable (),
779
+ 'joinparams ' => [
780
+ 'jointype ' => 'child ' ,
781
+ 'beforejoin ' => [
782
+ 'table ' => Ticket::getTable (),
783
+ 'joinparams ' => [
784
+ 'jointype ' => 'itemtype_item_revert ' ,
785
+ 'specific_itemtype ' => Ticket::class,
786
+ ]
787
+ ]
788
+ ]
789
+ ],
790
+ ]
745
791
];
792
+ $ tab [] = $ newtab ;
746
793
}
747
794
748
795
if (Plugin::isPluginActive (PLUGIN_FORMCREATOR_ADVANCED_VALIDATION )) {
0 commit comments