diff --git a/pandora_console/extras/mr/53.sql b/pandora_console/extras/mr/53.sql
index 2393c4cb85..ba62943ce9 100644
--- a/pandora_console/extras/mr/53.sql
+++ b/pandora_console/extras/mr/53.sql
@@ -19,5 +19,8 @@ CREATE TABLE IF NOT EXISTS `tbackup` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
-
+ALTER TABLE `treport_content` ADD COLUMN `macros_definition` TEXT;
+ALTER TABLE `treport_content` ADD COLUMN `render_definition` TEXT;
+ALTER TABLE `treport_content_template` ADD COLUMN `macros_definition` TEXT;
+ALTER TABLE `treport_content_template` ADD COLUMN `render_definition` TEXT;
COMMIT;
diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php
index 901549b253..75e3b306d3 100755
--- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php
+++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php
@@ -176,6 +176,8 @@ $unknown_checks = true;
$agent_max_value = true;
$agent_min_value = true;
$uncompressed_module = true;
+$macros_definition = '';
+$render_definition = '';
$only_data = false;
@@ -724,6 +726,12 @@ switch ($action) {
$graph_render = $item['graph_render'];
break;
+ case 'custom_render':
+ $description = $item['description'];
+ $macros_definition = $item['macros_definition'];
+ $render_definition = $item['render_definition'];
+ break;
+
case 'top_n':
$description = $item['description'];
$period = $item['period'];
@@ -2441,6 +2449,35 @@ $class = 'databox filters';
+
option:selected").val();
- if(serviceId != '' && serviceId.split('|').length > 1 ) {
+ if(serviceId != undefined && serviceId != '' && serviceId.split('|').length > 1 ) {
var ids = serviceId.split('|');
serverId = ids[0];
serviceId = ids[1];
@@ -5895,6 +5932,8 @@ function chooseType() {
$("#row_max_min_avg").hide();
$("#row_fullscale").hide();
$("#row_graph_render").hide();
+ $("#row_macros_definition").hide();
+ $("#row_render_definition").hide();
$("#row_time_compare_overlapped").hide();
$("#row_quantity").hide();
$("#row_exception_condition_value").hide();
@@ -6441,6 +6480,13 @@ function chooseType() {
}
break;
+ case 'custom_render':
+ $("#row_description").show();
+ $("#row_period").show();
+ $("#row_macros_definition").show();
+ $("#row_render_definition").show();
+ break;
+
case 'top_n':
$("#row_description").show();
$("#row_period").show();
@@ -6767,6 +6813,81 @@ function chooseType() {
}
}
+function addCustomFieldRow() {
+ var clone = $("#table-macros-definition #table-macros-definition-0")
+ .clone()
+ .prop("id", "table-macros-definition-" + $("tr.tr-macros-definition").length);
+
+ clone
+ .find("#macro_custom_name")
+ .prop("id", "macro_custom_name_" + $("tr.tr-macros-definition").length)
+ .val("");
+
+ 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 + ")");
+
+ clone
+ .find("#table-macros-definition-0-value")
+ .prop("id", "table-macros-definition-"+$("tr.tr-macros-definition").length+"-value");
+
+ clone
+ .find("#macro_custom_value")
+ .prop("id", "macro_custom_value_" + $("tr.tr-macros-definition").length)
+ .val('');
+
+ clone
+ .find(".icon-clean-custom-macro")
+ .attr("onclick", "cleanCustomFieldRow(" + $("tr.tr-macros-definition").length + ")");
+
+ clone
+ .find(".icon-delete-custom-macro")
+ .attr("onclick", "removeCustomFieldRow(" + $("tr.tr-macros-definition").length + ")")
+ .css("display", "inline-block");
+
+ clone
+ .appendTo("#table-macros-definition");
+}
+
+function cleanCustomFieldRow(row) {
+ if(row === 0) {
+ // Default value.
+ $("#macro_custom_name").val('');
+ $("#macro_custom_value").val('');
+ } else {
+ $("#macro_custom_name_"+row).val('');
+ $("#macro_custom_value_"+row).val('');
+ $("#macro_custom_width_"+row).val('');
+ $("#macro_custom_height_"+row).val('');
+ }
+}
+
+function removeCustomFieldRow(row) {
+ if(row !== 0) {
+ $("tr#table-macros-definition-"+row).remove();
+ }
+}
+
+function change_custom_fields_macros_report(id) {
+ var new_type = this.event.target.value;
+ jQuery.post (
+ "ajax.php",
+ {
+ "page" : "include/ajax/reporting.ajax",
+ "change_custom_fields_macros_report" : 1,
+ "macro_type": new_type,
+ "macro_id": id
+ },
+ function (data, status) {
+ console.log(id);
+ $("td#table-macros-definition-"+id+"-value").empty();
+ $("td#table-macros-definition-"+id+"-value").append(data);
+ },
+ "html"
+ );
+}
+
function event_change_id_agent_inventory() {
agent_changed_by_multiple_agents_inventory(
{"data" : {
diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php
index 7fc89b6267..9ca004fd3e 100755
--- a/pandora_console/godmode/reporting/reporting_builder.php
+++ b/pandora_console/godmode/reporting/reporting_builder.php
@@ -1852,6 +1852,36 @@ switch ($action) {
$good_format = true;
break;
+ case 'custom_render':
+ $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', []);
+ $macros_definition = [];
+
+ foreach ($macro_custom_name as $key_macro => $value_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) {
+ $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);
+ $values['render_definition'] = get_parameter('render_definition', '');
+ $good_format = true;
+ break;
+
case 'min_value':
case 'max_value':
case 'avg_value':
@@ -2602,6 +2632,36 @@ switch ($action) {
$good_format = true;
break;
+ case 'custom_render':
+ $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', []);
+ $macros_definition = [];
+
+ foreach ($macro_custom_name as $key_macro => $value_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) {
+ $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);
+ $values['render_definition'] = get_parameter('render_definition', '');
+ $good_format = true;
+ break;
+
case 'min_value':
case 'max_value':
case 'avg_value':
diff --git a/pandora_console/include/ajax/reporting.ajax.php b/pandora_console/include/ajax/reporting.ajax.php
index 89d5b715fb..bafe01307d 100755
--- a/pandora_console/include/ajax/reporting.ajax.php
+++ b/pandora_console/include/ajax/reporting.ajax.php
@@ -34,6 +34,10 @@ $id = get_parameter('id', 0);
$truncate_text = get_parameter('truncate_text', 0);
$get_metaconsole_hash_data = get_parameter('get_metaconsole_hash_data', 0);
$get_metaconsole_server_url = get_parameter('get_metaconsole_server_url', 0);
+$change_custom_fields_macros_report = (bool) get_parameter(
+ 'change_custom_fields_macros_report',
+ 0
+);
if ($delete_sla_item) {
$result = db_process_sql_delete('treport_content_sla_combined', ['id' => (int) $id]);
@@ -218,3 +222,25 @@ if ($get_metaconsole_server_url) {
echo $server['server_url'];
return;
}
+
+if ($change_custom_fields_macros_report === true) {
+ include_once $config['homedir'].'/include/functions_reports.php';
+ $macro_type = get_parameter('macro_type', '');
+ $macro_id = get_parameter('macro_id', 0);
+
+ $macro = [
+ 'name' => '',
+ 'type' => $macro_type,
+ 'value' => '',
+ ];
+ $custom_fields = custom_fields_macros_report($macro, $macro_id);
+ $custom_field_draw = '';
+ if (empty($custom_fields) === false) {
+ foreach ($custom_fields as $key => $value) {
+ $custom_field_draw .= $value;
+ }
+ }
+
+ echo $custom_field_draw;
+ return;
+}
diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php
index 82f5ea6cca..ca0c9dad7d 100644
--- a/pandora_console/include/functions.php
+++ b/pandora_console/include/functions.php
@@ -4194,7 +4194,7 @@ function generator_chart_to_pdf(
) {
$width_img = 650;
$height_img = ($params['height'] + 50);
- } else if ($type_graph_pdf === 'hbar') {
+ } else if ($type_graph_pdf === 'hbar' || $type_graph_pdf === 'pie_chart') {
$width_img = ($params['width'] ?? 550);
$height_img = $params['height'];
} else {
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index 944733ffd0..a6f76f667f 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -808,7 +808,7 @@ function html_print_select(
$output .= '';
}
- $output .= ' |