Dashboard / Devices: Update layout code to match other Dashboard components.
This commit is contained in:
@@ -17,16 +17,17 @@
|
|||||||
|
|
||||||
The Initial Developer of the Original Code is
|
The Initial Developer of the Original Code is
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
Copyright (C) 2016 All Rights Reserved.
|
Portions created by the Initial Developer are Copyright (C) 2016-2020
|
||||||
|
the Initial Developer. All Rights Reserved.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//includes
|
//includes
|
||||||
require_once "root.php";
|
require_once "root.php";
|
||||||
require_once "resources/require.php";
|
require_once "resources/require.php";
|
||||||
|
require_once "resources/check_auth.php";
|
||||||
|
|
||||||
//check permissions
|
//check permissions
|
||||||
require_once "resources/check_auth.php";
|
|
||||||
if (permission_exists('device_key_add') || permission_exists('device_key_edit')) {
|
if (permission_exists('device_key_add') || permission_exists('device_key_edit')) {
|
||||||
//access granted
|
//access granted
|
||||||
}
|
}
|
||||||
@@ -39,9 +40,6 @@
|
|||||||
$language = new text;
|
$language = new text;
|
||||||
$text = $language->get($_SESSION['domain']['language']['code'], 'app/devices');
|
$text = $language->get($_SESSION['domain']['language']['code'], 'app/devices');
|
||||||
|
|
||||||
//include the device class
|
|
||||||
//require_once "app/devices/resources/classes/device.php";
|
|
||||||
|
|
||||||
//get the vendor functions
|
//get the vendor functions
|
||||||
$sql = "select v.name as vendor_name, f.name, f.value ";
|
$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 .= "from v_device_vendors as v, v_device_vendor_functions as f ";
|
||||||
@@ -75,6 +73,14 @@
|
|||||||
//add or update the database
|
//add or update the database
|
||||||
if ($_POST["persistformvar"] != "true") {
|
if ($_POST["persistformvar"] != "true") {
|
||||||
|
|
||||||
|
//validate the token
|
||||||
|
$token = new token;
|
||||||
|
if (!$token->validate('/app/devices/device_dashboard.php')) {
|
||||||
|
message::add($text['message-invalid_token'],'negative');
|
||||||
|
header('Location: '.PROJECT_PATH."/core/user_settings/user_dashboard.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
//get device
|
//get device
|
||||||
$sql = "select device_uuid, device_profile_uuid from v_devices ";
|
$sql = "select device_uuid, device_profile_uuid from v_devices ";
|
||||||
$sql .= "where device_user_uuid = :device_user_uuid ";
|
$sql .= "where device_user_uuid = :device_user_uuid ";
|
||||||
@@ -274,7 +280,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//set the message
|
//set the message
|
||||||
message::add($text["message-$action"]);
|
message::add($text["message-".$action]);
|
||||||
|
|
||||||
//redirect the browser
|
//redirect the browser
|
||||||
header("Location: /core/user_settings/user_dashboard.php");
|
header("Location: /core/user_settings/user_dashboard.php");
|
||||||
@@ -419,53 +425,49 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//show the header
|
//create token
|
||||||
//require_once "resources/header.php";
|
$object = new token;
|
||||||
|
$token = $object->create('/app/devices/device_dashboard.php');
|
||||||
|
|
||||||
//show the content
|
//show the content
|
||||||
echo "<form name='frm' id='frm' method='post' action='/app/devices/device_dashboard.php'>\n";
|
echo "<div class='action_bar sub'>\n";
|
||||||
|
echo " <div class='heading'><b>".$text['title-device_keys']."</b></div>\n";
|
||||||
echo " <div style='float: left;'>";
|
echo " <div class='actions'>\n";
|
||||||
echo " <b>".$text['title-device_keys']."</b><br />";
|
echo button::create(['type'=>'button','label'=>$text['button-apply'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>false,'onclick'=>"document.location.href='".PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync&profile=".$sip_profile_name."&user=".$user_id."@".$server_address."&domain=".$server_address."&agent=".$device_key_vendor."';"]);
|
||||||
if (!$is_included) {
|
echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>false,'onclick'=>"list_form_submit('form_list_device_keys');"]);
|
||||||
echo " ".$text['description-device_keys']."<br />";
|
|
||||||
}
|
|
||||||
echo " <br />";
|
|
||||||
echo " </div>\n";
|
echo " </div>\n";
|
||||||
|
echo " <div style='clear: both;'></div>\n";
|
||||||
echo " <div style='float: right;'>";
|
|
||||||
echo " </div>\n";
|
|
||||||
|
|
||||||
echo "<div style='float: right;'>\n";
|
|
||||||
echo " <input type='button' class='btn' value='".$text['button-apply']."' onclick=\"document.location.href='".PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync&profile=".$sip_profile_name."&user=".$user_id."@".$server_address."&domain=".$server_address."&agent=".$device_key_vendor."';\"> \n";
|
|
||||||
echo " <input type='submit' class='btn' value='".$text['button-save']."'>";
|
|
||||||
echo "</div>\n";
|
echo "</div>\n";
|
||||||
|
|
||||||
|
if (!$is_included) {
|
||||||
|
echo $text['description-device_keys']."\n";
|
||||||
|
echo "<br /><br />\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "<form method='post' name='frm' id='form_list_device_keys' action='/app/devices/device_dashboard.php'>\n";
|
||||||
|
|
||||||
if (permission_exists('device_key_edit')) {
|
if (permission_exists('device_key_edit')) {
|
||||||
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
echo "<table class='list'>\n";
|
||||||
$x = 0;
|
$x = 0;
|
||||||
if (is_array($device_keys) && @sizeof($device_keys) != 0) {
|
if (is_array($device_keys) && @sizeof($device_keys) != 0) {
|
||||||
foreach($device_keys as $row) {
|
foreach ($device_keys as $row) {
|
||||||
//set the variables
|
//set the variables
|
||||||
$device_key_vendor = $row['device_key_vendor'];
|
$device_key_vendor = $row['device_key_vendor'];
|
||||||
$device_vendor = $row['device_key_vendor'];
|
$device_vendor = $row['device_key_vendor'];
|
||||||
|
|
||||||
//set the column names
|
//set the column names
|
||||||
if ($previous_device_key_vendor != $row['device_key_vendor']) {
|
if ($previous_device_key_vendor != $row['device_key_vendor'] || $row['device_key_vendor'] == '') {
|
||||||
echo " <tr>\n";
|
echo " <tr class='list-header'>\n";
|
||||||
//echo " <td class='vtable'>".$text['label-device_key_category']."</td>\n";
|
echo " <th class='shrink'>".$text['label-device_key_id']."</th>\n";
|
||||||
echo " <th>".$text['label-device_key_id']."</th>\n";
|
|
||||||
if (strlen($row['device_key_vendor']) > 0) {
|
if (strlen($row['device_key_vendor']) > 0) {
|
||||||
echo " <th>".ucwords($row['device_key_vendor'])."</th>\n";
|
echo " <th>".ucwords($row['device_key_vendor'])."</th>\n";
|
||||||
} else {
|
|
||||||
echo " <th>".$text['label-device_key_type']."</th>\n";
|
|
||||||
}
|
}
|
||||||
//echo " <td class='row_style".$c."'>".$text['label-device_key_line']."</td>\n";
|
else {
|
||||||
echo " <th>".$text['label-device_key_value']."</th>\n";
|
echo " <th>".$text['label-device_key_type']."</th>\n";
|
||||||
//echo " <td class='row_style".$c."'>".$text['label-device_key_extension']."</td>\n";
|
}
|
||||||
echo " <th>".$text['label-device_key_label']."</th>\n";
|
echo " <th>".$text['label-device_key_value']."</th>\n";
|
||||||
echo " <th>".$text['label-device_key_icon']."</th>\n";
|
echo " <th>".$text['label-device_key_label']."</th>\n";
|
||||||
echo " </tr>\n";
|
echo " <th class='shrink'>".$text['label-device_key_icon']."</th>\n";
|
||||||
|
echo " </tr>\n";
|
||||||
}
|
}
|
||||||
//determine whether to hide the element
|
//determine whether to hide the element
|
||||||
if (strlen($device_key_uuid) == 0) {
|
if (strlen($device_key_uuid) == 0) {
|
||||||
@@ -479,10 +481,7 @@
|
|||||||
//add the primary key uuid
|
//add the primary key uuid
|
||||||
if (strlen($row['device_key_uuid']) > 0) {
|
if (strlen($row['device_key_uuid']) > 0) {
|
||||||
echo " <input name='device_keys[".$x."][device_key_uuid]' type='hidden' value=\"".$row['device_key_uuid']."\">\n";
|
echo " <input name='device_keys[".$x."][device_key_uuid]' type='hidden' value=\"".$row['device_key_uuid']."\">\n";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//show all the rows in the array
|
//show all the rows in the array
|
||||||
/*
|
/*
|
||||||
echo " <tr>\n";
|
echo " <tr>\n";
|
||||||
@@ -543,108 +542,82 @@
|
|||||||
echo " </select>\n";
|
echo " </select>\n";
|
||||||
echo "</td>\n";
|
echo "</td>\n";
|
||||||
*/
|
*/
|
||||||
|
//output form rows
|
||||||
echo "<td class='row_style".$c." row_style_slim' valign='top' nowrap='nowrap'>\n";
|
echo " <tr class='list-row'>\n";
|
||||||
|
echo " <td class='input'>\n";
|
||||||
if (permission_exists('device_key_id') || permission_exists('device_key_add')) {
|
if (permission_exists('device_key_id') || permission_exists('device_key_add')) {
|
||||||
$selected = "selected='selected'";
|
$selected = "selected='selected'";
|
||||||
echo " <select class='formfld' name='device_keys[".$x."][device_key_id]'>\n";
|
echo " <select class='formfld' name='device_keys[".$x."][device_key_id]'>\n";
|
||||||
echo " <option value=''></option>\n";
|
echo " <option value=''></option>\n";
|
||||||
$i = 1;
|
$i = 1;
|
||||||
while ($i < 100) {
|
while ($i < 100) {
|
||||||
echo " <option value='$i' ".($row['device_key_id'] == $i ? $selected:"").">$i</option>\n";
|
echo " <option value='$i' ".($row['device_key_id'] == $i ? $selected:"").">$i</option>\n";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
echo " </select>\n";
|
echo " </select>\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo " ".$row['device_key_id'];
|
echo " ".$row['device_key_id'];
|
||||||
}
|
}
|
||||||
echo "</td>\n";
|
echo " </td>\n";
|
||||||
|
|
||||||
echo "<td class='row_style".$c." row_style_slim' nowrap='nowrap'>\n";
|
echo " <td class='input'>\n";
|
||||||
//echo " <input class='formfld' type='text' name='device_keys[".$x."][device_key_type]' style='width: 120px;' maxlength='255' value=\"$row['device_key_type']\">\n";
|
echo " <input class='formfld' type='hidden' id='key_vendor_".$x."' name='device_keys[".$x."][device_key_vendor]' value=\"".$device_key_vendor."\">\n";
|
||||||
?>
|
echo " <input class='formfld' type='hidden' id='key_category_".$x."' name='device_keys[".$x."][device_key_category]' value=\"".$device_key_category."\">\n";
|
||||||
<input class='formfld' type='hidden' id='key_vendor_<?php echo $x; ?>' name='device_keys[<?php echo $x; ?>][device_key_vendor]' value="<?php echo $device_key_vendor; ?>">
|
echo " <input class='formfld' type='hidden' id='key_uuid_".$x."' name='device_keys[".$x."][device_uuid]' value=\"".$device_uuid."\">\n";
|
||||||
<input class='formfld' type='hidden' id='key_category_<?php echo $x; ?>' name='device_keys[<?php echo $x; ?>][device_key_category]' value="<?php echo $device_key_category; ?>">
|
echo " <input class='formfld' type='hidden' id='key_key_line_".$x."' name='device_keys[".$x."][device_key_line]' value=\"".$device_key_line."\">\n";
|
||||||
<input class='formfld' type='hidden' id='key_uuid_<?php echo $x; ?>' name='device_keys[<?php echo $x; ?>][device_uuid]' value="<?php echo $device_uuid; ?>">
|
echo " <select class='formfld' name='device_keys[".$x."][device_key_type]' id='key_type_".$x."'>\n";
|
||||||
<input class='formfld' type='hidden' id='key_key_line_<?php echo $x; ?>' name='device_keys[<?php echo $x; ?>][device_key_line]' value="<?php echo $device_key_line; ?>">
|
echo " <option value=''></option>\n";
|
||||||
<?php
|
|
||||||
echo "<select class='formfld' name='device_keys[".$x."][device_key_type]' id='key_type_".$x."'>\n";
|
|
||||||
echo " <option value=''></option>\n";
|
|
||||||
$previous_vendor = '';
|
$previous_vendor = '';
|
||||||
$i=0;
|
$i = 0;
|
||||||
if (is_array($vendor_functions)) {
|
if (is_array($vendor_functions)) {
|
||||||
foreach ($vendor_functions as $function) {
|
foreach ($vendor_functions as $function) {
|
||||||
if (strlen($row['device_key_vendor']) == 0 && $function['vendor_name'] != $previous_vendor) {
|
if (strlen($row['device_key_vendor']) == 0 && $function['vendor_name'] != $previous_vendor) {
|
||||||
if ($i > 0) { echo " </optgroup>\n"; }
|
if ($i > 0) {
|
||||||
echo " <optgroup label='".ucwords($function['vendor_name'])."'>\n";
|
echo " </optgroup>\n";
|
||||||
|
}
|
||||||
|
echo " <optgroup label='".ucwords($function['vendor_name'])."'>\n";
|
||||||
}
|
}
|
||||||
$selected = '';
|
$selected = '';
|
||||||
if ($row['device_key_vendor'] == $function['vendor_name'] && $row['device_key_type'] == $function['value']) {
|
if ($row['device_key_vendor'] == $function['vendor_name'] && $row['device_key_type'] == $function['value']) {
|
||||||
$selected = "selected='selected'";
|
$selected = "selected='selected'";
|
||||||
}
|
}
|
||||||
if (strlen($row['device_key_vendor']) == 0) {
|
if (strlen($row['device_key_vendor']) == 0) {
|
||||||
echo " <option value='".$function['value']."' $selected >".$text['label-'.$function['name']]."</option>\n";
|
echo " <option value='".$function['value']."' $selected >".$text['label-'.$function['name']]."</option>\n";
|
||||||
}
|
}
|
||||||
if (strlen($row['device_key_vendor']) > 0 && $row['device_key_vendor'] == $function['vendor_name']) {
|
if (strlen($row['device_key_vendor']) > 0 && $row['device_key_vendor'] == $function['vendor_name']) {
|
||||||
echo " <option value='".$function['value']."' $selected >".$text['label-'.$function['name']]."</option>\n";
|
echo " <option value='".$function['value']."' $selected >".$text['label-'.$function['name']]."</option>\n";
|
||||||
}
|
}
|
||||||
$previous_vendor = $function['vendor_name'];
|
$previous_vendor = $function['vendor_name'];
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strlen($row['device_key_vendor']) == 0) {
|
if (strlen($row['device_key_vendor']) == 0) {
|
||||||
echo " </optgroup>\n";
|
echo " </optgroup>\n";
|
||||||
}
|
}
|
||||||
echo "</select>\n";
|
echo " </select>\n";
|
||||||
echo "</td>\n";
|
echo " </td>\n";
|
||||||
//echo "<td valign='top' align='left' nowrap='nowrap'>\n";
|
echo " <td class='input'>\n";
|
||||||
//echo " <select class='formfld' name='device_keys[".$x."][device_key_line]'>\n";
|
echo " <input class='formfld' style='min-width: 50px; max-width: 100px;' type='text' name='device_keys[".$x."][device_key_value]' maxlength='255' value=\"".$row['device_key_value']."\">\n";
|
||||||
//echo " <option value=''></option>\n";
|
echo " </td>\n";
|
||||||
//for ($l = 0; $l <= 12; $l++) {
|
echo " <td class='input'>\n";
|
||||||
//echo " <option value='".$l."' ".(($row['device_key_line'] == $l) ? "selected='selected'" : null).">".$l."</option>\n";
|
echo " <input class='formfld' style='min-width: 50px; max-width: 100px;' type='text' name='device_keys[".$x."][device_key_label]' maxlength='255' value=\"".$row['device_key_label']."\">\n";
|
||||||
//}
|
echo " </td>\n";
|
||||||
//echo " </select>\n";
|
echo " <td class='input'>\n";
|
||||||
//echo "</td>\n";
|
echo " <input class='formfld' style='min-width: 50px; max-width: 100px;' type='text' name='device_keys[".$x."][device_key_icon]' maxlength='255' value=\"".$row['device_key_icon']."\">\n";
|
||||||
|
echo " <input type='hidden' name='device_keys[".$x."][device_profile_uuid]' value=\"".$row['device_profile_uuid']."\">\n";
|
||||||
echo "<td class='row_style".$c." row_style_slim'>\n";
|
echo " </td>\n";
|
||||||
echo " <input class='formfld' style='min-width: 50px; max-width: 100px;' type='text' name='device_keys[".$x."][device_key_value]' maxlength='255' value=\"".$row['device_key_value']."\">\n";
|
echo " </tr>\n";
|
||||||
echo "</td>\n";
|
|
||||||
|
|
||||||
//echo "<td align='left'>\n";
|
|
||||||
//echo " <input class='formfld' type='text' name='device_keys[".$x."][device_key_extension]' style='width: 120px;' maxlength='255' value=\"".$row['device_key_extension']."\">\n";
|
|
||||||
//echo "</td>\n";
|
|
||||||
|
|
||||||
echo "<td class='row_style".$c." row_style_slim'>\n";
|
|
||||||
echo " <input class='formfld' style='min-width: 50px; max-width: 100px;' type='text' name='device_keys[".$x."][device_key_label]' maxlength='255' value=\"".$row['device_key_label']."\">\n";
|
|
||||||
echo " <input class='formfld' style='min-width: 50px; max-width: 100px;' type='text' name='device_keys[".$x."][device_key_icon]' maxlength='255' value=\"".$row['device_key_icon']."\">\n";
|
|
||||||
echo " <input type='hidden' name='device_keys[".$x."][device_profile_uuid]' value=\"".$row['device_profile_uuid']."\">\n";
|
|
||||||
echo "</td>\n";
|
|
||||||
|
|
||||||
//echo " <td align='left'>\n";
|
|
||||||
//echo " <input type='button' class='btn' value='".$text['button-save']."' onclick='submit_form();'>\n";
|
|
||||||
//echo " </td>\n";
|
|
||||||
//echo " <td nowrap='nowrap'>\n";
|
|
||||||
//echo " </td>\n";
|
|
||||||
|
|
||||||
echo " </tr>\n";
|
|
||||||
//set the previous vendor
|
//set the previous vendor
|
||||||
$previous_device_key_vendor = $row['device_key_vendor'];
|
$previous_device_key_vendor = $row['device_key_vendor'];
|
||||||
//increment the array key
|
//increment the array key
|
||||||
$x++;
|
$x++;
|
||||||
//alternate the value
|
|
||||||
$c = ($c) ? 0 : 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo " </table>\n";
|
echo "</table>\n";
|
||||||
//if (strlen($text['description-keys']) > 0) {
|
|
||||||
// echo " <br>".$text['description-keys']."\n";
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
||||||
echo "</form>";
|
echo "</form>";
|
||||||
|
|
||||||
//show the footer
|
|
||||||
//require_once "resources/footer.php";
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user