@@ -95,18 +95,16 @@ public static function getSyncIssuesRequest() : AbstractQuery {
9595 new QueryExpression ("CONCAT('f_', ` $ formAnswerTable`.`id`) as `display_id` " ),
9696 "$ formAnswerTable.id as items_id " ,
9797 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 ' ,
110108 ],
111109 'DISTINCT ' => true ,
112110 'FROM ' => $ formAnswerTable ,
@@ -142,16 +140,13 @@ public static function getSyncIssuesRequest() : AbstractQuery {
142140 new QueryExpression ("CONCAT('t_', ` $ ticketTable`.`id`) as `display_id` " ),
143141 "$ ticketTable.id as items_id " ,
144142 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 . " ') ,
146144 ` $ ticketTable`.`status`,
147- IF(` $ ticketTable`.`global_validation ` IN (' " . CommonITILValidation:: NONE . "', ' " . CommonITILValidation:: ACCEPTED . "'),
145+ IF(` $ ticketTable`.`status ` IN (' " . CommonITILObject:: SOLVED . "', ' " . CommonITILObject:: CLOSED . "'),
148146 ` $ 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 . "'
155150 )
156151 )
157152 ) AS `status` " ),
@@ -161,9 +156,9 @@ public static function getSyncIssuesRequest() : AbstractQuery {
161156 'entities_id as entities_id '
162157 ],
163158 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 ' ),
167162 "$ ticketTable.content as comment " ,
168163 'users_id_recipient as users_id_recipient '
169164 ],
@@ -195,12 +190,12 @@ public static function getSyncIssuesRequest() : AbstractQuery {
195190 $ ticketUserTable => $ ticketFk ,
196191 ],
197192 ],
198- $ ticketValidationTable => [
199- 'FKEY ' => [
200- $ ticketTable => 'id ' ,
201- $ ticketValidationTable => $ ticketFk ,
202- ],
203- ],
193+ // $ticketValidationTable => [
194+ // 'FKEY' => [
195+ // $ticketTable => 'id',
196+ // $ticketValidationTable => $ticketFk,
197+ // ],
198+ // ],
204199 ],
205200 'WHERE ' => [
206201 "$ ticketTable.is_deleted " => 0 ,
@@ -216,7 +211,7 @@ public static function getSyncIssuesRequest() : AbstractQuery {
216211 'INNER JOIN ' => [$ itemTicketTable => $ query2 ['LEFT JOIN ' ][$ itemTicketTable ]],
217212 'LEFT JOIN ' => [
218213 $ query2 ['LEFT JOIN ' ][0 ], // This is the TABLE => [...] subquery
219- $ ticketValidationTable => $ query2 ['LEFT JOIN ' ][$ ticketValidationTable ],
214+ // $ticketValidationTable => $query2['LEFT JOIN'][$ticketValidationTable],
220215 ],
221216 'WHERE ' => $ query2 ['WHERE ' ],
222217 'GROUPBY ' => ["$ itemTicketTable.items_id " ],
@@ -499,7 +494,6 @@ public function rawSearchOptions() {
499494 'name ' => __ ('Name ' ),
500495 'datatype ' => 'itemlink ' ,
501496 'massiveaction ' => false ,
502- 'forcegroupby ' => true ,
503497 'additionalfields ' => [
504498 '0 ' => 'display_id '
505499 ]
@@ -583,12 +577,21 @@ public function rawSearchOptions() {
583577
584578 $ newtab = [
585579 'id ' => '9 ' ,
586- 'table ' => ' glpi_users ' ,
580+ 'table ' => User:: getTable () ,
587581 'field ' => 'name ' ,
588582 'linkfield ' => 'users_id_validator ' ,
589583 'name ' => __ ('Form approver ' , 'formcreator ' ),
590584 '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+ ],
592595 ];
593596 if (!Session::isCron () // no filter for cron
594597 && Session::getCurrentInterface () == 'helpdesk ' ) {
@@ -613,12 +616,12 @@ public function rawSearchOptions() {
613616 'field ' => 'name ' ,
614617 'linkfield ' => 'users_id_validate ' ,
615618 'name ' => __ ('Ticket approver ' , 'formcreator ' ),
616- 'datatype ' => 'dropdown ' ,
619+ 'datatype ' => 'itemlink ' ,
617620 'right ' => [
618621 '0 ' => 'validate_request ' ,
619622 '1 ' => 'validate_incident '
620623 ],
621- 'forcegroupby ' => false ,
624+ 'forcegroupby ' => true ,
622625 'massiveaction ' => false ,
623626 'joinparams ' => [
624627 'beforejoin ' => [
@@ -636,6 +639,12 @@ public function rawSearchOptions() {
636639 ]
637640 ]
638641 ];
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+ }
639648 if (!Session::isCron () // no filter for cron
640649 && Session::getCurrentInterface () == 'helpdesk ' ) {
641650 $ newtab ['right ' ] = 'id ' ;
@@ -648,7 +657,6 @@ public function rawSearchOptions() {
648657 'field ' => 'name ' ,
649658 'name ' => __ ('Technician ' ),
650659 'datatype ' => 'dropdown ' ,
651- 'forcegroupby ' => true ,
652660 'massiveaction ' => false ,
653661 'nodisplay ' => $ hide_technician ,
654662 'nosearch ' => $ hide_technician ,
@@ -685,12 +693,14 @@ public function rawSearchOptions() {
685693 'massiveaction ' => false ,
686694 'nodisplay ' => $ hide_technician ,
687695 'nosearch ' => $ hide_technician ,
696+ 'condition ' => ['is_assign ' => 1 ],
688697 'joinparams ' => [
689- 'temoin ' => true ,
690698 'beforejoin ' => [
691699 'table ' => Group_Ticket::getTable (),
692700 'joinparams ' => [
693- 'condition ' => "AND NEWTABLE.`type` = '2' " , // Assign
701+ 'condition ' => [
702+ 'NEWTABLE.type ' => CommonITILActor::ASSIGN ,
703+ ],
694704 'jointype ' => 'child ' ,
695705 'beforejoin ' => [
696706 'table ' => Ticket::getTable (),
@@ -706,12 +716,21 @@ public function rawSearchOptions() {
706716
707717 $ tab [] = [
708718 'id ' => '16 ' ,
709- 'table ' => ' glpi_groups ' ,
719+ 'table ' => Group:: getTable () ,
710720 'field ' => 'completename ' ,
721+ 'linkfield ' => 'groups_id_validator ' ,
711722 'name ' => __ ('Form approver group ' , 'formcreator ' ),
712723 'datatype ' => 'itemlink ' ,
713724 '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+ ],
715734 ];
716735
717736 return $ tab ;
0 commit comments