Update Phone Types when new device found via hotline

Enable the device in Phone Types to avoid unnecessary fw/templates not found warnings
This commit is contained in:
stevenA 2022-01-19 16:35:28 +01:00
parent b646f4c31f
commit 7caf060e4a
3 changed files with 11 additions and 3 deletions

View file

@ -499,6 +499,7 @@ trait ajaxHelper {
} }
function saveSccpDevice($get_settings, $validateonly = false) { function saveSccpDevice($get_settings, $validateonly = false) {
dbug($get_settings);
$hdr_prefix = 'sccp_hw_'; $hdr_prefix = 'sccp_hw_';
$hdr_arprefix = 'sccp_hw-ar_'; $hdr_arprefix = 'sccp_hw-ar_';
$hdr_vendPrefix = 'vendorconfig_'; $hdr_vendPrefix = 'vendorconfig_';

View file

@ -42,6 +42,9 @@ trait bmoFunctions {
return $dbDevices; //this may be empty return $dbDevices; //this may be empty
} }
//$testData = $this->aminterface->sccp_getdevice_info('SEP0019305DC7F4');
//dbug($testData);
foreach ($dbDevices as &$dev_id) { foreach ($dbDevices as &$dev_id) {
if (!empty($activeDevices[$dev_id['name']])) { if (!empty($activeDevices[$dev_id['name']])) {
// Device is in db and is connected // Device is in db and is connected
@ -69,8 +72,12 @@ trait bmoFunctions {
} }
$dev_schema = $this->getSccpModelInformation('byciscoid', false, "all", array('model' => $dev_data['SCCP_Vendor']['model_id'])); $dev_schema = $this->getSccpModelInformation('byciscoid', false, "all", array('model' => $dev_data['SCCP_Vendor']['model_id']));
if (empty($dev_schema)) { if (empty($dev_schema)) {
$dev_schema[0]['model'] = "ERROR in Model Schema"; $dev_schema[0]['model'] = "Model ${dev_data['SCCP_Vendor']['model_id']} not found in model Database";
} else if ( $dev_schema[0]['enabled' == 0]) {
// Need to enable this model in phone types
$this->dbinterface->write('sccpdevmodel', array('model'=> $dev_data['SCCP_Vendor']['model_id'], 'enabled = 1'), 'update' , 'model');
} }
$dbDevices[] = array( $dbDevices[] = array(
'name' => $id_name, 'name' => $id_name,
'mac' => $id_name, 'mac' => $id_name,

View file

@ -31,7 +31,7 @@
<th data-sortable="true" data-field="name"><?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="SipDisplayTypeFormatter" data-field="type"><?php echo _('Device type') ?></th> <th data-sortable="true" data-formatter="SipDisplayTypeFormatter" 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="SipLineFormatter"><?php echo _('Line') ?></th>
<th data-sortable="true" data-field="status"><?php echo _('Status') ?></th> <th data-sortable="true" data-field="status"><?php echo _('Status') ?></th>
<th data-sortable="true" data-field="address"><?php echo _('Address') ?></th> <th data-sortable="true" data-field="address"><?php echo _('Address') ?></th>
<th data-field="actions" data-formatter="SipDisplayDeviceActionsKeyFormatterS"><?php echo _('Actions') ?></th> <th data-field="actions" data-formatter="SipDisplayDeviceActionsKeyFormatterS"><?php echo _('Actions') ?></th>
@ -76,7 +76,7 @@
} }
return exp_model; return exp_model;
} }
function LineFormatter(value, row, index) { function SipLineFormatter(value, row, index) {
if (value === null) { if (value === null) {
return '-- EMPTY --'; return '-- EMPTY --';
} }