Update destinations.php

This commit is contained in:
FusionPBX
2017-07-30 11:42:29 -06:00
committed by GitHub
parent 8778bdaa55
commit a99ca091f3
+27 -22
View File
@@ -47,6 +47,14 @@
$order_by = check_str($_GET["order_by"]); $order_by = check_str($_GET["order_by"]);
$order = check_str($_GET["order"]); $order = check_str($_GET["order"]);
//set the type
if ($_GET['type'] == 'outbound') {
$destination_type = 'outbound';
}
else {
$destination_type = 'inbound';
}
//includes and title //includes and title
require_once "resources/header.php"; require_once "resources/header.php";
$document['title'] = $text['title-destinations']; $document['title'] = $text['title-destinations'];
@@ -54,20 +62,15 @@
//get total destination count from the database //get total destination count from the database
$sql = "select count(*) as num_rows from v_destinations "; $sql = "select count(*) as num_rows from v_destinations ";
$sql .= "where destination_type = '".$destination_type."' ";
if ($_GET['showall'] && permission_exists('destination_all')) { if ($_GET['showall'] && permission_exists('destination_all')) {
if (strlen($search) > 0) { //show all
$sql .= "where ";
}
} else { } else {
$sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; $sql .= "and (domain_uuid = '".$domain_uuid."' or domain_uuid is null) ";
if (strlen($search) > 0) {
$sql .= "and ";
}
} }
if (strlen($search) > 0) { if (strlen($search) > 0) {
$sql .= "("; $sql .= "and (";
$sql .= " destination_type like '%".$search."%' "; $sql .= " destination_number like '%".$search."%' ";
$sql .= " or destination_number like '%".$search."%' ";
$sql .= " or lower(destination_context) like '%".strtolower($search)."%' "; $sql .= " or lower(destination_context) like '%".strtolower($search)."%' ";
$sql .= " or destination_enabled like '%".$search."%' "; $sql .= " or destination_enabled like '%".$search."%' ";
$sql .= " or lower(destination_description) like '%".strtolower($search)."%' "; $sql .= " or lower(destination_description) like '%".strtolower($search)."%' ";
@@ -96,20 +99,15 @@
//get the list //get the list
$sql = "select * from v_destinations "; $sql = "select * from v_destinations ";
$sql .= "where destination_type = '".$destination_type."' ";
if ($_GET['showall'] && permission_exists('destination_all')) { if ($_GET['showall'] && permission_exists('destination_all')) {
if (strlen($search) > 0) { //show all
$sql .= " where ";
}
} else { } else {
$sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; $sql .= "and (domain_uuid = '".$domain_uuid."' or domain_uuid is null) ";
if (strlen($search) > 0) {
$sql .= " and ";
}
} }
if (strlen($search) > 0) { if (strlen($search) > 0) {
$sql .= " ("; $sql .= " and (";
$sql .= " destination_type like '%".$search."%' "; $sql .= " destination_number like '%".$search."%' ";
$sql .= " or destination_number like '%".$search."%' ";
$sql .= " or lower(destination_context) like '%".strtolower($search)."%' "; $sql .= " or lower(destination_context) like '%".strtolower($search)."%' ";
$sql .= " or destination_enabled like '%".$search."%' "; $sql .= " or destination_enabled like '%".$search."%' ";
$sql .= " or lower(destination_description) like '%".strtolower($search)."%' "; $sql .= " or lower(destination_description) like '%".strtolower($search)."%' ";
@@ -138,6 +136,13 @@
echo " <td width='50%' align='left' nowrap='nowrap' valign='top'><b>".$text['header-destinations']." (".$num_rows.")</b></td>\n"; echo " <td width='50%' align='left' nowrap='nowrap' valign='top'><b>".$text['header-destinations']." (".$num_rows.")</b></td>\n";
echo " <form method='get' action=''>\n"; echo " <form method='get' action=''>\n";
echo " <td width='50%' align='right'>\n"; echo " <td width='50%' align='right'>\n";
if ($_GET['type'] == 'outbound') {
echo " <input type='button' class='btn' value='".$text['button-inbound']."' onclick=\"window.location='destinations.php?type=inbound';\">\n";
} else {
echo " <input type='button' class='btn' value='".$text['button-outbound']."' onclick=\"window.location='destinations.php?type=outbound';\">\n";
}
if (permission_exists('destination_all')) { if (permission_exists('destination_all')) {
if ($_GET['showall'] == 'true') { if ($_GET['showall'] == 'true') {
echo " <input type='hidden' name='showall' value='true'>"; echo " <input type='hidden' name='showall' value='true'>";
@@ -175,7 +180,7 @@
echo "<td class='list_control_icons'>"; echo "<td class='list_control_icons'>";
if (permission_exists('destination_add')) { if (permission_exists('destination_add')) {
if ($_SESSION['limit']['destinations']['numeric'] == '' || ($_SESSION['limit']['destinations']['numeric'] != '' && $num_rows < $_SESSION['limit']['destinations']['numeric'])) { if ($_SESSION['limit']['destinations']['numeric'] == '' || ($_SESSION['limit']['destinations']['numeric'] != '' && $num_rows < $_SESSION['limit']['destinations']['numeric'])) {
echo "<a href='destination_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>"; echo "<a href='destination_edit.php?type=".$destination_type."' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
} }
} }
echo "</td>\n"; echo "</td>\n";
@@ -216,7 +221,7 @@
} }
if (permission_exists('destination_add')) { if (permission_exists('destination_add')) {
if ($_SESSION['limit']['destinations']['numeric'] == '' || ($_SESSION['limit']['destinations']['numeric'] != '' && $num_rows < $_SESSION['limit']['destinations']['numeric'])) { if ($_SESSION['limit']['destinations']['numeric'] == '' || ($_SESSION['limit']['destinations']['numeric'] != '' && $num_rows < $_SESSION['limit']['destinations']['numeric'])) {
echo "<a href='destination_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>"; echo "<a href='destination_edit.php?type=".$destination_type."' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
} }
} }
echo "</td>\n"; echo "</td>\n";