- Fix SCCP

- Fix SIP
This commit is contained in:
PhantomVl 2019-09-25 11:10:51 +03:00
parent 859d15e140
commit e4e720a182
7 changed files with 351 additions and 229 deletions

View file

@ -677,7 +677,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'sccp_reload')); $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'sccp_reload'));
// $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'restart_phone')); // $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'restart_phone'));
$msg = 'Config Saved: ' . $res['Response'] . '. Info :' . $res['data']; $msg = '<p>Config Saved: ' . $res['Response'] . ".</p> <p>Info :" . $res['data']."</p>";
// needreload(); // needreload();
// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) // !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg)
return array('status' => true, 'message' => $msg, 'reload' => true); return array('status' => true, 'message' => $msg, 'reload' => true);
@ -1934,6 +1934,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$dev_ext_config = $this->dbinterface->get_db_SccpTableData("SccpDevice", array('name' => $dev_id, 'fields'=>'sip_ext')); $dev_ext_config = $this->dbinterface->get_db_SccpTableData("SccpDevice", array('name' => $dev_id, 'fields'=>'sip_ext'));
$data_value = array_merge($data_value, $dev_ext_config); $data_value = array_merge($data_value, $dev_ext_config);
$data_tmp = explode(';',$dev_ext_config['sip_lines']); $data_tmp = explode(';',$dev_ext_config['sip_lines']);
$data_value['sbind']=array();
foreach ($data_tmp as $value) { foreach ($data_tmp as $value) {
$tmp_line = explode(',',$value); $tmp_line = explode(',',$value);
switch ($tmp_line[0]) { switch ($tmp_line[0]) {

View file

@ -80,6 +80,7 @@ class sipconfigs {
$tmp_bind_ip = !empty($tmp_sipsetigs['bindaddr']) ? $tmp_sipsetigs['bindaddr'] : $tmp_bind_ip; $tmp_bind_ip = !empty($tmp_sipsetigs['bindaddr']) ? $tmp_sipsetigs['bindaddr'] : $tmp_bind_ip;
*/ */
$tmp_binds = is_array($tmp_binds) ? $tmp_binds: array(); $tmp_binds = is_array($tmp_binds) ? $tmp_binds: array();
$result = array();
foreach($tmp_binds as $f_protocol => $f_bind) { foreach($tmp_binds as $f_protocol => $f_bind) {
foreach($f_bind as $f_ip => $f_port) { foreach($f_bind as $f_ip => $f_port) {
if (($f_ip == '0.0.0.0') || ($f_ip == '[::]')) { if (($f_ip == '0.0.0.0') || ($f_ip == '[::]')) {

View file

@ -1,4 +1,5 @@
$(document).ready(function () { $(document).ready(function () {
$('.sortable').sortable({ $('.sortable').sortable({
update: function (event, ui) { update: function (event, ui) {
// console.log(ui.item.find('input').val(), ui.item.index()) // console.log(ui.item.find('input').val(), ui.item.index())
@ -24,37 +25,37 @@ $(document).ready(function () {
} }
}); });
/* /*
$('#ajaxbackup').on('click', function (e) { $('#ajaxbackup').on('click', function (e) {
var vdata = ''; var vdata = '';
var snd_command = 'backupsettings'; var snd_command = 'backupsettings';
$('.fpbx-submit').each(function () { $('.fpbx-submit').each(function () {
vdata = vdata + $(this).serialize() + '&'; vdata = vdata + $(this).serialize() + '&';
}); });
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: 'ajax.php?module=sccp_manager&command=' + snd_command, url: 'ajax.php?module=sccp_manager&command=' + snd_command,
data: vdata, data: vdata,
success: function (data) { success: function (data) {
if (data.status === true) { if (data.status === true) {
if (data.message) { if (data.message) {
alert(data.message); alert(data.message);
} else { } else {
alert('Data Save'); alert('Data Save');
} }
} else { } else {
if (Array.isArray(data.message)) { if (Array.isArray(data.message)) {
data.message.forEach(function (entry) { data.message.forEach(function (entry) {
fpbxToast(entry, 'error', 'error'); fpbxToast(entry, 'error', 'error');
}); });
} }
} }
} }
}); });
}); });
*/ */
$('#ajaxsubmit2').on('click', function (e) { $('#ajaxsubmit2').on('click', function (e) {
var vdata = ''; var vdata = '';
var snd_command = 'savesettings'; var snd_command = 'savesettings';
@ -74,7 +75,7 @@ $(document).ready(function () {
if ($('.fpbx-submit').data('id') == "dial_template") { if ($('.fpbx-submit').data('id') == "dial_template") {
snd_command = 'save_dialplan_template'; snd_command = 'save_dialplan_template';
} }
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: 'ajax.php?module=sccp_manager&command=' + snd_command, url: 'ajax.php?module=sccp_manager&command=' + snd_command,
@ -82,9 +83,9 @@ $(document).ready(function () {
success: function (data) { success: function (data) {
if (data.status === true) { if (data.status === true) {
if (data.message) { if (data.message) {
alert(data.message); bs_alert(data.message);
} else { } else {
alert('Data Save'); bs_alert('Data Save');
} }
} else { } else {
if (Array.isArray(data.message)) { if (Array.isArray(data.message)) {
@ -122,7 +123,7 @@ $(document).ready(function () {
success: function (data) { success: function (data) {
if (data.status === true) { if (data.status === true) {
if (data.message) { if (data.message) {
alert(data.message); var old_style = bs_alert(data.message, data.reload);
} }
if (data.table_reload === true) { if (data.table_reload === true) {
$('table').bootstrapTable('refresh'); $('table').bootstrapTable('refresh');
@ -139,7 +140,8 @@ $(document).ready(function () {
if (data.search != null) { if (data.search != null) {
location.search = data.search; location.search = data.search;
} }
if (data.reload === true) { // if (data.reload === true ) {
if (data.reload === true && old_style ===true ) {
location.reload(); location.reload();
} }
@ -153,71 +155,71 @@ $(document).ready(function () {
} }
}); });
}); });
$(".input-js-add").click(function(){ $(".input-js-add").click(function () {
add_dynamic_input($(this),$(this).data('for'),"",""); add_dynamic_input($(this), $(this).data('for'), "", "");
}); });
$(".table").on('click','.table-js-add', function (e) { $(".table").on('click', '.table-js-add', function (e) {
add_dynamic_table($(this),$(this).data('for'),"",""); add_dynamic_table($(this), $(this).data('for'), "", "");
}); });
$(".table").on('click','.table-js-del', function (e) { $(".table").on('click', '.table-js-del', function (e) {
del_dynamic_table($(this),$(this).data('for')); del_dynamic_table($(this), $(this).data('for'));
}); });
$(".table").on('click','.btn-item-delete', function (e) { $(".table").on('click', '.btn-item-delete', function (e) {
var dev_cmd = ''; var dev_cmd = '';
var dev_id = $(this).data('id'); var dev_id = $(this).data('id');
var dev_for = $(this).data('for'); var dev_for = $(this).data('for');
var ext_data = ''; var ext_data = '';
if (dev_for =='softkeys') { if (dev_for == 'softkeys') {
dev_cmd = 'deleteSoftKey'; dev_cmd = 'deleteSoftKey';
ext_data = "softkey=" + dev_id; ext_data = "softkey=" + dev_id;
} }
if (dev_for =='model') { if (dev_for == 'model') {
dev_cmd = 'model_delete'; dev_cmd = 'model_delete';
ext_data = "model=" + dev_id; ext_data = "model=" + dev_id;
} }
if (dev_for =='dialplan') { if (dev_for == 'dialplan') {
dev_cmd = 'delete_dialplan'; dev_cmd = 'delete_dialplan';
ext_data = "dialplan=" + dev_id; ext_data = "dialplan=" + dev_id;
} }
if (dev_for =='hardware') { if (dev_for == 'hardware') {
dev_cmd = 'delete_hardware'; dev_cmd = 'delete_hardware';
ext_data = "idn[0]=" + dev_id; ext_data = "idn[0]=" + dev_id;
} }
// console.log("delete : " + data); // console.log("delete : " + data);
if (dev_cmd != '') { if (dev_cmd != '') {
if (confirm(_('Are you sure you wish to delete "' + dev_id.toString().toUpperCase() + '" inormation ?'))) { if (confirm(_('Are you sure you wish to delete "' + dev_id.toString().toUpperCase() + '" inormation ?'))) {
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: 'ajax.php?module=sccp_manager&command=' + dev_cmd, url: 'ajax.php?module=sccp_manager&command=' + dev_cmd,
command: dev_cmd, command: dev_cmd,
data: ext_data, data: ext_data,
success: function (data) { success: function (data) {
// console.log(data); // console.log(data);
if (data.status === true) { if (data.status === true) {
if (data.message) { if (data.message) {
alert(data.message); var old_style = bs_alert(data.message, data.reload);
} }
if (data.table_reload === true) { if (data.table_reload === true) {
$('table').bootstrapTable('refresh'); $('table').bootstrapTable('refresh');
} }
if (data.reload === true) { if (data.reload === true && old_style === true ) {
location.reload(); location.reload();
} }
} else { } else {
if (Array.isArray(data.message)) { if (Array.isArray(data.message)) {
data.message.forEach(function (entry) { data.message.forEach(function (entry) {
fpbxToast(entry, 'error', 'error'); fpbxToast(entry, 'error', 'error');
}); });
}
} }
} }
}
});
});
} }
} }
@ -348,18 +350,18 @@ $(document).ready(function () {
}); });
}); });
$('.sccp_button_hide').each(function () { // On page create !! $('.sccp_button_hide').each(function () { // On page create !!
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') { if ($(this).data('btn') == 'checkbox') {
dev_val = $('input',this).is(":checked"); 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 () {
if (dev_val != dev_id) { if (dev_val != dev_id) {
$(this).removeClass('hidden'); $(this).removeClass('hidden');
$(this).removeAttr('hidden') $(this).removeAttr('hidden')
} else { } else {
@ -367,41 +369,41 @@ $(document).ready(function () {
} }
}); });
} }
dev_id = $(this).data('vshow'); dev_id = $(this).data('vshow');
if (dev_state == 'checked'){ if (dev_state == 'checked') {
dev_class = $(this).data('clshow'); dev_class = $(this).data('clshow');
$(dev_class).each(function () { $(dev_class).each(function () {
if (dev_val == dev_id) { if (dev_val == dev_id) {
$(this).removeClass('hidden'); $(this).removeClass('hidden');
$(this).removeAttr('hidden') $(this).removeAttr('hidden')
} else { } else {
$(this).addClass('hidden'); $(this).addClass('hidden');
} }
}); });
} }
}); });
$('.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') { if ($(this).data('btn') == 'checkbox') {
dev_val = $('input',this).is(":checked"); 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');
$(this).removeAttr('hidden') $(this).removeAttr('hidden')
} else { } else {
$(this).addClass('hidden'); $(this).addClass('hidden');
} }
}); });
dev_id = $(this).data('vshow'); dev_id = $(this).data('vshow');
if (dev_id !== ''){ if (dev_id !== '') {
dev_class = $(this).data('clshow'); dev_class = $(this).data('clshow');
$(dev_class).each(function () { $(dev_class).each(function () {
if (dev_val == dev_id) { if (dev_val == dev_id) {
$(this).removeClass('hidden'); $(this).removeClass('hidden');
$(this).removeAttr('hidden') $(this).removeAttr('hidden')
} else { } else {
@ -409,7 +411,7 @@ $(document).ready(function () {
} }
}); });
} }
}); });
$('.sccp_button_disabled').each(function () { // On page create !! $('.sccp_button_disabled').each(function () { // On page create !!
@ -417,28 +419,28 @@ $(document).ready(function () {
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') { if ($(this).data('btn') == 'checkbox') {
dev_val = $('input',this).is(":checked"); dev_val = $('input', this).is(":checked");
} }
$(dev_class).find('input, select, textarea, button').each(function() { $(dev_class).find('input, select, textarea, button').each(function () {
if (dev_val == dev_id) { if (dev_val == dev_id) {
$(this).removeClass('disabled'); $(this).removeClass('disabled');
$(this).removeAttr('disabled') $(this).removeAttr('disabled')
} else { } else {
$(this).addClass('disabled', true); $(this).addClass('disabled', true);
$(this).attr('disabled', 'disabled'); $(this).attr('disabled', 'disabled');
} }
}); });
}); });
$('.sccp_button_disabled').on('click', function (e) { $('.sccp_button_disabled').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') { if ($(this).data('btn') == 'checkbox') {
dev_val = $('input',this).is(":checked"); dev_val = $('input', this).is(":checked");
} }
$(dev_class).find('input, select, textarea, button').each(function() { $(dev_class).find('input, select, textarea, button').each(function () {
if (dev_val != dev_id) { if (dev_val != dev_id) {
$(this).removeClass('disabled'); $(this).removeClass('disabled');
$(this).removeAttr('disabled') $(this).removeAttr('disabled')
} else { } else {
@ -451,45 +453,45 @@ $(document).ready(function () {
$('.button-checkbox').on('click', '', function (e) { $('.button-checkbox').on('click', '', function (e) {
settings = { settings = {
true: { true: {
icon: 'glyphicon glyphicon-unchecked' icon: 'glyphicon glyphicon-unchecked'
}, },
false: { false: {
icon: 'glyphicon glyphicon-check' icon: 'glyphicon glyphicon-check'
} }
}; };
var button_1 = $('button',this); var button_1 = $('button', this);
var isChecked = $('input', this).is(':checked'); var isChecked = $('input', this).is(':checked');
if (button_1.find('.state-icon').length == 0) { if (button_1.find('.state-icon').length == 0) {
button_1.prepend('<i class="state-icon ' + settings[isChecked].icon + '"></i> '); button_1.prepend('<i class="state-icon ' + settings[isChecked].icon + '"></i> ');
} else { } else {
button_1.find('.state-icon') button_1.find('.state-icon')
.removeClass() .removeClass()
.addClass('state-icon ' + settings[isChecked].icon); .addClass('state-icon ' + settings[isChecked].icon);
} }
if (isChecked) { if (isChecked) {
$('input', this).removeAttr('checked'); $('input', this).removeAttr('checked');
button_1.removeClass('active'); button_1.removeClass('active');
} else { } else {
$('input', this).attr('checked'); $('input', this).attr('checked');
$('input', this).prop('checked','true'); $('input', this).prop('checked', 'true');
button_1.addClass('active'); button_1.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');
var dev_id = $(this).val(); var dev_id = $(this).val();
if (dev_class.includes('validate-netmask')) { if (dev_class.includes('validate-netmask')) {
confirm(dev_id); confirm(dev_id);
} }
// confirm(dev_id); // confirm(dev_id);
}); });
$('.sccp_test').on('click', function (e) { $('.sccp_test').on('click', function (e) {
var dev_id = []; var dev_id = [];
// $('table').bootstrapTable('getSelections').forEach(function (entry) { // $('table').bootstrapTable('getSelections').forEach(function (entry) {
@ -524,7 +526,6 @@ $(document).ready(function () {
}); });
$('.sccp_update').on('click', function (e) { $('.sccp_update').on('click', function (e) {
// console.log($(this).data('id')); // console.log($(this).data('id'));
@ -582,7 +583,7 @@ $(document).ready(function () {
} }
if (($(this).data('id') === 'model_enabled') || ($(this).data('id') === 'model_disabled')) { if (($(this).data('id') === 'model_enabled') || ($(this).data('id') === 'model_disabled')) {
var dev_cmd = $(this).data('id'); var dev_cmd = $(this).data('id');
var tab_name ='#'+$(this).data('table'); var tab_name = '#' + $(this).data('table');
var datas = ''; var datas = '';
var i = 0; var i = 0;
$(tab_name).bootstrapTable('getSelections').forEach(function (entry) { $(tab_name).bootstrapTable('getSelections').forEach(function (entry) {
@ -607,7 +608,7 @@ $(document).ready(function () {
} }
} }
if ($(this).data('id') === 'reset_dev' || $(this).data('id') === 'reset_token' || $(this).data('id') === 'update_button_label' ) { if ($(this).data('id') === 'reset_dev' || $(this).data('id') === 'reset_token' || $(this).data('id') === 'update_button_label') {
var dev_cmd = $(this).data('id'); var dev_cmd = $(this).data('id');
var datas = ''; var datas = '';
var i = 0; var i = 0;
@ -635,6 +636,7 @@ $(document).ready(function () {
} }
} }
if (dev_cmd !== '') { if (dev_cmd !== '') {
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: 'ajax.php?module=sccp_manager&command=' + dev_cmd, url: 'ajax.php?module=sccp_manager&command=' + dev_cmd,
@ -643,13 +645,13 @@ $(document).ready(function () {
// console.log(data); // console.log(data);
if (data.status === true) { if (data.status === true) {
if (data.message) { if (data.message) {
alert(data.message); var old_style = bs_alert(data.message, data.reload);
} }
if (data.table_reload === true) { if (data.table_reload === true) {
$('table').bootstrapTable('refresh'); $('table').bootstrapTable('refresh');
} }
if (data.reload === true) { if (data.reload === true && old_style === true) {
location.reload(); location.reload();
} }
} else { } else {
if (Array.isArray(data.message)) { if (Array.isArray(data.message)) {
@ -658,10 +660,10 @@ $(document).ready(function () {
}); });
} else { } else {
if (data.message) { if (data.message) {
alert(data.message); bs_alert(data.message);
} else { } else {
if (data) { if (data) {
alert(data); bs_alert(data);
} }
} }
} }
@ -669,6 +671,7 @@ $(document).ready(function () {
} }
}); });
} }
}); });
@ -677,6 +680,7 @@ $(document).ready(function () {
// console.log($('#update-sccp-phone').find(':selected').data('val')); // console.log($('#update-sccp-phone').find(':selected').data('val'));
}); });
}); });
@ -705,7 +709,7 @@ $("table").on('check.bs.table', function (e, row) {
}); });
$("table").on('uncheck.bs.table', function (e, row) { $("table").on('uncheck.bs.table', function (e, row) {
var id_fld = $(this).data('id'); var id_fld = $(this).data('id');
var id_parent = '#'+$(this).parent().find('table').attr('id'); var id_parent = '#' + $(this).parent().find('table').attr('id');
// console.log(id_parent); // console.log(id_parent);
var id_count = $(id_parent).bootstrapTable('getAllSelections').length; var id_count = $(id_parent).bootstrapTable('getAllSelections').length;
if (id_count < 1) { if (id_count < 1) {
@ -717,7 +721,7 @@ $("table").on('uncheck.bs.table', function (e, row) {
}); });
$("table").on('uncheck-all.bs.table', function (rows) { $("table").on('uncheck-all.bs.table', function (rows) {
var id_fld = $(this).data('id'); var id_fld = $(this).data('id');
var id_parent = '#'+$(this).parent().find('table').attr('id'); var id_parent = '#' + $(this).parent().find('table').attr('id');
// console.log(id_parent); // console.log(id_parent);
// var id_count = $(id_parent).bootstrapTable('getAllSelections').length; // var id_count = $(id_parent).bootstrapTable('getAllSelections').length;
var id_count = $("table").bootstrapTable('getAllSelections').length; var id_count = $("table").bootstrapTable('getAllSelections').length;
@ -736,7 +740,7 @@ $("table").on("post-body.bs.table", function () {
// delete extension // delete extension
$(this).find(".clickable.delete").click(function () { $(this).find(".clickable.delete").click(function () {
var id = $(this).data("id"); var id = $(this).data("id");
if (confirm(_("Are you sure you wish to delete this extension?"))) { if (confirm(_("Are you sure you wish to delete this extension?"))) {
$.post("ajax.php", {command: "delete", module: "core", extensions: [id], type: "extensions"}, function (data) { $.post("ajax.php", {command: "delete", module: "core", extensions: [id], type: "extensions"}, function (data) {
if (data.status) { if (data.status) {
@ -747,7 +751,7 @@ $("table").on("post-body.bs.table", function () {
}); });
toggle_reload_button("show"); toggle_reload_button("show");
} else { } else {
alert(data.message); bs_alert(data.message);
} }
}); });
} }
@ -813,102 +817,104 @@ function load_oncliсk(e, data) {
function add_dynamic_input(pe, pclass, vdefault) { function add_dynamic_input(pe, pclass, vdefault) {
// We'd like a new one, please. // We'd like a new one, please.
pcls = pe.data('for'); pcls = pe.data('for');
pname = pe.data('id'); pname = pe.data('id');
pmax = pe.data('max'); pmax = pe.data('max');
jdata = JSON.parse(hex2bin(pe.data('json'))); jdata = JSON.parse(hex2bin(pe.data('json')));
var last = $("."+pcls+":last"), var last = $("." + pcls + ":last"),
ourid = last.data('nextid'), ourid = last.data('nextid'),
nextid = ourid + 1; nextid = ourid + 1;
var html = "<div class = '" + pcls +" form-group form-inline' data-nextid="+nextid+">"; var html = "<div class = '" + pcls + " form-group form-inline' data-nextid=" + nextid + ">";
for (var key in jdata) { for (var key in jdata) {
html_opt = ''; html_opt = '';
html_calss = jdata[key]['class']; html_calss = jdata[key]['class'];
for (var skey in jdata[key]['options']) { for (var skey in jdata[key]['options']) {
html_opt += ' ' + skey+'="' + jdata[key]['options'][skey] +'"'; html_opt += ' ' + skey + '="' + jdata[key]['options'][skey] + '"';
}
html += "<input type='text' name='"+pname+ "["+ourid+"]["+key+"]' class='" + html_calss + "' " + html_opt + " value='" + vdefault+"'> "+ jdata[key]['nameseparator'] + " ";
}
html += "</div>\n";
if (pmax >= nextid) {
last.after(html);
} }
html += "<input type='text' name='" + pname + "[" + ourid + "][" + key + "]' class='" + html_calss + "' " + html_opt + " value='" + vdefault + "'> " + jdata[key]['nameseparator'] + " ";
}
html += "</div>\n";
if (pmax >= nextid) {
last.after(html);
}
} }
function del_dynamic_table(pe, pclass, vdefault) { function del_dynamic_table(pe, pclass, vdefault) {
pcls = pe.data('for'); pcls = pe.data('for');
pname = pe.data('id'); pname = pe.data('id');
// pe.preventDefault(); // pe.preventDefault();
var rowCount = $('#dp-table-'+pcls+'>tbody >tr').length; var rowCount = $('#dp-table-' + pcls + '>tbody >tr').length;
curRow =$('#'+pcls+'-row-'+ pname); curRow = $('#' + pcls + '-row-' + pname);
var curRow = pe.closest('tr'); var curRow = pe.closest('tr');
if(rowCount > 1){ if (rowCount > 1) {
curRow.fadeOut("slow", function(){ curRow.fadeOut("slow", function () {
$(this).remove(); $(this).remove();
}); });
}else{ } else {
curRow.find('input:text').each(function(){$(this).val('')}); curRow.find('input:text').each(function () {
} $(this).val('')
});
}
} }
function add_dynamic_table(pe, pclass, vdefault) { function add_dynamic_table(pe, pclass, vdefault) {
// We'd like a new one, please. // We'd like a new one, please.
pcls = pe.data('for'); pcls = pe.data('for');
pname = pe.data('id'); pname = pe.data('id');
jdata = JSON.parse(hex2bin(pe.data('json'))); jdata = JSON.parse(hex2bin(pe.data('json')));
var last = $("."+pcls+":last"),
ourid = last.data('nextid'),
nextid = ourid + 1;
var html = "<tr class = '" + pcls +"' data-nextid="+nextid+">";
for (var key in jdata) {
html_opt = '';
res_ni = pcls + '_' + nextid + '_' + key;
res_n = pcls + '[' + nextid + '][' + key + ']';
for (var skey in jdata[key]['options']) {
html_opt += ' ' + skey+'="' + jdata[key]['options'][skey] +'"';
}
var html_rs = '<div class="input-group"> <span class="input-group-addon" id="basep_' + res_ni + '" >' + jdata[key]['display_prefix'] + '</span>';
var html_re = '<span class="input-group-addon" id="bases_' + res_ni + '">' + jdata[key]['display_sufix'] + '</span></div>';
html += '<td class="">'; var last = $("." + pcls + ":last"),
switch (jdata[key]['type']) { ourid = last.data('nextid'),
case "title": nextid = ourid + 1;
break; var html = "<tr class = '" + pcls + "' data-nextid=" + nextid + ">";
case "label": for (var key in jdata) {
html +='<label ' + html_opt +' >' + jdata[key]['data'] + '</label>'; html_opt = '';
break; res_ni = pcls + '_' + nextid + '_' + key;
case "input": res_n = pcls + '[' + nextid + '][' + key + ']';
html += html_rs + '<input type="text" name="' + res_n + '" value="' + '"' + html_opt + '>' +html_re ; for (var skey in jdata[key]['options']) {
break; html_opt += ' ' + skey + '="' + jdata[key]['options'][skey] + '"';
case "number":
html += html_rs + '<input type="number" name="' + res_n + '" value="' + '"' + html_opt + '>' +html_re ;
break;
case "date":
html += html_rs + '<input type="date" name="' + res_n + '" value="' + '"' + html_opt + '>' +html_re ;
break;
case "select":
html += html_rs + '<select name="' + res_n + '" id="' + res_n + '"' + html_opt + ">";
sel_data = jdata[key]['data'].split(';');
for (var dkey in sel_data) {
html += '<option>' + sel_data[dkey] + '</option>';
}
html += '</select>'+ html_re;
break;
}
html += '</td>';
} }
html += '<td><input type="button" id="' + pcls+ nextid + '-btn" data-id="' + nextid + '" data-for="' + pcls + '"data-json="'+ pe.data('json') + '" class="table-js-add" value="+" />'; var html_rs = '<div class="input-group"> <span class="input-group-addon" id="basep_' + res_ni + '" >' + jdata[key]['display_prefix'] + '</span>';
html += '<input type="button" id="'+ pcls+ nextid +'-btndel" data-id="'+ nextid + '" data-for="' + pcls + '" class="table-js-del" value="-" />'; var html_re = '<span class="input-group-addon" id="bases_' + res_ni + '">' + jdata[key]['display_sufix'] + '</span></div>';
html += '<td class="">';
switch (jdata[key]['type']) {
case "title":
break;
case "label":
html += '<label ' + html_opt + ' >' + jdata[key]['data'] + '</label>';
break;
case "input":
html += html_rs + '<input type="text" name="' + res_n + '" value="' + '"' + html_opt + '>' + html_re;
break;
case "number":
html += html_rs + '<input type="number" name="' + res_n + '" value="' + '"' + html_opt + '>' + html_re;
break;
case "date":
html += html_rs + '<input type="date" name="' + res_n + '" value="' + '"' + html_opt + '>' + html_re;
break;
case "select":
html += html_rs + '<select name="' + res_n + '" id="' + res_n + '"' + html_opt + ">";
sel_data = jdata[key]['data'].split(';');
for (var dkey in sel_data) {
html += '<option>' + sel_data[dkey] + '</option>';
}
html += '</select>' + html_re;
break;
}
html += '</td>';
}
html += '<td><input type="button" id="' + pcls + nextid + '-btn" data-id="' + nextid + '" data-for="' + pcls + '"data-json="' + pe.data('json') + '" class="table-js-add" value="+" />';
html += '<input type="button" id="' + pcls + nextid + '-btndel" data-id="' + nextid + '" data-for="' + pcls + '" class="table-js-del" value="-" />';
// html += '<a href="#" id="routerowdel0"><i class="fa fa-trash"></i></a>'; // html += '<a href="#" id="routerowdel0"><i class="fa fa-trash"></i></a>';
html += "</td></tr>\n"; html += "</td></tr>\n";
last.after(html); last.after(html);
} }
var theForm = document.editIax; var theForm = document.editIax;
@ -984,25 +990,56 @@ var theForm = document.editIax;
})(jQuery); })(jQuery);
/* /*
String.prototype.hex2bin = function() String.prototype.hex2bin = function()
{ {
var i = 0, len = this.length, result = ""; var i = 0, len = this.length, result = "";
//Converting the hex string into an escaped string, so if the hex string is "a2b320", it will become "%a2%b3%20" //Converting the hex string into an escaped string, so if the hex string is "a2b320", it will become "%a2%b3%20"
for(; i < len; i+=2) for(; i < len; i+=2)
result += '%' + this.substr(i, 2); result += '%' + this.substr(i, 2);
return unescape(result); return unescape(result);
}
*/
function bs_test() {
// alert('asasasasas');
window.location.reload(false);
} }
*/ function bs_alert(data, reload)
{
if (document.getElementById('hwalert') === null) {
alert(data);
return true; // Old style
} else {
var modal = $("#hwalert");
modal.find('.modal-title').text('Success operation ');
modal.find('.modal-body').text(data);
if (typeof reload != "undefined") {
if (reload === true) {
$("#hwalert").on('hidden.bs.modal', bs_test);
}
}
$("#hwalert").modal('show');
return false;
}
}
function hex2bin(hex) function hex2bin(hex)
{ {
var bytes = [], str; var bytes = [], str;
for(var i=0; i< hex.length-1; i+=2) for (var i = 0; i < hex.length - 1; i += 2)
bytes.push(parseInt(hex.substr(i, 2), 16)); bytes.push(parseInt(hex.substr(i, 2), 16));
return String.fromCharCode.apply(String, bytes); return String.fromCharCode.apply(String, bytes);
}
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds) {
break;
}
}
} }

View file

@ -50,4 +50,23 @@ if (empty($spage->class_error)) {
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- Modal alerts-->
<div class="modal" id="hwalert" tabindex="-1" role="dialog" aria-labelledby="lhwalert">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- End Modal alerts-->

View file

@ -51,4 +51,23 @@ if (empty($spage->class_error)) {
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- Modal alerts-->
<div class="modal" id="hwalert" tabindex="-1" role="dialog" aria-labelledby="lhwalert">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- End Modal alerts-->

View file

@ -39,4 +39,23 @@ $spage = FreePBX::create()->Sccp_manager;
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- Modal alerts-->
<div class="modal" id="hwalert" tabindex="-1" role="dialog" aria-labelledby="lhwalert">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- End Modal alerts-->

View file

@ -902,7 +902,33 @@ foreach ($items as $child) {
echo '<!-- END '.$child->label.' -->'; echo '<!-- END '.$child->label.' -->';
} }
if ($child['type'] == 'MINFO' ) {
$res_n = (string)$child ->name;
$res_id = $npref.$res_n;
if (empty($child->class)) {
$child->class = 'form-control';
}
echo '<!-- Begin '.$child->label.' -->';
?>
<div class="modal fade malert" tabindex="-1" role="dialog" id="<?php echo $res_id;?>" aria-labelledby="<?php echo $res_n;?>">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body&hellip;</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<?php
echo '<!-- END '.$child->label.' -->';
}
} }
?> ?>