From 40d7713557feafebe7d3d099e86e9d10ea7db447 Mon Sep 17 00:00:00 2001 From: vgilc Date: Wed, 25 Apr 2012 09:12:42 +0000 Subject: [PATCH] 2012-04-25 Vanessa Gil * operation/agentes/exportdata.php: Fixed several bugs. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6142 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- .../operation/agentes/exportdata.php | 205 +++++++++--------- 1 file changed, 105 insertions(+), 100 deletions(-) diff --git a/pandora_console/operation/agentes/exportdata.php b/pandora_console/operation/agentes/exportdata.php index 8d3e85e4bf..665c651df6 100644 --- a/pandora_console/operation/agentes/exportdata.php +++ b/pandora_console/operation/agentes/exportdata.php @@ -147,17 +147,17 @@ ui_require_javascript_file ('calendar'); ui_print_page_header (__("Export data"), "images/server_export.png"); $group = get_parameter_post ('group', 0); -//$agent = get_parameter_post ('agent', 0); $agentName = get_parameter_post ('agent', 0); - switch ($config["dbtype"]) { - case "mysql": - case "postgresql": - $agents = agents_get_agents (array('nombre LIKE "' . $agentName . '"'), array ('id_agente')); - break; - case "oracle": - $agents = agents_get_agents (array('nombre LIKE \'%' . $agentName . '%\''), array ('id_agente')); - break; - } + +switch ($config["dbtype"]) { + case "mysql": + case "postgresql": + $agents = agents_get_agents (array('nombre LIKE "' . $agentName . '"'), array ('id_agente')); + break; + case "oracle": + $agents = agents_get_agents (array('nombre LIKE \'%' . $agentName . '%\''), array ('id_agente')); + break; +} $agent = $agents[0]['id_agente']; $module = (array) get_parameter_post ('module_arr', array ()); @@ -266,7 +266,6 @@ if (!empty ($export_btn) && !empty ($module)) { case "data": case "avg": echo $output; - exit; break; } unset($output); @@ -286,97 +285,96 @@ elseif (!empty ($export_btn) && empty ($module)) { ui_print_error_message (__('No modules specified')); } -echo '
'; +if (empty($export_btn)) { + echo ''; -$table->width = '98%'; -$table->border = 0; -$table->cellspacing = 3; -$table->cellpadding = 5; -$table->class = "databox_color"; -$table->style[0] = 'vertical-align: top;'; + $table->width = '98%'; + $table->border = 0; + $table->cellspacing = 3; + $table->cellpadding = 5; + $table->class = "databox_color"; + $table->style[0] = 'vertical-align: top;'; -$table->data = array (); + $table->data = array (); -//Group selector -$table->data[0][0] = ''.__('Group').''; - -$groups = users_get_groups ($config['id_user'], "AR"); - -$table->data[0][1] = html_print_select_groups($config['id_user'], "AR", true, "group", $group, 'this.form.submit();', '', 0, true, false, true, 'w130', false); - -//Agent selector -$table->data[1][0] = ''.__('Source agent').''; + //Group selector + $table->data[0][0] = ''.__('Group').''; + + $groups = users_get_groups ($config['id_user'], "AR"); + + $table->data[0][1] = html_print_select_groups($config['id_user'], "AR", true, "group", $group, 'submit_group();', '', 0, true, false, true, 'w130', false); + + //Agent selector + $table->data[1][0] = ''.__('Source agent').''; -if ($group > 0) { - $filter['id_grupo'] = (array) $group; -} else { - $filter['id_grupo'] = array_keys ($groups); + if ($group > 0) { + $filter['id_grupo'] = (array) $group; + } else { + $filter['id_grupo'] = array_keys ($groups); + } + + $agents = array (); + $rows = agents_get_agents ($filter, false, 'AR'); + + if ($rows == null) $rows = array(); + foreach ($rows as $row) { + $agents[$row['id_agente']] = $row['nombre']; + } + + //Src code of lightning image with skins + $src_code = html_print_image ('images/lightning.png', true, false, true); + + $table->data[1][1] = html_print_input_text_extended ('agent', agents_get_name ($agent), 'text-agent', '', 40, 100, false, '', + array('style' => "background: url($src_code) no-repeat right;"), true) + . ' ' . __("Type at least two characters to search") . ''; + + //Module selector + $table->data[2][0] = ''.__('Modules').''; + + if ($agent > 0) { + $modules = agents_get_modules ($agent); + } else { + $modules = array (); + } + + $disabled_export_button = false; + if (empty($modules)) { + $disabled_export_button = true; + } + + $table->data[2][1] = html_print_select ($modules, "module_arr[]", array_keys ($modules), '', '', 0, true, true, true, 'w155', 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 () - 86400), false, 10, 10, true); + $table->data[3][1] .= html_print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => "scwShow(scwID('text-start_date'),this);")); + $table->data[3][1] .= html_print_input_text ('start_time', date ("H:i", get_system_time () - 86400), false, 10, 5, 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, 10, 10, true); + $table->data[4][1] .= html_print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => "scwShow(scwID('text-end_date'),this);")); + $table->data[4][1] .= html_print_input_text ('end_time', date ("H:i", get_system_time ()), false, 10, 5, true); + + //Export type + $table->data[5][0] = ''.__('Export type').''; + + $export_types = array (); + $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, 'w130', false); + + html_print_table ($table); + + // Submit button + echo '
'; + html_print_submit_button (__('Export'), 'export_btn', $disabled_export_button, 'class="sub wand"'); + echo '
'; } - -$agents = array (); -$rows = agents_get_agents ($filter, false, 'AR'); -if ($rows == null) $rows = array(); -foreach ($rows as $row) { - $agents[$row['id_agente']] = $row['nombre']; -} - -if (!in_array ($agent, array_keys ($agents))) { - $agent = current (array_keys ($agents)); -} - -//Src code of lightning image with skins -$src_code = html_print_image ('images/lightning.png', true, false, true); -$table->data[1][1] = html_print_input_text_extended ('agent', agents_get_name ($agent), 'text-agent', '', 40, 100, false, '', - array('style' => "background: url($src_code) no-repeat right;"), true) - . ' ' . __("Type at least two characters to search") . ''; - -//Module selector -$table->data[2][0] = ''.__('Modules').''; - -if ($agent > 0) { - $modules = agents_get_modules ($agent); -} else { - $modules = array (); -} - -$disabled_export_button = false; -if (empty($modules)) { - $disabled_export_button = true; -} - -$table->data[2][1] = html_print_select ($modules, "module_arr[]", array_keys ($modules), '', '', 0, true, true, true, 'w155', 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 () - 86400), false, 10, 10, true); -$table->data[3][1] .= html_print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => "scwShow(scwID('text-start_date'),this);")); -$table->data[3][1] .= html_print_input_text ('start_time', date ("H:i", get_system_time () - 86400), false, 10, 5, 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, 10, 10, true); -$table->data[4][1] .= html_print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => "scwShow(scwID('text-end_date'),this);")); -$table->data[4][1] .= html_print_input_text ('end_time', date ("H:i", get_system_time ()), false, 10, 5, true); - -//Export type -$table->data[5][0] = ''.__('Export type').''; - -$export_types = array (); -$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, 'w130', false); - -html_print_table ($table); - -// Submit button -echo '
'; - html_print_submit_button (__('Export'), 'export_btn', $disabled_export_button, 'class="sub wand"'); -echo '
'; - ui_require_jquery_file ('pandora.controls'); ui_require_jquery_file ('ajaxqueue'); ui_require_jquery_file ('bgiframe'); @@ -464,6 +462,9 @@ $(document).ready (function () { //Force to style of items $(".ui-autocomplete").css("text-align", "left"); } + + $("select#export_type").trigger('change'); + }); $("select#export_type").change (function () { @@ -480,10 +481,14 @@ $("select#export_type").change (function () { case 'data': f.action = "index.php?sec=reporting&sec2=operation/agentes/exportdata"; break; - - } - + } }); +function submit_group() { + var f = document.forms.export_form; + f.action = "index.php?sec=reporting&sec2=operation/agentes/exportdata"; + f.form.submit(); +} + /* ]]> */