diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index c668cd0..0041013 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -160,7 +160,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * Generate Input elements in Html Code from sccpgeneral.xml */ - public function showGroup($group_name, $show_Header, $form_prefix = 'sccp', $form_values = array()) { + public function showGroup($group_name, $show_Header, $form_prefix = 'sccp', $form_values = array(), $defButton = '') { // load xml data - moved from Construct to simplify Construct. // TODO: This is static data so only load first time. Left as is for dbug. @@ -186,7 +186,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'fvalues' => $form_values, 'installedLangs' => $this->findInstLangs(), 'chanSccpHelp' => $this->sccpHelpInfo, - 'sccp_defaults' => $this->sccpvalues + 'sccp_defaults' => $this->sccpvalues, + 'defButton' => $defButton ) ); } diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 8052d27..e864a9f 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -1222,9 +1222,18 @@ function sleep(milliseconds) // custom values. Clicking on these buttons is handled by the 2 functions below. $(".sccp-restore").click(function() { //input is sent by data-for where for is an attribute + console.log('have click'); var id = $(this).data("for"), input = $("#" + id); + console.log('id ' + id); + console.log('input ' + input); var edit_style = document.getElementById("edit_" + id).style; + console.log('edit style ' + edit_style); input = document.getElementsByName(id); + console.log(input); + input = $("input[id^=" + id); + console.log(input); + //input = document.querySelectorAll("[id^=" + id])); + //console.log(input); if (input.length === 0) { return; } @@ -1236,7 +1245,7 @@ $(".sccp-restore").click(function() { var defaultVal = $(this).data("default"); if ($(this).data("type") === 'radio') { // simulate read only for checkboxes except default - input.forEach( + input.each( function(radioElement) { radioElement.setAttribute('disabled', true); if (radioElement.value === defaultVal){ diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php index 5c21ffc..3c6c1d7 100644 --- a/sccpManClasses/formcreate.class.php +++ b/sccpManClasses/formcreate.class.php @@ -337,11 +337,14 @@ class formcreate buttonDefLabel = 'site'; - $this->buttonHelpLabel = 'device'; - } + function addElementIS($child, $fvalues, $sccp_defaults,$npref, $disabledButtons, $defButton = '') { + if ($npref == 'sccp_hw_') { + $this->buttonDefLabel = 'site'; + $this->buttonHelpLabel = 'device'; + } + if ($defButton == 'site'){ + $this->buttonDefLabel = 'site'; + } $res_n = (string)$child->name; $res_id = $npref.$res_n; $res_ext = str_replace($npref,'',$res_n); @@ -384,8 +387,12 @@ class formcreate if ($sccp_defaults[$res_n]['systemdefault'] != $res_v) { $usingSysDefaults = false; } - if (!empty($sccp_defaults[$res_n]['systemdefault'])) { - // There is a system default, so add button to customise or reset + if ($sccp_defaults[$res_n]['data'] != $res_v) { + $usingSiteDefaults = false; + } + + if ((!empty($sccp_defaults[$res_n]['systemdefault'])) || ($defButton == 'site')) { + // There is a system default, or we are referencing site defaults, so add button to customise or reset // the closing } is after the code to include the button at line ~427 //-- Start include of defaults button -- @@ -403,16 +410,24 @@ class formcreate $res_v = $sccp_defaults[$res_n]['systemdefault']; // Setting a site specific value echo " class=sccp-edit :checked "; + } else if ($usingSiteDefaults) { + $res_v = $sccp_defaults[$res_n]['data']; + // Setting a site specific value + echo " class=sccp-edit :checked "; } else { - // reverting to chan-sccp default values - echo " data-default={$sccp_defaults[$res_n]['systemdefault']} class=sccp-restore "; + // reverting to chan-sccp or site default values + if ($defButton == 'site') { + echo " data-default={$sccp_defaults[$res_n]['data']} class=sccp-restore "; + } else { + echo " data-default={$sccp_defaults[$res_n]['systemdefault']} class=sccp-restore "; + } } ?> > diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 823d002..262a552 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -538,7 +538,7 @@ trait ajaxHelper { } } foreach ($db_field as $key) { - $value = ""; + $value = ''; switch ($key) { case 'name': if (!empty($get_settings[$hdr_prefix . 'mac'])) { @@ -553,10 +553,8 @@ trait ajaxHelper { $name_dev = $value; } break; - case 'daysdisplaynotactive' : $searchArr = ['daysdisplaynotactive_0', 'daysdisplaynotactive_1', 'daysdisplaynotactive_2', 'daysdisplaynotactive_3', 'daysdisplaynotactive_4', 'daysdisplaynotactive_5', 'daysdisplaynotactive_6']; - $value = ''; foreach ($searchArr as $settingsVal) { $value .= (isset($get_settings["sccpdevice_${settingsVal}"])) ? $get_settings["sccpdevice_${settingsVal}"] . ',' : ''; } diff --git a/views/form.adddevice.php b/views/form.adddevice.php index 73d30d3..3e11346 100644 --- a/views/form.adddevice.php +++ b/views/form.adddevice.php @@ -120,7 +120,7 @@ if (!empty($def_val['type']['data'])) { } echo $this->showGroup('sccp_hw_dev2', 1, 'sccp_hw', $def_val); echo $this->showGroup('sccp_hw_dev_advance', 1, 'sccp_hw', $def_val); - echo $this->showGroup('sccp_dev_vendor_display_conf', 1, 'sccpdevice', $def_val); + echo $this->showGroup('sccp_dev_vendor_display_conf', 1, 'sccpdevice', $def_val, 'site'); echo $this->showGroup('sccp_hw_dev_softkey', 1, 'sccp_hw', $def_val); echo $this->showGroup('sccp_hw_dev_conference', 1, 'sccp_hw', $def_val); echo $this->showGroup('sccp_dev_vendor_conf', 1, 'vendorconfig', $def_val); diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index 055edaa..034cf74 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -28,7 +28,6 @@ if (empty($form_prefix)) { // $npref = 'vendorconfig'; // $napref = 'vendorconfig-ar'; } - if (empty($fvalues)) { $fvalues = $sccp_defaults; } @@ -71,7 +70,7 @@ foreach ($items as $child) { $disabledButtons = array('off' => 'Off'); } case 'IS': - $sccpManager->formcreate->addElementIS($child, $fvalues, $sccp_defaults,$npref, $disabledButtons); + $sccpManager->formcreate->addElementIS($child, $fvalues, $sccp_defaults,$npref, $disabledButtons, $defButton); break; case 'SLD': case 'SLM':