Copyright (C) 2019 All Rights Reserved. Contributor(s): Mark J Crane */ //includes require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists('device_profile_view')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $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; } } } //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']); } } //get variables used to control the order $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)) { $sql_search = "and ("; $sql_search .= " lower(device_profile_name) like :search "; $sql_search .= " or lower(device_profile_description) like :search "; $sql_search .= ") "; $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) "; $parameters['domain_uuid'] = $domain_uuid; } if (isset($sql_search)) { $sql .= $sql_search; } $database = new database; $num_rows = $database->select($sql, $parameters, 'column'); //prepare to page the results $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $param = "&search=".$search; if ($_GET['show'] == "all" && permission_exists('device_profile_all')) { $param .= "&show=all"; } $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 $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; $database = new database; $device_profiles = $database->select($sql, $parameters, 'all'); unset ($sql, $parameters); //alternate the row style $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; //define the checkbox_toggle function //echo "\n"; //show the content echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; if ($paging_controls_mini != '') { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['title-device_profiles']." (".$num_rows.")\n"; echo "
\n"; if (permission_exists('device_profile_all')) { if ($_GET['show'] == 'all') { echo " "; } else { echo " \n"; } } //add buttons if (!isset($id)) { echo " "; } echo " \n"; echo " \n"; echo " ".$paging_controls_mini."
\n"; echo " ".$text['description-device_profiles']."

\n"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; //echo " \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 " \n"; echo "\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'])."'"; } echo "\n"; //echo " \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']; } else { $domain = $text['label-global']; } echo " \n"; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; $x++; if ($c==0) { $c=1; } else { $c=0; } } //end foreach unset($sql, $device_profiles); } //end if results echo "\n"; echo " \n"; echo "\n"; echo "
\n"; //echo " \n"; //echo " "; if (permission_exists('device_profile_add')) { echo " $v_link_label_add"; } else { echo " \n"; } echo "
".escape($domain)."".escape($row['device_profile_name'])." ".escape($row['device_profile_enabled'])." ".escape($row['device_profile_description'])." "; if (permission_exists('device_profile_edit')) { echo "$v_link_label_edit"; } if (permission_exists('device_profile_delete')) { echo " ".$v_link_label_delete."\n"; } echo "
\n"; echo "
\n"; echo " ".$paging_controls; echo "
"; echo "
\n"; echo "

"; //include the footer require_once "resources/footer.php"; ?>