Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions inc/item_softwareversion.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Comment thread
Herafia marked this conversation as resolved.
$itemname = $linkeditem->getFromDB($item_SoftwareVersion->fields['items_id']) ? $linkeditem->getName() : '(' . $item_SoftwareVersion->fields['items_id'] . ')';

$pdf->setColumnsSize(100);
$pdf->displayTitle('<b><i>' . sprintf(__s('%1$s: %2$s'), __s('ID') . '</i>', $ID . '</b>'));

$pdf->setColumnsSize(50, 50);
$pdf->displayLine(
'<b><i>' . sprintf(__s('%1$s: %2$s'), _sn('Software', 'Software', 1) . '</i></b>', $software->fields['name']),
'<b><i>' . sprintf(__s('%1$s: %2$s'), _n('Version', 'Versions', 1) . '</i></b>', $version->fields['name']),
);
$pdf->displayLine(
'<b><i>' . sprintf(__s('%1$s: %2$s'), _n('Associated element', 'Associated elements', 1) . '</i></b>', $itemname),
'<b><i>' . sprintf(__s('%1$s: %2$s'), __s('Installation date') . '</i></b>', Html::convDate($item_SoftwareVersion->fields['date_install'])),
);
$pdf->displaySpace();
}

public static function pdfForSoftware(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
/** @var array $CFG_GLPI */
Expand Down
1 change: 1 addition & 0 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down