Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Add an option to enable monitor serialnumber partial matching #2865

Merged
merged 3 commits into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function initConfigModule($getOnly = false) {
$input['import_registry'] = 1;
$input['import_process'] = 1;
$input['import_vm'] = 1;
$input['import_monitor_on_partial_sn'] = 0;
$input['component_processor'] = 1;
$input['component_memory'] = 1;
$input['component_harddrive'] = 1;
Expand Down Expand Up @@ -591,7 +592,12 @@ static function showFormInventory($options = []) {
echo "<td>";
Dropdown::showYesNo("manage_osname", $pfConfig->getValue('manage_osname'));
echo "</td>";
echo "<td colspan='2'></td>";
echo "<td>";
echo __('Import monitor on serial partial match:', 'fusioninventory');
echo "</td>";
echo "<td>";
Dropdown::showYesNo("import_monitor_on_partial_sn", $pfConfig->getValue('import_monitor_on_partial_sn'));
echo "</td>";
echo "</tr>";

echo "<tr class='tab_bg_1'>";
Expand Down
7 changes: 7 additions & 0 deletions inc/inventoryruleimport.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ function getCriteriaByID($critname) {
function findWithGlobalCriteria($input) {
global $DB, $CFG_GLPI;

$pfConfig = new PluginFusioninventoryConfig();

PluginFusioninventoryToolbox::logIfExtradebug(
"pluginFusioninventory-rules",
$input
Expand Down Expand Up @@ -568,6 +570,11 @@ function findWithGlobalCriteria($input) {
OR `[typetable]`.`serial`='".$serial2."')";
$_SESSION["plugin_fusioninventory_serialHP"] = $serial2;

// Support partial match for monitor serial
} else if (isset($input['itemtype'])
AND $input['itemtype'] == 'Monitor'
AND $pfConfig->getValue('import_monitor_on_partial_sn') == 1) {
$sql_where_temp = " AND `[typetable]`.`serial` LIKE '%".$input["serial"]."%'";
trasher marked this conversation as resolved.
Show resolved Hide resolved
} else {
$sql_where_temp = " AND `[typetable]`.`serial`='".$input["serial"]."'";
}
Expand Down
1 change: 1 addition & 0 deletions install/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ function pluginFusioninventoryUpdate($current_version, $migrationname = 'Migrati
'import_registry' => 1,
'import_process' => 1,
'import_vm' => 1,
'import_monitor_on_partial_sn' => 0,
'component_processor' => 1,
'component_memory' => 1,
'component_harddrive' => 1,
Expand Down