Fixed data editor in reports. Ticket #337

This commit is contained in:
Arturo Gonzalez 2017-02-27 09:48:57 +01:00
parent 023f4b1703
commit 19d79a73de
2 changed files with 52 additions and 8 deletions

View File

@ -197,6 +197,16 @@ switch ($action) {
case 'event_report_log': case 'event_report_log':
$period = $item['period']; $period = $item['period'];
$description = $item['description']; $description = $item['description'];
$es = json_decode($item['external_source'], true);
$id_agents = $es['id_agents'];
if ((count($es['module']) == 1) && ($es['module'][0] == 0)) {
$module = "";
}
else {
$module = $es['module'];
}
$idAgentModule = $module;
break;
case 'simple_graph': case 'simple_graph':
$only_avg = isset($style['only_avg']) ? (bool) $style['only_avg'] : true; $only_avg = isset($style['only_avg']) ? (bool) $style['only_avg'] : true;
$percentil = isset($style['percentil']) ? $config['percentil'] : 0; $percentil = isset($style['percentil']) ? $config['percentil'] : 0;
@ -499,7 +509,7 @@ switch ($action) {
case 'agent_module': case 'agent_module':
$description = $item['description']; $description = $item['description'];
$es = json_decode($item['external_source'], true); $es = json_decode($item['external_source'], true);
$agents_id = get_parameter('id_agents2'); $id_agents = $es['id_agents'];
$selection_a_m = get_parameter('selection'); $selection_a_m = get_parameter('selection');
if ((count($es['module']) == 1) && ($es['module'][0] == 0)) { if ((count($es['module']) == 1) && ($es['module'][0] == 0)) {
@ -588,7 +598,6 @@ switch ($action) {
break; break;
} }
$urlForm = $config['homeurl'] . $urlForm = $config['homeurl'] .
'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action=' . $actionParameter . '&id_report=' . $idReport; 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action=' . $actionParameter . '&id_report=' . $idReport;
@ -1001,7 +1010,7 @@ You can of course remove the warnings, that's why we include the source and do n
} }
} }
} }
html_print_select($agents, 'id_agents2[]', $agents_id, $script = '', "", 0, false, true, true, '', false, "min-width: 180px"); html_print_select($agents, 'id_agents2[]', $agents_select, $script = '', "", 0, false, true, true, '', false, "min-width: 180px");
?> ?>
</td> </td>
</tr> </tr>
@ -1021,9 +1030,23 @@ You can of course remove the warnings, that's why we include the source and do n
<td style="font-weight:bold;"><?php echo __('Modules'); ?></td> <td style="font-weight:bold;"><?php echo __('Modules'); ?></td>
<td> <td>
<?php <?php
$all_modules = db_get_all_rows_sql("SELECT DISTINCT nombre, id_agente_modulo FROM tagente_modulo WHERE id_agente IN (" . implode(',', array_keys($agents)) . ")"); $all_modules = db_get_all_rows_sql("SELECT DISTINCT nombre, id_agente_modulo FROM tagente_modulo WHERE id_agente IN (" . implode(',', array_values($id_agents)) . ")");
if ((empty($all_modules)) || $all_modules == -1) $all_modules = array();
html_print_select($all_modules, 'module[]', "", $script = '', __('None'), 0, false, true, true, '', false, "min-width: 180px"); $modules_select = array();
$all_modules_structured = array();
if (is_array($idAgentModule) || is_object($idAgentModule)){
foreach ($idAgentModule as $id) {
foreach ($all_modules as $key => $a) {
if ($a['id_agente_modulo'] == (int)$id) {
$modules_select[$a['id_agente_modulo']] = $a['id_agente_modulo'];
}
}
}
}
foreach ($all_modules as $a) {
$all_modules_structured[$a['id_agente_modulo']] = $a['nombre'];
}
html_print_select($all_modules_structured, 'module[]', $modules_select, $script = '', __('None'), 0, false, true, true, '', false, "min-width: 180px");
?> ?>
</td> </td>
</tr> </tr>
@ -2588,7 +2611,8 @@ function chooseType() {
$("#log_help_tip").css("visibility", "visible"); $("#log_help_tip").css("visibility", "visible");
$("#row_description").show(); $("#row_description").show();
$("#row_period").show(); $("#row_period").show();
$("#row_agent").show(); $("#agents_row").show();
$("#modules_row").show();
break; break;
case 'simple_graph': case 'simple_graph':

View File

@ -922,6 +922,16 @@ switch ($action) {
$values['text'] = get_parameter('text'); $values['text'] = get_parameter('text');
$good_format = true; $good_format = true;
break; break;
case 'event_report_log':
$agents_to_report = get_parameter('id_agents2');
$modules_to_report = get_parameter('module', "");
$es['module'] = get_same_modules($agents_to_report, $modules_to_report);
$es['id_agents'] = $agents_to_report;
$values['external_source'] = json_encode($es);
$good_format = true;
break;
case 'prediction_date': case 'prediction_date':
$values['period'] = get_parameter('period1'); $values['period'] = get_parameter('period1');
$values['top_n'] = get_parameter('radiobutton_max_min_avg'); $values['top_n'] = get_parameter('radiobutton_max_min_avg');
@ -1263,6 +1273,16 @@ switch ($action) {
$es['date'] = get_parameter('date'); $es['date'] = get_parameter('date');
$es['id_agents'] = get_parameter('id_agents'); $es['id_agents'] = get_parameter('id_agents');
$es['inventory_modules'] = get_parameter('inventory_modules'); $es['inventory_modules'] = get_parameter('inventory_modules');
$values['external_source'] = json_encode($es);
$good_format = true;
break;
case 'event_report_log':
$agents_to_report = get_parameter('id_agents2');
$modules_to_report = get_parameter('module', "");
$es['module'] = get_same_modules($agents_to_report, $modules_to_report);
$es['id_agents'] = $agents_to_report;
$values['external_source'] = json_encode($es); $values['external_source'] = json_encode($es);
$good_format = true; $good_format = true;
break; break;