Create new function to get device defaults

Add new function in helperFunctions and use
This commit is contained in:
steve-lad 2021-06-17 10:18:07 +02:00
parent a146cd2354
commit 416cedc425
3 changed files with 14 additions and 14 deletions

View file

@ -69,6 +69,16 @@ trait helperfunctions {
}
return FALSE;
}
private function getDeviceDefaults() {
$def_val = array();
$sccpDeviceDesc = $this->dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice');
foreach ($sccpDeviceDesc as $data) {
$key = (string) $data['Field'];
$def_val[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99");
}
return $def_val;
}
private function findAllFiles($dir, $file_mask = null, $mode = 'full') {
$result = null;

View file

@ -37,13 +37,8 @@ if (!empty($_REQUEST['new_id'])) {
}
}
if (empty($_REQUEST['id'])) {
// Adding new device to database
$sccpDeviceDesc = $this->dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice');
foreach ($sccpDeviceDesc as $data) {
$key = (string) $data['Field'];
$def_val[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99");
}
// Adding new device to database. Get default values
$def_val = $this->getDeviceDefaults();
} else {
// Editing an existing Device
$dev_id = $_REQUEST['id'];

View file

@ -14,15 +14,10 @@
// originally, this was populated by sccpgeneral.xml but that should be static
// now will populate from the db defaults.
$defaultVal = array();
$sccpDeviceDesc = $this->dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice');
$defaultVals = $this->getDeviceDefaults();
foreach ($sccpDeviceDesc as $data) {
$key = (string) $data['Field'];
$defaultVal[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99");
}
echo $this->showGroup('sccp_srst', 1);
echo $this->showGroup('sccp_dev_vendor_conf', 1,'vendorconfig',$defaultVal,false);
echo $this->showGroup('sccp_dev_vendor_conf', 1,'vendorconfig',$defaultVals,false);
?>
</form>