From bb37578bb15f30db1bc0f2919c73fd5b449023b4 Mon Sep 17 00:00:00 2001 From: Herafia Date: Thu, 18 Jun 2026 11:45:58 +0200 Subject: [PATCH 1/3] Add PDF export MA for software installations --- inc/item_softwareversion.class.php | 29 +++++++++++++++++++++++++++++ setup.php | 1 + 2 files changed, 30 insertions(+) diff --git a/inc/item_softwareversion.class.php b/inc/item_softwareversion.class.php index 9e0035a..169d2b8 100644 --- a/inc/item_softwareversion.class.php +++ b/inc/item_softwareversion.class.php @@ -71,6 +71,35 @@ public function __construct(?CommonGLPI $obj = null) $this->obj = ($obj ?: new Item_SoftwareVersion()); } + public static function pdfMain(PluginPdfSimplePDF $pdf, Item_SoftwareVersion $item_SoftwareVersion) + { + $ID = $item_SoftwareVersion->getField('id'); + + $version = new SoftwareVersion(); + $version->getFromDB($item_SoftwareVersion->fields['softwareversions_id']); + + $software = new Software(); + $software->getFromDB($version->fields['softwares_id']); + + $itemtype = $item_SoftwareVersion->fields['itemtype']; + $linkeditem = new $itemtype(); + $itemname = $linkeditem->getFromDB($item_SoftwareVersion->fields['items_id']) ? $linkeditem->getName() : '(' . $item_SoftwareVersion->fields['items_id'] . ')'; + + $pdf->setColumnsSize(100); + $pdf->displayTitle('' . sprintf(__s('%1$s: %2$s'), __s('ID') . '', $ID . '')); + + $pdf->setColumnsSize(50, 50); + $pdf->displayLine( + '' . sprintf(__s('%1$s: %2$s'), _sn('Software', 'Software', 1) . '', $software->fields['name']), + '' . sprintf(__s('%1$s: %2$s'), _n('Version', 'Versions', 1) . '', $version->fields['name']), + ); + $pdf->displayLine( + '' . sprintf(__s('%1$s: %2$s'), _n('Associated element', 'Associated elements', 1) . '', $itemname), + '' . sprintf(__s('%1$s: %2$s'), __s('Installation date') . '', Html::convDate($item_SoftwareVersion->fields['date_install'])), + ); + $pdf->displaySpace(); + } + public static function pdfForSoftware(PluginPdfSimplePDF $pdf, CommonDBTM $item) { /** @var array $CFG_GLPI */ diff --git a/setup.php b/setup.php index f3da516..8068aee 100644 --- a/setup.php +++ b/setup.php @@ -94,6 +94,7 @@ function plugin_init_pdf() $PLUGIN_HOOKS['plugin_pdf']['Printer'] = 'PluginPdfPrinter'; $PLUGIN_HOOKS['plugin_pdf']['Problem'] = 'PluginPdfProblem'; $PLUGIN_HOOKS['plugin_pdf']['Software'] = 'PluginPdfSoftware'; + $PLUGIN_HOOKS['plugin_pdf']['Item_SoftwareVersion'] = 'PluginPdfItem_SoftwareVersion'; $PLUGIN_HOOKS['plugin_pdf']['SoftwareLicense'] = 'PluginPdfSoftwareLicense'; $PLUGIN_HOOKS['plugin_pdf']['SoftwareVersion'] = 'PluginPdfSoftwareVersion'; $PLUGIN_HOOKS['plugin_pdf']['Ticket'] = 'PluginPdfTicket'; From d795ff450fcc162d8a7a73bbbfa9e44a7b390242 Mon Sep 17 00:00:00 2001 From: Herafia Date: Thu, 18 Jun 2026 11:51:31 +0200 Subject: [PATCH 2/3] CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f42bf7..0b3cf93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fix image (field : description) in to pdf - Fix massive action PDF export redirecting to item list instead of generating the PDF +### Added + +- PDF export mass action for software installations + ## [4.1.2] - 2026-01-08 ### Fixed From d6eab7bc57d614ffa8e591e5b95b8797f1186678 Mon Sep 17 00:00:00 2001 From: Herafia Date: Fri, 19 Jun 2026 09:37:15 +0200 Subject: [PATCH 3/3] fix --- inc/item_softwareversion.class.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/inc/item_softwareversion.class.php b/inc/item_softwareversion.class.php index 169d2b8..a67b47c 100644 --- a/inc/item_softwareversion.class.php +++ b/inc/item_softwareversion.class.php @@ -76,12 +76,18 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Item_SoftwareVersion $it $ID = $item_SoftwareVersion->getField('id'); $version = new SoftwareVersion(); - $version->getFromDB($item_SoftwareVersion->fields['softwareversions_id']); - + if (!$version->getFromDB($item_SoftwareVersion->fields['softwareversions_id'])) { + return; + } $software = new Software(); - $software->getFromDB($version->fields['softwares_id']); + if (!$software->getFromDB($version->fields['softwares_id'])) { + return; + } $itemtype = $item_SoftwareVersion->fields['itemtype']; + if (!class_exists($itemtype)) { + return; + } $linkeditem = new $itemtype(); $itemname = $linkeditem->getFromDB($item_SoftwareVersion->fields['items_id']) ? $linkeditem->getName() : '(' . $item_SoftwareVersion->fields['items_id'] . ')';