New branch without trash files

Former-commit-id: fd64df2d8fb7d69ad871d870cbe11e4e69ae677d
This commit is contained in:
marcos.alconada 2019-05-14 18:15:23 +02:00
parent be20163073
commit 0e99b750b4
2 changed files with 204 additions and 79 deletions

View File

@ -151,12 +151,105 @@ if ($multiple_delete) {
}
$id_group = (int) get_parameter('id_group', 0);
$search = trim(get_parameter('search', ''));
$graphs = custom_graphs_get_user($config['id_user'], false, true, $access);
$offset = (int) get_parameter('offset');
$table_aux = new stdClass();
ui_pagination(count($graphs));
$table_aux->width = '100%';
$table_aux->class = 'databox filters';
$table_aux->cellpadding = 0;
$table_aux->cellspacing = 0;
if (!empty($graphs)) {
$table_aux->colspan[0][0] = 4;
$table_aux->data[0][0] = '<b>'.__('Group').'</b>';
$table_aux->data[0][1] = html_print_select_groups(false, $access, true, 'id_group', $id_group, '', '', '', true, false, true, '', false, '', false, false, 'id_grupo', $strict_user).'<br>';
$table_aux->data[0][2] = '<b>'.__('Free text for search: ').ui_print_help_tip(
__('Search by report name or description, list matches.'),
true
).'</b>';
$table_aux->data[0][3] = html_print_input_text('search', $search, '', 30, '', true);
$table_aux->data[0][6] = html_print_submit_button(__('Search'), 'search_submit', false, 'class="sub upd"', true);
if (is_metaconsole()) {
$filter = "<form class ='' action='index.php?sec=reporting&sec2=godmode/reporting/graphs&id_group=$id_group&pure=$pure'
method='post'>";
$filter .= html_print_table($table_aux, true);
$filter .= '</form>';
ui_toggle($filter, __('Show Option'));
} else {
echo "<form action='index.php?sec=reporting&sec2=godmode/reporting/graphs&id_group=$id_group&pure=$pure'
method='post'>";
html_print_table($table_aux);
echo '</form>';
}
// Show only selected groups.
if ($id_group > 0) {
$group = ["$id_group" => $id_group];
} else {
$group = false;
}
$own_info = get_user_info($config['id_user']);
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'RM')) {
$return_all_group = true;
} else {
$return_all_group = false;
}
if ($search != '') {
$filter = [
'name' => $search_name,
'order' => 'name',
];
} else {
$filter = ['order' => 'name'];
}
// Fix : group filter was not working
// Show only selected groups.
if ($id_group > 0) {
$group = ["$id_group" => $id_group];
$filter['id_group'] = $id_group;
} else {
$group = false;
}
// Filter normal and metaconsole reports.
if ($config['metaconsole'] == 1 && defined('METACONSOLE')) {
$filter['metaconsole'] = 1;
} else {
$filter['metaconsole'] = 0;
}
/*
$reports = reports_get_reports(
$filter,
[
'name',
'description',
'id_graph',
'id_group',
],
$return_all_group,
$access,
$group,
false
);*/
if ($id_group != null || $search != null) {
$graphs = custom_graphs_search($id_group, $search);
}
ui_pagination(count($graphs));
if (!empty($graphs)) {
$table = new stdClass();
$table->width = '100%';
$table->class = 'info_table';
@ -240,11 +333,11 @@ if (!empty($graphs)) {
}
echo '</div>';
} else {
} else {
include_once $config['homedir'].'/general/firts_task/custom_graphs.php';
}
}
?>
?>
<script type="text/javascript">

View File

@ -161,3 +161,35 @@ function custom_graphs_get_user($id_user=0, $only_names=false, $returnAllGroup=t
return $graphs;
}
function custom_graphs_search($id_group, $search)
{
if ($id_group != '' && $search != '') {
$all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.' AND name LIKE "%'.$search.'%"');
} else if ($id_group != '') {
$all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.'');
} else {
$all_graphs = db_get_all_rows_sql('select * from tgraph where name LIKE "%'.$search.'%"');
}
if ($all_graphs === false) {
return [];
}
$graphs = [];
foreach ($all_graphs as $graph) {
$graphsCount = db_get_value_sql(
'SELECT COUNT(id_gs)
FROM tgraph_source
WHERE id_graph = '.$graph['id_graph'].''
);
$graphs[$graph['id_graph']]['graphs_count'] = $graphsCount;
$graphs[$graph['id_graph']]['name'] = $graph['name'];
$graphs[$graph['id_graph']]['description'] = $graph['description'];
$graphs[$graph['id_graph']]['id_group'] = $graph['id_group'];
}
return $graphs;
}