Finalise display and saving of daysdisplaynotactive
This commit is contained in:
parent
70e972b786
commit
14d9dfdf98
|
@ -385,86 +385,83 @@ class formcreate
|
||||||
$usingSysDefaults = false;
|
$usingSysDefaults = false;
|
||||||
}
|
}
|
||||||
if (!empty($sccp_defaults[$res_n]['systemdefault'])) {
|
if (!empty($sccp_defaults[$res_n]['systemdefault'])) {
|
||||||
// There is a system default, so add button to customise or reset
|
// There is a system default, so add button to customise or reset
|
||||||
// the closing } is after the code to include the button at line ~427
|
// the closing } is after the code to include the button at line ~427
|
||||||
|
|
||||||
//-- Start include of defaults button --
|
//-- Start include of defaults button --
|
||||||
echo "<div class='col-md-3'>";
|
echo "<div class='col-md-3'>";
|
||||||
// Output current value
|
// Output current value
|
||||||
echo $res_v;
|
echo $res_v;
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<span class="radioset">
|
<span class="radioset">
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
<?php
|
<?php
|
||||||
echo " data-for={$res_id} data-type=radio id=usedefault_{$res_id} ";
|
echo " data-for={$res_id} data-type=radio id=usedefault_{$res_id} ";
|
||||||
if ($usingSysDefaults) {
|
if ($usingSysDefaults) {
|
||||||
// Setting a site specific value
|
$res_v = $sccp_defaults[$res_n]['systemdefault'];
|
||||||
echo " class=sccp-edit :checked ";
|
// Setting a site specific value
|
||||||
} else {
|
echo " class=sccp-edit :checked ";
|
||||||
// reverting to chan-sccp default values
|
} else {
|
||||||
echo " data-default={$sccp_defaults[$res_n]['systemdefault']} class=sccp-restore ";
|
// reverting to chan-sccp default values
|
||||||
}
|
echo " data-default={$sccp_defaults[$res_n]['systemdefault']} class=sccp-restore ";
|
||||||
?>
|
}
|
||||||
>
|
?>
|
||||||
<label
|
>
|
||||||
<?php
|
<label
|
||||||
echo "for=usedefault_{$res_id} >";
|
<?php
|
||||||
echo ($usingSysDefaults) ? "Customise" : "Use {$this->buttonDefLabel} defaults";
|
echo "for=usedefault_{$res_id} >";
|
||||||
?>
|
echo ($usingSysDefaults) ? "Customise" : "Use {$this->buttonDefLabel} defaults";
|
||||||
</label>
|
?>
|
||||||
</span>
|
</label>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<!-- <div class="row" id="edit_<?php echo $res_id; ?>" style="display: none"> -->
|
||||||
<!-- <div class="row" id="edit_<?php echo $res_id; ?>" style="display: none"> -->
|
<div class="row" id="edit_<?php echo $res_id; ?>" style="display: none">
|
||||||
<div class="row" id="edit_<?php echo $res_id; ?>" style="display: none">
|
<div class="form-group <?php echo $res_id; ?>">
|
||||||
<div class="form-group <?php echo $res_id; ?>">
|
<div class="col-md-3">
|
||||||
<div class="col-md-3">
|
<i><?php echo "Choose new {$this->buttonHelpLabel} value for {$res_n}"; ?></i>
|
||||||
<i><?php echo "Choose new {$this->buttonHelpLabel} value for {$res_n}"; ?></i>
|
</div>
|
||||||
</div>
|
<!-- Finish include of defaults button -->
|
||||||
<!-- Finish include of defaults button -->
|
|
||||||
<?php
|
<?php
|
||||||
// Close the conditional include of the defaults button opened at line ~385
|
// Close the conditional include of the defaults button opened at line ~385
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="col-md-9 radioset " data-hide="on">
|
<div class="col-md-9 radioset " data-hide="on">
|
||||||
|
<?php
|
||||||
<?php
|
$opt_hide = (!empty($child->option_hide)) ? ' class="sccp_button_hide" data-vhide="'.$child->option_hide.'" data-clhide="'.$child->option_hide['class'].'" ' : '';
|
||||||
$i = 0;
|
|
||||||
$opt_hide = '';
|
|
||||||
|
|
||||||
if ($usingSysDefaults) {
|
|
||||||
$res_v = $sccp_defaults[$res_n]['systemdefault'];
|
|
||||||
}
|
|
||||||
if (!empty($child->option_hide)) {
|
|
||||||
$opt_hide = ' class="sccp_button_hide" data-vhide="'.$child->option_hide.'" data-clhide="'.$child->option_hide['class'].'" ';
|
|
||||||
}
|
|
||||||
if (!empty($child->option_show)) {
|
if (!empty($child->option_show)) {
|
||||||
if (empty($opt_hide)) {
|
if (empty($opt_hide)) {
|
||||||
$opt_hide =' class="sccp_button_hide" ';
|
$opt_hide =' class="sccp_button_hide" ';
|
||||||
}
|
}
|
||||||
$opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" ';
|
$opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" ';
|
||||||
}
|
}
|
||||||
|
if ($res_id == 'sccpdevice_daysdisplaynotactive') {
|
||||||
|
// This is a multi select button list for daysDisplayNotActive which is an
|
||||||
|
// exception - its values are in a csv list - 1,2,7 for example
|
||||||
|
$currentValue = array();
|
||||||
|
foreach (explode(',',$res_v) as $resValue) {
|
||||||
|
$currentValue[$resValue - 1] = $resValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$i = 0;
|
||||||
foreach ($child->xpath('button') as $value) {
|
foreach ($child->xpath('button') as $value) {
|
||||||
$opt_disabled = '';
|
$opt_disabled = (in_array($value, $disabledButtons )) ? 'disabled' : '';
|
||||||
if (in_array($value, $disabledButtons )) {
|
$valToCheck = strtolower((string)$value[@value]);
|
||||||
$opt_disabled = 'disabled';
|
// TODO: Matching empty values - is this required?
|
||||||
}
|
$val_check = (($valToCheck == strtolower($res_v)) || ($valToCheck == '' && $res_v == '' )) ? 'checked' : '';
|
||||||
$val_check = strtolower((string)$value[@value]);
|
$tmpName = $res_id;
|
||||||
if ($val_check == strtolower($res_v)) {
|
if ($res_id == 'sccpdevice_daysdisplaynotactive') {
|
||||||
$val_check = "checked";
|
if (isset($currentValue[$i])) {
|
||||||
|
$val_check = (($valToCheck == strtolower($currentValue[$i])) || ($valToCheck == '' && $currentValue[$i] == '' )) ? 'checked' : '';
|
||||||
|
}
|
||||||
|
echo "<input type=checkbox name= ${res_id}_{$i} id=${res_id}_{$i} value='{$value[@value]}' {$val_check} {$opt_hide} {$opt_disabled}>";
|
||||||
} else {
|
} else {
|
||||||
if ($val_check == '' || $val_check == 'none' ) {
|
echo "<input type=radio name= {$res_id} id=${res_id}_{$i} value='{$value[@value]}' {$val_check} {$opt_hide} {$opt_disabled}>";
|
||||||
if (strtolower($res_v) == 'none' || $res_v == '' ) {
|
|
||||||
$val_check = "checked";
|
|
||||||
} else {$val_check = "";}
|
|
||||||
} else {$val_check = "";}
|
|
||||||
}
|
}
|
||||||
$tmpName = ($res_id == 'sccpdevice_daysdisplaynotactive') ? "${res_id}_{$i}" : $res_id;
|
|
||||||
echo "<input type=radio name= {$tmpName} id=${res_id}_{$i} value='{$value[@value]}' {$val_check} {$opt_hide} {$opt_disabled}>";
|
|
||||||
echo "<label for= {$res_id}_{$i}>{$value}</label>";
|
echo "<label for= {$res_id}_{$i}>{$value}</label>";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
@ -476,7 +473,6 @@ class formcreate
|
||||||
<span id="<?php echo $res_id;?>-help" class="help-block fpbx-help-block"><?php echo _($child->help);?></span>
|
<span id="<?php echo $res_id;?>-help" class="help-block fpbx-help-block"><?php echo _($child->help);?></span>
|
||||||
</div></div>
|
</div></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -366,6 +366,11 @@ trait ajaxHelper {
|
||||||
foreach (array('sccpdevice', 'sccpline') as $tableName) {
|
foreach (array('sccpdevice', 'sccpline') as $tableName) {
|
||||||
$key = (str_replace("{$tableName}_", '', $key, $count_mods));
|
$key = (str_replace("{$tableName}_", '', $key, $count_mods));
|
||||||
if ($count_mods) {
|
if ($count_mods) {
|
||||||
|
$searchArr = ['daysdisplaynotactive_0', 'daysdisplaynotactive_1', 'daysdisplaynotactive_2', 'daysdisplaynotactive_3', 'daysdisplaynotactive_4', 'daysdisplaynotactive_5', 'daysdisplaynotactive_6'];
|
||||||
|
if (in_array($key, $searchArr, true)) {
|
||||||
|
$key = 'daysdisplaynotactive';
|
||||||
|
$value = (isset($save_settings[$key])) ? $save_settings[$key]['data'] . ',' . $value : $value;
|
||||||
|
}
|
||||||
// Have default to be saved to db table default
|
// Have default to be saved to db table default
|
||||||
$tableName_def = "{$tableName}_def";
|
$tableName_def = "{$tableName}_def";
|
||||||
if ((array_key_exists($key, ${$tableName_def})) && (${$tableName_def}[$key]['data'] == $value)) {
|
if ((array_key_exists($key, ${$tableName_def})) && (${$tableName_def}[$key]['data'] == $value)) {
|
||||||
|
@ -373,7 +378,7 @@ trait ajaxHelper {
|
||||||
} else {
|
} else {
|
||||||
$dbSaveArray[$key] = array('table' => $tableName, 'field' => $key, 'Default' => $value);
|
$dbSaveArray[$key] = array('table' => $tableName, 'field' => $key, 'Default' => $value);
|
||||||
// Save these settings to sccpsettings as backup - Doctrine overwrites defaults in installer.
|
// Save these settings to sccpsettings as backup - Doctrine overwrites defaults in installer.
|
||||||
$save_settings[$key]= ['keyword' => $key, 'seq' => 98, 'type' => 2, 'data' => $value, 'systemdefault' => ''];
|
$save_settings[$key]= ['keyword' => $key, 'seq' => $this->sccpvalues[$key]['seq'], 'type' => $this->sccpvalues[$key]['type'], 'data' => $value, 'systemdefault' => ''];
|
||||||
}
|
}
|
||||||
// If have matched on device, cannot match on line
|
// If have matched on device, cannot match on line
|
||||||
continue 2;
|
continue 2;
|
||||||
|
|
Loading…
Reference in a new issue