mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Devices (Profiles & Vendors): List view updates.
This commit is contained in:
@@ -27,6 +27,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_profile_view')) {
|
||||
@@ -41,25 +42,46 @@
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//get the action
|
||||
if (is_array($_POST["device_profiles"])) {
|
||||
$device_profiles = $_POST["device_profiles"];
|
||||
foreach($device_profiles as $row) {
|
||||
if ($row['action'] == 'delete') {
|
||||
$action = 'delete';
|
||||
break;
|
||||
}
|
||||
//get posted data
|
||||
if (is_array($_POST['profiles'])) {
|
||||
$action = $_POST['action'];
|
||||
$search = $_POST['search'];
|
||||
$profiles = $_POST['profiles'];
|
||||
}
|
||||
|
||||
//copy the device profiles
|
||||
if (permission_exists('device_profile_add')) {
|
||||
if ($action == 'copy' && is_array($profiles) && @sizeof($profiles) != 0) {
|
||||
//copy
|
||||
$obj = new device;
|
||||
$obj->copy_profiles($profiles);
|
||||
//redirect
|
||||
header('Location: device_profiles.php'.($search != '' ? '?search='.urlencode($search) : null));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
//delete the device_profiles
|
||||
//toggle the device profiles
|
||||
if (permission_exists('device_profile_edit')) {
|
||||
if ($action == 'toggle' && is_array($profiles) && @sizeof($profiles) != 0) {
|
||||
//toggle
|
||||
$obj = new device;
|
||||
$obj->toggle_profiles($profiles);
|
||||
//redirect
|
||||
header('Location: device_profiles.php'.($search != '' ? '?search='.urlencode($search) : null));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
//delete the device profiles
|
||||
if (permission_exists('device_profile_delete')) {
|
||||
if ($action == "delete") {
|
||||
//download
|
||||
$obj = new device_profiles;
|
||||
$obj->delete($device_profiles);
|
||||
//delete message
|
||||
message::add($text['message-delete']);
|
||||
if ($action == 'delete' && is_array($profiles) && @sizeof($profiles) != 0) {
|
||||
//delete
|
||||
$obj = new device;
|
||||
$obj->delete_profiles($profiles);
|
||||
//redirect
|
||||
header('Location: device_profiles.php'.($search != '' ? '?search='.urlencode($search) : null));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,28 +89,9 @@
|
||||
$order_by = $_GET["order_by"];
|
||||
$order = $_GET["order"];
|
||||
|
||||
//validate the order by
|
||||
if (strlen($order_by) > 0) {
|
||||
$order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', $order_by);
|
||||
}
|
||||
|
||||
//validate the order
|
||||
switch ($order) {
|
||||
case 'asc':
|
||||
break;
|
||||
case 'desc':
|
||||
break;
|
||||
default:
|
||||
$order = '';
|
||||
}
|
||||
|
||||
//search string
|
||||
if (isset($_GET["search"])) {
|
||||
$search = strtolower($_GET["search"]);
|
||||
}
|
||||
|
||||
//add the search
|
||||
if (isset($search)) {
|
||||
//add the search term
|
||||
$search = strtolower($_GET["search"]);
|
||||
if (strlen($search) > 0) {
|
||||
$sql_search = "and (";
|
||||
$sql_search .= " lower(device_profile_name) like :search ";
|
||||
$sql_search .= " or lower(device_profile_description) like :search ";
|
||||
@@ -96,22 +99,14 @@
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
}
|
||||
|
||||
//additional includes
|
||||
require_once "resources/header.php";
|
||||
require_once "resources/paging.php";
|
||||
|
||||
//get the count
|
||||
$sql = "select count(device_profile_uuid) from v_device_profiles ";
|
||||
if ($_GET['show'] == "all" && permission_exists('device_profile_all')) {
|
||||
$sql .= "where 1 = 1 ";
|
||||
}
|
||||
else {
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$sql = "select count(*) from v_device_profiles ";
|
||||
$sql .= "where true ";
|
||||
if ($_GET['show'] != "all" || !permission_exists('device_profile_all')) {
|
||||
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
}
|
||||
if (isset($sql_search)) {
|
||||
$sql .= $sql_search;
|
||||
}
|
||||
$sql .= $sql_search;
|
||||
$database = new database;
|
||||
$num_rows = $database->select($sql, $parameters, 'column');
|
||||
|
||||
@@ -123,123 +118,100 @@
|
||||
}
|
||||
$page = $_GET['page'];
|
||||
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
|
||||
list($paging_controls_mini, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page, true); //top
|
||||
list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); //bottom
|
||||
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); //bottom
|
||||
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); //top
|
||||
$offset = $rows_per_page * $page;
|
||||
|
||||
//get the list
|
||||
$sql = "select * from v_device_profiles ";
|
||||
if ($_GET['show'] == "all" && permission_exists('device_profile_all')) {
|
||||
$sql .= "where 1 = 1 ";
|
||||
}
|
||||
else {
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
}
|
||||
if (isset($sql_search)) {
|
||||
$sql .= $sql_search;
|
||||
}
|
||||
if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; }
|
||||
$sql .= "limit :rows_per_page offset :offset ";
|
||||
|
||||
$parameters['rows_per_page'] = $rows_per_page;
|
||||
$parameters['offset'] = $offset;
|
||||
$sql = str_replace('count(*)', '*', $sql);
|
||||
$sql .= order_by($order_by, $order, 'device_profile_name', 'asc');
|
||||
$sql .= limit_offset($rows_per_page, $offset);
|
||||
$database = new database;
|
||||
$device_profiles = $database->select($sql, $parameters, 'all');
|
||||
unset ($sql, $parameters);
|
||||
unset($sql, $parameters);
|
||||
|
||||
//alternate the row style
|
||||
$c = 0;
|
||||
$row_style["0"] = "row_style0";
|
||||
$row_style["1"] = "row_style1";
|
||||
//create token
|
||||
$object = new token;
|
||||
$token = $object->create($_SERVER['PHP_SELF']);
|
||||
|
||||
//define the checkbox_toggle function
|
||||
//echo "<script type=\"text/javascript\">\n";
|
||||
//echo " function checkbox_toggle(item) {\n";
|
||||
//echo " var inputs = document.getElementsByTagName(\"input\");\n";
|
||||
//echo " for (var i = 0, max = inputs.length; i < max; i++) {\n";
|
||||
//echo " if (inputs[i].type === 'checkbox') {\n";
|
||||
//echo " if (document.getElementById('checkbox_all').checked == true) {\n";
|
||||
//echo " inputs[i].checked = true;\n";
|
||||
//echo " }\n";
|
||||
//echo " else {\n";
|
||||
//echo " inputs[i].checked = false;\n";
|
||||
//echo " }\n";
|
||||
//echo " }\n";
|
||||
//echo " }\n";
|
||||
//echo " }\n";
|
||||
//echo "</script>\n";
|
||||
//include the header
|
||||
require_once "resources/header.php";
|
||||
|
||||
//show the content
|
||||
echo "<table width='100%' border='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td width='50%' align='left' nowrap='nowrap'>\n";
|
||||
echo " <b>".$text['title-device_profiles']." (".$num_rows.")</b>\n";
|
||||
echo " </td>\n";
|
||||
echo " <form method='get' action=''>\n";
|
||||
echo " <td width='50%' style='vertical-align: top; text-align: right; white-space: nowrap;'>\n";
|
||||
|
||||
echo "<div class='action_bar' id='action_bar'>\n";
|
||||
echo " <div class='heading'><b>".$text['title-device_profiles']." (".$num_rows.")</b></div>\n";
|
||||
echo " <div class='actions'>\n";
|
||||
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>'devices.php']);
|
||||
if (permission_exists('device_profile_add')) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'link'=>'device_profile_edit.php']);
|
||||
}
|
||||
if (permission_exists('device_profile_add') && $device_profiles) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'onclick'=>"if (confirm('".$text['confirm-copy']."')) { list_action_set('copy'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
|
||||
}
|
||||
if (permission_exists('device_profile_edit') && $device_profiles) {
|
||||
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_profile_delete') && $device_profiles) {
|
||||
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_profile_all')) {
|
||||
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='device_profiles.php?show=all';\">\n";
|
||||
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all']);
|
||||
}
|
||||
}
|
||||
|
||||
//add buttons
|
||||
if (!isset($id)) {
|
||||
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick='window.location=\"/app/devices/devices.php\"' value='".$text['button-back']."'>";
|
||||
}
|
||||
echo " <input type='text' class='txt' style='width: 150px; margin-left: 15px;' name='search' id='search' value='".escape($search)."'>\n";
|
||||
echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n";
|
||||
echo " </td>\n";
|
||||
echo " </form>\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'=>'device_profiles.php','style'=>($search == '' ? 'display: none;' : null)]);
|
||||
if ($paging_controls_mini != '') {
|
||||
echo " <td valign='top' nowrap='nowrap' style='padding-left: 15px;'>".$paging_controls_mini."</td>\n";
|
||||
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
|
||||
}
|
||||
echo " </tr>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align='left' colspan='2'>\n";
|
||||
echo " ".$text['description-device_profiles']."<br /><br />\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo "</table>\n";
|
||||
echo " </form>\n";
|
||||
echo " </div>\n";
|
||||
echo " <div style='clear: both;'></div>\n";
|
||||
echo "</div>\n";
|
||||
|
||||
echo "<form method='post' action=''>\n";
|
||||
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo "<tr>\n";
|
||||
//echo " <th style='width:30px;'>\n";
|
||||
//echo " <input type='checkbox' name='checkbox_all' id='checkbox_all' value='' onclick=\"checkbox_toggle();\">\n";
|
||||
//echo " </th>\n";
|
||||
echo $text['description-device_profiles']."\n";
|
||||
echo "<br /><br />\n";
|
||||
|
||||
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_profile_add') || permission_exists('device_profile_edit') || permission_exists('device_profile_delete')) {
|
||||
echo " <th class='checkbox'>\n";
|
||||
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($device_profiles ?: "style='visibility: hidden;'").">\n";
|
||||
echo " </th>\n";
|
||||
}
|
||||
if ($_GET['show'] == "all" && permission_exists('device_profile_all')) {
|
||||
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param);
|
||||
}
|
||||
echo th_order_by('device_profile_name', $text['label-device_profile_name'], $order_by, $order);
|
||||
echo th_order_by('device_profile_enabled', $text['label-device_profile_enabled'], $order_by, $order);
|
||||
echo th_order_by('device_profile_description', $text['label-device_profile_description'], $order_by, $order);
|
||||
echo " <td class='list_control_icons'>";
|
||||
if (permission_exists('device_profile_add')) {
|
||||
echo " <a href='device_profile_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
echo th_order_by('device_profile_enabled', $text['label-device_profile_enabled'], $order_by, $order, null, "class='center'");
|
||||
echo th_order_by('device_profile_description', $text['label-device_profile_description'], $order_by, $order, null, "class='hide-xs'");
|
||||
if (permission_exists('device_profile_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";
|
||||
|
||||
if (is_array($device_profiles) && @sizeof($device_profiles) != 0) {
|
||||
$x = 0;
|
||||
foreach($device_profiles as $row) {
|
||||
if (permission_exists('device_profile_edit')) {
|
||||
$tr_link = "href='device_profile_edit.php?id=".escape($row['device_profile_uuid'])."'";
|
||||
$list_row_url = "device_profile_edit.php?id=".urlencode($row['device_profile_uuid']);
|
||||
}
|
||||
echo "<tr class='list-row' href='".$list_row_url."'>\n";
|
||||
if (permission_exists('device_profile_add') || permission_exists('device_profile_edit') || permission_exists('device_profile_delete')) {
|
||||
echo " <td class='checkbox'>\n";
|
||||
echo " <input type='checkbox' name='profiles[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
|
||||
echo " <input type='hidden' name='profiles[$x][uuid]' value='".escape($row['device_profile_uuid'])."' />\n";
|
||||
echo " </td>\n";
|
||||
}
|
||||
echo "<tr ".$tr_link.">\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]." tr_link_void' style='align: center; padding: 3px 3px 0px 8px;'>\n";
|
||||
//echo " <input type='checkbox' name=\"device_profiles[$x][checked]\" id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('chk_all_".$x."').checked = false; }\">\n";
|
||||
//echo " <input type='hidden' name=\"device_profiles[$x][device_profile_uuid]\" value='".escape($row['device_profile_uuid'])."' />\n";
|
||||
//echo " </td>\n";
|
||||
if ($_GET['show'] == "all" && permission_exists('device_profile_all')) {
|
||||
if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) {
|
||||
$domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name'];
|
||||
@@ -247,37 +219,46 @@
|
||||
else {
|
||||
$domain = $text['label-global'];
|
||||
}
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($domain)."</td>\n";
|
||||
echo " <td>".escape($domain)."</td>\n";
|
||||
}
|
||||
echo " <td valign='top' class='".$row_style[$c]."' style=''>".escape($row['device_profile_name'])." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."' style=''>".escape($row['device_profile_enabled'])." </td>\n";
|
||||
echo " <td valign='top' class='row_stylebg' style=''>".escape($row['device_profile_description'])." </td>\n";
|
||||
echo " <td class='list_control_icons'>";
|
||||
echo " <td>";
|
||||
if (permission_exists('device_profile_edit')) {
|
||||
echo "<a href='device_profile_edit.php?id=".escape($row['device_profile_uuid'])."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
|
||||
echo " <a href='".$list_row_url."' title=\"".$text['button-edit']."\">".escape($row['device_profile_name'])."</a>\n";
|
||||
}
|
||||
if (permission_exists('device_profile_delete')) {
|
||||
echo " <a href=\"device_profile_delete.php?id=".escape($row['device_profile_uuid'])."&a=delete\" alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">".$v_link_label_delete."</a>\n";
|
||||
else {
|
||||
echo " ".escape($row['device_profile_name'])."\n";
|
||||
}
|
||||
echo " </td>\n";
|
||||
if (permission_exists('device_profile_edit')) {
|
||||
echo " <td class='no-link center'>";
|
||||
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['device_profile_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_profile_enabled']];
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " <td class='description overflow hide-xs'>".escape($row['device_profile_description'])." </td>\n";
|
||||
if (permission_exists('device_profile_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";
|
||||
$x++;
|
||||
if ($c==0) { $c=1; } else { $c=0; }
|
||||
} //end foreach
|
||||
unset($sql, $device_profiles);
|
||||
} //end if results
|
||||
}
|
||||
unset($device_profiles);
|
||||
}
|
||||
|
||||
echo "</table>\n";
|
||||
echo "<br />\n";
|
||||
echo "<div align='center'>".$paging_controls."</div>\n";
|
||||
|
||||
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
||||
|
||||
echo "<tr>\n";
|
||||
echo " <td colspan='3' align='center'>\n";
|
||||
echo " <br />\n";
|
||||
echo " ".$paging_controls;
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "</table>";
|
||||
echo "</form>\n";
|
||||
echo "<br /><br />";
|
||||
|
||||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
?>
|
||||
Reference in New Issue
Block a user