Merge branch 'ent-8540-contel-nuevo-informe-custom-render' into 'develop'

add new report custom render pandora_enterprise#8540

See merge request artica/pandorafms!4793
This commit is contained in:
Daniel Rodriguez 2022-04-06 12:16:26 +00:00
commit 2471bbf1d4
13 changed files with 1408 additions and 9 deletions

View File

@ -22,5 +22,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;

View File

@ -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,38 @@ $class = 'databox filters';
</td>
</tr>
<tr id="row_macros_definition" class="datos">
<td class="bolder">
<?php
echo __('Macros definition');
?>
</td>
<td>
<?php echo get_table_custom_macros_report($macros_definition); ?>
</td>
</tr>
<tr id="row_render_definition" class="datos">
<td class="bolder">
<?php
echo __('Render definition').ui_print_help_tip(
__('Be aware because not all CSS inline styles are supported in the pdf library'),
true
);
?>
</td>
<td>
<?php
echo html_print_textarea(
'render_definition',
3,
25,
$render_definition
);
?>
</td>
</tr>
<tr id="row_fullscale" class="datos">
<td class="bolder">
<?php
@ -4593,6 +4633,9 @@ ui_require_javascript_file(
'pandora_inventory',
ENTERPRISE_DIR.'/include/javascript/'
);
ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
ui_require_javascript_file('pandora');
?>
<script type="text/javascript">
@ -4830,6 +4873,14 @@ $(document).ready (function () {
});
});
var added_config = {
"elements": "textarea_render_definition",
"plugins": "preview, print, table, searchreplace, nonbreaking, xhtmlxtras, noneditable",
"theme_advanced_buttons1": "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect",
"theme_advanced_buttons2": "search,replace,|,bullist,numlist,|,undo,redo,|,link,unlink,image,|,cleanup,code,preview,|,forecolor,backcolor"
}
defineTinyMCE(added_config);
$("#checkbox-select_by_group").change(function () {
var select_by_group = $('#checkbox-select_by_group').prop('checked');
@ -5453,7 +5504,7 @@ function addSLARow() {
var slaMax = $("input[name=sla_max]").val();
var slaLimit = $("input[name=sla_limit]").val();
var serviceId = $("select#id_service>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 +5946,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 +6494,11 @@ function chooseType() {
}
break;
case 'custom_render':
$("#row_macros_definition").show();
$("#row_render_definition").show();
break;
case 'top_n':
$("#row_description").show();
$("#row_period").show();
@ -6767,6 +6825,98 @@ 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-" + max);
clone
.find("#macro_custom_name")
.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" + max)
.attr("onchange", "change_custom_fields_macros_report(" + max + ")");
clone
.find("#table-macros-definition-0-value")
.prop("id", "table-macros-definition-"+max+"-value");
clone
.find("#macro_custom_value")
.prop("id", "macro_custom_value_" + max)
.val('');
clone
.find(".icon-clean-custom-macro")
.attr("onclick", "cleanCustomFieldRow(" + max + ")");
clone
.find(".icon-delete-custom-macro")
.attr("onclick", "removeCustomFieldRow(" + max + ")")
.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('');
$("#macro_custom_width").val('');
} else {
$("#macro_custom_name_"+row).val('');
$("#macro_custom_value_"+row).val('');
$("#macro_custom_width_"+row).val('');
}
$("#macro_custom_height_"+row).val('');
$("#macro_custom_period_"+row).val('');
$("#text-macro_custom_value_agent_name_"+row).val('');
$("#macro_custom_value"+row+"id_agent_module")
.val('')
.trigger('change');
}
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" : {

View File

@ -1852,6 +1852,33 @@ 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_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 (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];
}
}
$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 +2629,33 @@ 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_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 (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];
}
}
$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':

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 775 B

View File

@ -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;
}

View File

@ -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 {

View File

@ -808,7 +808,7 @@ function html_print_select(
$output .= '<div class="flex-row-center">';
}
$output .= '<select '.$required.' onclick="'.$script.'" id="'.$id.'" name="'.$name.'"'.$attributes.' '.$styleText.'>';
$output .= '<select '.$required.' id="'.$id.'" name="'.$name.'"'.$attributes.' '.$styleText.'>';
if ($nothing !== false) {
if ($nothing != '' || empty($fields)) {
@ -4766,10 +4766,15 @@ function html_print_input($data, $wrapper='div', $input_only=false)
enterprise_include_once('include/functions_metaconsole.php');
$style = '';
if ($config['style'] === 'pandora_black' && !is_metaconsole()) {
$style = 'style="color: white"';
}
if (isset($data['label_class']) === false) {
$data['label_class'] = '';
}
$output = '';
if (($data['label'] ?? false) && $input_only === false) {

View File

@ -688,6 +688,15 @@ function reporting_make_reporting_data(
);
break;
case 'custom_render':
$report['contents'][] = reporting_custom_render(
$report,
$content,
$type,
$pdf
);
break;
case 'group_configuration':
$report['contents'][] = reporting_group_configuration(
$report,
@ -4675,6 +4684,294 @@ function reporting_network_interfaces_report($report, $content, $type='dinamic',
}
function reporting_custom_render($report, $content, $type='dinamic', $pdf=0)
{
global $config;
$return['type'] = 'custom_render';
if (empty($content['name'])) {
$content['name'] = __('Custom render report');
}
$return['title'] = $content['name'];
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = '';
$return['description'] = $content['description'];
$return['date'] = reporting_get_date_text($report, $content);
$return['failed'] = null;
$macros = [];
$patterns = [];
$substitutions = [];
if (isset($content['macros_definition']) === true
&& empty($content['macros_definition']) === false
) {
$macros = json_decode(
io_safe_output($content['macros_definition']),
true
);
if (empty($macros) === false && is_array($macros) === true) {
foreach ($macros as $key_macro => $data_macro) {
switch ($data_macro['type']) {
case 0:
// Type: String.
$patterns[] = addslashes(
'/_'.$data_macro['name'].'_/'
);
$substitutions[] = $data_macro['value'];
break;
case 1:
// Type Sql value.
$patterns[] = addslashes(
'/_'.$data_macro['name'].'_/'
);
$regex = '/(UPDATE|INSERT INTO|DELETE FROM|TRUNCATE|DROP|ALTER|CREATE|GRANT|REVOKE)\s+(.*?)\s+/i';
if (preg_match($regex, $data_macro['value']) > 0) {
$value_query = __('This query is insecure, it could apply unwanted modiffications on the schema');
} else {
$error_reporting = error_reporting();
error_reporting(0);
$value_query = db_get_value_sql(
trim($data_macro['value'], ';')
);
if ($value_query === false) {
$value_query = __('Error: %s', $config['dbconnection']->error);
}
error_reporting($error_reporting);
}
$substitutions[] = $value_query;
break;
case 2:
// Type: SQL graph.
$patterns[] = addslashes(
'/_'.$data_macro['name'].'_/'
);
$regex = '/(UPDATE|INSERT INTO|DELETE FROM|TRUNCATE|DROP|ALTER|CREATE|GRANT|REVOKE)\s+(.*?)\s+/i';
if (preg_match($regex, $data_macro['value']) > 0) {
$value_query = __('This query is insecure, it could apply unwanted modiffications on the schema');
} else {
$error_reporting = error_reporting();
error_reporting(0);
$data_query = db_get_all_rows_sql(
trim($data_macro['value'], ';')
);
error_reporting($error_reporting);
if ($data_query === false) {
$value_query = __('Error: %s', $config['dbconnection']->error);
} else {
$width = 210;
if (isset($data_macro['width']) === true
&& empty($data_macro['width']) === false
) {
$width = $data_macro['width'];
}
$height = 210;
if (isset($data_macro['height']) === true
&& empty($data_macro['height']) === false
) {
$height = $data_macro['height'];
}
// TODO: Allow to paint horizontal and vertical bar graphs for the moment only pie graphs.
$type = 'sql_graph_pie';
$SQL_GRAPH_MAX_LABEL_SIZE = 5;
$count = 0;
$flagOther = false;
foreach ($data_query as $data_item) {
$count++;
$value = 0;
if (empty($data_item['value']) === false) {
$value = $data_item['value'];
}
if ($count <= 5) {
$label = __('Data');
if (empty($data_item['label']) === false) {
$label = io_safe_output($data_item['label']);
if (strlen($label) > $SQL_GRAPH_MAX_LABEL_SIZE) {
$first_label = $label;
$label = substr(
$first_label,
0,
floor($SQL_GRAPH_MAX_LABEL_SIZE / 2)
);
$label .= '...<br>';
$label .= substr(
$first_label,
floor(-$SQL_GRAPH_MAX_LABEL_SIZE / 2)
);
}
}
switch ($type) {
case 'sql_graph_vbar':
default:
// Vertical bar.
$data[] = [
'tick' => $label.'_'.$count,
'data' => $value,
];
break;
case 'sql_graph_hbar':
// Horizontal bar.
$data[$label.'_'.$count]['g'] = $value;
break;
case 'sql_graph_pie':
// Pie.
$data[$label.'_'.$count] = $value;
break;
}
} else {
switch ($type) {
case 'sql_graph_vbar':
default:
// Vertical bar.
if ($flagOther === false) {
$data[] = [
'tick' => __('Other'),
'data' => $value,
];
$flagOther = true;
}
$data[(count($data) - 1)]['data'] += $value;
break;
case 'sql_graph_hbar':
// Horizontal bar.
if (isset($data[__('Other')]['g']) === false) {
$data[__('Other')]['g'] = 0;
}
$data[__('Other')]['g'] += $value;
break;
case 'sql_graph_pie':
// Pie.
if (isset($data[__('Other')]) === false) {
$data[__('Other')] = 0;
}
$data[__('Other')] += $value;
break;
}
}
}
$value_query = pie_graph(
$data,
$width,
$height,
__('other'),
ui_get_full_url(false, false, false, false),
'',
$config['fontpath'],
$config['font_size'],
($pdf === true) ? 2 : 1,
'hidden',
'',
true
);
}
}
$substitutions[] = $value_query;
break;
case 3:
// Type: Simple graph.
$patterns[] = addslashes(
'/_'.$data_macro['name'].'_/'
);
$height = $config['graph_image_height'];
if (isset($data_macro['height']) === true
&& empty($data_macro['height']) === false
) {
$height = $data_macro['height'];
}
$period = SECONDS_1DAY;
if (isset($data_macro['period']) === true
&& empty($data_macro['period']) === false
) {
$period = $data_macro['period'];
}
if (is_metaconsole() === true) {
$server = db_get_row(
'tmetaconsole_setup',
'id',
$data_macro['server_id']
);
if (metaconsole_connect($server) != NOERR) {
continue;
}
}
$params = [
'agent_module_id' => $data_macro['id_agent_module'],
'period' => $period,
'title' => '',
'label' => '',
'pure' => false,
'only_image' => true,
'homeurl' => ui_get_full_url(
false,
false,
false,
false
),
'ttl' => ($pdf === true) ? 2 : 1,
'show_unknown' => true,
'height' => $height,
'backgroundColor' => 'transparent',
'return_img_base_64' => true,
'server_id' => (is_metaconsole() === true) ? $data_macro['server_id'] : 0,
];
$substitutions[] = '<img style="max-width:100%;" src="data:image/png;base64,'.grafico_modulo_sparse($params).'" />';
if (is_metaconsole() === true) {
metaconsole_restore_db();
}
break;
default:
// Not possible.
break;
}
}
}
}
$return['data'] = preg_replace(
$patterns,
$substitutions,
$content['render_definition']
);
return reporting_check_structure_content($return);
}
function agents_get_network_interfaces_array(
$network_interfaces_by_agents,
$return,
@ -9961,10 +10258,12 @@ function reporting_get_date_text($report=null, $content=null)
if (!empty($report) && !empty($content)) {
if ($content['period'] == 0) {
$es = json_decode($content['external_source'], true);
if ($es['date'] == 0) {
$return['period'] = 0;
} else {
$return['date'] = $es['date'];
if (empty($es) === false) {
if ($es['date'] == 0) {
$return['period'] = 0;
} else {
$return['date'] = $es['date'];
}
}
} else {
$return['period'] = $content['period'];

View File

@ -350,6 +350,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
reporting_html_network_interfaces_report($table, $item);
break;
case 'custom_render':
reporting_html_custom_render($table, $item);
break;
case 'group_configuration':
reporting_html_group_configuration($table, $item);
break;
@ -3060,6 +3064,47 @@ function reporting_html_network_interfaces_report($table, $item, $pdf=0)
}
/**
* This type of report element will generate the interface graphs
* of all those devices that belong to the selected group.
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
* @param boolean $pdf If it comes from pdf.
*
* @return string HTML code.
*/
function reporting_html_custom_render($table, $item, $pdf=0)
{
$return_pdf = '';
if (empty($item['failed']) === false) {
if ($pdf === 0) {
$table->colspan['interfaces']['cell'] = 3;
$table->cellstyle['interfaces']['cell'] = 'text-align: left;';
$table->data['interfaces']['cell'] = $item['failed'];
} else {
$return_pdf .= $item['failed'];
}
} else {
$output = '<div id="reset-styles">';
$output .= $item['data'];
$output .= '</div>';
if ($pdf === 1) {
$return_pdf .= $output;
} else {
$id = uniqid();
$table->colspan[$id][0] = 3;
$table->data[$id] = $output;
}
}
if ($pdf !== 0) {
return $return_pdf;
}
}
/**
* Unified alert report HTML
*/

View File

@ -818,6 +818,13 @@ function reports_get_report_types($template=false, $not_editor=false)
'optgroup' => __('Grouped'),
'name' => __('Network interfaces'),
];
if (!$template) {
$types['custom_render'] = [
'optgroup' => __('Grouped'),
'name' => __('Custom Render'),
];
}
$types['availability'] = [
'optgroup' => __('Grouped'),
'name' => __('Availability'),
@ -1031,3 +1038,366 @@ function reports_copy_report($id_report)
return true;
}
/**
* Table custom macros.
*
* @param string $data JSON.
*
* @return string Html output.
*/
function get_table_custom_macros_report($data)
{
$table = new StdClass();
$table->data = [];
$table->width = '100%';
$table->class = 'databox data fullwidth';
$table->id = 'table-macros-definition';
$table->rowclass = [];
$table->size = [];
$table->size['name'] = '20%';
$table->size['type'] = '20%';
$table->size['value'] = '50%';
$table->size['op'] = '10%';
$table->head = [];
$table->head['name'] = __('Macro');
$table->head['type'] = __('Type');
$table->head['value'] = __('Value');
$table->head['op'] = html_print_image(
'images/add.png',
true,
[
'class' => 'invert_filter btn_debugModule',
'style' => 'cursor: pointer; filter: invert(100%);',
'onclick' => 'addCustomFieldRow();',
]
);
$list_macro_custom_type = [
0 => __('String'),
1 => __('Sql'),
2 => __('Graph Sql'),
3 => __('Simple graph'),
];
$data = json_decode($data, true);
if (is_array($data) === false || empty($data) === true) {
$data = [];
$data[0] = [
'name' => '',
'type' => 0,
'value' => '',
];
}
$table->data = [];
foreach ($data as $key_macro => $value_data_macro) {
$table->rowclass[$key_macro] = 'tr-macros-definition';
$table->data[$key_macro]['name'] = html_print_input_text_extended(
'macro_custom_name[]',
$value_data_macro['name'],
($key_macro === 0) ? 'macro_custom_name' : 'macro_custom_name_'.$key_macro,
'',
15,
255,
false,
'',
'class="fullwidth"',
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[]',
$value_data_macro['type'],
'change_custom_fields_macros_report('.$key_macro.')',
'',
0,
true,
false,
false,
'fullwidth',
false,
'height: 32px;',
false,
false,
false,
'',
false,
false,
false,
false,
false
);
$custom_fields = custom_fields_macros_report(
$value_data_macro,
$key_macro
);
$custom_field_draw = '';
if (empty($custom_fields) === false) {
foreach ($custom_fields as $key => $value) {
$custom_field_draw .= $value;
}
}
$table->data[$key_macro]['value'] = $custom_field_draw;
$table->data[$key_macro]['op'] = html_print_image(
'images/clean.png',
true,
[
'class' => 'invert_filter icon-clean-custom-macro',
'style' => 'cursor: pointer;',
'onclick' => 'cleanCustomFieldRow('.$key_macro.')',
]
);
$styles_remove = 'cursor: pointer; margin-right:10px;';
if ($key_macro === 0) {
$styles_remove .= 'display:none';
}
$table->data[$key_macro]['op'] .= html_print_image(
'images/delete.png',
true,
[
'class' => 'invert_filter icon-delete-custom-macro',
'style' => $styles_remove,
'onclick' => 'removeCustomFieldRow('.$key_macro.')',
]
);
}
return html_print_table(
$table,
true
);
}
/**
* Custom field macros report
*
* @param array $macro Info macro.
* @param string $key_macro Key.
*
* @return array
*/
function custom_fields_macros_report($macro, $key_macro)
{
$result = [];
switch ($macro['type']) {
case 0:
case 1:
$result['value'] = '<div class="custom-field-macro-report">';
$result['value'] .= '<label>';
$result['value'] .= ($macro['type'] == 0) ? __('String') : __('Sql');
$result['value'] .= '</label>';
$result['value'] .= html_print_input_text_extended(
'macro_custom_value[]',
$macro['value'],
($key_macro === 0) ? 'macro_custom_value' : 'macro_custom_value_'.$key_macro,
'',
15,
255,
false,
'',
'',
true
);
$result['value'] .= '</div>';
break;
case 2:
$result['value'] = '<div class="custom-field-macro-report mb10">';
$result['value'] .= '<label>';
$result['value'] .= __('Sql');
$result['value'] .= '</label>';
$result['value'] .= html_print_input_text_extended(
'macro_custom_value['.$key_macro.'][value]',
$macro['value'],
($key_macro === 0) ? 'macro_custom_value' : 'macro_custom_value_'.$key_macro,
'',
15,
255,
false,
'',
'class="fullwidth"',
true
);
$result['value'] .= '</div>';
$result['size'] = '<div class="custom-field-macro-report">';
$result['size'] .= '<label>';
$result['size'] .= __('Width');
$result['size'] .= '</label>';
$result['size'] .= html_print_input_text_extended(
'macro_custom_value['.$key_macro.'][width]',
$macro['width'],
($key_macro === 0) ? 'macro_custom_width' : 'macro_custom_width_'.$key_macro,
'',
5,
255,
false,
'',
'',
true
);
$result['size'] .= '<label>';
$result['size'] .= __('Height');
$result['size'] .= '</label>';
$result['size'] .= html_print_input_text_extended(
'macro_custom_value['.$key_macro.'][height]',
$macro['height'],
($key_macro === 0) ? 'macro_custom_height' : 'macro_custom_height_'.$key_macro,
'',
5,
255,
false,
'',
'',
true
);
$result['size'] .= '</div>';
break;
case 3:
$params = [];
$params['show_helptip'] = true;
$params['input_name'] = 'macro_custom_value_agent_name_'.$key_macro;
$params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'macro_custom_value_agent_id_'.$key_macro;
$params['hidden_input_idagent_name'] = 'macro_custom_value['.$key_macro.'][agent_id]';
$params['hidden_input_idagent_value'] = $macro['agent_id'];
$params['javascript_is_function_select'] = true;
$params['selectbox_id'] = 'macro_custom_value'.$key_macro.'id_agent_module';
$params['add_none_module'] = false;
$params['return'] = true;
$params['disabled_javascript_on_blur_function'] = true;
if (is_metaconsole() === true) {
$params['print_input_id_server'] = true;
$params['metaconsole_enabled'] = true;
$params['input_id_server_id'] = 'macro_custom_value_id_server_'.$key_macro;
$params['input_id_server_name'] = 'macro_custom_value['.$key_macro.'][server_id]';
$params['input_id_server_value'] = $macro['server_id'];
$params['value'] = agents_meta_get_alias(
$macro['agent_id'],
'none',
$macro['server_id'],
true
);
} else {
$params['value'] = agents_get_alias($macro['agent_id']);
}
$result['size'] = '<div class="custom-field-macro-report mb10">';
$result['size'] .= '<label>';
$result['size'] .= __('Agent');
$result['size'] .= '</label>';
$result['size'] .= ui_print_agent_autocomplete_input($params);
$modules = [];
if (isset($macro['agent_id']) === true
&& empty($macro['agent_id']) === false
) {
if (is_metaconsole() === true) {
$server = db_get_row(
'tmetaconsole_setup',
'id',
$macro['server_id']
);
if (metaconsole_connect($server) != NOERR) {
continue;
}
}
$modules = agents_get_modules(
$macro['agent_id'],
false,
['delete_pending' => 0]
);
if (is_metaconsole() === true) {
metaconsole_restore_db();
}
}
$result['size'] .= '<label>';
$result['size'] .= __('Module');
$result['size'] .= '</label>';
$result['size'] .= html_print_select(
$modules,
'macro_custom_value['.$key_macro.'][id_agent_module]',
$macro['id_agent_module'],
true,
__('Select'),
0,
true,
false,
true,
'',
(empty($macro['agent_id']) === true),
'min-width: 250px;margin-right: 0.5em;'
);
$result['size'] .= '</div>';
$result['size'] .= '<div class="custom-field-macro-report">';
$result['size'] .= '<label>';
$result['size'] .= __('Height');
$result['size'] .= '</label>';
$result['size'] .= html_print_input_text_extended(
'macro_custom_value['.$key_macro.'][height]',
$macro['height'],
($key_macro === 0) ? 'macro_custom_height' : 'macro_custom_height_'.$key_macro,
'',
5,
255,
false,
'',
'',
true
);
$result['size'] .= '<label>';
$result['size'] .= __('Period ');
$result['size'] .= '</label>';
$result['size'] .= html_print_input_text_extended(
'macro_custom_value['.$key_macro.'][period]',
$macro['period'],
($key_macro === 0) ? 'macro_custom_period' : 'macro_custom_period_'.$key_macro,
'',
5,
255,
false,
'',
'',
true
);
$result['size'] .= '</div>';
break;
default:
// Not possible.
break;
}
return $result;
}

View File

@ -104,7 +104,7 @@ function pandoraFlotPie(
'<div style="font-size:' +
font_size +
"pt;" +
'text-align:center;padding:2px;color:white;">' +
'text-align:center;padding:2px;color:#4a4a4a;">' +
label +
"<br/>" +
series.percent.toFixed(2) +

View File

@ -8572,3 +8572,446 @@ div#err_msg_centralised {
width: 90%;
margin: 0 auto;
}
.custom-field-macro-report {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
align-content: center;
}
.custom-field-macro-report label {
flex: 0;
margin-right: 10px;
margin-left: 10px;
}
.custom-field-macro-report input {
flex: 2;
}
.mb10 {
margin-bottom: 10px;
}
#reset-styles {
font-size: 9pt;
line-height: 16pt;
padding: 0px;
box-sizing: border-box;
/*page-break-after: always;*/
}
#reset-styles a:link {
text-decoration: underline;
cursor: auto;
}
#reset-styles a:visited {
text-decoration: underline;
cursor: auto;
}
#reset-styles address {
display: block;
font-style: italic;
}
#reset-styles area {
display: none;
}
#reset-styles article {
display: block;
}
#reset-styles aside {
display: block;
}
#reset-styles b {
font-weight: bold;
}
#reset-styles bdo {
unicode-bidi: bidi-override;
}
#reset-styles blockquote {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 40px;
margin-right: 40px;
}
#reset-styles body {
display: block;
margin: 8px;
}
#reset-styles body:focus {
outline: none;
}
#reset-styles caption {
display: table-caption;
text-align: center;
}
#reset-styles cite {
font-style: italic;
}
#reset-styles code {
font-family: monospace;
}
#reset-styles col {
display: table-column;
}
#reset-styles colgroup {
display: table-column-group;
}
#reset-styles datalist {
display: none;
}
#reset-styles dd {
display: block;
margin-left: 40px;
}
#reset-styles del {
text-decoration: line-through;
}
#reset-styles details {
display: block;
}
#reset-styles dfn {
font-style: italic;
}
#reset-styles div {
display: block;
}
#reset-styles dl {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
}
#reset-styles dt {
display: block;
}
#reset-styles em {
font-style: italic;
}
#reset-styles embed:focus {
outline: none;
}
#reset-styles fieldset {
display: block;
margin-left: 2px;
margin-right: 2px;
padding-top: 0.35em;
padding-bottom: 0.625em;
padding-left: 0.75em;
padding-right: 0.75em;
border: 2px groove;
}
#reset-styles figcaption {
display: block;
}
#reset-styles figure {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 40px;
margin-right: 40px;
}
#reset-styles footer {
display: block;
}
#reset-styles form {
display: block;
margin-top: 0em;
}
#reset-styles h1 {
display: inline-block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
margin-block-start: 0.67em;
margin-block-end: 0.67em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-weight: bold;
text-transform: uppercase;
padding: 0;
}
#reset-styles h2 {
display: inline-block;
font-size: 1.5em;
margin-top: 0.83em;
margin-bottom: 0.83em;
margin-left: 0;
margin-right: 0;
margin-block-start: 0.83em;
margin-block-end: 0.83em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-weight: bold;
text-transform: uppercase;
padding: 0;
}
#reset-styles h3 {
display: inline-block;
font-size: 1.17em;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-weight: bold;
text-transform: uppercase;
padding: 0;
}
#reset-styles h4 {
display: inline-block;
margin-top: 1.33em;
margin-bottom: 1.33em;
margin-left: 0;
margin-right: 0;
margin-block-start: 1.33em;
margin-block-end: 1.33em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-weight: bold;
text-transform: uppercase;
padding: 0;
}
#reset-styles h5 {
display: inline-block;
font-size: 0.83em;
margin-top: 1.67em;
margin-bottom: 1.67em;
margin-block-start: 1.67em;
margin-block-end: 1.67em;
margin-inline-start: 0px;
margin-inline-end: 0px;
margin-left: 0;
margin-right: 0;
font-weight: bold;
text-transform: uppercase;
padding: 0;
}
#reset-styles h6 {
display: inline-block;
font-size: 0.67em;
margin-top: 2.33em;
margin-bottom: 2.33em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
text-transform: uppercase;
padding: 0;
}
#reset-styles head {
display: none;
}
#reset-styles header {
display: block;
}
#reset-styles hr {
display: block;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: auto;
margin-right: auto;
border-style: inset;
border-width: 1px;
}
#reset-styles html {
display: block;
}
#reset-styles html:focus {
outline: none;
}
#reset-styles i {
font-style: italic;
}
#reset-styles iframe:focus {
outline: none;
}
#reset-styles iframe[seamless] {
display: block;
}
#reset-styles img {
display: inline-block;
}
#reset-styles ins {
text-decoration: underline;
}
#reset-styles kbd {
font-family: monospace;
}
#reset-styles label {
cursor: default;
}
#reset-styles legend {
display: block;
padding-left: 2px;
padding-right: 2px;
border: none;
}
#reset-styles li {
display: list-item;
}
#reset-styles link {
display: none;
}
#reset-styles map {
display: inline;
}
#reset-styles mark {
background-color: yellow;
color: black;
}
#reset-styles menu {
display: block;
list-style-type: disc;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
padding-left: 40px;
}
#reset-styles nav {
display: block;
}
#reset-styles object:focus {
outline: none;
}
#reset-styles ol {
display: block;
list-style-type: decimal;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
padding-left: 40px;
}
#reset-styles output {
display: inline;
}
#reset-styles p {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
}
#reset-styles param {
display: none;
}
#reset-styles pre {
display: block;
font-family: monospace;
white-space: pre;
margin: 1em 0;
}
#reset-styles q {
display: inline;
}
#reset-styles q::before {
content: open-quote;
}
#reset-styles q::after {
content: close-quote;
}
#reset-styles rt {
line-height: normal;
}
#reset-styles s {
text-decoration: line-through;
}
#reset-styles samp {
font-family: monospace;
}
#reset-styles script {
display: none;
}
#reset-styles section {
display: block;
}
#reset-styles small {
font-size: smaller;
}
#reset-styles strike {
text-decoration: line-through;
}
#reset-styles strong {
font-weight: bold;
}
#reset-styles style {
display: none;
}
#reset-styles sub {
vertical-align: sub;
font-size: smaller;
}
#reset-styles summary {
display: block;
}
#reset-styles sup {
vertical-align: super;
font-size: smaller;
}
#reset-styles table {
display: table;
border-collapse: separate;
border-spacing: 2px;
border-color: gray;
}
#reset-styles tbody {
display: table-row-group;
vertical-align: middle;
border-color: inherit;
}
#reset-styles td {
display: table-cell;
vertical-align: inherit;
text-align: inherit;
}
#reset-styles tfoot {
display: table-footer-group;
vertical-align: middle;
border-color: inherit;
}
#reset-styles thead tr th {
display: table-cell;
vertical-align: inherit;
font-weight: bold;
text-align: center;
background-color: initial;
color: initial;
}
#reset-styles thead {
display: table-header-group;
vertical-align: middle;
border-color: inherit;
}
#reset-styles title {
display: none;
}
#reset-styles tr {
display: table-row;
vertical-align: inherit;
border-color: inherit;
}
#reset-styles u {
text-decoration: underline;
}
#reset-styles ul {
display: block;
list-style-type: disc;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
padding-left: 40px;
}
#reset-styles var {
font-style: italic;
}

View File

@ -1610,6 +1610,8 @@ CREATE TABLE IF NOT EXISTS `treport_content` (
`ipam_network_filter` INT UNSIGNED DEFAULT 0,
`ipam_alive_ips` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`ipam_ip_not_assigned_to_agent` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`macros_definition` TEXT,
`render_definition` TEXT,
PRIMARY KEY(`id_rc`),
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
ON UPDATE CASCADE ON DELETE CASCADE
@ -3244,6 +3246,8 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` (
`ipam_network_filter` INT UNSIGNED DEFAULT 0,
`ipam_alive_ips` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`ipam_ip_not_assigned_to_agent` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`macros_definition` TEXT,
`render_definition` TEXT,
PRIMARY KEY(`id_rc`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;