Update device_dashboard.php

Add profile keys to the dashboard in a way they can be overridden by the device keys.
This commit is contained in:
FusionPBX 2016-07-16 03:34:51 -06:00 committed by GitHub
parent dd2e18fbdd
commit 9fe48e8da2
1 changed files with 27 additions and 7 deletions

View File

@ -191,11 +191,16 @@
//set the sip profile name
$sip_profile_name = 'internal';
//get device keys
$sql = "SELECT * from v_device_keys ";
$sql .= "WHERE device_uuid = '".$device_uuid."' ";
//get device keys in the right order where device keys are listed after the profile keys
$sql = "SELECT * FROM v_device_keys ";
$sql .= "WHERE (";
$sql .= "device_uuid = '".$device_uuid."' ";
if (strlen($device_profile_uuid) > 0) {
$sql .= "or device_profile_uuid = '".$device_profile_uuid."' ";
}
$sql .= ") ";
$sql .= "ORDER BY ";
$sql .= "device_key_vendor asc, ";
$sql .= "device_key_vendor ASC, ";
$sql .= "CASE device_key_category ";
$sql .= "WHEN 'line' THEN 1 ";
$sql .= "WHEN 'memory' THEN 2 ";
@ -203,14 +208,29 @@
$sql .= "WHEN 'expansion' THEN 4 ";
$sql .= "ELSE 100 END, ";
if ($db_type == "mysql") {
$sql .= "device_key_id asc ";
$sql .= "device_key_id ASC ";
}
else {
$sql .= "cast(device_key_id as numeric) asc ";
$sql .= "CAST(device_key_id as numeric) ASC, ";
}
$sql .= "CASE WHEN device_uuid IS NULL THEN 0 ELSE 1 END ASC ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$device_keys = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$keys = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($sql,$prep_statement);
//override profile keys with device keys
foreach($keys as $row) {
$id = $row['device_key_id'];
$device_keys[$id] = $row;
if (is_uuid($row['device_profile_uuid'])) {
$device_keys[$id]['device_key_owner'] = "profile";
}
else {
$device_keys[$id]['device_key_owner'] = "device";
}
}
unset($keys);
//get the vendor count and last and device information
$vendor_count = 0;