File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -803,6 +803,8 @@ protected function getTargetTemplate(array $data): int {
803803 * @return Ticket|null Generated ticket if success, null otherwise
804804 */
805805 public function save (PluginFormcreatorFormAnswer $ formanswer ): ?CommonDBTM {
806+ global $ CFG_GLPI ;
807+
806808 $ ticket = new Ticket ();
807809 $ form = $ formanswer ->getForm ();
808810 $ data = $ this ->getDefaultData ($ formanswer );
@@ -904,6 +906,22 @@ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM {
904906 return null ;
905907 }
906908
909+ // Set default document category
910+ $ document_category = $ CFG_GLPI ['documentcategories_id_forticket ' ] ?? 0 ;
911+ if ($ document_category ) {
912+ foreach (array_keys ($ this ->attachedDocuments ) as $ documents_id ) {
913+ $ document = Document::getById ($ documents_id );
914+ if (!$ document ) {
915+ continue ;
916+ }
917+
918+ $ document ->update ([
919+ 'id ' => $ document ->fields ['id ' ],
920+ 'documentcategories_id ' => $ document_category ,
921+ ]);
922+ }
923+ }
924+
907925 $ this ->saveTags ($ formanswer , $ ticketID );
908926
909927 // Add link between Ticket and FormAnswer
You can’t perform that action at this time.
0 commit comments