fusioninventory-for-glpi
fusioninventory-for-glpi copied to clipboard
Get computers linked to printers
Hi everybody,
With Fusioninventory 9.5+3.0 plugin for GLPI and Fusioninventory agent 2.5 i got my printer from computer
image and for this i use this rules : rules.txt (Rename it to xml) But the same printer could be install on different computer ! On each computer inventory the link between printer and computer are changed and i don't see how to fix it ! I thinks it is because this part of code or this one :
if (count($a_printers) || count($db_printers)) {
if (count($db_printers) != 0) {
// Delete printers links in DB
foreach ($db_printers as $idtmp => $data) {
$computer_Item->delete(['id'=>$idtmp], 1);
}
}
if (count($a_printers) != 0) {
foreach ($a_printers as $printers_id) {
$input['entities_id'] = $entities_id;
$input['computers_id'] = $computers_id;
$input['itemtype'] = 'Printer';
$input['items_id'] = $printers_id;
$input['is_dynamic'] = 1;
$input['_no_history'] = $no_history;
$this->computerItemAdd($input, $no_history);
}
/**
-
Manage attach a device (monitor, printer....) to computer */ function computerItemAdd($input, $no_history) { $computer_Item = new Computer_Item();
// Check if the device is yet connected to another computer
$computer_Item->getFromDBByCrit([ 'itemtype' => $input['itemtype'], 'items_id' => $input['items_id'] ]); if (isset($computer_Item->fields['id'])) { $computer_Item->delete(['id' => $computer_Item->fields['id']], true); } $computer_Item->add($input, [], !$no_history);
} }
I have try to make some change but it doesn't work !!
@ddurieux I have reopen a new issue because the previous one will be closed could you mark it to feature please ! Thanks