Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default document category #3345

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading