Add a search to Extensions and Destinations

This commit is contained in:
Mark Crane 2014-05-02 08:22:27 +00:00
parent 509788da94
commit cc68c60cdb
2 changed files with 37 additions and 6 deletions

View File

@ -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 "<div align='center'>";
@ -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));

View File

@ -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 "</table>\n";
echo "<br />";
//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 ";
}