Merge branch '1979-Informe-MAX-no-es-coherente-dev' into 'develop'

Fixed max_value report

See merge request artica/pandorafms!1777
This commit is contained in:
vgilc 2018-09-18 12:59:11 +02:00
commit bbb36fe6d8
2 changed files with 184 additions and 182 deletions

View File

@ -513,6 +513,8 @@ function grafico_modulo_sparse_data(
}
$period_time_interval = $period_time_interval - $params['time_interval'];
}
//drag the last value to paint the graph correctly
$acum_array_data[]= array( 0 => $start_period, 1 => $acum_array_data[$i-1][1]);
$array_data['sum1']['data'] = $acum_array_data;
}

View File

@ -3854,114 +3854,114 @@ function reporting_value($report, $content, $type,$pdf) {
'type_graph' => $config['type_module_charts'],
'time_interval' => $content['lapse'],
'server_id' => $id_meta,
'height' => $config['graph_image_height']
'height' => $config['graph_image_height'],
'fullscale' => true
);
switch ($type) {
case 'max':
if($content['lapse_calc'] == 0){
$value = reporting_get_agentmodule_data_max(
$content['id_agent_module'], $content['period'], $report["datetime"]);
if (!$config['simple_module_value']) {
$formated_value = $value;
if($content['lapse_calc'] == 0){
$value = reporting_get_agentmodule_data_max(
$content['id_agent_module'], $content['period'], $report["datetime"]);
if (!$config['simple_module_value']) {
$formated_value = $value;
}
else {
$formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit;
}
}
else {
$formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit;
}
}
else{
$value = '
<table border="0" style="margin:0 auto;text-align:center;">
<tr>
<td width="400px;" height="20%;">';
if($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3){
else{
$value = '
<table border="0" style="margin:0 auto;text-align:center;">
<tr>
<td width="400px;" height="20%;">';
if($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3){
$value .= '
<table style="width:90%;margin:0 auto;background-color:#eee;border: solid lightgray 1px;">
<tr>
<th style="padding:5px;background-color:#82b92e;">
'.__("Agent").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Module").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Maximum").'
</th>
<tr>
<td style="padding:5px;">
'.$agent_name.'
</td>
<td style="padding:5px;">
'.$module_name.'
</td>
<td style="padding:5px;">
'.format_for_graph(reporting_get_agentmodule_data_max(
$content['id_agent_module'], $content['period'], $report["datetime"]), $config['graph_precision']) . ' ' . $unit.'
</td>
</tr>
</table>';
}
$value .= '
</td>
<td rowspan="2" width="150px">
</td>
<td rowspan="2">';
if($content['visual_format'] == 2 || $content['visual_format'] == 3){
$params['force_interval'] = 'max_only';
$value .= grafico_modulo_sparse($params);
}
$value .= '
<table style="width:90%;margin:0 auto;background-color:#eee;border: solid lightgray 1px;">
</td>
</tr>
<tr>
<td>';
if($content['visual_format'] == 1 || $content['visual_format'] == 3){
$value .= '
<table style="width:90%;margin:0 auto;margin-top:30px;background-color:#eee;border: solid lightgray 1px;">
<tr>
<th style="padding:5px;background-color:#82b92e;">
'.__("Agent").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Module").'
'.__("Lapse").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Maximum").'
</th>
<tr>
<td style="padding:5px;">
'.$agent_name.'
</td>
<td style="padding:5px;">
'.$module_name.'
</td>
<td style="padding:5px;">
'.format_for_graph(reporting_get_agentmodule_data_max(
$content['id_agent_module'], $content['period'], $report["datetime"]), $config['graph_precision']) . ' ' . $unit.'
</td>
</tr>
</table>';
<tr>';
$time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module'], true);
$date_reference = getdate();
for ($i=$date_reference[0]; $i > ($date_reference[0]-$content["period"]); $i -= $content["lapse"]) {
$value .= '<tr><td style="padding:5px;">'. date("Y-m-d H:i:s", ($i-$content["lapse"]+1)).' to '.date("Y-m-d H:i:s",$i).'</td><td>';
if ($i>$time_begin['utimestamp']) {
$value .= format_for_graph(reporting_get_agentmodule_data_max(
$content['id_agent_module'], $content["lapse"], $i), $config['graph_precision']) . ' ' . $unit.'</td></tr>';
} else {
$value .= 'N/A</td></tr>';
}
}
$value .='</table>';
}
$value .= '
</td>
</tr>
</table>';
$value .= '
</td>
<td rowspan="2" width="150px">
</td>
<td rowspan="2">';
$formated_value = $value;
}
if($content['visual_format'] == 2 || $content['visual_format'] == 3){
$params['force_interval'] = 'max_only';
$value .= grafico_modulo_sparse($params);
}
$value .= '
</td>
</tr>
<tr>
<td>';
if($content['visual_format'] == 1 || $content['visual_format'] == 3){
$value .= '
<table style="width:90%;margin:0 auto;margin-top:30px;background-color:#eee;border: solid lightgray 1px;">
<tr>
<th style="padding:5px;background-color:#82b92e;">
'.__("Lapse").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Maximum").'
</th>
</tr>
<tr>';
$time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']);
$date_reference = getdate();
for ($i=$date_reference[0]; $i > ($date_reference[0]-$content["period"]); $i -= $content["lapse"]) {
$value .= '<tr><td style="padding:5px;">'. date("Y-m-d H:i:s", ($i-$content["lapse"]+1)).' to '.date("Y-m-d H:i:s",$i).'</td><td>';
if($i>$time_begin['utimestamp']){
$value .= format_for_graph(reporting_get_agentmodule_data_max(
$content['id_agent_module'], $content["lapse"], $i), $config['graph_precision']) . ' ' . $unit.'</td></tr>';
}
else{
$value .= 'N/A</td></tr>';
}
}
$value .='</table>';
}
$value .= '
</td>
</tr>
</table>';
$formated_value = $value;
}
break;
break;
case 'min':
if($content['lapse_calc'] == 0){
$value = reporting_get_agentmodule_data_min(
@ -4072,111 +4072,111 @@ function reporting_value($report, $content, $type,$pdf) {
break;
case 'avg':
if($content['lapse_calc'] == 0){
$value = reporting_get_agentmodule_data_average(
$content['id_agent_module'], $content['period'], $report["datetime"]);
if (!$config['simple_module_value']) {
$formated_value = $value;
if($content['lapse_calc'] == 0){
$value = reporting_get_agentmodule_data_average(
$content['id_agent_module'], $content['period'], $report["datetime"]);
if (!$config['simple_module_value']) {
$formated_value = $value;
}
else {
$formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit;
}
}
else {
$formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit;
}
}
else{
$value = '
<table border="0" style="margin:0 auto;text-align:center;">
<tr>
<td width="400px;" height="20%;">';
else{
$value = '
<table border="0" style="margin:0 auto;text-align:center;">
<tr>
<td width="400px;" height="20%;">';
if($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3){
$value .= '
<table style="width:90%;margin:0 auto;background-color:#eee;border: solid lightgray 1px;">
<tr>
<th style="padding:5px;background-color:#82b92e;">
'.__("Agent").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Module").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Average").'
</th>
<tr>
<td style="padding:5px;">
'.$agent_name.'
</td>
<td style="padding:5px;">
'.$module_name.'
</td>
<td style="padding:5px;">
'.format_for_graph(reporting_get_agentmodule_data_average(
$content['id_agent_module'], $content['period'], $report["datetime"]), $config['graph_precision']) . ' ' . $unit.'
</td>
</tr>
</table>';
}
$value .= '
</td>
<td rowspan="2" width="150px">
</td>
<td rowspan="2">';
if($content['visual_format'] == 2 || $content['visual_format'] == 3){
$params['force_interval'] = 'avg_only';
$value .= grafico_modulo_sparse($params);
}
if($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3){
$value .= '
<table style="width:90%;margin:0 auto;background-color:#eee;border: solid lightgray 1px;">
</td>
</tr>
<tr>
<td>';
if($content['visual_format'] == 1 || $content['visual_format'] == 3){
$value .= '
<table style="width:90%;margin:0 auto;margin-top:30px;background-color:#eee;border: solid lightgray 1px;">
<tr>
<th style="padding:5px;background-color:#82b92e;">
'.__("Agent").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Module").'
'.__("Lapse").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Average").'
</th>
<tr>
<td style="padding:5px;">
'.$agent_name.'
</td>
<td style="padding:5px;">
'.$module_name.'
</td>
<td style="padding:5px;">
'.format_for_graph(reporting_get_agentmodule_data_average(
$content['id_agent_module'], $content['period'], $report["datetime"]), $config['graph_precision']) . ' ' . $unit.'
</td>
</tr>
</table>';
<tr>';
$time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']);
$date_reference = getdate();
for ($i=$date_reference[0]; $i > ($date_reference[0]-$content["period"]); $i -= $content["lapse"]) {
$value .= '<tr><td style="padding:5px;">'. date("Y-m-d H:i:s", ($i-$content["lapse"]+1)).' to '.date("Y-m-d H:i:s",$i).'</td><td>';
if($i>$time_begin['utimestamp']){
$value .= format_for_graph(reporting_get_agentmodule_data_average(
$content['id_agent_module'], $content["lapse"], $i), $config['graph_precision']) . ' ' . $unit.'</td></tr>';
}
else{
$value .= 'N/A</td></tr>';
}
}
$value .='</table>';
}
$value .= '
</td>
<td rowspan="2" width="150px">
</td>
<td rowspan="2">';
if($content['visual_format'] == 2 || $content['visual_format'] == 3){
$params['force_interval'] = 'avg_only';
$value .= grafico_modulo_sparse($params);
}
$value .= '
</td>
</tr>
</table>';
$value .= '
</td>
</tr>
<tr>
<td>';
if($content['visual_format'] == 1 || $content['visual_format'] == 3){
$value .= '
<table style="width:90%;margin:0 auto;margin-top:30px;background-color:#eee;border: solid lightgray 1px;">
<tr>
<th style="padding:5px;background-color:#82b92e;">
'.__("Lapse").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Average").'
</th>
</tr>
<tr>';
$time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']);
$date_reference = getdate();
for ($i=$date_reference[0]; $i > ($date_reference[0]-$content["period"]); $i -= $content["lapse"]) {
$value .= '<tr><td style="padding:5px;">'. date("Y-m-d H:i:s", ($i-$content["lapse"]+1)).' to '.date("Y-m-d H:i:s",$i).'</td><td>';
if($i>$time_begin['utimestamp']){
$value .= format_for_graph(reporting_get_agentmodule_data_average(
$content['id_agent_module'], $content["lapse"], $i), $config['graph_precision']) . ' ' . $unit.'</td></tr>';
}
else{
$value .= 'N/A</td></tr>';
}
}
$value .='</table>';
}
$value .= '
</td>
</tr>
</table>';
$formated_value = $value;
$formated_value = $value;
}
break;
}
break;
case 'sum':
$value = reporting_get_agentmodule_data_sum(