From 85086ef5cd0263c113ddc040b6a4bb12206932a5 Mon Sep 17 00:00:00 2001 From: vgilc Date: Thu, 14 Jun 2012 16:10:10 +0000 Subject: [PATCH] 2012-06-14 Vanessa Gil * include/functions_agents.php godmode/agentes/modificar_agente.php operation/agentes/estado_agente.php: Fixed bug: sort doesn't work. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6552 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 +++ .../godmode/agentes/modificar_agente.php | 44 +++++++++---------- pandora_console/include/functions_agents.php | 6 ++- .../operation/agentes/estado_agente.php | 24 +++++----- 4 files changed, 45 insertions(+), 35 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 40164bd84e..da0db944bb 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2012-06-14 Vanessa Gil + + * include/functions_agents.php + godmode/agentes/modificar_agente.php + operation/agentes/estado_agente.php: Fixed bug: sort doesn't work. + 2012-06-14 Sergio Martin * include/functions_api.php diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 15c5e224ba..5387d748ea 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -155,11 +155,11 @@ switch ($sortField) { switch ($sort) { case 'up': $selectNameUp = $selected; - $order = array('field' => 'nombre', 'order' => 'ASC'); + $order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; case 'down': $selectNameDown = $selected; - $order = array('field' => 'nombre', 'order' => 'DESC'); + $order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); break; } break; @@ -167,11 +167,11 @@ switch ($sortField) { switch ($sort) { case 'up': $selectOsUp = $selected; - $order = array('field' => 'id_os', 'order' => 'ASC'); + $order = array('field' => 'id_os', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; case 'down': $selectOsDown = $selected; - $order = array('field' => 'id_os', 'order' => 'DESC'); + $order = array('field' => 'id_os', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); break; } break; @@ -179,11 +179,11 @@ switch ($sortField) { switch ($sort) { case 'up': $selectGroupUp = $selected; - $order = array('field' => 'id_grupo', 'order' => 'ASC'); + $order = array('field' => 'id_grupo', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; case 'down': $selectGroupDown = $selected; - $order = array('field' => 'id_grupo', 'order' => 'DESC'); + $order = array('field' => 'id_grupo', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); break; } break; @@ -194,7 +194,7 @@ switch ($sortField) { $selectOsDown = ''; $selectGroupUp = ''; $selectGroupDown = ''; - $order = array('field' => 'nombre', 'order' => 'ASC'); + $order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; } @@ -224,16 +224,16 @@ if ($ag_group > 0) { FROM tagente WHERE id_grupo IN (%s) %s - ORDER BY %s %s LIMIT %d, %d', - implode (",", $ag_groups), $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]); + ORDER BY %s, %s %s LIMIT %d, %d', + implode (",", $ag_groups), $search_sql, $order['field'], $order['field2'], $order['order'], $offset, $config["block_size"]); break; case "postgresql": $sql = sprintf ('SELECT * FROM tagente WHERE id_grupo IN (%s) %s - ORDER BY %s %s LIMIT %d OFFSET %d', - implode (",", $ag_groups), $search_sql, $order['field'], $order['order'], $config["block_size"], $offset); + ORDER BY %s, %s %s LIMIT %d OFFSET %d', + implode (",", $ag_groups), $search_sql, $order['field'], $order['field2'], $order['order'], $config["block_size"], $offset); break; case "oracle": $set = array (); @@ -243,8 +243,8 @@ if ($ag_group > 0) { FROM tagente WHERE id_grupo IN (%s) %s - ORDER BY %s %s', - implode (",", $ag_groups), $search_sql, $order['field'], $order['order']); + ORDER BY %s, %s %s', + implode (",", $ag_groups), $search_sql, $order['field'], $order['field2'], $order['order']); $sql = oracle_recode_query ($sql, $set); break; } @@ -267,13 +267,13 @@ else { case "mysql": $sql = sprintf ('SELECT * FROM tagente WHERE (1=1 %s) %s - ORDER BY %s %s LIMIT %d, %d', $search_sql, $sql_extra, $order['field'], + ORDER BY %s, %s %s LIMIT %d, %d', $search_sql, $sql_extra, $order['field'], $order['field2'], $order['order'], $offset, $config["block_size"]); break; case "postgresql": $sql = sprintf ('SELECT * FROM tagente WHERE (1=1 %s) %s - ORDER BY %s %s LIMIT %d OFFSET %d', $search_sql, $sql_extra, $order['field'], + ORDER BY %s, %s %s LIMIT %d OFFSET %d', $search_sql, $sql_extra, $order['field'], $order['field2'], $order['order'], $config["block_size"], $offset); break; case "oracle": @@ -282,7 +282,7 @@ else { $set['offset'] = $offset; $sql = sprintf ('SELECT * FROM tagente WHERE (1=1 %s) %s - ORDER BY %s %s', $search_sql, $sql_extra, $order['field'], $order['order']); + ORDER BY %s, %s %s', $search_sql, $sql_extra, $order['field'], $order['field2'], $order['order']); $sql = oracle_recode_query ($sql, $set); break; } @@ -303,18 +303,18 @@ else { FROM tagente WHERE (id_grupo IN (%s) %s) %s - ORDER BY %s %s LIMIT %d, %d', + ORDER BY %s, %s %s LIMIT %d, %d', implode (',', array_keys (users_get_groups ())), - $search_sql, $sql_extra, $order['field'], $order['order'], $offset, $config["block_size"]); + $search_sql, $sql_extra, $order['field'], $order['field2'], $order['order'], $offset, $config["block_size"]); break; case "postgresql": $sql = sprintf ('SELECT * FROM tagente WHERE (id_grupo IN (%s) %s) %s - ORDER BY %s %s LIMIT %d OFFSET %d', + ORDER BY %s, %s %s LIMIT %d OFFSET %d', implode (',', array_keys (users_get_groups ())), - $search_sql, $sql_extra, $order['field'], $order['order'], $config["block_size"], $offset); + $search_sql, $sql_extra, $order['field'], $order['field2'], $order['order'], $config["block_size"], $offset); break; case "oracle": $set = array (); @@ -324,9 +324,9 @@ else { FROM tagente WHERE (id_grupo IN (%s) %s) %s - ORDER BY %s %s', + ORDER BY %s, %s %s', implode (',', array_keys (users_get_groups ())), - $search_sql, $order['field'], $order['order']); + $search_sql, $order['field'], $order['field2'], $order['order']); $sql = oracle_recode_query ($sql, $set); break; } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index de40351a23..80f6c9a536 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -462,7 +462,11 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o if(!isset($order['order'])) { $order['order'] = 'ASC'; } - $order = 'ORDER BY '.$order['field'] . ' ' . $order['order']; + if (!isset($order['field2'])) { + $order = 'ORDER BY '.$order['field'] . ' ' . $order['order']; + } else { + $order = 'ORDER BY '.$order['field'] . ', '. $order['field2'] . ' '. $order['order']; + } } $where = db_format_array_where_clause_sql ($filter, 'AND', ''); diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index eed32edc42..56e828cbbc 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -253,11 +253,11 @@ switch ($sortField) { switch ($sort) { case 'up': $selectNameUp = $selected; - $order = array('field' => 'nombre', 'order' => 'ASC'); + $order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; case 'down': $selectNameDown = $selected; - $order = array('field' => 'nombre', 'order' => 'DESC'); + $order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); break; } break; @@ -265,11 +265,11 @@ switch ($sortField) { switch ($sort) { case 'up': $selectOsUp = $selected; - $order = array('field' => 'id_os', 'order' => 'ASC'); + $order = array('field' => 'id_os', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; case 'down': $selectOsDown = $selected; - $order = array('field' => 'id_os', 'order' => 'DESC'); + $order = array('field' => 'id_os', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); break; } break; @@ -277,11 +277,11 @@ switch ($sortField) { switch ($sort) { case 'up': $selectIntervalUp = $selected; - $order = array('field' => 'intervalo', 'order' => 'ASC'); + $order = array('field' => 'intervalo', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; case 'down': $selectIntervalDown = $selected; - $order = array('field' => 'intervalo', 'order' => 'DESC'); + $order = array('field' => 'intervalo', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); break; } break; @@ -289,11 +289,11 @@ switch ($sortField) { switch ($sort) { case 'up': $selectGroupUp = $selected; - $order = array('field' => 'id_grupo', 'order' => 'ASC'); + $order = array('field' => 'id_grupo', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; case 'down': $selectGroupDown = $selected; - $order = array('field' => 'id_grupo', 'order' => 'DESC'); + $order = array('field' => 'id_grupo', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); break; } break; @@ -301,11 +301,11 @@ switch ($sortField) { switch ($sort) { case 'up': $selectLastContactUp = $selected; - $order = array('field' => 'ultimo_contacto', 'order' => 'ASC'); + $order = array('field' => 'ultimo_contacto', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; case 'down': $selectLastContactDown = $selected; - $order = array('field' => 'ultimo_contacto', 'order' => 'DESC'); + $order = array('field' => 'ultimo_contacto', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); break; } break; @@ -320,7 +320,7 @@ switch ($sortField) { $selectGroupDown = ''; $selectLastContactUp = ''; $selectLastContactDown = ''; - $order = array('field' => 'nombre', 'order' => 'ASC'); + $order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; } @@ -354,7 +354,7 @@ $total_agents = agents_get_agents(array ( $total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0; $agents = agents_get_agents(array ( - 'order' => 'nombre ASC', + 'order' => 'nombre COLLATE utf8_general_ci ASC', 'id_grupo' => $groups, 'disabled' => 0, 'status' => $status,