$interval,
'width' => '100%',
'graph_width' => '85%',
'height' => 100,
'date' => time(),
'percentil' => null,
'fullscale' => 1,
'type_graph' => 'line',
'timestamp_top_fixed' => 'timestamp-top-fixed',
'graph_analytics' => true,
'realtime' => true,
];
$params_combined = [
'stacked' => 2,
'labels' => [],
'modules_series' => $modules,
'id_graph' => null,
'return' => 1,
'graph_analytics' => true,
];
$graph_return = graphic_combined_module(
$modules,
$params,
$params_combined
);
$graph_return .= "
";
echo $graph_return;
return;
}
// Save filter.
if (empty($save_filter) === false) {
$graphs = get_parameter('graphs');
$interval = (int) get_parameter('interval');
if (empty($save_filter) === true) {
echo __('Empty name');
return;
}
if (empty($graphs) === true) {
echo __('Empty graphs');
return;
}
$id_filter = db_process_sql_insert(
'tgraph_analytics_filter',
[
'filter_name' => $save_filter,
'user_id' => $config['id_user'],
'graph_modules' => json_encode($graphs),
'interval' => $interval,
]
);
if ($id_filter > 0) {
echo 'saved';
return;
} else {
echo __('Empty graphs');
return;
}
}
// Update filter.
if (empty($update_filter) === false) {
$graphs = get_parameter('graphs');
$interval = (int) get_parameter('interval');
if (empty($graphs) === true) {
echo __('Empty graphs');
return;
}
$update_filter = db_process_sql_update(
'tgraph_analytics_filter',
[
'graph_modules' => json_encode($graphs),
'interval' => $interval,
],
['id' => $update_filter]
);
if ($update_filter > 0) {
echo 'updated';
return;
} else {
echo __('No updated');
return;
}
echo $update_filter;
return;
}
// Load filter.
if (empty($load_filter) === false) {
$data = [];
$data['graphs'] = json_decode(db_get_value('graph_modules', 'tgraph_analytics_filter', 'id', $load_filter));
$data['interval'] = db_get_value('tgraph_analytics_filter.interval', 'tgraph_analytics_filter', 'id', $load_filter);
echo json_encode($data);
return;
}
// Get new values.
if (empty($get_new_values) === false) {
$data = [];
$agent_module_id = $get_new_values;
$date_array = get_parameter('date_array');
$data_module_graph = get_parameter('data_module_graph');
$params = get_parameter('params');
$suffix = get_parameter('suffix');
// Stract data.
$array_data_module = grafico_modulo_sparse_data(
$agent_module_id,
$date_array,
$data_module_graph,
$params,
$suffix
);
echo json_encode($array_data_module);
return;
}
return;
}
// Save filter modal.
echo '
';
if (check_acl($config['id_user'], 0, 'RW') === 1 || check_acl($config['id_user'], 0, 'RM') === 1) {
echo '
';
$table = new StdClass;
$table->id = 'save_filter_form';
$table->width = '100%';
$table->cellspacing = 4;
$table->cellpadding = 4;
$table->class = 'databox no_border';
$table->styleTable = 'font-weight: bold; text-align:left;';
$data = [];
$table->rowid[0] = 'update_save_selector';
$data[0] = html_print_div(
[
'style' => 'display: flex;',
'content' => html_print_radio_button(
'filter_mode',
'new',
__('New filter'),
true,
true
),
],
true
);
$data[1] = html_print_div(
[
'style' => 'display: flex;',
'content' => html_print_radio_button(
'filter_mode',
'update',
__('Update filter'),
false,
true
),
],
true
);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$table->rowid[1] = 'save_filter_row1';
$data[0] = __('Filter name');
$data[0] .= html_print_input_text('id_name', '', '', 15, 255, true);
$data[1] = html_print_submit_button(
__('Save filter'),
'save_filter',
false,
[
'class' => 'mini ',
'icon' => 'save',
'style' => 'margin-left: 175px; width: 125px;',
'onclick' => 'save_new_filter();',
],
true
);
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$table->rowid[2] = 'save_filter_row2';
$table->data[] = $data;
$table->rowclass[] = '';
$data = [];
$table->rowid[3] = 'update_filter_row1';
$data[0] = __('Overwrite filter');
$select_filters_update = graph_analytics_filter_select();
$data[0] .= html_print_select(
$select_filters_update,
'overwrite_filter',
'',
'',
'',
0,
true
);
$table->rowclass[] = 'display-grid';
$data[1] = html_print_submit_button(
__('Update filter'),
'update_filter',
false,
[
'class' => 'mini ',
'icon' => 'save',
'style' => 'margin-left: 155px; width: 145px;',
'onclick' => 'save_update_filter();',
],
true
);
$table->data[] = $data;
$table->rowclass[] = '';
html_print_table($table);
} else {
include 'general/noaccess.php';
}
echo '
';
// Load filter modal.
$filters = graph_analytics_filter_select();
echo '';
$table = new StdClass;
$table->id = 'load_filter_form';
$table->width = '100%';
$table->cellspacing = 4;
$table->cellpadding = 4;
$table->class = 'databox no_border';
$table->styleTable = 'font-weight: bold; color: #555; text-align:left;';
$filter_id_width = 'w100p';
$data = [];
$table->rowid[3] = 'update_filter_row1';
$data[0] = __('Load filter');
$data[0] .= html_print_select(
$filters,
'filter_id',
'',
'',
__('None'),
0,
true,
false,
true,
'',
false,
'width:'.$filter_id_width.';'
);
$table->rowclass[] = 'display-grid';
$data[1] = html_print_submit_button(
__('Load filter'),
'load_filter',
false,
[
'class' => 'mini w30p',
'icon' => 'load',
'style' => 'margin-left: 208px; width: 130px;',
'onclick' => 'load_filter_values();',
],
true
);
$data[1] .= html_print_input_hidden('load_filter', 1, true);
$table->data[] = $data;
$table->rowclass[] = '';
html_print_table($table);
echo '
';
// Header & Actions.
$title_tab = __('Start realtime');
$tab_start_realtime = [
'text' => ''.html_print_image(
'images/change-active.svg',
true,
[
'title' => $title_tab,
'class' => 'invert_filter main_menu_icon',
]
).$title_tab.'',
];
$title_tab = __('Pause realtime');
$tab_pause_realtime = [
'text' => ''.html_print_image(
'images/change-pause.svg',
true,
[
'title' => $title_tab,
'class' => 'invert_filter main_menu_icon',
]
).$title_tab.'',
];
$title_tab = __('New');
$tab_new = [
'text' => ''.html_print_image(
'images/plus-black.svg',
true,
[
'title' => $title_tab,
'class' => 'invert_filter main_menu_icon',
]
).$title_tab.'',
];
$title_tab = __('Save');
$tab_save = [
'text' => ''.html_print_image(
'images/save_mc.png',
true,
[
'title' => $title_tab,
'class' => 'invert_filter main_menu_icon',
]
).$title_tab.'',
];
$title_tab = __('Load');
$tab_load = [
'text' => ''.html_print_image(
'images/logs@svg.svg',
true,
[
'title' => $title_tab,
'class' => 'invert_filter main_menu_icon',
]
).$title_tab.'',
];
$title_tab = __('Share');
$tab_share = [
'text' => ''.html_print_image(
'images/responses.svg',
true,
[
'title' => $title_tab,
'class' => 'invert_filter main_menu_icon',
]
).$title_tab.'',
];
$title_tab = __('Export to custom graph');
$tab_export = [
'text' => ''.html_print_image(
'images/module-graph.svg',
true,
[
'title' => $title_tab,
'class' => 'invert_filter main_menu_icon',
]
).$title_tab.'',
];
ui_print_standard_header(
__('Graph analytics'),
'images/menu/reporting.svg',
false,
'',
false,
[
$tab_export,
$tab_share,
$tab_load,
$tab_save,
$tab_new,
$tab_pause_realtime,
$tab_start_realtime,
],
[
[
'link' => '',
'label' => __('Reporting'),
],
]
);
// Content.
$left_content = '';
$right_content = '';
$left_content .= '
'.ui_toggle(
'',
__('Agents'),
'agents-toggle',
'agents-toggle',
true,
true,
'',
'white-box-content',
'box-flat white_table_graph',
'images/arrow@svg.svg',
'images/arrow@svg.svg',
false,
false,
false,
'',
'',
null,
null,
false,
false,
'static'
).ui_toggle(
'',
__('Groups'),
'groups-toggle',
'groups-toggle',
true,
true,
'',
'white-box-content',
'box-flat white_table_graph',
'images/arrow@svg.svg',
'images/arrow@svg.svg',
false,
false,
false,
'',
'',
null,
null,
false,
false,
'static'
).ui_toggle(
'',
__('Modules'),
'modules-toggle',
'modules-toggle',
true,
true,
'',
'white-box-content',
'box-flat white_table_graph',
'images/arrow@svg.svg',
'images/arrow@svg.svg',
false,
false,
false,
'',
'',
null,
null,
false,
false,
'static'
).'
';
$intervals = [];
$intervals[SECONDS_1HOUR] = _('Last ').human_time_description_raw(SECONDS_1HOUR, true, 'large');
$intervals[SECONDS_6HOURS] = _('Last ').human_time_description_raw(SECONDS_6HOURS, true, 'large');
$intervals[SECONDS_12HOURS] = _('Last ').human_time_description_raw(SECONDS_12HOURS, true, 'large');
$intervals[SECONDS_1DAY] = _('Last ').human_time_description_raw(SECONDS_1DAY, true, 'large');
$intervals[SECONDS_2DAY] = _('Last ').human_time_description_raw(SECONDS_2DAY, true, 'large');
$intervals[SECONDS_1WEEK] = _('Last ').human_time_description_raw(SECONDS_1WEEK, true, 'large');
$right_content .= ''.html_print_select(
$intervals,
'interval',
SECONDS_12HOURS,
'',
'',
0,
true,
false,
false,
''
).'
';
$right_content .= '
';
//
//
//
$filters_div = html_print_div(
[
'class' => 'filters-div-main',
'content' => $left_content,
],
true
);
$graphs_div = html_print_div(
[
'class' => 'padding-div graphs-div-main',
'content' => $right_content,
],
true
);
html_print_div(
[
'class' => 'white_box main-div',
'content' => $filters_div.$graphs_div,
]
);
?>