From 4af67db415e2528ced9ab3bb6e1cf41726f102f2 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 7 Mar 2023 18:10:07 +0100 Subject: [PATCH] Export data view --- .../operation/agentes/exportdata.php | 312 +++++++++++------- 1 file changed, 185 insertions(+), 127 deletions(-) diff --git a/pandora_console/operation/agentes/exportdata.php b/pandora_console/operation/agentes/exportdata.php index 604131d888..910a46acb2 100644 --- a/pandora_console/operation/agentes/exportdata.php +++ b/pandora_console/operation/agentes/exportdata.php @@ -1,10 +1,10 @@ '', + 'label' => __('Tools'), + ], + [ + 'link' => '', + 'label' => __('Export data'), + ], + ] +); $group = get_parameter_post('group', 0); $agentName = get_parameter_post('agent', 0); @@ -220,48 +242,10 @@ if (!empty($export_btn) && !empty($module)) { } if (empty($export_btn) || $show_form) { - echo '
'; - - $table = new stdClass(); - $table->width = '100%'; - $table->border = 0; - $table->cellspacing = 3; - $table->cellpadding = 5; - $table->class = 'databox filters'; - $table->style[0] = 'vertical-align: top;'; - - $table->data = []; - - // Group selector - $table->data[0][0] = ''.__('Group').''; - $groups = users_get_groups($config['id_user'], 'RR', users_can_manage_group_all()); - $table->data[0][1] = '
'.html_print_select_groups( - $config['id_user'], - 'RR', - true, - 'group', - $group, - '', - '', - 0, - true, - false, - true, - '', - false - ).'
'; - - // Agent selector. - $table->data[1][0] = ''.__('Source agent').''; - $filter = []; - if ($group > 0) { - $filter['id_grupo'] = (array) $group; - } else { - $filter['id_grupo'] = array_keys($groups); - } + $filter['id_grupo'] = ($group > 0) ? (array) $group : array_keys($groups); $agents = []; $rows = agents_get_agents($filter, false, 'RR'); @@ -286,11 +270,6 @@ if (empty($export_btn) || $show_form) { $params['add_none_module'] = false; $params['size'] = 38; $params['selectbox_id'] = 'module_arr'; - $table->data[1][1] = ui_print_agent_autocomplete_input($params); - - // Module selector. - $table->data[2][0] = ''.__('Modules').''; - $table->data[2][0] .= ui_print_help_tip(__('No modules of type string. You can not calculate their average'), true); if ($agent > 0) { $modules = agents_get_modules($agent); @@ -325,91 +304,170 @@ if (empty($export_btn) || $show_form) { $disabled_export_button = true; } - $table->data[2][1] = html_print_select($modules, 'module_arr[]', array_keys($modules), '', '', 0, true, true, true, 'w250px', false); - - // Start date selector. - $table->data[3][0] = ''.__('Begin date').''; - - $table->data[3][1] = html_print_input_text( - 'start_date', - date('Y-m-d', (get_system_time() - SECONDS_1DAY)), - false, - 13, - 10, - true - ); - $table->data[3][1] .= html_print_image( - 'images/calendar_view_day.png', - true, - [ - 'alt' => 'calendar', - 'onclick' => "scwShow(scwID('text-start_date'),this);", - 'class' => 'invert_filter', - ] - ); - $table->data[3][1] .= html_print_input_text( - 'start_time', - date('H:i:s', (get_system_time() - SECONDS_1DAY)), - false, - 10, - 9, - true - ); - - // End date selector. - $table->data[4][0] = ''.__('End date').''; - $table->data[4][1] = html_print_input_text( - 'end_date', - date('Y-m-d', get_system_time()), - false, - 13, - 10, - true - ); - $table->data[4][1] .= html_print_image( - 'images/calendar_view_day.png', - true, - [ - 'alt' => 'calendar', - 'onclick' => "scwShow(scwID('text-end_date'),this);", - 'class' => 'invert_filter', - ] - ); - $table->data[4][1] .= html_print_input_text( - 'end_time', - date('H:i:s', get_system_time()), - false, - 10, - 9, - true - ); - - // Export type. - $table->data[5][0] = ''.__('Export type').''; - $export_types = []; $export_types['data'] = __('Data table'); $export_types['csv'] = __('CSV'); $export_types['excel'] = __('MS Excel'); $export_types['avg'] = __('Average per hour/day'); - $table->data[5][1] = html_print_select($export_types, 'export_type', $export_type, '', '', 0, true, false, true, 'w250px', false); + + echo ''; + + $table = new stdClass(); + $table->width = '100%'; + $table->border = 0; + $table->cellspacing = 3; + $table->cellpadding = 5; + $table->class = 'databox filter-table-adv'; + $table->style[0] = 'vertical-align: top;'; + + $table->data = []; + + // Group selector. + $table->data[0][] = html_print_label_input_block( + __('Group'), + html_print_select_groups( + $config['id_user'], + 'RR', + true, + 'group', + $group, + '', + '', + 0, + true, + false, + true, + '', + false + ) + ); + + // Agent selector. + $table->data[0][] = html_print_label_input_block( + __('Source agent'), + ui_print_agent_autocomplete_input($params) + ); + + // Module selector. + $table->data[1][] = html_print_label_input_block( + __('Modules'), + html_print_select( + $modules, + 'module_arr[]', + array_keys($modules), + '', + '', + 0, + true, + true, + true, + 'w100p', + false + ).ui_print_input_placeholder( + __('No modules of type string. You can not calculate their average'), + true + ) + ); + + // Export type. + $table->data[1][] = html_print_label_input_block( + __('Export type'), + html_print_select( + $export_types, + 'export_type', + $export_type, + '', + '', + 0, + true, + false, + true, + 'w100p', + false + ) + ); + + // Start date selector. + $table->data[2][] = html_print_label_input_block( + __('Begin date'), + html_print_div( + [ + 'class' => 'flex-content', + 'content' => html_print_input_text( + 'start_date', + date('Y-m-d', (get_system_time() - SECONDS_1DAY)), + false, + 13, + 10, + true + ).html_print_image( + 'images/calendar_view_day.png', + true, + [ + 'alt' => 'calendar', + 'onclick' => "scwShow(scwID('text-start_date'),this);", + 'class' => 'main_menu_icon invert_filter', + ] + ).html_print_input_text( + 'start_time', + date('H:i:s', (get_system_time() - SECONDS_1DAY)), + false, + 10, + 9, + true + ), + ], + true + ) + ); + + // End date selector. + $table->data[2][] = html_print_label_input_block( + __('End date'), + html_print_div( + [ + 'class' => 'flex-content', + 'content' => html_print_input_text( + 'end_date', + date('Y-m-d', get_system_time()), + false, + 13, + 10, + true + ).html_print_image( + 'images/calendar_view_day.png', + true, + [ + 'alt' => 'calendar', + 'onclick' => "scwShow(scwID('text-end_date'),this);", + 'class' => 'main_menu_icon invert_filter', + ] + ).html_print_input_text( + 'end_time', + date('H:i:s', get_system_time()), + false, + 10, + 9, + true + ), + ], + true + ), + ); html_print_table($table); // Submit button. - html_print_div( - [ - 'class' => 'action-buttons', - 'content' => html_print_button( - __('Export'), - 'export_btn', - false, - 'change_action()', - ['icon' => 'wand'], - true - ), - ] + html_print_action_buttons( + html_print_button( + __('Export'), + 'export_btn', + false, + 'change_action()', + ['icon' => 'wand'], + true + ) ); echo '
';