diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index f576f6ec87..ecb57d97e4 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -3252,59 +3252,42 @@ function reporting_html_availability_graph($table, $item, $pdf=0) $tables_chart = ''; - foreach ($item['charts'] as $k_chart => $chart) { - $checks_resume = ''; - $sla_value = ''; - if (reporting_sla_is_not_init_from_array($chart)) { - $color = COL_NOTINIT; - $sla_value = __('Not init'); - } else if (reporting_sla_is_ignored_from_array($chart)) { - $color = COL_IGNORED; - $sla_value = __('No data'); - } else { - switch ($chart['sla_status']) { - case REPORT_STATUS_ERR: - $color = COL_CRITICAL; - break; + if (isset($item['failed']) === true && empty($item['failed']) === false) { + $tables_chart .= $item['failed']; + } else { + foreach ($item['charts'] as $k_chart => $chart) { + $checks_resume = ''; + $sla_value = ''; + if (reporting_sla_is_not_init_from_array($chart)) { + $color = COL_NOTINIT; + $sla_value = __('Not init'); + } else if (reporting_sla_is_ignored_from_array($chart)) { + $color = COL_IGNORED; + $sla_value = __('No data'); + } else { + switch ($chart['sla_status']) { + case REPORT_STATUS_ERR: + $color = COL_CRITICAL; + break; - case REPORT_STATUS_OK: - $color = COL_NORMAL; - break; + case REPORT_STATUS_OK: + $color = COL_NORMAL; + break; - default: - $color = COL_UNKNOWN; - break; + default: + $color = COL_UNKNOWN; + break; + } + + $sla_value = sla_truncate( + $chart['sla_value'], + $config['graph_precision'] + ).'%'; + $checks_resume = '('.$chart['checks_ok'].'/'.$chart['checks_total'].')'; } - $sla_value = sla_truncate( - $chart['sla_value'], - $config['graph_precision'] - ).'%'; - $checks_resume = '('.$chart['checks_ok'].'/'.$chart['checks_total'].')'; - } - - // Check failover availability report. - if ($item['data'][$k_chart]['failover'] === '') { - $table1 = new stdClass(); - $table1->width = '99%'; - $table1->data = []; - $table1->size = []; - $table1->size[0] = '10%'; - $table1->size[1] = '80%'; - $table1->size[2] = '5%'; - $table1->size[3] = '5%'; - $table1->data[0][0] = $chart['agent'].'
'.$chart['module']; - $table1->data[0][1] = $chart['chart']; - $table1->data[0][2] = "".$sla_value.''; - $table1->data[0][3] = $checks_resume; - $tables_chart .= html_print_table( - $table1, - true - ); - } else { - if ($item['data'][$k_chart]['failover'] === 'primary' - || $item['failover_type'] == REPORT_FAILOVER_TYPE_SIMPLE - ) { + // Check failover availability report. + if ($item['data'][$k_chart]['failover'] === '') { $table1 = new stdClass(); $table1->width = '99%'; $table1->data = []; @@ -3313,44 +3296,65 @@ function reporting_html_availability_graph($table, $item, $pdf=0) $table1->size[1] = '80%'; $table1->size[2] = '5%'; $table1->size[3] = '5%'; - } - - $title = ''; - $checks_resume_text = $checks_resume; - $sla_value_text = "".$sla_value.''; - switch ($item['data'][$k_chart]['failover']) { - case 'primary': - $title = ''.__('Primary').''; - $title .= '
'.$chart['agent']; - $title .= '
'.$chart['module']; - break; - - case (preg_match('/failover.*/', $item['data'][$k_chart]['failover']) ? true : false): - $title = ''.__('Failover').''; - $title .= '
'.$chart['agent']; - $title .= '
'.$chart['module']; - break; - - case 'result': - default: - $title = ''.__('Result').''; - $sla_value_text = "".$sla_value.''; - $checks_resume_text = ''; - $checks_resume_text .= $checks_resume; - $checks_resume_text .= ''; - break; - } - - $table1->data[$item['data'][$k_chart]['failover']][0] = $title; - $table1->data[$item['data'][$k_chart]['failover']][1] = $chart['chart']; - $table1->data[$item['data'][$k_chart]['failover']][2] = $sla_value_text; - $table1->data[$item['data'][$k_chart]['failover']][3] = $checks_resume_text; - - if ($item['data'][$k_chart]['failover'] === 'result') { + $table1->data[0][0] = $chart['agent'].'
'.$chart['module']; + $table1->data[0][1] = $chart['chart']; + $table1->data[0][2] = "".$sla_value.''; + $table1->data[0][3] = $checks_resume; $tables_chart .= html_print_table( $table1, true ); + } else { + if ($item['data'][$k_chart]['failover'] === 'primary' + || $item['failover_type'] == REPORT_FAILOVER_TYPE_SIMPLE + ) { + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->data = []; + $table1->size = []; + $table1->size[0] = '10%'; + $table1->size[1] = '80%'; + $table1->size[2] = '5%'; + $table1->size[3] = '5%'; + } + + $title = ''; + $checks_resume_text = $checks_resume; + $sla_value_text = "".$sla_value.''; + switch ($item['data'][$k_chart]['failover']) { + case 'primary': + $title = ''.__('Primary').''; + $title .= '
'.$chart['agent']; + $title .= '
'.$chart['module']; + break; + + case (preg_match('/failover.*/', $item['data'][$k_chart]['failover']) ? true : false): + $title = ''.__('Failover').''; + $title .= '
'.$chart['agent']; + $title .= '
'.$chart['module']; + break; + + case 'result': + default: + $title = ''.__('Result').''; + $sla_value_text = "".$sla_value.''; + $checks_resume_text = ''; + $checks_resume_text .= $checks_resume; + $checks_resume_text .= ''; + break; + } + + $table1->data[$item['data'][$k_chart]['failover']][0] = $title; + $table1->data[$item['data'][$k_chart]['failover']][1] = $chart['chart']; + $table1->data[$item['data'][$k_chart]['failover']][2] = $sla_value_text; + $table1->data[$item['data'][$k_chart]['failover']][3] = $checks_resume_text; + + if ($item['data'][$k_chart]['failover'] === 'result') { + $tables_chart .= html_print_table( + $table1, + true + ); + } } } }