fusioninventory-for-glpi
fusioninventory-for-glpi copied to clipboard
9.5+4.1 monitor model clean
The monitor name "Acer G227HQL" where "Acer" is the brand and "G227HQL" the model. Is it possible that the model also goes to the Model field?
Version of plugin FusionInventory?
Version of plugin FusionInventory 9.5 - 4.1
I changed the file formatconvert.class.php. In the part on the monitor and it was resolved. I send the code below. // * MONITORS $a_inventory['monitor'] = []; if (isset($array['MONITORS'])) { $a_serialMonitor = []; foreach ($array['MONITORS'] as $a_monitors) { $array_tmp = $thisc->addValues($a_monitors, [ 'CAPTION' => 'name', 'MANUFACTURER' => 'manufacturers_id', 'SERIAL' => 'serial', 'DESCRIPTION' => 'comment']);
$array_tmp['is_dynamic'] = 1;
if (isset($array_tmp['name'])) {
if (isset($array_tmp['manufacturers_id'])) {
preg_match('/\b\w+\b/i', $array_tmp['manufacturers_id'], $res_manufacture);
preg_match('/\b\w+\b/i', $array_tmp['name'], $res_monitormodel);
if (strcasecmp($res_manufacture[0], $res_monitormodel[0]) != 0) {
$array_tmp['name'] = $res_manufacture[0] . " " . $array_tmp['name'];
}
}
} else if (isset($array_tmp['comment'])) {
$array_tmp['name'] = $array_tmp['comment'];
}
if (isset($array_tmp['comment'])) {
unset($array_tmp['comment']);
}
if (!isset($array_tmp['serial'])) {
$array_tmp['serial'] = '';
}
if (!isset($array_tmp['manufacturers_id'])) {
$array_tmp['manufacturers_id'] = '';
}
if (!isset($a_serialMonitor[$array_tmp['serial']])) {
$a_inventory['monitor'][] = $array_tmp;
$a_serialMonitor[$array_tmp['serial']] = 1;
}
if (!isset($array_tmp['serial'])) {
$array_tmp['serial'] = '';
}
}
}
But it's only for a monitor case, because many not have model in the name
But in the original code, if there is no model in the name, it puts the comments original code:
$array_tmp = $thisc->addValues($a_monitors,
[
'CAPTION' => 'monitormodels_id',
'MANUFACTURER' => 'manufacturers_id',
'SERIAL' => 'serial',
'DESCRIPTION' => 'comment']);
$array_tmp['is_dynamic'] = 1;
$array_tmp['name'] = '';
if ($array_tmp['name'] == '' && isset($array_tmp['monitormodels_id'])) {
if (isset($array_tmp['manufacturers_id'])) {
preg_match('/\b\w+\b/i', $array_tmp['manufacturers_id'], $res_manufacture);
preg_match('/\b\w+\b/i', $array_tmp['monitormodels_id'], $res_monitormodel);
if (strcasecmp($res_manufacture[0], $res_monitormodel[0]) != 0) {
$array_tmp['name'] = $res_manufacture[0] . " " . $array_tmp['monitormodels_id'];
} else {
$array_tmp['name'] = $array_tmp['monitormodels_id'];
}
} else {
$array_tmp['name'] = $array_tmp['monitormodels_id'];
}
} else if (isset($array_tmp['comment'])) {
$array_tmp['name'] = $array_tmp['comment'];
}
proposed code:
foreach ($array['MONITORS'] as $a_monitors) {
$array_tmp = $thisc->addValues($a_monitors,
[
'CAPTION' => 'name',
'MANUFACTURER' => 'manufacturers_id',
'SERIAL' => 'serial',
'DESCRIPTION' => 'comment']);
$array_tmp['is_dynamic'] = 1;
if (isset($array_tmp['name'])) {
if (isset($array_tmp['manufacturers_id'])) {
preg_match('/\b\w+\b/i', $array_tmp['manufacturers_id'], $res_manufacture);
preg_match('/\b\w+\b/i', $array_tmp['name'], $res_monitormodel);
if (strcasecmp($res_manufacture[0], $res_monitormodel[0]) != 0) {
$array_tmp['name'] = $res_manufacture[0] . " " . $array_tmp['name'];
}
}
} else if (isset($array_tmp['comment'])) {
$array_tmp['name'] = $array_tmp['comment'];
}
If I'm seeing the code wrong, can you explain it better?