Skip to content

Commit

Permalink
Fix default document category
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienClairembault authored and btry committed Aug 1, 2023
1 parent c5499ad commit 5f2604a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions inc/targetticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5f2604a

Please sign in to comment.