diff --git a/inc/targetticket.class.php b/inc/targetticket.class.php index a20f6f32c..8620abaec 100644 --- a/inc/targetticket.class.php +++ b/inc/targetticket.class.php @@ -803,6 +803,8 @@ protected function getTargetTemplate(array $data): int { * @return Ticket|null Generated ticket if success, null otherwise */ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM { + global $CFG_GLPI; + $ticket = new Ticket(); $form = $formanswer->getForm(); $data = $this->getDefaultData($formanswer); @@ -904,6 +906,22 @@ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM { return null; } + // Set default document category + $document_category = $CFG_GLPI['documentcategories_id_forticket'] ?? 0; + if ($document_category) { + foreach (array_keys($this->attachedDocuments) as $documents_id) { + $document = Document::getById($documents_id); + if (!$document) { + continue; + } + + $document->update([ + 'id' => $document->fields['id'], + 'documentcategories_id' => $document_category, + ]); + } + } + $this->saveTags($formanswer, $ticketID); // Add link between Ticket and FormAnswer