mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Device: List view updates.
This commit is contained in:
@@ -263,7 +263,7 @@
|
||||
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
|
||||
}
|
||||
if (permission_exists('contact_add')) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>'file-import','link'=>'contact_import.php','style'=>'margin-left: 15px;']);
|
||||
echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'link'=>'contact_import.php','style'=>'margin-left: 15px;']);
|
||||
}
|
||||
echo " </form>\n";
|
||||
echo " </div>\n";
|
||||
|
||||
@@ -198,7 +198,7 @@
|
||||
echo button::create(['type'=>'button','label'=>$text['button-outbound'],'icon'=>'location-arrow','link'=>'?type=outbound'.($_GET['show'] == 'all' ? '&show=all' : null).($search != '' ? "&search=".urlencode($search) : null)]);
|
||||
echo button::create(['type'=>'button','label'=>$text['button-local'],'icon'=>'vector-square','link'=>'?type=local'.($_GET['show'] == 'all' ? '&show=all' : null).($search != '' ? "&search=".urlencode($search) : null)]);
|
||||
if (permission_exists('destination_import')) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>'file-import','link'=>'destination_imports.php']);
|
||||
echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'link'=>'destination_imports.php']);
|
||||
}
|
||||
echo " </form>\n";
|
||||
echo " </div>\n";
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2008-2015 All Rights Reserved.
|
||||
Portions created by the Initial Developer are Copyright (C) 2008 - 2019
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
@@ -27,6 +28,7 @@
|
||||
require_once "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
require_once "resources/paging.php";
|
||||
|
||||
//check permissions
|
||||
if (permission_exists('device_view')) {
|
||||
@@ -37,16 +39,42 @@
|
||||
exit;
|
||||
}
|
||||
|
||||
//additional includes
|
||||
require_once "resources/header.php";
|
||||
require_once "resources/paging.php";
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//get the http values and set them as variables
|
||||
$search = $_GET["search"];
|
||||
//get posted data
|
||||
if (is_array($_POST['devices'])) {
|
||||
$action = $_POST['action'];
|
||||
$search = $_POST['search'];
|
||||
$devices = $_POST['devices'];
|
||||
}
|
||||
|
||||
//toggle the devices
|
||||
if (permission_exists('device_edit')) {
|
||||
if ($action == 'toggle' && is_array($devices) && @sizeof($devices) != 0) {
|
||||
//toggle
|
||||
$obj = new device;
|
||||
$obj->toggle($devices);
|
||||
//redirect
|
||||
header('Location: devices.php'.($search != '' ? '?search='.urlencode($search) : null));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
//delete the devices
|
||||
if (permission_exists('device_delete')) {
|
||||
if ($action == 'delete' && is_array($devices) && @sizeof($devices) != 0) {
|
||||
//delete
|
||||
$obj = new device;
|
||||
$obj->delete($devices);
|
||||
//redirect
|
||||
header('Location: devices.php'.($search != '' ? '?search='.urlencode($search) : null));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
//get order and order by and sanatize the values
|
||||
$order_by = $_GET["order_by"];
|
||||
$order = $_GET["order"];
|
||||
|
||||
@@ -110,12 +138,14 @@
|
||||
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
||||
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
|
||||
$param = "&search=".$search."&show=all";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$param = "&search=".$search;
|
||||
}
|
||||
$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);
|
||||
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);
|
||||
$offset = $rows_per_page * $page;
|
||||
|
||||
//get the list
|
||||
@@ -174,54 +204,78 @@
|
||||
}
|
||||
}
|
||||
|
||||
//create token
|
||||
$object = new token;
|
||||
$token = $object->create($_SERVER['PHP_SELF']);
|
||||
|
||||
//include the header
|
||||
require_once "resources/header.php";
|
||||
|
||||
//show the content
|
||||
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td width='100%' align='left' valign='top'>\n";
|
||||
echo " <b>".$text['header-devices']." (".$total_devices.")</b>\n";
|
||||
echo " </td>\n";
|
||||
echo " <td align='right' nowrap='nowrap' valign='top'>\n";
|
||||
echo " <form method='get' action=''>\n";
|
||||
echo "<div class='action_bar' id='action_bar'>\n";
|
||||
echo " <div class='heading'><b>".$text['header-devices']." (".$num_rows.")</b></div>\n";
|
||||
echo " <div class='actions'>\n";
|
||||
if (permission_exists('device_add') && (!is_numeric($_SESSION['limit']['devices']['numeric']) || ($total_devices < $_SESSION['limit']['devices']['numeric']))) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'link'=>'device_edit.php']);
|
||||
}
|
||||
if (permission_exists('device_edit') && $devices) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'onclick'=>"if (confirm('".$text['confirm-toggle']."')) { list_action_set('toggle'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
|
||||
}
|
||||
if (permission_exists('device_delete') && $devices) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
|
||||
}
|
||||
echo "<form id='form_search' class='inline' method='get'>\n";
|
||||
if (permission_exists('device_all')) {
|
||||
if (isset($_GET['show']) && $_GET['show'] == 'all') {
|
||||
echo " <input type='hidden' name='show' value='all'>\n";
|
||||
if ($_GET['show'] == 'all') {
|
||||
echo " <input type='hidden' name='show' value='all'>";
|
||||
}
|
||||
else {
|
||||
echo " <input type='button' class='btn' value='".$text['button-show_all']."' onclick=\"window.location='devices.php?show=all';\">\n";
|
||||
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all']);
|
||||
}
|
||||
}
|
||||
if (permission_exists('device_vendor_view')) {
|
||||
echo " <input type='button' class='btn' value='".$text['button-vendors']."' onclick=\"document.location.href='device_vendors.php';\">\n";
|
||||
}
|
||||
if (permission_exists('device_profile_view')) {
|
||||
echo " <input type='button' class='btn' value='".$text['button-profiles']."' onclick=\"document.location.href='device_profiles.php';\">\n";
|
||||
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
|
||||
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]);
|
||||
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'devices.php','style'=>($search == '' ? 'display: none;' : null)]);
|
||||
if ($paging_controls_mini != '') {
|
||||
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
|
||||
}
|
||||
$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_import')) {
|
||||
echo " <input type='button' class='btn' alt='".$text['button-import']."' onclick=\"window.location='device_imports.php'\" value='".$text['button-import']."'>\n";
|
||||
echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'style'=>$margin_left,'link'=>'device_imports.php']);
|
||||
unset($margin_left);
|
||||
}
|
||||
if (permission_exists('device_export')) {
|
||||
echo " <input type='button' class='btn' value='".$text['button-export']."' onclick=\"window.location.href='device_download.php'\">\n";
|
||||
echo button::create(['type'=>'button','label'=>$text['button-export'],'icon'=>$_SESSION['theme']['button_icon_export'],'style'=>$margin_left,'link'=>'device_download.php']);
|
||||
unset($margin_left);
|
||||
}
|
||||
echo " <input type='text' class='txt' style='width: 150px; margin-left: 15px;' name='search' value='".escape($search)."'>\n";
|
||||
echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n";
|
||||
echo " </form>\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td colspan='2'>\n";
|
||||
echo " ".$text['description-devices'];
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "<br />\n";
|
||||
if (permission_exists('device_vendor_view')) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-vendors'],'icon'=>'fax','style'=>$margin_left,'link'=>'device_vendors.php']);
|
||||
unset($margin_left);
|
||||
}
|
||||
if (permission_exists('device_profile_view')) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-profiles'],'icon'=>'clone','style'=>$margin_left,'link'=>'device_profiles.php']);
|
||||
unset($margin_left);
|
||||
}
|
||||
echo " </form>\n";
|
||||
echo " </div>\n";
|
||||
echo " <div style='clear: both;'></div>\n";
|
||||
echo "</div>\n";
|
||||
|
||||
$c = 0;
|
||||
$row_style["0"] = "row_style0";
|
||||
$row_style["1"] = "row_style1";
|
||||
echo $text['description-devices']."\n";
|
||||
echo "<br /><br />\n";
|
||||
|
||||
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo "<tr>\n";
|
||||
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
|
||||
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 "<table class='list'>\n";
|
||||
echo "<tr class='list-header'>\n";
|
||||
if (permission_exists('device_edit') || permission_exists('device_delete')) {
|
||||
echo " <th class='checkbox'>\n";
|
||||
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($devices ?: "style='visibility: hidden;'").">\n";
|
||||
echo " </th>\n";
|
||||
}
|
||||
if ($_GET['show'] == "all" && permission_exists('device_all')) {
|
||||
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param);
|
||||
}
|
||||
echo th_order_by('device_mac_address', $text['label-device_mac_address'], $order_by, $order);
|
||||
@@ -232,22 +286,16 @@
|
||||
echo th_order_by('device_vendor', $text['label-device_vendor'], $order_by, $order);
|
||||
echo th_order_by('device_template', $text['label-device_template'], $order_by, $order);
|
||||
echo "<th>". $text['label-device_profiles']."</th>\n";
|
||||
echo th_order_by('device_enabled', $text['label-device_enabled'], $order_by, $order);
|
||||
echo th_order_by('device_enabled', $text['label-device_enabled'], $order_by, $order, null, "class='center'");
|
||||
echo th_order_by('device_status', $text['label-device_status'], $order_by, $order);
|
||||
echo th_order_by('device_description', $text['label-device_description'], $order_by, $order);
|
||||
echo "<td class='list_control_icons'>\n";
|
||||
if (permission_exists('device_add')) {
|
||||
if ($_SESSION['limit']['devices']['numeric'] == '' || ($_SESSION['limit']['devices']['numeric'] != '' && $total_devices < $_SESSION['limit']['devices']['numeric'])) {
|
||||
echo " <a href='device_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>\n";
|
||||
}
|
||||
echo th_order_by('device_description', $text['label-device_description'], $order_by, $order, null, "class='hide-sm-dn'");
|
||||
if (permission_exists('device_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
|
||||
echo " <td class='action-button'> </td>\n";
|
||||
}
|
||||
else {
|
||||
echo " \n";
|
||||
}
|
||||
echo "</td>\n";
|
||||
echo "<tr>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
if (is_array($devices) && @sizeof($devices) != 0) {
|
||||
$x = 0;
|
||||
foreach($devices as $row) {
|
||||
|
||||
$device_profile_name = '';
|
||||
@@ -257,50 +305,67 @@
|
||||
}
|
||||
}
|
||||
|
||||
$tr_link = (permission_exists('device_edit')) ? "href='device_edit.php?id=".escape($row['device_uuid'])."'" : null;
|
||||
echo "<tr ".$tr_link.">\n";
|
||||
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."</td>\n";
|
||||
if (permission_exists('device_edit')) {
|
||||
$list_row_url = "device_edit.php?id=".urlencode($row['device_uuid']);
|
||||
}
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>\n";
|
||||
echo (permission_exists('device_edit')) ? "<a href='device_edit.php?id=".escape($row['device_uuid'])."'>".format_mac(escape($row['device_mac_address']))."</a>" : format_mac(escape($row['device_mac_address']));
|
||||
echo " </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['device_label'])." </td>\n";
|
||||
if ($device_alternate) {
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>\n";
|
||||
if (strlen($row['device_uuid_alternate']) > 0) {
|
||||
echo " <a href='device_edit.php?id=".escape($row['device_uuid_alternate'])."' alt=''>".escape($row['alternate_label'])."</a>\n";
|
||||
}
|
||||
echo "<tr class='list-row' href='".$list_row_url."'>\n";
|
||||
if (permission_exists('device_edit') || permission_exists('device_delete')) {
|
||||
echo " <td class='checkbox'>\n";
|
||||
echo " <input type='checkbox' name='devices[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
|
||||
echo " <input type='hidden' name='devices[$x][uuid]' value='".escape($row['device_uuid'])."' />\n";
|
||||
echo " </td>\n";
|
||||
}
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['device_vendor'])." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['device_template'])." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($device_profile_name)." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$text['label-'.escape($row['device_enabled'])]." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['device_provisioned_date'])." - ".escape($row['device_provisioned_method'])." - <a href='http://".escape($row['device_provisioned_ip'])."' target='_blank'>".escape($row['device_provisioned_ip'])."</a> </td>\n";
|
||||
echo " <td valign='top' class='row_stylebg'>".escape($row['device_description'])." </td>\n";
|
||||
echo " <td class='list_control_icons'>\n";
|
||||
if (permission_exists('device_edit')) {
|
||||
echo "<a href='device_edit.php?id=".$row['device_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
|
||||
if ($_GET['show'] == "all" && permission_exists('device_all')) {
|
||||
echo " <td>".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."</td>\n";
|
||||
}
|
||||
if (permission_exists('device_delete')) {
|
||||
echo "<a href='device_delete.php?id=".$row['device_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
|
||||
echo " <td class='no-wrap'>";
|
||||
echo permission_exists('device_edit') ? "<a href='".$list_row_url."'>".escape(format_mac($row['device_mac_address']))."</a>" : escape(format_mac($row['device_mac_address']));
|
||||
echo " </td>\n";
|
||||
echo " <td>".escape($row['device_label'])." </td>\n";
|
||||
if ($device_alternate) {
|
||||
if (strlen($row['device_uuid_alternate']) > 0) {
|
||||
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> </td>\n";
|
||||
}
|
||||
}
|
||||
echo " <td>".escape($row['device_vendor'])." </td>\n";
|
||||
echo " <td>".escape($row['device_template'])." </td>\n";
|
||||
echo " <td>".escape($device_profile_name)." </td>\n";
|
||||
if (permission_exists('device_edit')) {
|
||||
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')"]);
|
||||
}
|
||||
else {
|
||||
echo " <td class='center'>";
|
||||
echo $text['label-'.$row['device_enabled']];
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " <td class='no-link'>".escape($row['device_provisioned_date'])." - ".escape($row['device_provisioned_method'])." - <a href='http://".escape($row['device_provisioned_ip'])."' target='_blank'>".escape($row['device_provisioned_ip'])."</a> </td>\n";
|
||||
echo " <td class='description overflow hide-sm-dn'>".escape($row['device_description'])." </td>\n";
|
||||
if (permission_exists('device_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
|
||||
echo " <td class='action-button'>";
|
||||
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
|
||||
echo " </td>\n";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
if ($c==0) { $c=1; } else { $c=0; }
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
unset($devices, $row);
|
||||
unset($devices);
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "<br />\n";
|
||||
echo "<div align='center'>".$paging_controls."</div>\n";
|
||||
|
||||
echo $paging_controls."\n";
|
||||
echo "<br /><br />\n";
|
||||
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
||||
|
||||
echo "</form>\n";
|
||||
|
||||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -31,8 +31,31 @@ include "root.php";
|
||||
public $domain_uuid;
|
||||
public $template_dir;
|
||||
|
||||
/**
|
||||
* declare private variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
private $permission_prefix;
|
||||
private $list_page;
|
||||
private $table;
|
||||
private $uuid_prefix;
|
||||
private $toggle_field;
|
||||
private $toggle_values;
|
||||
|
||||
public function __construct() {
|
||||
//require_once "resources/classes/database.php";
|
||||
|
||||
//assign private variables
|
||||
$this->app_name = 'devices';
|
||||
$this->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
|
||||
$this->permission_prefix = 'device_';
|
||||
$this->list_page = 'devices.php';
|
||||
$this->table = 'devices';
|
||||
$this->uuid_prefix = 'device_';
|
||||
$this->toggle_field = 'device_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
@@ -258,12 +281,11 @@ include "root.php";
|
||||
return $this->template_dir;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* delete drives
|
||||
* delete records
|
||||
*/
|
||||
public function delete($devices) {
|
||||
if (permission_exists('device_delete')) {
|
||||
public function delete($records) {
|
||||
if (permission_exists($this->permission_prefix.'delete')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
@@ -273,39 +295,136 @@ include "root.php";
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: devices.php');
|
||||
header('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//delete multiple devices
|
||||
if (is_array($devices)) {
|
||||
//get the action
|
||||
foreach($devices as $row) {
|
||||
if ($row['action'] == 'delete') {
|
||||
$action = 'delete';
|
||||
break;
|
||||
//delete multiple records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//build the delete array
|
||||
foreach ($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
||||
$array['device_settings'][$x]['device_uuid'] = $record['uuid'];
|
||||
$array['device_lines'][$x]['device_uuid'] = $record['uuid'];
|
||||
$array['device_keys'][$x]['device_uuid'] = $record['uuid'];
|
||||
}
|
||||
}
|
||||
|
||||
//delete the checked rows
|
||||
if ($action == 'delete') {
|
||||
$database = new database;
|
||||
foreach($devices as $x => $row) {
|
||||
if ($row['action'] == 'delete' or $row['checked'] == 'true') {
|
||||
$array['devices'][$x]['device_uuid'] = $row['device_uuid'];
|
||||
$array['devices'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
}
|
||||
}
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
$database->app_name = 'devices';
|
||||
$database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('device_setting_delete', 'temp');
|
||||
$p->add('device_line_delete', 'temp');
|
||||
$p->add('device_key_delete', 'temp');
|
||||
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
}
|
||||
unset($devices);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p->delete('device_setting_delete', 'temp');
|
||||
$p->delete('device_line_delete', 'temp');
|
||||
$p->delete('device_key_delete', 'temp');
|
||||
|
||||
//write the provision files
|
||||
if (strlen($_SESSION['provision']['path']['text']) > 0) {
|
||||
$prov = new provision;
|
||||
$prov->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$response = $prov->write();
|
||||
}
|
||||
|
||||
//set message
|
||||
message::add($text['message-delete']);
|
||||
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
}
|
||||
} //end the delete function
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
/**
|
||||
* toggle records
|
||||
*/
|
||||
public function toggle($records) {
|
||||
if (permission_exists($this->permission_prefix.'edit')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//toggle the checked records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//get current toggle state
|
||||
foreach($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$record_uuids[] = $this->uuid_prefix."uuid = '".$record['uuid']."'";
|
||||
}
|
||||
}
|
||||
if (is_array($record_uuids) && @sizeof($record_uuids) != 0) {
|
||||
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$sql .= "and ( ".implode(' or ', $record_uuids)." ) ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$states[$row['uuid']] = $row['toggle'];
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
|
||||
//build update array
|
||||
$x = 0;
|
||||
foreach($states as $uuid => $state) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid;
|
||||
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
|
||||
$x++;
|
||||
}
|
||||
|
||||
//save the changes
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
|
||||
//save the array
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//write the provision files
|
||||
if (strlen($_SESSION['provision']['path']['text']) > 0) {
|
||||
$prov = new provision;
|
||||
$prov->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$response = $prov->write();
|
||||
}
|
||||
|
||||
//set message
|
||||
message::add($text['message-toggle']);
|
||||
}
|
||||
unset($records, $states);
|
||||
}
|
||||
|
||||
}
|
||||
} //method
|
||||
|
||||
} //class
|
||||
|
||||
?>
|
||||
@@ -161,7 +161,7 @@
|
||||
if (permission_exists('xml_cdr_archive')) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-archive'],'icon'=>'archive','link'=>'xml_cdr_archive.php'.($_REQUEST['show'] == 'all' ? '?show=all' : null)]);
|
||||
}
|
||||
echo button::create(['type'=>'button','label'=>$text['button-export'],'icon'=>'file-export','onclick'=>"toggle_select('export_format'); this.blur();"]);
|
||||
echo button::create(['type'=>'button','label'=>$text['button-export'],'icon'=>$_SESSION['theme']['button_icon_export'],'onclick'=>"toggle_select('export_format'); this.blur();"]);
|
||||
echo "<select class='formfld' style='display: none; width: auto;' name='export_format' id='export_format' onchange=\"display_message('".$text['message-preparing_download']."'); toggle_select('export_format'); document.getElementById('frm_export').submit();\">";
|
||||
echo " <option value='' disabled='disabled' selected='selected'>".$text['label-format']."</option>";
|
||||
echo " <option value='csv'>CSV</option>";
|
||||
|
||||
Reference in New Issue
Block a user