#12026 Fixed widget

This commit is contained in:
Daniel Maya 2023-12-14 17:28:34 +01:00
parent abe950e7d7
commit a008c7486c
1 changed files with 10 additions and 26 deletions

View File

@ -177,6 +177,12 @@ class InventoryWidget extends Widget
// Must be configured before using.
$this->configurationRequired = false;
if (isset($this->values['inventoryModuleId'])
&& $this->values['inventoryModuleId'] === 'basic'
&& $this->values['agentId'] === 0
) {
$this->configurationRequired = true;
}
}
@ -296,9 +302,12 @@ class InventoryWidget extends Widget
];
$fields = [];
array_unshift($fields, __('All'));
if (isset($values['inventoryModuleId']) === false) {
$values['inventoryModuleId'] = 0;
}
$inputs[] = [
'label' => __('Module'),
'arguments' => [
@ -316,31 +325,6 @@ class InventoryWidget extends Widget
],
];
// Agent select.
if ($is_metaconsole === false) {
$agents = [];
$sql = 'SELECT id_agente, nombre FROM tagente';
if ($inventory_id_group > 0) {
$sql .= ' WHERE id_grupo = '.$inventory_id_group;
} else {
$user_groups = implode(',', array_keys(users_get_groups($config['id_user'])));
// Avoid errors if there are no groups.
if (empty($user_groups) === true) {
$user_groups = '"0"';
}
$sql .= ' WHERE id_grupo IN ('.$user_groups.')';
}
$result = db_get_all_rows_sql($sql);
if ($result) {
foreach ($result as $row) {
$agents[$row['id_agente']] = $row['nombre'];
}
}
}
// Date filter.
if (is_metaconsole() === false) {
$inputs[] = [