Simplify getPhoneGrid
This commit is contained in:
parent
4ffcfaf6b7
commit
6775b6686b
|
@ -69,14 +69,15 @@ class dbinterface
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'phoneGrid':
|
case 'phoneGrid':
|
||||||
$fld = 'name, name as mac, type, button, addon, description';
|
|
||||||
switch ($data['type']) {
|
switch ($data['type']) {
|
||||||
case "cisco-sip":
|
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;
|
break;
|
||||||
case "sccp": // Fall through to default intentionally
|
case "sccp": // Fall through to default intentionally
|
||||||
default:
|
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;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -315,6 +315,7 @@ trait ajaxHelper {
|
||||||
$dbDevices = array();
|
$dbDevices = array();
|
||||||
// Find all devices defined in the database.
|
// Find all devices defined in the database.
|
||||||
$dbDevices = $this->dbinterface->getSccpDeviceTableData('phoneGrid', array('type' => $request['type']));
|
$dbDevices = $this->dbinterface->getSccpDeviceTableData('phoneGrid', array('type' => $request['type']));
|
||||||
|
|
||||||
// Return if only interested in SIP devices
|
// Return if only interested in SIP devices
|
||||||
if ($request['type'] == 'cisco-sip') {
|
if ($request['type'] == 'cisco-sip') {
|
||||||
return $dbDevices; //this may be empty
|
return $dbDevices; //this may be empty
|
||||||
|
@ -323,19 +324,14 @@ trait ajaxHelper {
|
||||||
$activeDevices = $this->aminterface->sccp_get_active_device();
|
$activeDevices = $this->aminterface->sccp_get_active_device();
|
||||||
|
|
||||||
foreach ($dbDevices as &$dev_id) {
|
foreach ($dbDevices as &$dev_id) {
|
||||||
$id_name = $dev_id['mac'];
|
if (!empty($activeDevices[$dev_id['name']])) {
|
||||||
if (!empty($activeDevices[$id_name])) {
|
|
||||||
// Device is in db and is connected
|
// Device is in db and is connected
|
||||||
$dev_id['description'] = $activeDevices[$id_name]['descr'];
|
$dev_id['description'] = $activeDevices[$dev_id['name']]['descr'];
|
||||||
$dev_id['status'] = $activeDevices[$id_name]['status'];
|
$dev_id['status'] = $activeDevices[$dev_id['name']]['status'];
|
||||||
$dev_id['address'] = $activeDevices[$id_name]['address'];
|
$dev_id['address'] = $activeDevices[$dev_id['name']]['address'];
|
||||||
$dev_id['new_hw'] = 'N';
|
$dev_id['new_hw'] = 'N';
|
||||||
// No further action required on this active device
|
// No further action required on this active device
|
||||||
unset($activeDevices[$id_name]);
|
unset($activeDevices[$dev_id['name']]);
|
||||||
} else {
|
|
||||||
// Device is in db but not connected
|
|
||||||
$dev_id['status'] = 'not connected';
|
|
||||||
$dev_id['address'] = '- -';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($dev_id); // unset reference.
|
unset($dev_id); // unset reference.
|
||||||
|
|
|
@ -31,11 +31,14 @@
|
||||||
<i class="glyphicon glyphicon-ok"></i> <span><?php echo _('Reset Token Device') ?></span>
|
<i class="glyphicon glyphicon-ok"></i> <span><?php echo _('Reset Token Device') ?></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th data-checkbox="true"></th>
|
<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-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-formatter="DispayTypeFormatter" data-field="type"><?php echo _('Device type') ?></th>
|
||||||
<th data-sortable="true" data-field="button" data-formatter="LineFormatter"><?php echo _('Line') ?></th>
|
<th data-sortable="true" data-field="button" data-formatter="LineFormatter"><?php echo _('Line') ?></th>
|
||||||
|
|
Loading…
Reference in a new issue