$id_graph]); if ($res) { $result = ui_print_success_message(__('Successfully deleted'), '', true); } else { $result = ui_print_error_message(__('Not deleted. Error deleting data'), '', true); } $res = db_process_sql_delete('tgraph', ['id_graph' => $id_graph]); if ($res) { $result = ui_print_success_message(__('Successfully deleted'), '', true); } else { $result = ui_print_error_message(__('Not deleted. Error deleting data'), '', true); } echo $result; } else { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to delete a graph from access graph builder' ); include 'general/noaccess.php'; exit; } } if ($view_graph) { $sql = "SELECT * FROM tgraph_source WHERE id_graph = $id_graph"; $sources = db_get_all_rows_sql($sql); if ($sources === false) { $sources = []; } $sql = "SELECT * FROM tgraph WHERE id_graph = $id_graph"; $graph = db_get_row_sql($sql); $id_user = $graph['id_user']; $private = $graph['private']; $width = $graph['width']; $height = ($graph['height'] + count($sources) * 10); $zoom = (int) get_parameter('zoom', 0); // Increase the height to fix the leyend rise if ($zoom > 0) { switch ($zoom) { case 1: $width = 500; $height = (200 + count($sources) * 15); break; case 2: $width = 650; $height = (300 + count($sources) * 10); break; case 3: $width = 770; $height = (400 + count($sources) * 5); break; } } // Calculate range dates. $custom_date = get_parameter('custom_date', 0); $date = get_parameter('date', SECONDS_1DAY); $date_text = get_parameter('date_text', SECONDS_1DAY); if ($custom_date === '1') { $date_init_less = (strtotime(date('Y-m-j')) - SECONDS_1DAY); $date_init = get_parameter('date_init', date(DATE_FORMAT, $date_init_less)); $time_init = get_parameter('time_init', date(TIME_FORMAT, $date_init_less)); $datetime_init = strtotime($date_init.' '.$time_init); $date_end = (string) get_parameter('date_end', date(DATE_FORMAT)); $time_end = (string) get_parameter('time_end', date(TIME_FORMAT)); $datetime_end = strtotime($date_end.' '.$time_end); if ($datetime_init >= $datetime_end) { $datetime_init = $date_init_less; } $unixdate = $datetime_end; $period = ($unixdate - $datetime_init); } else if ($custom_date === '2') { $unixdate = strtotime('now'); $date_units = get_parameter('date_units'); $date_start = date('Y/m/d H:i:s', ($unixdate - ($date_text * $date_units))); $period = ($unixdate - strtotime($date_start)); } else if (in_array($date, ['this_week', 'this_month', 'past_week', 'past_month'])) { if ($date === 'this_week') { $monday = date('Y/m/d 00:00:00', strtotime('Monday this week')); $sunday = date('Y/m/d 23:59:59', strtotime($monday.' +6 days')); $period = (strtotime($sunday) - strtotime($monday)); $unixdate = strtotime($sunday); } else if ($date === 'this_month') { $unixdate = strtotime('last day of this month'); $first_of_month = date('Y/m/d', strtotime('first day of this month')); $period = ($unixdate - strtotime($first_of_month)); } else if ($date === 'past_month') { $unixdate = strtotime('last day of previous month'); $first_of_month = date('Y/m/d', strtotime('first day of previous month')); $period = ($unixdate - strtotime($first_of_month)); } else if ($date === 'past_week') { $unixdate = strtotime('sunday', strtotime('last week')); $first_of_week = date('Y-m-d', strtotime('monday', strtotime('last week'))); $period = ($unixdate - strtotime($first_of_week)); } } else { $unixdate = strtotime('now'); $date_start = date('Y/m/d H:i:s', ($unixdate - $date)); $period = ($unixdate - strtotime($date_start)); } $events = $graph['events']; $description = $graph['description']; $stacked = (int) get_parameter('stacked', -1); $percentil = ($graph['percentil']) ? 1 : null; $check = get_parameter('threshold', false); $fullscale = ($graph['fullscale']) ? 1 : null; if ($check == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD) { $check = true; $stacked = CUSTOM_GRAPH_BULLET_CHART_THRESHOLD; } if ($stacked == -1) { $stacked = $graph['stacked']; } if ($stacked == CUSTOM_GRAPH_BULLET_CHART || $stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD) { $height = 50; } if ($stacked == CUSTOM_GRAPH_GAUGE) { // Use the defined graph height, that's why // the user can setup graph height. $height = $graph['height']; } $name = $graph['name']; if (($graph['private'] == 1) && ($graph['id_user'] != $id_user)) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to access to a custom graph not allowed' ); include 'general/noaccess.php'; exit; } html_print_input_hidden('line_width_graph', $config['custom_graph_width']); html_print_input_hidden('custom_graph', 1); $url = 'index.php?'.'sec=reporting&'.'sec2=operation/reporting/graph_viewer&'."id=$id_graph&".'view_graph=1'; $options = []; if (check_acl_restricted_all($config['id_user'], $graph['id_group'], 'RW') || check_acl_restricted_all($config['id_user'], $graph['id_group'], 'RM') ) { $options = [ 'graph_list' => [ 'active' => false, 'text' => ''.html_print_image( 'images/logs@svg.svg', true, [ 'title' => __('Graph list'), 'class' => 'main_menu_icon invert_filter', ] ).'', ], 'main' => [ 'active' => false, 'text' => ''.html_print_image( 'images/graph@svg.svg', true, [ 'title' => __('Main data'), 'class' => 'invert_filter', ] ).'', ], 'graph_editor' => [ 'active' => false, 'text' => ''.html_print_image( 'images/builder@svg.svg', true, [ 'title' => __('Graph editor'), 'class' => 'main_menu_icon invert_filter', ] ).'', ], ]; } else { $options = [ 'graph_list' => [ 'active' => false, 'text' => ''.html_print_image('images/logs@svg.svg', true, ['title' => __('Graph list'), 'class' => 'main_menu_icon invert_filter']).'', ], ]; } $options['view']['text'] = ''.html_print_image( 'images/enable.svg', true, [ 'title' => __('View graph'), 'class' => 'main_menu_icon invert_filter', ] ).''; $options['view']['active'] = true; if ($config['pure'] == 0) { $options['screen']['text'] = "".html_print_image( 'images/fullscreen@svg.svg', true, [ 'title' => __('Full screen mode'), 'class' => 'main_menu_icon invert_filter', ] ).''; } else { $options['screen']['text'] = "".html_print_image( 'images/exit_fullscreen@svg.svg', true, [ 'title' => __('Back to normal mode'), 'class' => 'main_menu_icon invert_filter', ] ).''; // In full screen, the manage options are not available. $options = [ 'view' => $options['view'], 'screen' => $options['screen'], ]; } if (!is_ajax()) { // Header. ui_print_standard_header( $graph['name'], 'images/chart.png', false, '', false, $options, [ [ 'link' => '', 'label' => __('Reporting'), ], [ 'link' => '', 'label' => __('Custom graphs'), ], ] ); } $width = null; $height = null; $params = [ 'period' => $period, 'width' => $width, 'height' => $height, 'date' => $unixdate, 'percentil' => $percentil, 'fullscale' => $fullscale, ]; if ($stacked === CUSTOM_GRAPH_AREA || $stacked === CUSTOM_GRAPH_STACKED_AREA) { $params['type_graph'] = 'area'; } else if ($stacked === CUSTOM_GRAPH_LINE || $stacked === CUSTOM_GRAPH_STACKED_LINE) { $params['type_graph'] = 'line'; } $params_combined = [ 'stacked' => $stacked, 'id_graph' => $id_graph, ]; $graph_return = graphic_combined_module( false, $params, $params_combined ); if (is_ajax()) { echo $graph_return; return; } if ($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD) { $stacked = 4; } $period_label = human_time_description_raw($period); $searchForm = '
'; ui_toggle( $searchForm, ''.__('Filters').'', 'filter_form', '', true, false, '', 'white-box-content', 'box-flat white_table_graph fixed_filter_bar' ); if ($graph_return) { echo '