diff --git a/app/devices/app_languages.php b/app/devices/app_languages.php new file mode 100644 index 0000000000..617e8baf0f --- /dev/null +++ b/app/devices/app_languages.php @@ -0,0 +1,130 @@ + \ No newline at end of file diff --git a/app/devices/device_delete.php b/app/devices/device_delete.php index c54895e499..9a4b5f9021 100644 --- a/app/devices/device_delete.php +++ b/app/devices/device_delete.php @@ -33,9 +33,16 @@ else { exit; } -if (count($_GET)>0) { - $id = check_str($_GET["id"]); -} +//add multi-lingual support + require_once "app_languages.php"; + foreach($text as $key => $value) { + $text[$key] = $value[$_SESSION['domain']['language']['code']]; + } + +//get the id + if (count($_GET)>0) { + $id = check_str($_GET["id"]); + } //delete the data if (strlen($id)>0) { @@ -54,7 +61,7 @@ if (count($_GET)>0) { require_once "includes/header.php"; echo "\n"; echo "
\n"; - echo "Delete Complete\n"; + echo $text['message-delete']."\n"; echo "
\n"; require_once "includes/footer.php"; return; diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 0fbe9dfa3a..f9f1bf3495 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -35,6 +35,12 @@ require_once "includes/require.php"; exit; } +//add multi-lingual support + require_once "app_languages.php"; + foreach($text as $key => $value) { + $text[$key] = $value[$_SESSION['domain']['language']['code']]; + } + //action add or update if (isset($_REQUEST["id"])) { $action = "update"; @@ -44,7 +50,7 @@ require_once "includes/require.php"; $action = "add"; } -//get the http post values and set them to php variables +//get http post variables and set them to php variables if (count($_POST) > 0) { $device_mac_address = check_str($_POST["device_mac_address"]); $device_mac_address = strtolower($device_mac_address); @@ -104,7 +110,7 @@ require_once "includes/require.php"; } //check for all required data - if (strlen($device_mac_address) == 0) { $msg .= "Please provide: MAC Address
\n"; } + if (strlen($device_mac_address) == 0) { $msg .= $text['message-required'].$text['label-extension']."
\n"; } //if (strlen($device_label) == 0) { $msg .= "Please provide: Label
\n"; } //if (strlen($device_vendor) == 0) { $msg .= "Please provide: Vendor
\n"; } //if (strlen($device_model) == 0) { $msg .= "Please provide: Model
\n"; } @@ -175,7 +181,7 @@ require_once "includes/require.php"; require_once "includes/header.php"; echo "\n"; echo "
\n"; - echo "Add Complete\n"; + echo $text['message-add']."\n"; echo "
\n"; require_once "includes/footer.php"; return; @@ -207,7 +213,7 @@ require_once "includes/require.php"; require_once "includes/header.php"; echo "\n"; echo "
\n"; - echo "Update Complete\n"; + echo $text['message-update']."\n"; echo "
\n"; require_once "includes/footer.php"; return; @@ -217,7 +223,7 @@ require_once "includes/require.php"; //pre-populate the form if (count($_GET)>0 && $_POST["persistformvar"] != "true") { - $device_uuid = $_GET["id"]; + $device_uuid = check_str($_GET["id"]); $sql = "select * from v_devices "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and device_uuid = '$device_uuid' "; @@ -241,57 +247,156 @@ require_once "includes/require.php"; unset ($prep_statement); } -//begin the content +//show the header require_once "includes/header.php"; +//show the content echo "
"; echo "\n"; echo "\n"; echo "
\n"; - echo "
"; + echo "
"; 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"; 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"; echo "\n"; echo "\n"; echo "\n"; - echo "\n"; echo "\n"; echo "\n"; echo "\n"; - echo "\n"; echo "\n"; echo "\n"; echo " \n"; @@ -439,7 +547,7 @@ require_once "includes/require.php"; if ($action == "update") { echo " \n"; } - echo " \n"; + echo " \n"; echo " \n"; echo " "; echo "
".$text['header-device']."
Device
\n"; - echo "The following information is used to provision endpoints.

\n"; + echo $text['description-device']."

\n"; echo "
\n"; - echo " MAC Address:\n"; + echo "\n"; + echo " ".$text['label-device_mac_address'].":\n"; echo "\n"; echo " \n"; echo "
\n"; - echo "Enter the MAC address.\n"; + echo $text['description-device_mac_address']."\n"; echo "
\n"; - echo " Label:\n"; + echo "\n"; + echo " ".$text['label-device_label'].":\n"; echo "\n"; echo " \n"; echo "
\n"; - echo "Enter the device label.\n"; + echo $text['description-device_label']."\n"; + echo "
\n"; + echo " ".$text['label-extension'].":\n"; + echo "\n"; + + echo " \n"; + $sql = "SELECT e.extension, e.description, d.extension_uuid, d.device_uuid, d.device_line \n"; + $sql .= "FROM v_device_extensions as d, v_extensions as e \n"; + $sql .= "WHERE e.extension_uuid = d.extension_uuid \n"; + $sql .= "AND d.device_uuid = '".$device_uuid."' \n"; + $sql .= "AND d.domain_uuid = '".$_SESSION['domain_uuid']."' \n"; + $sql .= "ORDER BY e.extension asc\n"; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + foreach($result as $row) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + } + echo "
".$row['extension']."".$row['device_line']."".$row['description']." \n"; + //echo " $v_link_label_delete\n"; + //echo "
\n"; + echo "
\n"; + /* + $sql = "SELECT * FROM v_devices "; + $sql .= "WHERE domain_uuid = '".$domain_uuid."' "; + $sql .= "ORDER BY device_mac_address asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + echo "\n"; + + echo " \n"; + echo " \n"; + echo "
\n"; + echo $text['description-extension']."\n"; + */ echo "
\n"; - echo " Template:\n"; + echo " ".$text['label-device_template'].":\n"; echo "\n"; - echo "\n"; echo "
\n"; - echo "Select a template.\n"; + echo $text['description-device_template']."\n"; echo "
\n"; - echo " Vendor:\n"; + echo "\n"; + echo " ".$text['label-device_vendor'].":\n"; echo "\n"; echo " \n"; echo "
\n"; - echo "Enter the vendor name.\n"; + echo $text['description-device_vendor']."\n"; echo "
\n"; - echo " Model:\n"; + echo "\n"; + echo " ".$text['label-device_model'].":\n"; echo "\n"; echo " \n"; echo "
\n"; - echo "Enter the model number.\n"; + echo $text['description-device_model']."\n"; echo "
\n"; - echo " Firmware Version:\n"; + echo "\n"; + echo " ".$text['label-device_firmware_version'].":\n"; echo "\n"; echo " \n"; echo "
\n"; - echo "Enter the firmware version.\n"; + echo $text['description-device_firmware_version']."\n"; echo "
\n"; - echo " Username:\n"; + echo "\n"; + echo " ".$text['label-device_username'].":\n"; echo "\n"; echo " \n"; echo "
\n"; - echo "Enter the username.\n"; + echo $text['description-device_username']."\n"; echo "
\n"; - echo " Password:\n"; + echo "\n"; + echo " ".$text['label-device_password'].":\n"; echo "\n"; echo " \n"; echo "
\n"; - echo "Enter the password.\n"; + echo $text['description-device_password']."\n"; echo "
\n"; - echo " Enabled:\n"; + echo "\n"; + echo " ".$text['label-device_provision_enable'].":\n"; echo "\n"; echo " \n"; echo "
\n"; - echo "Enable or disable provisioning for this device.\n"; + echo $text['description-device_provision_enable']."\n"; + echo "
\n"; - echo " Time Zone:\n"; + echo "\n"; + echo " ".$text['label-device_time_zone'].":\n"; echo "\n"; echo " \n"; echo "
\n"; - echo "Enter the time zone.\n"; + echo $text['description-device_time_zone']."\n"; echo "
\n"; - echo " Description:\n"; + echo "\n"; + echo " ".$text['label-device_description'].":\n"; echo "\n"; echo " \n"; echo "
\n"; - echo "Enter the description.\n"; + echo $text['description-device_description']."\n"; echo "
"; diff --git a/app/devices/devices.php b/app/devices/devices.php index 872e8954be..961eed2871 100644 --- a/app/devices/devices.php +++ b/app/devices/devices.php @@ -32,130 +32,154 @@ else { echo "access denied"; exit; } -require_once "includes/header.php"; -require_once "includes/paging.php"; -$order_by = $_GET["order_by"]; -$order = $_GET["order"]; +//add multi-lingual support + require_once "app_languages.php"; + foreach($text as $key => $value) { + $text[$key] = $value[$_SESSION['domain']['language']['code']]; + } -echo "
"; -echo "\n"; -echo "\n"; -echo " "; -echo ""; -echo "
\n"; -echo "
"; +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "
Devices 
\n"; +//additional includes + require_once "includes/header.php"; + require_once "includes/paging.php"; -echo "Devices in this list are added to the list when they contact the provisioning \n"; -echo "server or added manually by an administrator. \n"; -echo "Items in this list are assigned from the extensions page.

\n"; -echo "
\n"; +//show the content + echo "
"; + echo "
"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
".$text['header-devices']." 
\n"; + echo " ".$text['description-devices']."

\n"; + echo "
\n"; -$sql = "select * from v_devices "; -$sql .= "where domain_uuid = '$domain_uuid' "; -if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } -$prep_statement = $db->prepare(check_sql($sql)); -$prep_statement->execute(); -$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); -$num_rows = count($result); -unset ($prep_statement, $result, $sql); -$rows_per_page = 150; -$param = ""; -$page = $_GET['page']; -if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } -list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); -$offset = $rows_per_page * $page; - -$sql = "select * from v_devices "; -$sql .= "where domain_uuid = '$domain_uuid' "; -if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } -$sql .= " limit $rows_per_page offset $offset "; -$prep_statement = $db->prepare(check_sql($sql)); -$prep_statement->execute(); -$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); -$result_count = count($result); -unset ($prep_statement, $sql); - -$c = 0; -$row_style["0"] = "row_style0"; -$row_style["1"] = "row_style1"; - -echo "
\n"; -echo "\n"; -echo "\n"; -echo th_order_by('device_mac_address', 'MAC Address', $order_by, $order); -echo th_order_by('device_template', 'Template', $order_by, $order); -echo th_order_by('device_vendor', 'Vendor', $order_by, $order); -//echo th_order_by('device_model', 'Model', $order_by, $order); -echo th_order_by('device_provision_enable', 'Enabled', $order_by, $order); -echo th_order_by('device_description', 'Description', $order_by, $order); -echo "\n"; -echo "\n"; - -if ($result_count > 0) { //no results - foreach($result as $row) { - $device_mac_address = $row[device_mac_address]; - $device_mac_address = substr($device_mac_address, 0,2).'-'.substr($device_mac_address, 2,2).'-'.substr($device_mac_address, 4,2).'-'.substr($device_mac_address, 6,2).'-'.substr($device_mac_address, 8,2).'-'.substr($device_mac_address, 10,2); - - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - //echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } - } //end foreach - unset($sql, $result, $row_count); -} //end if results -echo "\n"; -echo "\n"; -echo "\n"; + //prepare to page the results + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; -echo "
\n"; -if (permission_exists('device_add')) { - echo " $v_link_label_add\n"; -} -echo "
".$device_mac_address." ".$row['device_template']." ".$row['device_vendor']." ".$row['device_mode'l]." ".$row['device_provision_enable']." ".$row['device_description']." \n"; - if (permission_exists('device_edit')) { - echo " $v_link_label_edit\n"; + //prepare to page the results + $sql = "select count(*) as num_rows from v_devices "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } } - if (permission_exists('device_delete')) { - echo " $v_link_label_delete\n"; - } - echo "
\n"; -echo " \n"; -echo " \n"; -echo " \n"; -echo " \n"; -echo " \n"; -echo " \n"; -echo "
 $paging_controls\n"; -if (permission_exists('device_add')) { - echo " $v_link_label_add\n"; -} -echo "
\n"; -echo "
"; -echo "
"; -echo "

"; -echo "

"; + //get the list + $sql = "select * from v_devices "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= "limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); -echo "
"; -echo "
"; -echo "

"; + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; -require_once "includes/footer.php"; + echo "
\n"; + echo "\n"; + echo "\n"; + //echo th_order_by('device_uuid', $text['label-device_uuid'], $order_by, $order); + echo th_order_by('device_mac_address', $text['label-device_mac_address'], $order_by, $order); + echo th_order_by('device_label', $text['label-device_label'], $order_by, $order); + //echo th_order_by('device_vendor', $text['label-device_vendor'], $order_by, $order); + echo th_order_by('device_model', $text['label-device_model'], $order_by, $order); + //echo th_order_by('device_firmware_version', $text['label-device_firmware_version'], $order_by, $order); + echo th_order_by('device_provision_enable', $text['label-device_provision_enable'], $order_by, $order); + echo th_order_by('device_template', $text['label-device_template'], $order_by, $order); + //echo th_order_by('device_username', $text['label-device_username'], $order_by, $order); + //echo th_order_by('device_password', $text['label-device_password'], $order_by, $order); + //echo th_order_by('device_time_zone', $text['label-device_time_zone'], $order_by, $order); + echo th_order_by('device_description', $text['label-device_description'], $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + $device_mac_address = $row[device_mac_address]; + $device_mac_address = substr($device_mac_address, 0,2).'-'.substr($device_mac_address, 2,2).'-'.substr($device_mac_address, 4,2).'-'.substr($device_mac_address, 6,2).'-'.substr($device_mac_address, 8,2).'-'.substr($device_mac_address, 10,2); + + 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 ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + if (permission_exists('device_add')) { + echo " $v_link_label_add\n"; + } + else { + echo "  \n"; + } + echo "
".$row['device_uuid']." ".$row['device_mac_address']." ".$row['device_label']." ".$row['device_vendor']." ".$row['device_model']." ".$row['device_firmware_version']." ".$row['device_provision_enable']." ".$row['device_template']." ".$row['device_username']." ".$row['device_password']." ".$row['device_time_zone']." ".$row['device_description']." \n"; + 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"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('device_add')) { + echo " $v_link_label_add\n"; + } + else { + echo "  \n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; ?> \ No newline at end of file