From be5c23ec2ad88216261730ebcd87eb2366e1ddaa Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 21 Jul 2010 10:06:13 +0000 Subject: [PATCH] 2010-07-21 Miguel de Dios * include/functions_agents.php: in function "get_agent_alerts_simple" changed the query for added the posibility of sort the rows. * include/functions_db.php: in function "format_array_to_where_clause_sql" added the posibility of order pass as array of field and sort order. *godmode/alerts/alert_list.list.php: added the icons and source code for order rows of list alerts by columns Disabled, Agent Name, Module Name or Template Name. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3046 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 12 ++ .../godmode/alerts/alert_list.list.php | 122 +++++++++++++++++- pandora_console/include/functions_agents.php | 16 ++- pandora_console/include/functions_db.php | 7 +- 4 files changed, 146 insertions(+), 11 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 308753e782..dde72ef7ab 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,15 @@ +2010-07-21 Miguel de Dios + + * include/functions_agents.php: in function "get_agent_alerts_simple" + changed the query for added the posibility of sort the rows. + + * include/functions_db.php: in function "format_array_to_where_clause_sql" + added the posibility of order pass as array of field and sort order. + + *godmode/alerts/alert_list.list.php: added the icons and source code for + order rows of list alerts by columns Disabled, Agent Name, Module Name or + Template Name. + 2010-07-20 Miguel de Dios * operation/search_results.php: added icons and source code for order the diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 2ea8e2a30b..1b2cca2082 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -128,21 +128,125 @@ $total = get_agent_alerts_simple (array_keys ($agents), array('priority' => $pri if(empty($total)) $total = 0; +$order = null; + +$sortField = get_parameter('sort_field'); +$sort = get_parameter('sort', 'none'); +$selected = 'border: 1px solid black;'; +$selectDisabledUp = ''; +$selectDisabledDown = ''; +$selectAgentUp = ''; +$selectAgentDown = ''; +$selectModuleUp = ''; +$selectModuleDown = ''; +$selectTemplateUp = ''; +$selectTemplateDown = ''; + +switch ($sortField) { + case 'disabled': + switch ($sort) { + case 'up': + $selectDisabledUp = $selected; + $order = array('field' => 'disabled', 'order' => 'ASC'); + break; + case 'down': + $selectDisabledDown = $selected; + $order = array('field' => 'disabled', 'order' => 'DESC'); + break; + } + break; + case 'agent': + switch ($sort) { + case 'up': + $selectAgentUp = $selected; + $order = array('field' => 'agent_name', 'order' => 'ASC'); + break; + case 'down': + $selectAgentDown = $selected; + $order = array('field' => 'agent_name', 'order' => 'DESC'); + break; + } + break; + case 'module': + switch ($sort) { + case 'up': + $selectModuleUp = $selected; + $order = array('field' => 'agent_module_name', 'order' => 'ASC'); + break; + case 'down': + $selectModuleDown = $selected; + $order = array('field' => 'agent_module_name', 'order' => 'DESC'); + break; + } + break; + case 'template': + switch ($sort) { + case 'up': + $selectTemplateUp = $selected; + $order = array('field' => 'template_name', 'order' => 'ASC'); + break; + case 'down': + $selectTemplateDown = $selected; + $order = array('field' => 'template_name', 'order' => 'DESC'); + break; + } + break; + default: + if (!$id_agente) { + $selectDisabledUp = ''; + $selectDisabledDown = ''; + $selectAgentUp = $selected; + $selectAgentDown = ''; + $selectModuleUp = ''; + $selectModuleDown = ''; + $selectTemplateUp = ''; + $selectTemplateDown = ''; + $order = array('field' => 'agent_name', 'order' => 'ASC'); + } + else { + $selectDisabledUp = ''; + $selectDisabledDown = ''; + $selectAgentUp = ''; + $selectAgentDown = ''; + $selectModuleUp = $selected; + $selectModuleDown = ''; + $selectTemplateUp = ''; + $selectTemplateDown = ''; + $order = array('field' => 'agent_module_name', 'order' => 'ASC'); + } + break; +} + pagination ($total, 'index.php?sec=gagente&sec2=godmode/alerts/alert_list'); $simple_alerts = get_agent_alerts_simple (array_keys ($agents), array('priority' => $priority), array ('offset' => (int) get_parameter ('offset'), - 'limit' => $config['block_size']), $where); + 'limit' => $config['block_size'], 'order' => $order), $where, false); +$offset = get_parameter('offset'); +if (!$id_agente) { + $url = 'index.php?sec=galertas&sec2=godmode/alerts/alert_list&tab=list&offset=' . $offset; +} +else { + $url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente=' . $id_agente; +} + $table->class = 'alert_list'; $table->width = '90%'; $table->size = array (); + +$table->align[0] = 'center'; + $table->head = array (); -$table->head[0] = "" . __('E/D') . ""; +$table->head[0] = "" . __('E/D') . "" . ' ' . + '' . + ''; if (! $id_agente) { $table->style = array (); $table->style[1] = 'font-weight: bold'; - $table->head[1] = __('Agent'); - $table->size[0] = '20px'; + $table->head[1] = __('Agent') . ' ' . + '' . + ''; + $table->size[0] = '12%'; $table->size[1] = '15%'; $table->size[2] = '20%'; $table->size[3] = '15%'; @@ -153,7 +257,7 @@ if (! $id_agente) { } else { /* Different sizes or the layout screws up */ - $table->size[0] = '20px'; + $table->size[0] = '12%'; $table->size[2] = '30%'; $table->size[3] = '20%'; if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { @@ -162,8 +266,12 @@ else { $table->size[5] = '50%'; } -$table->head[2] = __('Module'); -$table->head[3] = __('Template'); +$table->head[2] = __('Module') . ' ' . + '' . + ''; +$table->head[3] = __('Template') . ' ' . + '' . + ''; if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { $table->head[4] = "" . __('P.') . ""; } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 749bc9c6cd..3c4ccff841 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -156,10 +156,16 @@ function get_agent_alerts_simple ($id_agent = false, $filter = '', $options = fa } $orderbyText = ''; - if ($orderby !== false) - $orderbyText = sprintf("ORDER BY %s", $orderby); + if ($orderby !== false) { + if (is_array($orderby)) { + $orderbyText = sprintf("ORDER BY %s", $orderby['field'], $orderby['order']); + } + else { + $orderbyText = sprintf("ORDER BY %s", $orderby); + } + } - $selectText = 'talert_template_modules.*, t2.nombre AS agent_module_name'; + $selectText = 'talert_template_modules.*, t2.nombre AS agent_module_name, t3.nombre AS agent_name, t4.name AS template_name'; if ($count !== false) { $selectText = 'COUNT(talert_template_modules.id) AS count'; } @@ -168,6 +174,10 @@ function get_agent_alerts_simple ($id_agent = false, $filter = '', $options = fa FROM talert_template_modules INNER JOIN tagente_modulo AS t2 ON talert_template_modules.id_agent_module = t2.id_agente_modulo + INNER JOIN tagente AS t3 + ON t2.id_agente = t3.id_agente + INNER JOIN talert_templates AS t4 + ON talert_template_modules.id_alert_template = t4.id WHERE id_agent_module in (%s) %s %s %s", $selectText, $subQuery, $where, $filter, $orderbyText); diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 5ccbdba84c..d6d3de1a30 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -2511,7 +2511,12 @@ function format_array_to_where_clause_sql ($values, $join = 'AND', $prefix = fal } if (isset ($values['order'])) { - $order = sprintf (' ORDER BY %s', $values['order']); + if (is_array($values['order'])) { + $order = sprintf (' ORDER BY %s %s', $values['order']['field'], $values['order']['order']); + } + else { + $order = sprintf (' ORDER BY %s', $values['order']); + } unset ($values['order']); }