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 diff --git a/inc/item_softwareversion.class.php b/inc/item_softwareversion.class.php index 9e0035a..a67b47c 100644 --- a/inc/item_softwareversion.class.php +++ b/inc/item_softwareversion.class.php @@ -71,6 +71,41 @@ 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(); + if (!$version->getFromDB($item_SoftwareVersion->fields['softwareversions_id'])) { + return; + } + $software = new Software(); + 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'] . ')'; + + $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';