fusionpbx/app/devices/devices.php

481 lines
21 KiB
PHP
Raw Normal View History

<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2024
2019-11-07 17:00:29 +01:00
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
2022-10-11 00:35:14 +02:00
//includes files
Use magic constant dir (#6711) * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ to load only functions.php * replace spaces with tab character * update dirname command to use levels instead of nesting * use magic constant __DIR__ * update dirname command to use levels instead of nesting * Update access_control_edit.php * Update access_control_import.php * Update access_controls.php * Update dnd.php * Update access_controls_reload.php * Update call_center_agents.php * Update call_center_agents.php * Update fax_queue.php * Update login.php * Update pdo.php * Update pdo_vm.php * Update switch.php * Update index.php * Update css.php * Update v_mailto.php * Update fax_to_email.php --------- Co-authored-by: FusionPBX <markjcrane@gmail.com>
2023-06-15 19:28:23 +02:00
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
2019-11-07 17:00:29 +01:00
require_once "resources/paging.php";
//check permissions
if (permission_exists('device_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//set the current domain and user information
$domain_name = $_SESSION['domain_name'] ?? '';
$domain_uuid = $_SESSION['domain_uuid'] ?? '';
$user_uuid = $_SESSION['user_uuid'] ?? '';
$user_name = $_SESSION['username'] ?? '';
//create database connection and settings object
$database = database::new();
$settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid, 'user_uuid' => $user_uuid]);
//add multi-lingual support
$language = new text;
$text = $language->get();
2019-11-07 17:00:29 +01:00
//get posted data
2023-05-24 22:52:26 +02:00
if (!empty($_POST['devices']) && is_array($_POST['devices'])) {
2019-11-07 17:00:29 +01:00
$action = $_POST['action'];
$devices = $_POST['devices'];
}
2019-11-20 22:48:31 +01:00
//get the search
$search = strtolower($_REQUEST["search"] ?? '');
$fields = strtolower($_REQUEST["fields"] ?? '');
2019-11-20 22:48:31 +01:00
2019-11-30 22:18:00 +01:00
//process the http post data by action
2023-05-24 22:52:26 +02:00
if (!empty($action) && !empty($devices) && is_array($devices) && @sizeof($devices) != 0) {
2019-11-30 19:12:41 +01:00
switch ($action) {
case 'toggle':
if (permission_exists('device_edit')) {
2019-11-30 22:18:00 +01:00
$obj = new device;
2019-11-30 19:12:41 +01:00
$obj->toggle($devices);
}
break;
case 'delete':
if (permission_exists('device_delete')) {
2019-11-30 22:18:00 +01:00
$obj = new device;
2019-11-30 19:12:41 +01:00
$obj->delete($devices);
}
break;
2019-11-07 17:00:29 +01:00
}
2019-11-30 19:12:41 +01:00
header('Location: devices.php'.($search != '' ? '?search='.urlencode($search).'&fields='.urlencode($fields) : null));
2019-11-30 19:12:41 +01:00
exit;
2019-11-07 17:00:29 +01:00
}
//get order and order by and sanatize the values
2023-05-24 22:52:26 +02:00
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
//set the time zone
$time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get());
2015-09-05 06:19:11 +02:00
//get total devices count from the database
2019-08-04 04:21:56 +02:00
$sql = "select count(*) from v_devices ";
$sql .= "where domain_uuid = :domain_uuid ";
if (!permission_exists('device_all') && !permission_exists('device_domain_all')) {
$sql .= "and device_user_uuid = :user_uuid ";
$parameters['user_uuid'] = $user_uuid;
}
$parameters['domain_uuid'] = $domain_uuid;
2019-08-04 04:21:56 +02:00
$total_devices = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
2015-09-05 06:19:11 +02:00
2018-05-28 08:14:13 +02:00
//get the devices profiles
$sql = "select * from v_device_profiles ";
$sql .= "where true ";
if (!permission_exists('device_profile_all')) {
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $domain_uuid;
}
2019-08-04 04:21:56 +02:00
$device_profiles = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
2018-05-28 08:14:13 +02:00
2015-09-05 06:19:11 +02:00
//prepare to page the results
2019-08-04 04:21:56 +02:00
$sql = "select count(*) from v_devices as d ";
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
if (!empty($search)) {
2015-09-05 06:19:11 +02:00
$sql .= "where ";
}
2019-08-04 04:21:56 +02:00
}
else {
2015-09-05 06:19:11 +02:00
$sql .= "where (";
2019-08-04 04:21:56 +02:00
$sql .= " d.domain_uuid = :domain_uuid ";
if (permission_exists('device_all')) {
2015-09-05 06:19:11 +02:00
$sql .= " or d.domain_uuid is null ";
}
$sql .= ") ";
if (!empty($search)) {
2015-09-05 06:19:11 +02:00
$sql .= "and ";
}
2019-08-04 04:21:56 +02:00
$parameters['domain_uuid'] = $domain_uuid;
2015-09-05 06:19:11 +02:00
}
if (!empty($search)) {
2015-09-05 06:19:11 +02:00
$sql .= "(";
$sql .= " lower(d.device_address) like :search ";
2019-08-04 04:21:56 +02:00
$sql .= " or lower(d.device_label) like :search ";
$sql .= " or lower(d.device_vendor) like :search ";
$sql .= " or lower(d.device_enabled) like :search ";
$sql .= " or lower(d.device_template) like :search ";
$sql .= " or lower(d.device_description) like :search ";
$sql .= " or lower(d.device_provisioned_method) like :search ";
$sql .= " or lower(d.device_provisioned_ip) like :search ";
if ($fields == 'all' || $fields == 'lines') {
$sql .= " or d.device_uuid in ( ";
$sql .= " select dl.device_uuid from v_device_lines as dl ";
$sql .= " where dl.display_name like :search ";
$sql .= " or dl.user_id like :search ";
$sql .= " or dl.auth_id like :search ";
$sql .= " ) ";
}
if ($fields == 'all' || $fields == 'keys') {
$sql .= " or d.device_uuid in ( ";
$sql .= " select dk.device_uuid from v_device_keys as dk ";
$sql .= " where dk.device_key_value like :search ";
$sql .= " or dk.device_key_label like :search ";
$sql .= " ) ";
}
if ($fields == 'all' || $fields == 'settings') {
$sql .= " or d.device_uuid in ( ";
$sql .= " select ds.device_uuid from v_device_settings as ds ";
$sql .= " where ds.device_setting_subcategory like :search ";
$sql .= " or ds.device_setting_value like :search ";
$sql .= " or ds.device_setting_description like :search ";
$sql .= " ) ";
}
2015-09-05 06:19:11 +02:00
$sql .= ") ";
2019-08-04 04:21:56 +02:00
$parameters['search'] = '%'.strtolower($search).'%';
2015-09-05 06:19:11 +02:00
}
2023-05-24 22:52:26 +02:00
$num_rows = $database->select($sql, $parameters ?? null, 'column');
2019-08-04 04:21:56 +02:00
unset($sql, $parameters);
2015-09-05 06:19:11 +02:00
//prepare to page the results
$rows_per_page = intval($settings->get('domain', 'paging', 50));
2023-05-24 22:52:26 +02:00
$param = '';
if ($search) {
$param = "&search=".$search;
$param .= "&fields=".$fields;
}
if (!empty($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
$param .= "&show=all";
2015-12-09 23:01:35 +01:00
}
2023-05-24 22:52:26 +02:00
$page = $_GET['page'] ?? 0;
list($paging_controls, $rows_per_page) = paging($num_rows, $param ?? '', $rows_per_page);
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param ?? '', $rows_per_page, true);
2015-09-05 06:19:11 +02:00
$offset = $rows_per_page * $page;
//get the list
2025-02-03 02:01:27 +01:00
$sql = "select ";
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
$sql .= "d3.domain_name, ";
}
$sql .="d.*, d2.device_label as alternate_label, ";
$sql .= "to_char(timezone(:time_zone, d.device_provisioned_date), 'DD Mon YYYY') as provisioned_date_formatted, \n";
$sql .= "to_char(timezone(:time_zone, d.device_provisioned_date), 'HH12:MI:SS am') as provisioned_time_formatted \n";
2015-09-05 06:19:11 +02:00
$sql .= "from v_devices as d, v_devices as d2 ";
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
$sql .= ", v_domains as d3 ";
}
2015-09-05 06:19:11 +02:00
$sql .= "where ( ";
$sql .= " d.device_uuid_alternate = d2.device_uuid ";
$sql .= " or ( ";
$sql .= " d.device_uuid_alternate is null and ";
$sql .= " d.device_uuid = d2.device_uuid ";
$sql .= " ) ";
2015-09-05 06:19:11 +02:00
$sql .= ") ";
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
$sql .= " and d.domain_uuid = d3.domain_uuid ";
2019-08-04 04:21:56 +02:00
}
else {
2015-09-05 06:19:11 +02:00
$sql .= "and (";
2019-08-04 04:21:56 +02:00
$sql .= " d.domain_uuid = :domain_uuid ";
if (permission_exists('device_all')) {
2015-09-05 06:19:11 +02:00
$sql .= " or d.domain_uuid is null ";
}
$sql .= ") ";
2019-08-04 04:21:56 +02:00
$parameters['domain_uuid'] = $domain_uuid;
2015-09-05 06:19:11 +02:00
}
if (!permission_exists('device_all') && !permission_exists('device_domain_all')) {
$sql .= "and d.device_user_uuid = :user_uuid ";
$parameters['user_uuid'] = $user_uuid;
}
if (!empty($search)) {
2015-09-05 06:19:11 +02:00
$sql .= "and (";
$sql .= " lower(d.device_address) like :search ";
2019-08-04 04:21:56 +02:00
$sql .= " or lower(d.device_label) like :search ";
$sql .= " or lower(d.device_vendor) like :search ";
$sql .= " or lower(d.device_enabled) like :search ";
$sql .= " or lower(d.device_template) like :search ";
$sql .= " or lower(d.device_description) like :search ";
$sql .= " or lower(d.device_provisioned_method) like :search ";
$sql .= " or lower(d.device_provisioned_ip) like :search ";
if ($fields == 'all' || $fields == 'lines') {
$sql .= " or d.device_uuid in ( ";
$sql .= " select dl.device_uuid from v_device_lines as dl ";
$sql .= " where dl.display_name like :search ";
$sql .= " or dl.user_id like :search ";
$sql .= " or dl.auth_id like :search ";
$sql .= " ) ";
}
if ($fields == 'all' || $fields == 'keys') {
$sql .= " or d.device_uuid in ( ";
$sql .= " select dk.device_uuid from v_device_keys as dk ";
$sql .= " where dk.device_key_value like :search ";
$sql .= " or dk.device_key_label like :search ";
$sql .= " ) ";
}
if ($fields == 'all' || $fields == 'settings') {
$sql .= " or d.device_uuid in ( ";
$sql .= " select ds.device_uuid from v_device_settings as ds ";
$sql .= " where ds.device_setting_subcategory like :search ";
$sql .= " or ds.device_setting_value like :search ";
$sql .= " or ds.device_setting_description like :search ";
$sql .= " ) ";
}
2015-09-05 06:19:11 +02:00
$sql .= ") ";
2019-08-04 04:21:56 +02:00
$parameters['search'] = '%'.strtolower($search).'%';
2015-09-05 06:19:11 +02:00
}
if (empty($order_by)) {
2015-09-05 06:19:11 +02:00
$sql .= "order by d.device_label, d.device_description asc ";
}
else {
$sql .= "order by $order_by $order ";
}
2019-08-04 04:21:56 +02:00
$sql .= limit_offset($rows_per_page, $offset);
$parameters['time_zone'] = $time_zone;
2019-08-04 04:21:56 +02:00
$devices = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
2015-09-05 06:19:11 +02:00
//alternate_found
$device_alternate = false;
2020-01-21 22:21:34 +01:00
if (is_array($devices)) {
foreach($devices as $row) {
if (is_uuid($row['device_uuid_alternate'])) {
$device_alternate = true;
break;
}
2015-09-05 06:19:11 +02:00
}
}
2019-11-07 17:00:29 +01:00
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header
2020-01-06 15:39:59 +01:00
$document['title'] = $text['title-devices'];
2019-11-07 17:00:29 +01:00
require_once "resources/header.php";
//show the content
2019-11-07 17:00:29 +01:00
echo "<div class='action_bar' id='action_bar'>\n";
2024-09-07 00:43:42 +02:00
echo " <div class='heading'><b>".$text['header-devices']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
2019-11-07 17:00:29 +01:00
echo " <div class='actions'>\n";
if (permission_exists('device_import')) {
echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>$settings->get('theme', 'button_icon_import'),'link'=>'device_imports.php']);
2019-11-08 06:31:54 +01:00
}
if (permission_exists('device_export')) {
echo button::create(['type'=>'button','label'=>$text['button-export'],'icon'=>$settings->get('theme', 'button_icon_export'),'link'=>'device_download.php']);
2019-11-08 06:31:54 +01:00
}
if (permission_exists('device_vendor_view')) {
2019-11-08 07:01:35 +01:00
echo button::create(['type'=>'button','label'=>$text['button-vendors'],'icon'=>'fax','link'=>'device_vendors.php']);
2019-11-08 06:31:54 +01:00
}
if (permission_exists('device_profile_view')) {
2019-11-08 07:01:35 +01:00
echo button::create(['type'=>'button','label'=>$text['button-profiles'],'icon'=>'clone','link'=>'device_profiles.php']);
2019-11-08 06:31:54 +01:00
}
$margin_left = permission_exists('device_import') || permission_exists('device_export') || permission_exists('device_vendor_view') || permission_exists('device_profile_view') ? "margin-left: 15px;" : null;
if (permission_exists('device_add') && (empty($_SESSION['limit']['devices']['numeric']) || ($total_devices < $_SESSION['limit']['devices']['numeric']))) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','style'=>$margin_left,'link'=>'device_edit.php']);
2019-11-08 07:01:35 +01:00
unset($margin_left);
2019-11-07 17:00:29 +01:00
}
if (permission_exists('device_edit') && $devices) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$settings->get('theme', 'button_icon_toggle'),'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display: none; '.($margin_left ?? null),'onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
2019-11-08 07:01:35 +01:00
unset($margin_left);
2019-11-07 17:00:29 +01:00
}
if (permission_exists('device_delete') && $devices) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete'),'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; '.($margin_left ?? null),'onclick'=>"modal_open('modal-delete','btn_delete');"]);
2019-11-08 07:01:35 +01:00
unset($margin_left);
2019-11-07 17:00:29 +01:00
}
echo "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('device_all')) {
2023-05-24 22:52:26 +02:00
if (!empty($_GET['show']) && $_GET['show'] == 'all') {
2019-11-07 17:00:29 +01:00
echo " <input type='hidden' name='show' value='all'>";
}
else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$settings->get('theme','button_icon_all'),'link'=>'?show=all']);
2015-03-07 23:51:32 +01:00
}
}
2019-11-08 06:31:54 +01:00
echo "<select class='formfld' name='fields' id='select_fields' style='width: auto; margin-left: 15px;' onchange=\"if (document.getElementById('search').value != '') { this.form.submit(); }\">\n";
echo " <option value='' selected='selected' disabled hidden>".$text['label-fields']."...</option>\n";
echo " <option value=''></option>\n";
echo " <option value=''>".$text['label-default']."</option>\n";
echo " <option value='lines' ".($fields == 'lines' ? " selected='selected'" : null).">".$text['label-lines']."</option>\n";
echo " <option value='keys' ".($fields == 'keys' ? " selected='selected'" : null).">".$text['label-keys']."</option>\n";
echo " <option value='settings' ".($fields == 'settings' ? " selected='selected'" : null).">".$text['label-settings']."</option>\n";
echo " <option value='all' ".($fields == 'all' ? " selected='selected'" : null).">".$text['label-all']."</option>\n";
echo " </select>";
echo "<input type='text' class='txt list-search' name='search' id='search' style='margin-left: 0 !important;' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
echo button::create(['label'=>$text['button-search'],'icon'=>$settings->get('theme', 'button_icon_search'),'type'=>'submit','id'=>'btn_search']);
//echo button::create(['label'=>$text['button-reset'],'icon'=>$settings->get('theme', 'button_icon_reset'),'type'=>'button','id'=>'btn_reset','link'=>'devices.php','style'=>($search == '' ? 'display: none;' : null)]);
2019-11-07 17:00:29 +01:00
if ($paging_controls_mini != '') {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
}
2019-11-07 17:00:29 +01:00
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('device_edit') && $devices) {
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
}
if (permission_exists('device_delete') && $devices) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
2019-11-07 17:00:29 +01:00
echo $text['description-devices']."\n";
echo "<br /><br />\n";
2019-11-07 17:00:29 +01:00
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<input type='hidden' name='fields' value=\"".escape($fields)."\">\n";
2019-11-07 17:00:29 +01:00
echo "<div class='card'>\n";
2019-11-07 17:00:29 +01:00
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('device_edit') || permission_exists('device_delete')) {
2019-11-07 17:00:29 +01:00
echo " <th class='checkbox'>\n";
2023-05-24 22:52:26 +02:00
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(empty($devices) ? "style='visibility: hidden;'" : null).">\n";
2019-11-07 17:00:29 +01:00
echo " </th>\n";
}
if (!empty($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, null, null, $param);
}
echo th_order_by('device_address', $text['label-device_address'], $order_by, $order, null, null, $param ?? null);
2023-05-24 22:52:26 +02:00
echo th_order_by('device_label', $text['label-device_label'], $order_by, $order, null, null, $param ?? null);
2015-05-22 06:10:43 +02:00
if ($device_alternate) {
2023-05-24 22:52:26 +02:00
echo th_order_by('device_template', $text['label-device_uuid_alternate'], $order_by, $order, null, null, $param ?? null);
2015-05-22 06:10:43 +02:00
}
2023-05-24 22:52:26 +02:00
echo th_order_by('device_vendor', $text['label-device_vendor'], $order_by, $order, null, null, $param ?? null);
echo th_order_by('device_template', $text['label-device_template'], $order_by, $order, null, null, $param ?? null);
2018-05-28 08:14:13 +02:00
echo "<th>". $text['label-device_profiles']."</th>\n";
2023-05-24 22:52:26 +02:00
echo th_order_by('device_enabled', $text['label-device_enabled'], $order_by, $order, null, "class='center'", $param ?? null);
echo th_order_by('device_provisioned_date', $text['label-device_status'], $order_by, $order, null, null, $param ?? null);
echo th_order_by('device_description', $text['label-device_description'], $order_by, $order, null, "class='hide-sm-dn'", $param ?? null);
if (permission_exists('device_edit') && $settings->get('theme', 'list_row_edit_button', false)) {
2019-11-07 17:00:29 +01:00
echo " <td class='action-button'>&nbsp;</td>\n";
}
2019-11-07 17:00:29 +01:00
echo "</tr>\n";
2023-05-26 17:24:02 +02:00
if (!empty($devices) && @sizeof($devices) != 0) {
2019-11-07 17:00:29 +01:00
$x = 0;
2015-05-22 05:08:02 +02:00
foreach($devices as $row) {
2018-05-28 08:14:13 +02:00
$device_profile_name = '';
foreach($device_profiles as $profile) {
if ($profile['device_profile_uuid'] == $row['device_profile_uuid']) {
$device_profile_name = $profile['device_profile_name'];
}
}
$list_row_url = '';
if (permission_exists('device_edit')) {
2019-11-07 17:00:29 +01:00
$list_row_url = "device_edit.php?id=".urlencode($row['device_uuid']);
if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) {
$list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
}
2019-11-07 17:00:29 +01:00
}
$device_provisioned_method = '';
if (isset($row['device_provisioned_method']) && ($row['device_provisioned_method'] == 'http' || $row['device_provisioned_method'] == 'https')) {
$device_provisioned_method = $row['device_provisioned_method'];
}
$device_provisioned_ip = '';
if (isset($row['device_provisioned_ip']) && filter_var($row['device_provisioned_ip'], FILTER_VALIDATE_IP)) {
$device_provisioned_ip = $row['device_provisioned_ip'];
}
2019-11-07 17:00:29 +01:00
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('device_edit') || permission_exists('device_delete')) {
2019-11-07 17:00:29 +01:00
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='devices[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
2019-11-07 17:00:29 +01:00
echo " <input type='hidden' name='devices[$x][uuid]' value='".escape($row['device_uuid'])."' />\n";
echo " </td>\n";
}
if (!empty($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
echo " <td>".escape($row['domain_name'])."</td>\n";
}
2019-11-07 17:00:29 +01:00
echo " <td class='no-wrap'>";
echo permission_exists('device_edit') ? "<a href='".$list_row_url."'>".escape(format_device_address($row['device_address']))."</a>" : escape(format_device_address($row['device_address']));
echo " </td>\n";
2019-11-07 17:00:29 +01:00
echo " <td>".escape($row['device_label'])."&nbsp;</td>\n";
2015-05-22 06:10:43 +02:00
if ($device_alternate) {
if (!empty($row['device_uuid_alternate'])) {
2019-11-07 17:00:29 +01:00
echo " <td class='no-link'>\n";
echo " <a href='device_edit.php?id=".urlencode($row['device_uuid_alternate'])."'>".escape($row['alternate_label'])."</a>\n";
echo " </td>\n";
}
else {
echo " <td>&nbsp;</td>\n";
2015-05-22 06:10:43 +02:00
}
}
2019-11-07 17:00:29 +01:00
echo " <td>".escape($row['device_vendor'])."&nbsp;</td>\n";
echo " <td>".escape($row['device_template'])."&nbsp;</td>\n";
echo " <td>".escape($device_profile_name)."&nbsp;</td>\n";
if (permission_exists('device_edit')) {
2019-11-07 17:00:29 +01:00
echo " <td class='no-link center'>";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['device_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
}
2019-11-07 17:00:29 +01:00
else {
echo " <td class='center'>";
echo $text['label-'.$row['device_enabled']];
}
echo " </td>\n";
echo " <td class='no-link'><a title='".escape($row['device_provisioned_agent'])."' href='javascript:void(0)'>".escape($row['provisioned_date_formatted'])." ".escape($row['provisioned_time_formatted'])."</a> &nbsp; ".escape($device_provisioned_method)." &nbsp; <a href='".escape($device_provisioned_method)."://".escape($row['device_provisioned_ip'])."' target='_blank'>".escape($row['device_provisioned_ip'])."</a>&nbsp;</td>\n";
2019-11-07 17:00:29 +01:00
echo " <td class='description overflow hide-sm-dn'>".escape($row['device_description'])."&nbsp;</td>\n";
if (permission_exists('device_edit') && $settings->get('theme', 'list_row_edit_button', false)) {
2019-11-07 17:00:29 +01:00
echo " <td class='action-button'>";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$settings->get('theme','button_icon_edit'),'link'=>$list_row_url]);
2019-11-07 17:00:29 +01:00
echo " </td>\n";
}
echo "</tr>\n";
2019-11-07 17:00:29 +01:00
$x++;
2019-08-04 04:21:56 +02:00
}
}
2019-11-07 17:00:29 +01:00
unset($devices);
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
2019-11-07 17:00:29 +01:00
echo "<div align='center'>".$paging_controls."</div>\n";
2019-11-07 17:00:29 +01:00
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
2015-03-07 23:51:32 +01:00
?>