diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index 02fd6a6..25fd292 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -69,14 +69,15 @@ class dbinterface } break; case 'phoneGrid': - $fld = 'name, name as mac, type, button, addon, description'; switch ($data['type']) { case "cisco-sip": - $stmts = $this->db->prepare("SELECT {$fld} FROM sccpdeviceconfig WHERE type LIKE '%-sip' ORDER BY name"); + $stmts = $this->db->prepare("SELECT name, type, button, addon, description, 'not connected' AS status, '- -' AS address + FROM sccpdeviceconfig WHERE type LIKE '%-sip' ORDER BY name"); break; case "sccp": // Fall through to default intentionally default: - $stmts = $this->db->prepare("SELECT {$fld} FROM sccpdeviceconfig WHERE type not LIKE '%-sip' ORDER BY name"); + $stmts = $this->db->prepare("SELECT name, type, button, addon, description, 'not connected' AS status, '- -' AS address + FROM sccpdeviceconfig WHERE type not LIKE '%-sip' ORDER BY name"); break; } break; diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 3aa2a20..6b55527 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -315,6 +315,7 @@ trait ajaxHelper { $dbDevices = array(); // Find all devices defined in the database. $dbDevices = $this->dbinterface->getSccpDeviceTableData('phoneGrid', array('type' => $request['type'])); + // Return if only interested in SIP devices if ($request['type'] == 'cisco-sip') { return $dbDevices; //this may be empty @@ -323,19 +324,14 @@ trait ajaxHelper { $activeDevices = $this->aminterface->sccp_get_active_device(); foreach ($dbDevices as &$dev_id) { - $id_name = $dev_id['mac']; - if (!empty($activeDevices[$id_name])) { + if (!empty($activeDevices[$dev_id['name']])) { // Device is in db and is connected - $dev_id['description'] = $activeDevices[$id_name]['descr']; - $dev_id['status'] = $activeDevices[$id_name]['status']; - $dev_id['address'] = $activeDevices[$id_name]['address']; + $dev_id['description'] = $activeDevices[$dev_id['name']]['descr']; + $dev_id['status'] = $activeDevices[$dev_id['name']]['status']; + $dev_id['address'] = $activeDevices[$dev_id['name']]['address']; $dev_id['new_hw'] = 'N'; // No further action required on this active device - unset($activeDevices[$id_name]); - } else { - // Device is in db but not connected - $dev_id['status'] = 'not connected'; - $dev_id['address'] = '- -'; + unset($activeDevices[$dev_id['name']]); } } unset($dev_id); // unset reference. diff --git a/views/hardware.phone.php b/views/hardware.phone.php index d350909..6f24829 100644 --- a/views/hardware.phone.php +++ b/views/hardware.phone.php @@ -31,11 +31,14 @@ - +
- +