fusioninventory-for-glpi icon indicating copy to clipboard operation
fusioninventory-for-glpi copied to clipboard

9.5+4.1 monitor model clean

Open 39612 opened this issue 3 years ago • 5 comments
trafficstars

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? Capturar

39612 avatar Jun 17 '22 12:06 39612

Version of plugin FusionInventory?

ddurieux avatar Jun 17 '22 12:06 ddurieux

Version of plugin FusionInventory 9.5 - 4.1

39612 avatar Jun 17 '22 14:06 39612

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'] = '';
			}
        } 
    }

39612 avatar Jun 24 '22 17:06 39612

But it's only for a monitor case, because many not have model in the name

ddurieux avatar Jun 24 '22 19:06 ddurieux

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?

39612 avatar Jun 25 '22 21:06 39612