From cc68c60cdb4e269dbc498630a6a1c640bb288fef Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Fri, 2 May 2014 08:22:27 +0000 Subject: [PATCH] Add a search to Extensions and Destinations --- app/destinations/destinations.php | 25 +++++++++++++++++++++---- app/extensions/extensions.php | 18 ++++++++++++++++-- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/app/destinations/destinations.php b/app/destinations/destinations.php index 3ab5e0d8d8..334140ebdd 100644 --- a/app/destinations/destinations.php +++ b/app/destinations/destinations.php @@ -45,9 +45,12 @@ $page["title"] = $text['title-destinations']; require_once "resources/paging.php"; -//get variables used to control the order - $order_by = $_GET["order_by"]; - $order = $_GET["order"]; +//get the http values and set them as variables + $search = check_str($_GET["search"]); + if (isset($_GET["order_by"])) { + $order_by = check_str($_GET["order_by"]); + $order = check_str($_GET["order"]); + } //show the content echo "
"; @@ -75,7 +78,14 @@ require_once "resources/paging.php"; //prepare to page the results $sql = " select count(*) as num_rows from v_destinations "; - $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and ("; + $sql .= " destination_type = '".$search."' "; + $sql .= " or destination_number = '".$search."' "; + $sql .= " or destination_context = '".$search."' "; + $sql .= " or destination_enabled = '".$search."' "; + $sql .= " or destination_description = '".$search."' "; + $sql .= ") "; if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } $prep_statement = $db->prepare($sql); if ($prep_statement) { @@ -100,6 +110,13 @@ require_once "resources/paging.php"; //get the list $sql = "select * from v_destinations "; $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and ("; + $sql .= " destination_type = '".$search."' "; + $sql .= " or destination_number = '".$search."' "; + $sql .= " or destination_context = '".$search."' "; + $sql .= " or destination_enabled = '".$search."' "; + $sql .= " or destination_description = '".$search."' "; + $sql .= ") "; if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } $sql .= "limit $rows_per_page offset $offset "; $prep_statement = $db->prepare(check_sql($sql)); diff --git a/app/extensions/extensions.php b/app/extensions/extensions.php index 6d7f07767c..c95eadd92f 100644 --- a/app/extensions/extensions.php +++ b/app/extensions/extensions.php @@ -46,6 +46,7 @@ $page["title"] = $text['title-extensions']; require_once "resources/paging.php"; //get the http values and set them as variables + $search = check_str($_GET["search"]); if (isset($_GET["order_by"])) { $order_by = check_str($_GET["order_by"]); $order = check_str($_GET["order"]); @@ -74,9 +75,15 @@ require_once "resources/paging.php"; echo "\n"; echo "
"; - //get the number of rows in v_extensions + //get the number of extensions $sql = "select count(*) as num_rows from v_extensions "; $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and ("; + $sql .= " extension = '".$search."' "; + $sql .= " or call_group = '".$search."' "; + $sql .= " or enabled = '".$search."' "; + $sql .= " or description = '".$search."' "; + $sql .= ") "; $prep_statement = $db->prepare(check_sql($sql)); if ($prep_statement) { $prep_statement->execute(); @@ -98,9 +105,16 @@ require_once "resources/paging.php"; list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); $offset = $rows_per_page * $_GET['page']; - //get the extension list + //get the extensions $sql = "select * from v_extensions "; $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and ("; + $sql .= " extension = '".$search."' "; + $sql .= " or call_group = '".$search."' "; + $sql .= " or enabled = '".$search."' "; + $sql .= " or description = '".$search."' "; + $sql .= ") "; + $sql .= "and (moderator_pin = '".$search."' or participant_pin = '".$search."') "; if (isset($order_by)) { $sql .= "order by $order_by $order "; }