diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 4fbe0c5314..ba0ae3bb1b 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -137,10 +137,10 @@ require_once "resources/require.php"; /* //remove the invalid characters from the extension name foreach ($_POST as $key => $value) { - if ($key == "dialplan_name") { - $dialplan_name = str_replace(" ", "_", $value); - $dialplan_name = str_replace("/", "", $dialplan_name); - $_POST["dialplan_name"] = $dialplan_name; + if ($key == "device_name") { + $device_name = str_replace(" ", "_", $value); + $device_name = str_replace("/", "", $device_name); + $_POST["device_name"] = $device_name; } } */ @@ -167,7 +167,7 @@ require_once "resources/require.php"; if (strlen($row["line_number"]) == 0) { unset($_POST["device_lines"][$x]); } - //unset dialplan_detail_uuid if the field has no value + //unset device_detail_uuid if the field has no value if (strlen($row["device_line_uuid"]) == 0) { unset($_POST["device_lines"][$x]["device_line_uuid"]); } @@ -180,7 +180,7 @@ require_once "resources/require.php"; if (strlen($row["device_key_id"]) == 0) { unset($_POST["device_keys"][$x]); } - //unset dialplan_detail_uuid if the field has no value + //unset device_detail_uuid if the field has no value if (strlen($row["device_key_uuid"]) == 0) { unset($_POST["device_keys"][$x]["device_key_uuid"]); } @@ -193,7 +193,7 @@ require_once "resources/require.php"; if (strlen($row["device_setting_subcategory"]) == 0) { unset($_POST["device_settings"][$x]); } - //unset dialplan_detail_uuid if the field has no value + //unset device_detail_uuid if the field has no value if (strlen($row["device_setting_uuid"]) == 0) { unset($_POST["device_settings"][$x]["device_setting_uuid"]); } @@ -208,7 +208,6 @@ require_once "resources/require.php"; if (strlen($device_uuid) > 0) { $orm->uuid($device_uuid); } - $orm->save($_POST); $message = $orm->message; } @@ -225,14 +224,14 @@ require_once "resources/require.php"; } } //if ($_POST["persistformvar"] != "true") - } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + } //(count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { - $dialplan_uuid = check_str($_GET["id"]); + $device_uuid = check_str($_GET["id"]); $orm = new orm; $orm->name('devices'); - $orm->uuid($dialplan_uuid); + $orm->uuid($device_uuid); $result = $orm->find()->get(); //$message = $orm->message; foreach ($result as &$row) { @@ -252,6 +251,9 @@ require_once "resources/require.php"; unset ($prep_statement); } +//set the sub array index + $x = "999"; + //get device lines $sql = "SELECT * FROM v_device_lines "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; @@ -260,6 +262,13 @@ require_once "resources/require.php"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $device_lines = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $device_lines[$x]['line_number'] = ''; + $device_lines[$x]['server_address'] = ''; + $device_lines[$x]['outbound_proxy'] = ''; + $device_lines[$x]['display_name'] = ''; + $device_lines[$x]['user_id'] = ''; + $device_lines[$x]['auth_id'] = ''; + $device_lines[$x]['password'] = ''; //get device keys $sql = "SELECT * FROM v_device_keys "; @@ -276,6 +285,13 @@ require_once "resources/require.php"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $device_keys = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $device_keys[$x]['device_key_category'] = ''; + $device_keys[$x]['device_key_id'] = ''; + $device_keys[$x]['device_key_type'] = ''; + $device_keys[$x]['device_key_line'] = ''; + $device_keys[$x]['device_key_value'] = ''; + $device_keys[$x]['device_key_extension'] = ''; + $device_keys[$x]['device_key_label'] = ''; //get device settings $sql = "SELECT * FROM v_device_settings "; @@ -285,14 +301,16 @@ require_once "resources/require.php"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $device_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $device_settings[$x]['device_setting_name'] = ''; + $device_settings[$x]['device_setting_value'] = ''; + $device_settings[$x]['enabled'] = ''; + $device_settings[$x]['device_setting_description'] = ''; //use the mac address to get the vendor if (strlen($device_vendor) == 0) { $device_vendor = device::get_vendor($device_mac_address); } -//name='dialplan_details[".$x."][dialplan_detail_type]' - //show the header require_once "resources/header.php"; @@ -435,89 +453,80 @@ require_once "resources/require.php"; $x = 0; foreach($device_lines as $row) { - //if (strlen($row['line_number']) == 0) { $row['line_number'] = "1"; } - echo " \n"; - echo " \n"; - echo " ".$row['line_number']." \n"; - echo " \n"; - echo " \n"; - echo " ".$row['server_address']." \n"; - echo " \n"; - echo " \n"; - echo " ".$row['outbound_proxy']." \n"; - echo " \n"; - echo " \n"; - echo " ".$row['display_name']." \n"; - echo " \n"; - echo " \n"; - echo " ".$row['user_id']." \n"; - echo " \n"; - echo " \n"; - echo " ".$row['auth_id']." \n"; - echo " \n"; - echo " \n"; - echo " ********  \n"; //$row['password'] - echo " \n"; + //determine whether to hide the element + if (strlen($device_line_uuid) == 0) { + $element['hidden'] = false; + $element['visibility'] = "visibility:visible;"; + } + else { + $element['hidden'] = true; + $element['visibility'] = "visibility:hidden;"; + } + //add the primary key uuid + if (strlen($row['device_line_uuid']) > 0) { + echo " \n"; + } + //show each row in the array + echo " \n"; + echo " \n"; + $selected = "selected=\"selected\" "; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + + //echo " \n"; + //echo " \n"; + //echo " \n"; echo " \n"; - if (permission_exists('device_edit')) { - echo " $v_link_label_edit\n"; - } - if (permission_exists('device_delete')) { - echo " $v_link_label_delete\n"; + if (strlen($row['device_line_uuid']) > 0) { + if (permission_exists('device_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('device_delete')) { + echo " $v_link_label_delete\n"; + } } echo " \n"; echo " \n"; $x++; } -//device lines - $x = 0; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - - echo " \n"; - echo " \n"; - echo " \n"; - - echo " \n"; - echo " \n"; - echo " \n"; - - echo " \n"; - echo " \n"; - echo " \n"; - - echo " \n"; - echo " \n"; - echo " \n"; - - echo " \n"; - echo " \n"; - echo " \n"; - - echo " \n"; - echo " \n"; - echo " \n"; - - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; echo " \n"; if (strlen($text['description-lines']) > 0) { echo "
".$text['description-lines']."\n"; @@ -543,199 +552,193 @@ require_once "resources/require.php"; $x = 0; foreach($device_keys as $row) { - echo " \n"; - echo " \n"; - echo " ".$row['device_key_category']." \n"; - echo " \n"; - echo " \n"; - echo " ".$row['device_key_id']." \n"; - echo " \n"; - echo " \n"; - echo " ".$row['device_key_type']." \n"; - echo " \n"; - echo " \n"; - echo " ".$row['device_key_line']." \n"; - echo " \n"; - echo " \n"; - echo " ".$row['device_key_value']." \n"; - echo " \n"; - echo " \n"; - echo " ".$row['device_key_extension']." \n"; - echo " \n"; - echo " \n"; - echo " ".$row['device_key_label']." \n"; - echo " \n"; - echo " \n"; - if (permission_exists('device_key_edit')) { - echo " $v_link_label_edit\n"; - } - if (permission_exists('device_key_delete')) { - echo " $v_link_label_delete\n"; - } - echo " \n"; - echo " \n"; - $x++; + //determine whether to hide the element + if (strlen($device_key_uuid) == 0) { + $element['hidden'] = false; + $element['visibility'] = "visibility:visible;"; + } + else { + $element['hidden'] = true; + $element['visibility'] = "visibility:hidden;"; + } + //add the primary key uuid + if (strlen($row['device_key_uuid']) > 0) { + echo " \n"; + } + //show all the rows in the array + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + + echo "\n"; + $selected = "selected='selected'"; + echo " \n"; + echo "\n"; + + echo "\n"; + //echo " \n"; + ?> + + + + + + \n"; + $selected = "selected='selected'"; + echo "\n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + if (strlen($row['device_key_uuid']) > 0) { + if (permission_exists('device_key_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('device_key_delete')) { + echo " $v_link_label_delete\n"; + } + } + echo " \n"; + echo " \n"; + //increment the array key + $x++; } - - $x = 0; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo "\n"; - - echo "\n"; - //echo " \n"; - ?> - - - - - - \n"; - - echo "\n"; - echo " \n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo "\n"; - - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; echo " \n"; if (strlen($text['description-keys']) > 0) { echo "
".$text['description-keys']."\n"; @@ -760,74 +763,77 @@ require_once "resources/require.php"; $x = 0; foreach($device_settings as $row) { - //if (strlen($row['line_number']) == 0) { $row['line_number'] = "1"; } - echo " \n"; - echo " \n"; - echo " ".$row['device_setting_subcategory']." \n"; - echo " \n"; - echo " \n"; - echo " ".$row['device_setting_value']." \n"; - echo " \n"; - echo " \n"; - echo " ".$row['device_setting_enabled']." \n"; - echo " \n"; - echo " \n"; - echo " ".$row['device_setting_description']." \n"; - echo " \n"; - echo " \n"; - if (permission_exists('device_edit')) { - echo " $v_link_label_edit\n"; + //determine whether to hide the element + if (strlen($device_setting_uuid) == 0) { + $element['hidden'] = false; + $element['visibility'] = "visibility:visible;"; + } + else { + $element['hidden'] = true; + $element['visibility'] = "visibility:hidden;"; + } + //add the primary key uuid + if (strlen($row['device_setting_uuid']) > 0) { + echo " \n"; + } + + //show alls rows in the array + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + if (strlen($text['description-settings']) > 0) { + echo "
".$text['description-settings']."\n"; + } + echo " "; + + echo " \n"; + if (strlen($row['device_setting_uuid']) > 0) { + if (permission_exists('device_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('device_delete')) { + echo " $v_link_label_delete\n"; + } + } + echo " \n"; + echo " \n"; + $x++; } - if (permission_exists('device_delete')) { - echo " $v_link_label_delete\n"; - } - echo " \n"; + /* + echo " \n"; + echo " \n"; + */ + echo " \n"; + echo " \n"; echo " \n"; - $x++; - } - - $x = 0; - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo "\n"; - - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - if (strlen($text['description-settings']) > 0) { - echo "
".$text['description-settings']."\n"; - } - echo " "; - echo " "; } echo "\n";