From 8d34e8f5c6a94912fb2c48f7bb8bddb70d718adb Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Tue, 2 Aug 2016 13:35:38 -0600 Subject: [PATCH] Update device_edit.php Get the vendor functions for device edit from the database. --- app/devices/device_edit.php | 283 ++++++------------------------------ 1 file changed, 41 insertions(+), 242 deletions(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 4c784ee6b2..0f44537040 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -431,6 +431,17 @@ $device_keys[$x]['device_key_extension'] = ''; $device_keys[$x]['device_key_label'] = ''; +//get the vendor functions + $sql = "SELECT v.name as vendor_name, f.name, f.value "; + $sql .= "FROM v_device_vendors as v, v_device_vendor_functions as f "; + $sql .= "where v.device_vendor_uuid = f.device_vendor_uuid "; + $sql .= "and v.enabled = 'true' "; + $sql .= "and f.enabled = 'true' "; + $sql .= "order by v.name asc, f.name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $vendor_functions = $prep_statement->fetchAll(PDO::FETCH_NAMED); + //get device settings $sql = "SELECT * FROM v_device_settings "; $sql .= "WHERE device_uuid = '".$device_uuid."' "; @@ -1075,250 +1086,38 @@ } ?> - - - \n"; +echo " \n"; +$previous_vendor = ''; +$i=0; +foreach ($vendor_functions as $function) { + if (strlen($row['device_key_vendor']) == 0 && $function['vendor_name'] != $previous_vendor) { + if ($i > 0) { echo " \n"; } + echo " \n"; + } + $selected = ''; + if ($row['device_key_vendor'] == $function['vendor_name'] && $row['device_key_type'] == $function['value']) { + $selected = "selected='selected'"; + } + if (strlen($row['device_key_vendor']) == 0) { + echo " \n"; + } + if (strlen($row['device_key_vendor']) > 0 && $row['device_key_vendor'] == $function['vendor_name']) { + echo " \n"; + + } + $previous_vendor = $function['vendor_name']; + $i++; + +} +if (strlen($row['device_key_vendor']) == 0) { + echo " \n"; +} +echo "\n"; - - - - - "; } - } - if (strtolower($device_vendor) == "cisco" || strlen($device_vendor) == 0 || strlen($device_username) > 0) { - echo ""; - $match_vendor = (strtolower($device_key_vendor) == "cisco"); - ?> - - - - "; } - } - if (strtolower($device_vendor) == "escene" || strlen($device_vendor) == 0 || strlen($device_username) > 0) { - ?> - "; ?> - - - - - - - - - - - "; ?> - "; ?> - - - - - - - - - - - - - - - - - - - - - - > */?> - "; - } - if (strtolower($device_vendor) == "grandstream" || strlen($device_vendor) == 0 || strlen($device_username) > 0) { - echo ""; - $match_vendor = (strtolower($device_key_vendor) == "grandstream"); - ?> - - - - - - - - - - - - - - - "; } - } - if (strtolower($device_vendor) == "mitel" || strlen($device_vendor) == 0 || strlen($device_username) > 0) { - echo ""; - $match_vendor = (strtolower($device_key_vendor) == "mitel"); - ?> - - - - - - - - - - - - - - - - "; } - } - if (strtolower($device_vendor) == "polycom" || strlen($device_vendor) == 0 || strlen($device_username) > 0) { - echo ""; - $match_vendor = (strtolower($device_key_vendor) == "polycom"); - ?> - - - - - - - - - - - "; } - } - if (strtolower($device_vendor) == "snom" || strlen($device_vendor) == 0 || strlen($device_username) > 0) { - echo ""; - $match_vendor = (strtolower($device_key_vendor) == "snom"); - ?> - - - - - - - - - - - - - - - - - - - - - - - "; } - } - if (strtolower($device_vendor) == "yealink" || strlen($device_vendor) == 0 || strlen($device_username) > 0) { - echo ""; - $match_vendor = (strtolower($device_key_vendor) == "yealink"); - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "; } - } - ?> - - - 0) { +//if ($match_vendor && $row['device_key_type'] == "blf") { echo $selected;$found=true; } echo "\n"; echo "\n"; echo "