fixed error cfv status

Former-commit-id: cccd14ea5d2e202124233372e3db47564b2d8475
This commit is contained in:
Daniel Barbero Martin 2019-04-29 15:43:51 +02:00
parent e54112641d
commit 94932d23ac
2 changed files with 40 additions and 5 deletions

View File

@ -159,22 +159,22 @@ if (check_login()) {
switch ($value) {
default:
case AGENT_STATUS_NORMAL:
$status_module_search .= ' temp.critical_count = 0 AND temp.warning_count = 0 AND temp.unknown_count = 0 AND temp.notinit_count <> temp.total_count ) ';
$status_module_search .= ' temp.normal_count > 0) ';
break;
case AGENT_STATUS_CRITICAL:
$status_module_search .= ' temp.critical_count > 0) ';
break;
case AGENT_STATUS_WARNING:
$status_module_search .= ' temp.critical_count = 0 AND temp.warning_count > 0) ';
$status_module_search .= ' temp.warning_count > 0) ';
break;
case AGENT_STATUS_UNKNOWN:
$status_module_search .= ' temp.critical_count = 0 AND temp.warning_count = 0 AND temp.unknown_count > 0) ';
$status_module_search .= ' temp.unknown_count > 0) ';
break;
case AGENT_STATUS_NOT_INIT:
$status_module_search .= ' temp.total_count = temp.notinit_count) ';
$status_module_search .= ' temp.notinit_count > 0) ';
break;
}
}
@ -183,7 +183,7 @@ if (check_login()) {
}
} else {
// Not normal.
$status_module_search = ' AND NOT ( temp.critical_count = 0 AND temp.warning_count = 0 AND temp.unknown_count = 0 AND temp.notinit_count <> temp.total_count)';
$status_module_search = ' AND ( temp.critical_count > 0 OR temp.warning_count > 0 OR temp.unknown_count > 0 AND temp.notinit_count > 0 )';
}
}
}

View File

@ -658,3 +658,38 @@ function get_group_filter_custom_field_view($id)
return false;
}
/**
* Function for print counters agents or modules.
*
* @param array $status_array Array need value, image, title, color, counter.
* @param string $id_form Id form default value ''.
* @param string $id_input Id input default value ''.
*
* @return array Return html print div container counters.
*/
function print_counters_cfv(
array $status_array,
string $id_form='',
string $id_input=''
) {
$html_result = '<form class = "cfv_status_agent" id="'.$id_form.'">';
foreach ($status_array as $key => $value) {
$checked = ($value['checked'] === 1) ? 'checked=true' : '';
$disabled = ($value['counter'] === 0) ? 'disabled=true' : '';
$html_result .= '<input id="lists_'.$id_input.'['.$key.']" '.$checked.' '.$disabled.' type="checkbox" name="lists_'.$id_input.'['.$key.']" />';
$html_result .= '<label for="lists_'.$id_input.'['.$key.']" style="background-color:'.$value['color'].';">';
$html_result .= html_print_image(
$value['image'],
true,
['title' => $value['title']]
);
$html_result .= $value['counter'];
$html_result .= '</label>';
}
$html_result .= '</form>';
return $html_result;
}