diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php
index 75e3b306d3..999fdd0f1b 100755
--- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php
+++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php
@@ -6814,36 +6814,46 @@ function chooseType() {
}
function addCustomFieldRow() {
+ var array_tr = $("tr.tr-macros-definition");
+ var last_tr = array_tr[array_tr.length - 1];
+ var array_id = /(\d)+$/.exec($(last_tr).attr('id'));
+ var max = (parseInt(array_id[0]) + 1);
+
var clone = $("#table-macros-definition #table-macros-definition-0")
.clone()
- .prop("id", "table-macros-definition-" + $("tr.tr-macros-definition").length);
+ .prop("id", "table-macros-definition-" + max);
clone
.find("#macro_custom_name")
- .prop("id", "macro_custom_name_" + $("tr.tr-macros-definition").length)
+ .prop("id", "macro_custom_name_" + max)
.val("");
+ clone
+ .find("#macro_custom_key")
+ .prop("id", "macro_custom_key_" + max)
+ .val(max);
+
clone
.find("#macro_custom_type")
- .prop("id", "macro_custom_type" + $("tr.tr-macros-definition").length)
- .attr("onchange", "change_custom_fields_macros_report(" + $("tr.tr-macros-definition").length + ")");
+ .prop("id", "macro_custom_type" + max)
+ .attr("onchange", "change_custom_fields_macros_report(" + max + ")");
clone
.find("#table-macros-definition-0-value")
- .prop("id", "table-macros-definition-"+$("tr.tr-macros-definition").length+"-value");
+ .prop("id", "table-macros-definition-"+max+"-value");
clone
.find("#macro_custom_value")
- .prop("id", "macro_custom_value_" + $("tr.tr-macros-definition").length)
+ .prop("id", "macro_custom_value_" + max)
.val('');
clone
.find(".icon-clean-custom-macro")
- .attr("onclick", "cleanCustomFieldRow(" + $("tr.tr-macros-definition").length + ")");
+ .attr("onclick", "cleanCustomFieldRow(" + max + ")");
clone
.find(".icon-delete-custom-macro")
- .attr("onclick", "removeCustomFieldRow(" + $("tr.tr-macros-definition").length + ")")
+ .attr("onclick", "removeCustomFieldRow(" + max + ")")
.css("display", "inline-block");
clone
diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php
index 9ca004fd3e..4dd455d5fc 100755
--- a/pandora_console/godmode/reporting/reporting_builder.php
+++ b/pandora_console/godmode/reporting/reporting_builder.php
@@ -1856,25 +1856,24 @@ switch ($action) {
$macro_custom_name = get_parameter('macro_custom_name', []);
$macro_custom_type = get_parameter('macro_custom_type', []);
$macro_custom_value = get_parameter('macro_custom_value', []);
- $macro_custom_width = get_parameter('macro_custom_width', []);
- $macro_custom_height = get_parameter('macro_custom_height', []);
+ $macro_custom_key = get_parameter('macro_custom_key', []);
$macros_definition = [];
+ hd($_POST);
+
foreach ($macro_custom_name as $key_macro => $value_macro) {
+ $kl = (empty($macro_custom_key[$key_macro]) === true) ? 0 : $macro_custom_key[$key_macro];
$macros_definition[$key_macro]['name'] = $value_macro;
$macros_definition[$key_macro]['type'] = $macro_custom_type[$key_macro];
- if (isset($macro_custom_value[$key_macro]) === true) {
+
+ if (is_array($macro_custom_value[$kl]) === true) {
+ foreach ($macro_custom_value[$kl] as $k => $v) {
+ $macros_definition[$key_macro][$k] = $v;
+ }
+ } else {
$macros_definition[$key_macro]['value'] = $macro_custom_value[$key_macro];
}
-
- if (isset($macro_custom_width[$key_macro]) === true) {
- $macros_definition[$key_macro]['width'] = $macro_custom_width[$key_macro];
- }
-
- if (isset($macro_custom_height[$key_macro]) === true) {
- $macros_definition[$key_macro]['height'] = $macro_custom_height[$key_macro];
- }
}
$values['macros_definition'] = json_encode($macros_definition);
@@ -2636,25 +2635,22 @@ switch ($action) {
$macro_custom_name = get_parameter('macro_custom_name', []);
$macro_custom_type = get_parameter('macro_custom_type', []);
$macro_custom_value = get_parameter('macro_custom_value', []);
- $macro_custom_width = get_parameter('macro_custom_width', []);
- $macro_custom_height = get_parameter('macro_custom_height', []);
+ $macro_custom_key = get_parameter('macro_custom_key', []);
$macros_definition = [];
foreach ($macro_custom_name as $key_macro => $value_macro) {
+ $kl = (empty($macro_custom_key[$key_macro]) === true) ? 0 : $macro_custom_key[$key_macro];
$macros_definition[$key_macro]['name'] = $value_macro;
$macros_definition[$key_macro]['type'] = $macro_custom_type[$key_macro];
- if (isset($macro_custom_value[$key_macro]) === true) {
+
+ if (is_array($macro_custom_value[$kl]) === true) {
+ foreach ($macro_custom_value[$kl] as $k => $v) {
+ $macros_definition[$key_macro][$k] = $v;
+ }
+ } else {
$macros_definition[$key_macro]['value'] = $macro_custom_value[$key_macro];
}
-
- if (isset($macro_custom_width[$key_macro]) === true) {
- $macros_definition[$key_macro]['width'] = $macro_custom_width[$key_macro];
- }
-
- if (isset($macro_custom_height[$key_macro]) === true) {
- $macros_definition[$key_macro]['height'] = $macro_custom_height[$key_macro];
- }
}
$values['macros_definition'] = json_encode($macros_definition);
diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php
index 2904c4f681..30406c4e71 100755
--- a/pandora_console/include/functions_reporting.php
+++ b/pandora_console/include/functions_reporting.php
@@ -4884,6 +4884,35 @@ function reporting_custom_render($report, $content, $type='dinamic', $pdf=0)
$substitutions[] = $value_query;
break;
+ case 3:
+ // Type: SQL graph.
+ $patterns[] = addslashes(
+ '/_'.$data_macro['name'].'_/'
+ );
+
+ $params = [
+ 'agent_module_id' => $data_macro['id_agent_module'],
+ 'period' => 86400,
+ 'title' => '',
+ 'label' => '',
+ 'pure' => false,
+ 'only_image' => true,
+ 'homeurl' => ui_get_full_url(
+ false,
+ false,
+ false,
+ false
+ ),
+ 'ttl' => 2,
+ 'show_unknown' => true,
+ 'height' => $config['graph_image_height'],
+ 'backgroundColor' => 'transparent',
+ 'return_img_base_64' => true,
+ ];
+
+ $substitutions[] = '';
+ break;
+
default:
// Not possible.
break;
diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php
index 03cd82742b..91b29ec1f3 100755
--- a/pandora_console/include/functions_reports.php
+++ b/pandora_console/include/functions_reports.php
@@ -1099,6 +1099,15 @@ function get_table_custom_macros_report($data)
true
);
+ $table->data[$key_macro]['name'] .= html_print_input_hidden(
+ 'macro_custom_key[]',
+ $key_macro,
+ true,
+ false,
+ false,
+ ($key_macro === 0) ? 'macro_custom_key' : 'macro_custom_key_'.$key_macro
+ );
+
$table->data[$key_macro]['type'] = html_print_select(
$list_macro_custom_type,
'macro_custom_type[]',
@@ -1180,10 +1189,10 @@ function custom_fields_macros_report($macro, $key_macro)
case 1:
$result['value'] = '