Fix Fill Phone status column

Add db query to include mac to allow join with ami active device data
Change output fields
This commit is contained in:
steve-lad 2021-07-20 18:03:44 +02:00
parent 65f3a6cd37
commit 97c1395eb1
3 changed files with 28 additions and 4 deletions

View file

@ -47,12 +47,19 @@ class dbinterface
public function getSccpDeviceTableData($dataid, $data = array()) public function getSccpDeviceTableData($dataid, $data = array())
{ {
// $stmt is a single row fetch, $stmts is a fetchAll. // $stmt is a single row fetch, $stmts is a fetchAll.
dbug($dataid);
dbug($data);
$stmt = ''; $stmt = '';
$stmts = ''; $stmts = '';
if ($dataid == '') { if ($dataid == '') {
return false; return false;
} }
switch ($dataid) { switch ($dataid) {
case 'sccp':
// 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');
break;
case 'SccpExtension': case 'SccpExtension':
if (empty($data['name'])) { if (empty($data['name'])) {
$stmts = $this->db->prepare('SELECT * FROM sccpline ORDER BY name'); $stmts = $this->db->prepare('SELECT * FROM sccpline ORDER BY name');

View file

@ -290,11 +290,28 @@ trait ajaxHelper {
return $result; return $result;
break; break;
case 'getExtensionGrid': case 'getExtensionGrid':
$result = $this->dbinterface->getSccpDeviceTableData('SccpExtension'); $lineList = $this->dbinterface->getSccpDeviceTableData($request['type']);
if (empty($result)) { if (empty($lineList)) {
return array(); return array();
} }
return $result; dbug($lineList);
$activeDevices = $this->aminterface->sccp_get_active_device();
dbug($activeDevices);
if (!empty($activeDevices)) {
foreach ($lineList as $key => $lineArr) {
if (isset($activeDevices[$lineArr['mac']])) {
$tpm_info = $activeDevices[$lineArr['mac']];
if (!empty($tpm_info)) {
$lineList[$key]['line_status'] = $tpm_info['status'];
$lineList[$key]['line_status'] .= " | {$tpm_info['act']}";
} else {
$lineList[$key]['line_status'] = '';
$lineList[$key]['line_status'] .= '|';
}
}
}
}
return $lineList;
break; break;
case 'getPhoneGrid': case 'getPhoneGrid':
$dbDevices = array(); $dbDevices = array();

View file

@ -26,7 +26,7 @@ if (!empty($this->sccpvalues['system_rouminguser'])) {
<!-- <th data-checkbox="true"></th> --> <!-- <th data-checkbox="true"></th> -->
<th data-sortable="true" data-field="name"><?php echo _('Extension') ?></th> <th data-sortable="true" data-field="name"><?php echo _('Extension') ?></th>
<th data-sortable="true" data-field="label"><?php echo _('Display Name') ?></th> <th data-sortable="true" data-field="label"><?php echo _('Display Name') ?></th>
<th data-sortable="true" data-field="line_statustext"><?php echo _('Status') ?></th> <th data-sortable="true" data-field="line_status"><?php echo _('Status | Active') ?></th>
<th data-field="actions" data-formatter="DispayPhoneActionsKeyFormatter"><?php echo _('Actions') ?></th> <th data-field="actions" data-formatter="DispayPhoneActionsKeyFormatter"><?php echo _('Actions') ?></th>
</tr> </tr>
</thead> </thead>