Simplify getPhoneGrid
This commit is contained in:
parent
4ffcfaf6b7
commit
6775b6686b
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -31,11 +31,14 @@
|
|||
<i class="glyphicon glyphicon-ok"></i> <span><?php echo _('Reset Token Device') ?></span>
|
||||
</button>
|
||||
</div>
|
||||
<table data-cookie="true" data-cookie-id-table="sccp-phone" data-url="ajax.php?module=sccp_manager&command=getPhoneGrid&type=sccp" data-cache="false" data-show-refresh="true" data-toolbar="#toolbar-sccp" data-maintain-selected="true" data-show-columns="true" data-show-toggle="true" data-toggle="table" data-pagination="true" data-search="true" class="table table-striped ext-list" id="table-sccp" data-id="mac">
|
||||
<table data-cookie="true" data-cookie-id-table="sccp-phone" data-url="ajax.php?module=sccp_manager&command=getPhoneGrid&type=sccp"
|
||||
data-cache="false" data-show-refresh="true" data-toolbar="#toolbar-sccp" data-maintain-selected="true"
|
||||
data-show-columns="true" data-show-toggle="true" data-toggle="table" data-pagination="true"
|
||||
data-search="true" class="table table-striped ext-list" id="table-sccp" data-id="name">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-checkbox="true"></th>
|
||||
<th data-sortable="true" data-field="mac"><?php echo _('Device ID') ?></th>
|
||||
<th data-sortable="true" data-field="name"><?php echo _('Device ID') ?></th>
|
||||
<th data-sortable="true" data-field="description"><?php echo _('Device Description') ?></th>
|
||||
<th data-sortable="true" data-formatter="DispayTypeFormatter" data-field="type"><?php echo _('Device type') ?></th>
|
||||
<th data-sortable="true" data-field="button" data-formatter="LineFormatter"><?php echo _('Line') ?></th>
|
||||
|
|
Loading…
Reference in a new issue