Add butons 'Internal', 'Inherit'

This commit is contained in:
PhantomVl 2017-11-15 14:06:32 +03:00
parent e41476560c
commit aff9404d6c
7 changed files with 1135 additions and 681 deletions

View file

@ -914,22 +914,43 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
} }
if (!empty($get_settings[$hdr_arprefix . $key])) { if (!empty($get_settings[$hdr_arprefix . $key])) {
$arr_data = ''; $arr_data = '';
$arr_clear = FALSE;
foreach ($get_settings[$hdr_arprefix . $key] as $vkey => $vval) { foreach ($get_settings[$hdr_arprefix . $key] as $vkey => $vval) {
$tmp_data = ''; $tmp_data = '';
foreach ($vval as $vkey => $vval) { foreach ($vval as $vkey => $vval) {
switch ($vkey) {
case 'inherit':
if ($vval=='on') {
$arr_clear = TRUE; ;
}
break;
case 'internal':
if ($vval=='on') {
$tmp_data .= 'internal;';
}
break;
default:
$tmp_data .= $vval . '/'; $tmp_data .= $vval . '/';
break;
}
} }
if (strlen($tmp_data) > 2) { if (strlen($tmp_data) > 2) {
if (substr($tmp_data,-1)=='/') { while (substr($tmp_data,-1)=='/') {
$tmp_data = substr($tmp_data, 0, -1); $tmp_data = substr($tmp_data, 0, -1);
} }
$arr_data .= substr($tmp_data, 0, -1) . ';'; $arr_data .= $tmp_data . ';';
} }
} }
while (substr($arr_data,-1)==';') {
$arr_data = substr($arr_data, 0, -1); $arr_data = substr($arr_data, 0, -1);
}
if ($arr_clear) {
$value = 'NONE';
} else {
$value = $arr_data; $value = $arr_data;
} }
} }
}
if (!empty($value)) { if (!empty($value)) {
$save_settings[$key] = $value; $save_settings[$key] = $value;
} }
@ -1078,13 +1099,28 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
foreach ($value as $vkey => $vval) { foreach ($value as $vkey => $vval) {
$tmp_data = ''; $tmp_data = '';
foreach ($vval as $vkey => $vval) { foreach ($vval as $vkey => $vval) {
switch ($vkey) {
case 'inherit':
case 'internal':
if ($vval=='on') {
$tmp_data .= 'internal;';
}
break;
default:
$tmp_data .= $vval . '/'; $tmp_data .= $vval . '/';
break;
}
} }
if (strlen($tmp_data) > 2) { if (strlen($tmp_data) > 2) {
$arr_data .= substr($tmp_data, 0, -1) . ';'; while (substr($tmp_data,-1)=='/') {
$tmp_data = substr($tmp_data, 0, -1);
}
$arr_data .= $tmp_data. ';';
} }
} }
while (substr($arr_data,-1)==';') {
$arr_data = substr($arr_data, 0, -1); $arr_data = substr($arr_data, 0, -1);
}
if (!($this->sccpvalues[$key1]['data'] == $arr_data)) { if (!($this->sccpvalues[$key1]['data'] == $arr_data)) {
$save_settings[] = array('keyword' => $this->sccpvalues[$key1]['keyword'], 'data' => $arr_data, $save_settings[] = array('keyword' => $this->sccpvalues[$key1]['keyword'], 'data' => $arr_data,
'seq' => $this->sccpvalues[$key1]['seq'], 'type' => $this->sccpvalues[$key1]['type']); 'seq' => $this->sccpvalues[$key1]['seq'], 'type' => $this->sccpvalues[$key1]['type']);

View file

@ -309,6 +309,9 @@ $(document).ready(function () {
var dev_id = $(this).data('vhide'); var dev_id = $(this).data('vhide');
var dev_class = $(this).data('clhide'); var dev_class = $(this).data('clhide');
var dev_val = $(this).val(); var dev_val = $(this).val();
if ($(this).data('btn') == 'checkbox') {
dev_val = $('input',this).is(":checked");
}
var dev_state = $(this).attr('checked'); var dev_state = $(this).attr('checked');
if (dev_state == 'checked'){ if (dev_state == 'checked'){
$(dev_class).each(function () { $(dev_class).each(function () {
@ -321,11 +324,13 @@ $(document).ready(function () {
}); });
} }
}); });
$('.sccp_button_hide').on('click', function (e) { $('.sccp_button_hide').on('click', function (e) {
var dev_id = $(this).data('vhide'); var dev_id = $(this).data('vhide');
var dev_class = $(this).data('clhide'); var dev_class = $(this).data('clhide');
var dev_val = $(this).val(); var dev_val = $(this).val();
if ($(this).data('btn') == 'checkbox') {
dev_val = $('input',this).is(":checked");
}
$(dev_class).each(function () { $(dev_class).each(function () {
if (dev_val != dev_id) { if (dev_val != dev_id) {
$(this).removeClass('hidden'); $(this).removeClass('hidden');
@ -336,6 +341,56 @@ $(document).ready(function () {
}); });
}); });
$('.sccp_button_disabled').each(function () { // On page create !!
var dev_id = $(this).data('vhide');
var dev_class = $(this).data('clhide');
var dev_val = $(this).val();
if ($(this).data('btn') == 'checkbox') {
dev_val = $('input',this).is(":checked");
}
$(dev_class).find('input, select, textarea, button').each(function() {
if (dev_val == dev_id) {
$(this).removeClass('disabled');
$(this).removeAttr('disabled')
} else {
$(this).addClass('disabled', true);
$(this).attr('disabled', 'disabled');
}
});
});
$('.sccp_button_disabled').on('click', function (e) {
var dev_id = $(this).data('vhide');
var dev_class = $(this).data('clhide');
var dev_val = $(this).val();
if ($(this).data('btn') == 'checkbox') {
dev_val = $('input',this).is(":checked");
}
$(dev_class).find('input, select, textarea, button').each(function() {
if (dev_val != dev_id) {
$(this).removeClass('disabled');
$(this).removeAttr('disabled')
} else {
$(this).addClass('disabled', true);
$(this).attr('disabled', 'disabled');
}
});
});
$('.button-checkbox').on('click', '', function (e) {
if ($('button',this).hasClass('active')) {
$('input', this).removeAttr('checked');
$('button',this).removeClass('active');
} else {
$('input', this).attr('checked');
$('input', this).prop('checked','true');
$('button',this).addClass('active');
}
});
// ----------------------- TEST Validate ---------------- // ----------------------- TEST Validate ----------------
$('.need-validate').on('change', function (e) { $('.need-validate').on('change', function (e) {
var dev_class = $(this).attr('class'); var dev_class = $(this).attr('class');

View file

@ -107,7 +107,7 @@ and open the template in the editor. Base Version before all crash :-)
<default>0.0.0.0/0.0.0.0</default> <default>0.0.0.0/0.0.0.0</default>
<input value="NONE" field="net" nameseparator="/"><options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/></input> <input value="NONE" field="net" nameseparator="/"><options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/></input>
<input value="NONE" field="mask"><options placeholder="255.255.255.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/> </input> <input value="NONE" field="mask"><options placeholder="255.255.255.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/> </input>
<button>Add Allow network</button> <addbutton>Add Allow network</addbutton>
<help>Allow network settings. Blank fields will be ignored, use Network 0.0.0.0.</help> <help>Allow network settings. Blank fields will be ignored, use Network 0.0.0.0.</help>
</item> </item>
@ -117,7 +117,7 @@ and open the template in the editor. Base Version before all crash :-)
<default>0.0.0.0/0.0.0.0</default> <default>0.0.0.0/0.0.0.0</default>
<input value="NONE" field="net" nameseparator="/"><options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/><class></class></input> <input value="NONE" field="net" nameseparator="/"><options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/><class></class></input>
<input value="NONE" field="mask"><options placeholder="255.255.255.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/><class></class></input> <input value="NONE" field="mask"><options placeholder="255.255.255.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/><class></class></input>
<button>Add Deny network</button> <addbutton>Add Deny network</addbutton>
<help>All RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'.</help> <help>All RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'.</help>
</item> </item>
@ -127,7 +127,7 @@ and open the template in the editor. Base Version before all crash :-)
<default>0.0.0.0/0.0.0.0</default> <default>0.0.0.0/0.0.0.0</default>
<input value="NONE" field="net" nameseparator="/"><options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$" /><class></class></input> <input value="NONE" field="net" nameseparator="/"><options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$" /><class></class></input>
<input value="NONE" field="mask"><options placeholder="255.255.255.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/> <class></class></input> <input value="NONE" field="mask"><options placeholder="255.255.255.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/> <class></class></input>
<button>Add local networks</button> <addbutton>Add local networks</addbutton>
<help>Local network settings. Blank fields will be ignored used Network 0.0.0.0.</help> <help>Local network settings. Blank fields will be ignored used Network 0.0.0.0.</help>
</item> </item>
@ -855,7 +855,7 @@ and open the template in the editor. Base Version before all crash :-)
<default>/</default> <default>/</default>
<input value="NONE" field="net" nameseparator="/"><options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/></input> <input value="NONE" field="net" nameseparator="/"><options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/></input>
<input value="NONE" field="mask"><options placeholder="255.255.255.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/> </input> <input value="NONE" field="mask"><options placeholder="255.255.255.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/> </input>
<button>Add Allow network</button> <addbutton>Add Allow network</addbutton>
<help>Allow network settings. Blank fields will be ignored used Network 0.0.0.0.</help> <help>Allow network settings. Blank fields will be ignored used Network 0.0.0.0.</help>
</item> </item>
@ -865,7 +865,7 @@ and open the template in the editor. Base Version before all crash :-)
<default>/</default> <default>/</default>
<input value="NONE" field="net" nameseparator="/"><options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/><class></class></input> <input value="NONE" field="net" nameseparator="/"><options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/><class></class></input>
<input value="NONE" field="mask"><options placeholder="255.255.255.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/><class></class></input> <input value="NONE" field="mask"><options placeholder="255.255.255.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/><class></class></input>
<button>Add Deny network</button> <addbutton>Add Deny network</addbutton>
<help>All RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'.</help> <help>All RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'.</help>
</item> </item>
<item type="IS" id="3" seq="99"> <item type="IS" id="3" seq="99">
@ -1005,7 +1005,7 @@ and open the template in the editor. Base Version before all crash :-)
<default>/</default> <default>/</default>
<input value="NONE" field="Addr" nameseparator=":"><options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$" /><class></class></input> <input value="NONE" field="Addr" nameseparator=":"><options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$" /><class></class></input>
<input value="NONE" field="port"><options placeholder="2000" pattern="^([0-9]){3,5}$"/> <class></class></input> <input value="NONE" field="port"><options placeholder="2000" pattern="^([0-9]){3,5}$"/> <class></class></input>
<button>Add Server</button> <addbutton>Add Server</addbutton>
<help></help> <help></help>
</item> </item>
<item type="IED-disabled" id="3" seq="20"> <item type="IED-disabled" id="3" seq="20">
@ -1015,7 +1015,7 @@ and open the template in the editor. Base Version before all crash :-)
<default>/</default> <default>/</default>
<input value="NONE" field="Addr" nameseparator=":"><options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$" /><class></class></input> <input value="NONE" field="Addr" nameseparator=":"><options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$" /><class></class></input>
<input value="NONE" field="port"><options placeholder="2000" pattern="^[0-9]{3,5}$"/> <class></class></input> <input value="NONE" field="port"><options placeholder="2000" pattern="^[0-9]{3,5}$"/> <class></class></input>
<button>Add Server</button> <addbutton>Add Server</addbutton>
<help></help> <help></help>
</item> </item>
</page_group> </page_group>

File diff suppressed because it is too large Load diff

View file

@ -93,11 +93,11 @@ function Get_DB_config($sccp_compatible) {
'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"), 'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"),
'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"), 'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"),
'transfer' => array('create' => 'VARCHAR(5) DEFAULT "on"', 'modify' => "VARCHAR(5)", 'def_modify' => "on"), 'transfer' => array('create' => 'VARCHAR(5) DEFAULT "on"', 'modify' => "VARCHAR(5)", 'def_modify' => "on"),
'cfwdall' => array('create' => 'VARCHAR(5) DEFAULT "on"', 'modify' => "VARCHAR(5)", 'def_modify' => "on"), 'cfwdall' => array('create' => 'VARCHAR(5) NULL DEFAULT "on"', 'modify' => "VARCHAR(5)", 'def_modify' => "on"),
'cfwdbusy' => array('create' => 'VARCHAR(5) DEFAULT "on"', 'modify' => "VARCHAR(5)", 'def_modify' => "on"), 'cfwdbusy' => array('create' => 'VARCHAR(5) NULL DEFAULT "on"', 'modify' => "VARCHAR(5)", 'def_modify' => "on"),
'directrtp' => array('create' => 'VARCHAR(3) DEFAULT "off"', 'modify' => "VARCHAR(3)", 'def_modify' => "off"), 'directrtp' => array('create' => 'VARCHAR(3) NULL DEFAULT "off"', 'modify' => "VARCHAR(3)", 'def_modify' => "off"),
'dndFeature' => array('create' => 'VARCHAR(5) DEFAULT "on"', 'modify' => "VARCHAR(5)", 'def_modify' => "on"), 'dndFeature' => array('create' => 'VARCHAR(5) NULL DEFAULT "on"', 'modify' => "VARCHAR(5)", 'def_modify' => "on"),
'earlyrtp' => array('create' => 'VARCHAR(10) DEFAULT "progress"', 'modify' => "VARCHAR(10)", 'def_modify' => "progress"), 'earlyrtp' => array('create' => 'VARCHAR(10) NULL DEFAULT "progress"', 'modify' => "VARCHAR(10)", 'def_modify' => "progress"),
'audio_tos' => array('def_modify' => "0xB8"), 'audio_tos' => array('def_modify' => "0xB8"),
'audio_cos' => array('def_modify' => "6"), 'audio_cos' => array('def_modify' => "6"),
'video_tos' => array('def_modify' => "0x88"), 'video_tos' => array('def_modify' => "0x88"),
@ -156,8 +156,8 @@ function Get_DB_config($sccp_compatible) {
'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"), 'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"),
'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"), 'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"),
'transfer' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), 'transfer' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"),
'cfwdall' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), 'cfwdall' => array('create' => "enum('on','off') NULL default 'on'", 'modify' => "enum('on','off')"),
'cfwdbusy' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), 'cfwdbusy' => array('create' => "enum('on','off') NULL default 'on'", 'modify' => "enum('on','off')"),
'directrtp' => array('create' => "enum('on','off') NULL default NULL", 'modify' => "enum('on','off')"), 'directrtp' => array('create' => "enum('on','off') NULL default NULL", 'modify' => "enum('on','off')"),
'dndFeature' => array('create' => "enum('on','off') NULL default NULL", 'modify' => "enum('on','off')"), 'dndFeature' => array('create' => "enum('on','off') NULL default NULL", 'modify' => "enum('on','off')"),
'earlyrtp' => array('create' => "ENUM('immediate','offHook','dialing','ringout','progress','none') NULL default NULL", 'modify' => "ENUM('immediate','offHook','dialing','ringout','progress','none')"), 'earlyrtp' => array('create' => "ENUM('immediate','offHook','dialing','ringout','progress','none') NULL default NULL", 'modify' => "ENUM('immediate','offHook','dialing','ringout','progress','none')"),

View file

@ -186,7 +186,45 @@ foreach ($items as $child) {
<label class="control-label" for="<?php echo $res_id; ?>"><?php echo _($child->label);?></label> <label class="control-label" for="<?php echo $res_id; ?>"><?php echo _($child->label);?></label>
<i class="fa fa-question-circle fpbx-help-icon" data-for="<?php echo $res_id; ?>"></i> <i class="fa fa-question-circle fpbx-help-icon" data-for="<?php echo $res_id; ?>"></i>
</div> </div>
<div class="col-md-9"><div class = "col-sm-7">
<div class="col-md-9">
<?php
if (!empty($child->cbutton)) {
echo '<div class="form-group form-inline">';
foreach ($child->xpath('cbutton') as $value) {
$res_n = $res_id.'[0]['.$value['field'].']';
$res_vf = '';
if ($value['value']=='NONE' && empty($res_value)){
$res_vf = 'active';
}
$ch_key = array_search($value['value'],$res_value);
if ($ch_key !== false) {
unset($res_value[$ch_key]);
$res_vf = 'active';
$res_value = explode(';', implode(';', $res_value));
}
$opt_hide ='';
$opt_class="button-checkbox";
if (!empty($value->option_hide)) {
$opt_class .= " sccp_button_hide";
$opt_hide = ' data-vhide="'.$value->option_hide.'" data-btn="checkbox" data-clhide="'.$value->option_hide['class'].'" ';
}
if (!empty($value->option_disabled)) {
$opt_class .= " sccp_button_disabled";
$opt_hide = ' data-vhide="'.$value->option_disabled.'" data-btn="checkbox" data-clhide="'.$value->option_disabled['class'].'" ';
}
if (!empty($value->class)) {
$opt_class .= " ".(string)$value->class;
}
echo '<span class="'.$opt_class.'"'.$opt_hide.'><button type="button" class="btn '.$res_vf.'" data-color="primary">'.$value.'</button>';
echo '<input type="checkbox" name="'. $res_n.'" class="hidden" '. (($res_vf == 'active')?'checked="checked"':'') .'/></span>';
}
echo '</div>';
}
?>
<div class = "col-sm-7 <?php echo $res_id;?>-gr">
<?php <?php
foreach ($res_value as $dat_v) { foreach ($res_value as $dat_v) {
?> ?>
@ -220,12 +258,12 @@ foreach ($items as $child) {
?> ?>
</div> </div>
<div class = "col-sm-5"> <div class = "col-sm-5 <?php echo $res_id;?>-gr">
<?php <?php
// print_r($opt_at); // print_r($opt_at);
// print_r(json_encode($opt_at)); // print_r(json_encode($opt_at));
// print_r(bin2hex(json_encode($opt_at))); // print_r(bin2hex(json_encode($opt_at)));
echo '<input type="button" id="'.$res_id.'-btn" data-id="'.$res_id.'" data-for="'.$res_id.'" data-max="'.$max_row.'"data-json="'.bin2hex(json_encode($opt_at)).'" class="input-js-add" value="'._($child->button).'" />'; echo '<input type="button" id="'.$res_id.'-btn" data-id="'.$res_id.'" data-for="'.$res_id.'" data-max="'.$max_row.'"data-json="'.bin2hex(json_encode($opt_at)).'" class="input-js-add" value="'._($child->addbutton).'" />';
?> ?>
</div> </div>
</div> </div>
@ -276,7 +314,13 @@ foreach ($items as $child) {
$opt_hide = ' class="sccp_button_hide" data-vhide="'.$child->option_hide.'" data-clhide="'.$child->option_hide['class'].'" '; $opt_hide = ' class="sccp_button_hide" data-vhide="'.$child->option_hide.'" data-clhide="'.$child->option_hide['class'].'" ';
} }
foreach ($child->xpath('button') as $value) { foreach ($child->xpath('button') as $value) {
echo '<input type="radio" name="' . $res_id . '" id="' . $res_id. '_' . $i .'" value="' . $value[@value] . '"' . (strtolower((string)$value[@value]) == strtolower($res_v) ? " checked" : "") . $opt_hide.'>'; $val_check = (string)$value[@value];
if ($val_check == '' || $val_check == 'NONE' || $val_check == 'none' ) {
$val_check = (((string)$value[@value] == $res_v) ? " checked" : "");
} else {
$val_check = (strtolower((string)$value[@value]) == strtolower($res_v) ? " checked" : "");
}
echo '<input type="radio" name="' . $res_id . '" id="' . $res_id. '_' . $i .'" value="' . $value[@value] . '"' . $val_check . $opt_hide.'>';
echo '<label for="' . $res_id. '_' . $i . '">' . _($value) . '</label>'; echo '<label for="' . $res_id. '_' . $i . '">' . _($value) . '</label>';
$i++; $i++;
} }

View file

@ -23,6 +23,8 @@ if (strlen($data) >0 ){
<?php <?php
echo $this->ShowGroup('sccp_dev_config',1); echo $this->ShowGroup('sccp_dev_config',1);
echo $this->ShowGroup('sccp_dev_advconfig',1);
echo $this->ShowGroup('sccp_dev_softkey',1);
echo $this->ShowGroup('sccp_dev_url',1); echo $this->ShowGroup('sccp_dev_url',1);
echo $this->ShowGroup('sccp_hotline_config',1); echo $this->ShowGroup('sccp_hotline_config',1);
?> ?>