diff --git a/app/destinations/destinations.php b/app/destinations/destinations.php index 89ffc63f31..f2f016d446 100644 --- a/app/destinations/destinations.php +++ b/app/destinations/destinations.php @@ -47,6 +47,14 @@ $order_by = check_str($_GET["order_by"]); $order = check_str($_GET["order"]); +//set the type + if ($_GET['type'] == 'outbound') { + $destination_type = 'outbound'; + } + else { + $destination_type = 'inbound'; + } + //includes and title require_once "resources/header.php"; $document['title'] = $text['title-destinations']; @@ -54,20 +62,15 @@ //get total destination count from the database $sql = "select count(*) as num_rows from v_destinations "; + $sql .= "where destination_type = '".$destination_type."' "; if ($_GET['showall'] && permission_exists('destination_all')) { - if (strlen($search) > 0) { - $sql .= "where "; - } + //show all } else { - $sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; - if (strlen($search) > 0) { - $sql .= "and "; - } + $sql .= "and (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; } if (strlen($search) > 0) { - $sql .= "("; - $sql .= " destination_type like '%".$search."%' "; - $sql .= " or destination_number like '%".$search."%' "; + $sql .= "and ("; + $sql .= " destination_number like '%".$search."%' "; $sql .= " or lower(destination_context) like '%".strtolower($search)."%' "; $sql .= " or destination_enabled like '%".$search."%' "; $sql .= " or lower(destination_description) like '%".strtolower($search)."%' "; @@ -96,20 +99,15 @@ //get the list $sql = "select * from v_destinations "; + $sql .= "where destination_type = '".$destination_type."' "; if ($_GET['showall'] && permission_exists('destination_all')) { - if (strlen($search) > 0) { - $sql .= " where "; - } + //show all } else { - $sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; - if (strlen($search) > 0) { - $sql .= " and "; - } + $sql .= "and (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; } if (strlen($search) > 0) { - $sql .= " ("; - $sql .= " destination_type like '%".$search."%' "; - $sql .= " or destination_number like '%".$search."%' "; + $sql .= " and ("; + $sql .= " destination_number like '%".$search."%' "; $sql .= " or lower(destination_context) like '%".strtolower($search)."%' "; $sql .= " or destination_enabled like '%".$search."%' "; $sql .= " or lower(destination_description) like '%".strtolower($search)."%' "; @@ -138,6 +136,13 @@ echo "