2011-01-24 Miguel de Dios <miguel.dedios@artica.es>

* operation/search_agents.php: fixed the pagination in the global search
	result.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3767 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2011-01-24 13:09:48 +00:00
parent 9e444a9160
commit 63b7dd6343
2 changed files with 39 additions and 34 deletions

View File

@ -1,4 +1,9 @@
2011-01-21 Miguel de Dios <miguel.dedios@artica.es>
2011-01-24 Miguel de Dios <miguel.dedios@artica.es>
* operation/search_agents.php: fixed the pagination in the global search
result.
2011-01-24 Miguel de Dios <miguel.dedios@artica.es>
* include/javascript/pandora.js, operation/agentes/exportdata.php,
operation/agentes/ver_agente.php,

View File

@ -105,43 +105,43 @@ switch ($sortField) {
$agents = false;
if ($searchAgents) {
$sql = "SELECT id_agente, tagente.ultimo_contacto, tagente.nombre, tagente.id_os, tagente.intervalo, tagente.id_grupo, tagente.disabled
FROM tagente
$sql = "
FROM tagente AS t1
INNER JOIN tgrupo
ON tgrupo.id_grupo = tagente.id_grupo
WHERE tagente.nombre COLLATE utf8_general_ci LIKE '%" . $stringSearchSQL . "%' OR
tgrupo.nombre LIKE '%" . $stringSearchSQL . "%'
ORDER BY " . $order['field'] . " " . $order['order'] . "
LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$agents = process_sql($sql);
ON tgrupo.id_grupo = t1.id_grupo
WHERE (t1.id_grupo IN (
SELECT id_grupo
FROM tusuario_perfil
WHERE id_usuario = '" . $config['id_user'] . "'
AND id_perfil IN (
SELECT id_perfil
FROM tperfil WHERE agent_view = 1
)
)
OR 0 IN (
SELECT id_grupo
FROM tusuario_perfil
WHERE id_usuario = '" . $config['id_user'] . "'
AND id_perfil IN (
SELECT id_perfil
FROM tperfil WHERE agent_view = 1
)
)
) AND
t1.nombre COLLATE utf8_general_ci LIKE '%" . $stringSearchSQL . "%' OR
tgrupo.nombre LIKE '%" . $stringSearchSQL . "%'";
$select = "SELECT t1.id_agente, t1.ultimo_contacto, t1.nombre, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled";
$limit = " ORDER BY " . $order['field'] . " " . $order['order'] .
" LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$agents = process_sql($select . $sql . $limit);
if($agents !== false) {
// ACLs check
$agents_id = array();
foreach($agents as $key => $agent){
if (!give_acl ($config["id_user"], $agent["id_grupo"], "AR")) {
unset($agents[$key]);
} else {
$agents_id[] = $agent["id_agente"];
}
}
$totalAgents = get_db_row_sql('SELECT COUNT(id_agente) AS agent_count ' . $sql);
if(!$agents_id) {
$agent_condition = "";
}else {
// Condition with the visible agents
$agent_condition = " AND id_agente IN (".implode(',',$agents_id).")";
}
$sql = "SELECT count(id_agente) AS count
FROM tagente
INNER JOIN tgrupo
ON tgrupo.id_grupo = tagente.id_grupo
WHERE (tagente.nombre COLLATE utf8_general_ci LIKE '%" . $stringSearchSQL . "%' OR
tgrupo.nombre LIKE '%" . $stringSearchSQL . "%')".$agent_condition;
$totalAgents = get_db_row_sql($sql);
$totalAgents = $totalAgents['count'];
$totalAgents = $totalAgents['agent_count'];
}
}