From 0095194e3e5462a10b01002ce0b368499e39c603 Mon Sep 17 00:00:00 2001
From: mdtrooper <tres.14159@gmail.com>
Date: Wed, 7 Apr 2010 16:20:19 +0000
Subject: [PATCH] 2010-04-07  Miguel de Dios  <miguel.dedios@artica.es>

	* godmode/alerts/alert_list.php: added request the search parameter.

	* godmode/alerts/alert_list.list.php: fixed recove lost source code for
	build $where var of old version of godmode/alerts/alert_list.php .



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2550 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_console/ChangeLog                     |  7 +++++
 .../godmode/alerts/alert_list.list.php        | 27 +++++++++++++++++--
 pandora_console/godmode/alerts/alert_list.php |  1 +
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index c8f7125c4a..434d258e50 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-07  Miguel de Dios  <miguel.dedios@artica.es>
+
+	* godmode/alerts/alert_list.php: added request the search parameter.
+	
+	* godmode/alerts/alert_list.list.php: fixed recove lost source code for
+	build $where var of old version of godmode/alerts/alert_list.php .
+
 2010-04-07  Miguel de Dios  <miguel.dedios@artica.es>
 
 	* godmode/alerts/alert_list.list.php: fixed the id of agent in source and
diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php
index 134da5aaef..b3fa9cd07e 100644
--- a/pandora_console/godmode/alerts/alert_list.list.php
+++ b/pandora_console/godmode/alerts/alert_list.list.php
@@ -41,7 +41,7 @@ echo "<div id='alert_control' style='display:none'>\n";
 	// Table for filter controls
 	echo '<form method="post" action="index.php?sec=galertas&amp;sec2=godmode/alerts/alert_list&amp;refr='.$config["refr"].'&amp;pure='.$config["pure"].'">';
 	echo "<input type='hidden' name='search' value='1' />\n";
-	echo '<table style="width: 550px;" cellpadding="4" cellspacing="4" class="databox">'."\n";
+	echo '<table style="width: 90%;" cellpadding="4" cellspacing="4" class="databox">'."\n";
 	echo "<tr>\n";
 	echo "<td>".__('Template name')."</td><td>";
 	print_input_text ('template_name', $templateName, '', 15);
@@ -52,7 +52,7 @@ echo "<div id='alert_control' style='display:none'>\n";
 		$arrayAgents[$agentElement['id_agente']] = $agentElement['nombre'];
 	}
 	echo "<td>".__('Agents')."</td><td>";
-	echo print_input_text_extended ('agent_name', $agentName, 'text-agent_name', '', 25, 100, false, '',
+	echo print_input_text_extended ('agent_name', $agentName, 'text-agent_name', '', 15, 100, false, '',
 	array('style' => 'background: url(images/lightning.png) no-repeat right;'), true)
 	. '<a href="#" class="tip">&nbsp;<span>' . __("Type at least two characters to search") . '</span></a>';
 	echo "</td>\n";
@@ -97,6 +97,29 @@ $simple_alerts = array();
 $total = 0;
 $where = '';
 
+if ($searchFlag) {
+	if ($priority != -1 )
+		$where .= " AND priority = " . $priority;
+	if (strlen(trim($templateName)) > 0)
+		$where .= " AND id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE '%" . trim($templateName) . "%')";
+	if (strlen(trim($fieldContent)) > 0)
+		$where .= " AND id_alert_template IN (SELECT id FROM talert_templates
+			WHERE field1 LIKE '%" . trim($fieldContent) . "%' OR field2 LIKE '%" . trim($fieldContent) . "%' OR
+				field3 LIKE '%" . trim($fieldContent) . "%' OR
+				field2_recovery LIKE '%" . trim($fieldContent) . "%' OR
+				field3_recovery LIKE '%" . trim($fieldContent) . "%')";
+	if (strlen(trim($moduleName)) > 0)
+		$where .= " AND id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE nombre LIKE '%" . trim($moduleName) . "%')";
+	//if ($agentID != -1)
+		//$where .= " AND id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = " . $agentID . ")";
+	if (strlen(trim($agentName)) > 0)
+		$where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo
+			FROM tagente AS t1 INNER JOIN tagente_modulo AS t2 ON t1.id_agente = t2.id_agente
+			WHERE t1.nombre LIKE '" . trim($agentName) . "')";
+	if ($actionID != -1)
+		$where .= " AND id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action = " . $actionID . ")";
+}
+
 $total = get_agent_alerts_simple (array_keys ($agents), array('priority' => $priority),
 	false, $where, false, false, false, true);
 
diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php
index 8c87ca31e7..420ef47bad 100644
--- a/pandora_console/godmode/alerts/alert_list.php
+++ b/pandora_console/godmode/alerts/alert_list.php
@@ -54,6 +54,7 @@ $actionID = get_parameter('action_id','');
 $fieldContent = get_parameter('field_content','');
 $searchType = get_parameter('search_type','');
 $priority = get_parameter('priority','');
+$searchFlag = get_parameter('search',0);
 
 $messageAction = '';