From a4aa4eb03bae3fb9eaf9339818cac1c945f68636 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 21 Jul 2021 08:57:43 +0200 Subject: [PATCH] Simplify db queries and change alignment --- sccpManClasses/dbinterface.class.php | 14 +++++++++++++- sccpManTraits/ajaxHelper.php | 9 ++++----- views/hardware.extension.php | 4 ++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index f259558..b8b5077 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -55,7 +55,7 @@ class dbinterface return false; } switch ($dataid) { - case 'sccp': + case 'extGrid': // only called by getExtensionGrid from hardware.extension.php view $stmts = $this->db->prepare('SELECT sccpline.name, sccpline.label, sccpbuttonconfig.ref as mac FROM sccpline INNER JOIN sccpbuttonconfig ON sccpline.name=sccpbuttonconfig.name'); @@ -68,6 +68,18 @@ class dbinterface $stmts->bindParam(':name', $data['name'],\PDO::PARAM_STR); } break; + case 'phoneGrid': + $fld = 'name, name as mac, type, button, addon, _description as description'; + switch ($data['type']) { + case "cisco-sip": + $stmts = $this->db->prepare("SELECT {$fld} 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"); + break; + } + break; case 'SccpDevice': if (empty($data['fields'])) { $fld = 'name, name as mac, type, button, addon, _description as description'; diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 7db3732..938314d 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -315,19 +315,18 @@ trait ajaxHelper { break; case 'getPhoneGrid': $dbDevices = array(); - $cmd_type = !empty($request['type']) ? $request['type'] : ''; - // Find all devices defined in the database - $dbDevices = $this->dbinterface->getSccpDeviceTableData('SccpDevice', array('type' => $cmd_type)); + // Find all devices defined in the database. + $dbDevices = $this->dbinterface->getSccpDeviceTableData('phoneGrid', array('type' => $request['type'])); // Return if only interested in SIP devices - if ($cmd_type == 'cisco-sip') { + if ($request['type'] == 'cisco-sip') { return $dbDevices; //this may be empty } // Find all devices currently connected $activeDevices = $this->aminterface->sccp_get_active_device(); foreach ($dbDevices as &$dev_id) { - $id_name = $dev_id['name']; + $id_name = $dev_id['mac']; if (!empty($activeDevices[$id_name])) { // Device is in db and is connected $dev_id['description'] = $activeDevices[$id_name]['descr']; diff --git a/views/hardware.extension.php b/views/hardware.extension.php index d72b473..2f3b1ea 100644 --- a/views/hardware.extension.php +++ b/views/hardware.extension.php @@ -20,13 +20,13 @@ if (!empty($this->sccpvalues['system_rouminguser'])) {
-- | + |
---|