2023-05-31 14:48:05 +00:00
|
|
|
|
var numbers = [];
|
2023-06-02 23:28:18 +00:00
|
|
|
|
var sms = [];
|
2023-06-03 23:00:19 +00:00
|
|
|
|
var ussd = [];
|
2023-05-31 14:48:05 +00:00
|
|
|
|
|
2023-05-30 23:04:03 +00:00
|
|
|
|
$(document).ready(function () {
|
2023-05-31 22:10:08 +00:00
|
|
|
|
noticer = new Noticer;
|
2023-05-30 23:04:03 +00:00
|
|
|
|
|
2023-06-03 18:27:07 +00:00
|
|
|
|
let tabs = {
|
2023-06-03 23:00:19 +00:00
|
|
|
|
0: () => { loadNumbers() },
|
|
|
|
|
1: () => { loadSMS() },
|
|
|
|
|
2: () => { loadUSSD() },
|
2023-06-04 18:50:36 +00:00
|
|
|
|
3: () => { loadServerInfo() }
|
2023-06-03 23:00:19 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let lists = {
|
2023-06-03 18:27:07 +00:00
|
|
|
|
0: () => { showListNumbers($("#accordion-numbers .ui-accordion-content-active")) },
|
|
|
|
|
1: () => { showListSMS($("#accordion-sms .ui-accordion-content-active")) },
|
2023-06-03 23:00:19 +00:00
|
|
|
|
2: () => { showListUSSD($("#accordion-ussd .ui-accordion-content-active")) },
|
2023-06-03 18:27:07 +00:00
|
|
|
|
3: () => {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let groups = {
|
|
|
|
|
0: () => { generateListGroupNumbers($("#accordion-numbers .ui-accordion-content-active")) },
|
|
|
|
|
1: () => { generateListGroupSMS($("#accordion-sms .ui-accordion-content-active")) },
|
2023-06-03 23:00:19 +00:00
|
|
|
|
2: () => { generateListGroupUSSD($("#accordion-ussd .ui-accordion-content-active")) },
|
2023-06-04 18:50:36 +00:00
|
|
|
|
3: () => {}
|
2023-06-03 18:27:07 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-05-30 23:04:03 +00:00
|
|
|
|
$("button").button();
|
2023-06-03 23:00:19 +00:00
|
|
|
|
$("#update-tab").button("option", "icon", "ui-icon-refresh");
|
|
|
|
|
$("#update-group").button("option", "icon", "ui-icon-arrowrefresh-1-s");
|
2023-06-03 18:27:07 +00:00
|
|
|
|
$("#add-number").button("option", "icon", "ui-icon-plusthick");
|
|
|
|
|
$("#logout").button("option", "icon", "ui-icon-power");
|
|
|
|
|
|
2023-06-02 23:28:18 +00:00
|
|
|
|
$("#tabs").tabs({
|
|
|
|
|
activate: function( event, ui ) {
|
2023-06-03 23:00:19 +00:00
|
|
|
|
lists[$(this).tabs( "option", "active" )]();
|
2023-06-02 23:28:18 +00:00
|
|
|
|
$("#add-number").button( "option", "disabled", $(this).tabs( "option", "active" ) > 0 );
|
2023-06-04 18:50:36 +00:00
|
|
|
|
$("#update-group").button( "option", "disabled", $(this).tabs( "option", "active" ) > 2 );
|
2023-06-02 23:28:18 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2023-05-30 23:04:03 +00:00
|
|
|
|
|
2023-06-03 23:00:19 +00:00
|
|
|
|
$("#update-tab").click(() => {
|
|
|
|
|
tabs[$("#tabs").tabs( "option", "active" )]()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#update-group").click(() => {
|
2023-06-03 18:27:07 +00:00
|
|
|
|
groups[$("#tabs").tabs( "option", "active" )]()
|
2023-06-01 21:36:21 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#add-number").click(() => {
|
|
|
|
|
addNumber($("#accordion-numbers .ui-accordion-content-active"))
|
|
|
|
|
});
|
2023-05-30 23:04:03 +00:00
|
|
|
|
|
2023-06-01 21:36:21 +00:00
|
|
|
|
$("#search").on("input", function () {
|
2023-06-03 23:00:19 +00:00
|
|
|
|
lists[$("#tabs").tabs( "option", "active" )]()
|
2023-05-30 23:04:03 +00:00
|
|
|
|
}).keydown(function (e) {
|
2023-06-03 23:00:19 +00:00
|
|
|
|
e.key == "Escape" && ($(this).val(""), lists[$("#tabs").tabs( "option", "active" )]())
|
2023-05-30 23:04:03 +00:00
|
|
|
|
});
|
|
|
|
|
|
2023-06-05 16:48:33 +00:00
|
|
|
|
$("#logout").click(() => {
|
|
|
|
|
request('logout', 'json').then(data => {
|
|
|
|
|
data.error ? noticer.error(data.message) : (window.location.href = ".");
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2023-06-02 23:28:18 +00:00
|
|
|
|
loadNumbers();
|
|
|
|
|
loadSMS();
|
2023-06-03 23:00:19 +00:00
|
|
|
|
loadUSSD();
|
2023-06-04 18:50:36 +00:00
|
|
|
|
loadServerInfo();
|
2023-06-03 18:27:07 +00:00
|
|
|
|
|
|
|
|
|
$("body").fadeTo(500, 1);
|
2023-05-30 23:04:03 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
async function request(query, type, queryData = {}) {
|
|
|
|
|
let response = await fetch('.', {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json;charset=utf-8'
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
...queryData,
|
|
|
|
|
query: query
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!response.ok)
|
|
|
|
|
throw new Error(`Произошла неизвестаня ошибка: ${response.status}`);
|
|
|
|
|
|
|
|
|
|
const data = await response[type]();
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isJSON(str) {
|
|
|
|
|
try {
|
|
|
|
|
return (JSON.parse(str) && !!str);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 23:28:18 +00:00
|
|
|
|
function isNumeric(value) {
|
|
|
|
|
return /^-?\d+$/.test(value);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-03 23:00:19 +00:00
|
|
|
|
function divNotFoundNumbers(text = '') {
|
2023-06-03 18:27:07 +00:00
|
|
|
|
let notFound = $('.notFoundNumbers');
|
|
|
|
|
let divTable = $('.body-rows');
|
2023-06-03 23:00:19 +00:00
|
|
|
|
let divNotFound = $(`<div class="notFoundNumbers">${text}</div>`);
|
2023-05-30 23:04:03 +00:00
|
|
|
|
|
2023-06-03 18:27:07 +00:00
|
|
|
|
divNotFound.css({
|
|
|
|
|
"color": "#333",
|
|
|
|
|
"text-align": "center",
|
|
|
|
|
"padding": "20px 0 20px 0"
|
2023-06-02 23:28:18 +00:00
|
|
|
|
});
|
|
|
|
|
|
2023-06-03 23:00:19 +00:00
|
|
|
|
this.push = function() {
|
|
|
|
|
divTable.append(divNotFound);
|
2023-06-02 23:28:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-03 18:27:07 +00:00
|
|
|
|
this.remove = function() {
|
|
|
|
|
notFound.remove();
|
2023-06-02 23:28:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-03 23:00:19 +00:00
|
|
|
|
function pEmpty(text) {
|
|
|
|
|
return $(`<p>${text}</p>`).css('text-align', 'center');
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-03 18:27:07 +00:00
|
|
|
|
/************************************************************************************
|
2023-06-02 23:28:18 +00:00
|
|
|
|
|
2023-06-03 18:27:07 +00:00
|
|
|
|
Обработка таблицы с номерами телефонов
|
2023-06-02 23:28:18 +00:00
|
|
|
|
|
2023-06-03 18:27:07 +00:00
|
|
|
|
************************************************************************************/
|
2023-06-02 23:28:18 +00:00
|
|
|
|
|
2023-06-03 18:27:07 +00:00
|
|
|
|
function loadNumbers() {
|
|
|
|
|
request('listnumbergroups', 'text').then(data => {
|
2023-06-05 16:48:33 +00:00
|
|
|
|
if (isJSON(data) && JSON.parse(data).error)
|
|
|
|
|
noticer.error(JSON.parse(data).message);
|
|
|
|
|
else
|
|
|
|
|
generateListNumberGroups(data);
|
2023-06-02 23:28:18 +00:00
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-03 18:27:07 +00:00
|
|
|
|
function generateListNumberGroups(data) {
|
2023-06-02 23:28:18 +00:00
|
|
|
|
if (!$(data).children().length) {
|
2023-06-03 23:00:19 +00:00
|
|
|
|
$("#tabs-numbers").html(pEmpty('Номера телефонов отсутствуют'));
|
2023-06-02 23:28:18 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-31 14:48:05 +00:00
|
|
|
|
$("#tabs-numbers").html(data);
|
2023-05-30 23:04:03 +00:00
|
|
|
|
$("#accordion-numbers").accordion({
|
|
|
|
|
heightStyle: "content",
|
|
|
|
|
create: function( event, ui ) {
|
2023-06-03 18:27:07 +00:00
|
|
|
|
generateListGroupNumbers(ui.panel);
|
2023-05-30 23:04:03 +00:00
|
|
|
|
},
|
|
|
|
|
beforeActivate: function( event, ui ) {
|
2023-06-03 18:27:07 +00:00
|
|
|
|
generateListGroupNumbers(ui.newPanel);
|
2023-05-30 23:04:03 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-03 18:27:07 +00:00
|
|
|
|
function generateListGroupNumbers(panel) {
|
2023-06-02 23:28:18 +00:00
|
|
|
|
if (!$("#accordion-numbers").children().length) {
|
|
|
|
|
noticer.warning("Номера телефонов отсутствуют");
|
2023-06-03 23:00:19 +00:00
|
|
|
|
$("#tabs-numbers").html(pEmpty('Номера телефонов отсутствуют'));
|
2023-06-02 23:28:18 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-03 18:27:07 +00:00
|
|
|
|
request('listgroupnumbers', 'json', { group: panel.data("group-name") }).then(data => {
|
2023-06-05 16:48:33 +00:00
|
|
|
|
if (data.error)
|
|
|
|
|
noticer.error(data.message);
|
2023-05-30 23:04:03 +00:00
|
|
|
|
else {
|
2023-05-31 14:48:05 +00:00
|
|
|
|
numbers = data;
|
2023-06-03 18:27:07 +00:00
|
|
|
|
showListNumbers(panel);
|
2023-05-30 23:04:03 +00:00
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
2023-05-31 22:10:08 +00:00
|
|
|
|
noticer.error(error.message);
|
2023-05-30 23:04:03 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
2023-05-31 14:48:05 +00:00
|
|
|
|
|
2023-06-03 18:27:07 +00:00
|
|
|
|
function showListNumbers(panel, data = numbers.filter(e => e.number.includes($("#search").val()))) {
|
2023-05-31 14:48:05 +00:00
|
|
|
|
(new divNotFoundNumbers).remove();
|
|
|
|
|
let body = panel.find('.body').html('');
|
|
|
|
|
$(data).each((i, j) => {
|
2023-05-31 22:10:08 +00:00
|
|
|
|
let row = $(`<tr class="row" data-number="${j.number}"></tr>`);
|
2023-05-31 14:48:05 +00:00
|
|
|
|
row.append(`<td>${j.number}</td>`);
|
|
|
|
|
row.append(`<td>${j.list}</td>`);
|
|
|
|
|
row.append(`<td>${j.all_cc}</td>`);
|
|
|
|
|
row.append(`<td>${j.white_cc}</td>`);
|
|
|
|
|
row.append(`<td>${j.black_cc}</td>`);
|
|
|
|
|
row.append(`<td>${j.comment}</td>`);
|
|
|
|
|
body.append(row);
|
|
|
|
|
|
2023-05-31 22:10:08 +00:00
|
|
|
|
row.click(function() {
|
2023-06-03 18:27:07 +00:00
|
|
|
|
viewNumber(panel, $(this).data('number'));
|
2023-05-31 14:48:05 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!body.children().length)
|
2023-06-03 23:00:19 +00:00
|
|
|
|
(new divNotFoundNumbers('Нет номеров')).push();
|
2023-05-31 14:48:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-03 18:27:07 +00:00
|
|
|
|
function viewNumber(panel, number) {
|
|
|
|
|
request('viewnumber', 'text', {number: number}).then(data => {
|
2023-05-31 22:10:08 +00:00
|
|
|
|
if (isJSON(data) && JSON.parse(data).error)
|
|
|
|
|
noticer.error(JSON.parse(data).message);
|
|
|
|
|
else {
|
2023-06-03 18:27:07 +00:00
|
|
|
|
showViewNumber(data, [
|
2023-05-31 22:10:08 +00:00
|
|
|
|
{
|
|
|
|
|
id: "btn-save",
|
|
|
|
|
text: "Сохранить",
|
|
|
|
|
icon: "ui-icon-check",
|
|
|
|
|
click: function() {
|
2023-06-01 21:36:21 +00:00
|
|
|
|
actionNumber(panel, $(this), 'updatenumber');
|
2023-05-31 22:10:08 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "btn-delete",
|
|
|
|
|
text: "Удалить",
|
|
|
|
|
icon: "ui-icon-trash",
|
|
|
|
|
click: function() {
|
2023-06-01 21:36:21 +00:00
|
|
|
|
delNumber(panel, $(this));
|
2023-05-31 22:10:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
], `Редактирование номера ${number}`);
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-03 18:27:07 +00:00
|
|
|
|
function showViewNumber(data, actionButton, title) {
|
2023-05-31 22:10:08 +00:00
|
|
|
|
let form = $(data);
|
|
|
|
|
|
|
|
|
|
form.appendTo('body').dialog({
|
|
|
|
|
title: title,
|
|
|
|
|
height: 'auto',
|
|
|
|
|
width: 'auto',
|
|
|
|
|
resizable: false,
|
|
|
|
|
modal: true,
|
|
|
|
|
show: { effect: "fade", duration: 500 },
|
|
|
|
|
close: function(event, ui) {
|
|
|
|
|
$(this).dialog('destroy').remove()
|
|
|
|
|
},
|
|
|
|
|
buttons: [
|
|
|
|
|
...actionButton,
|
|
|
|
|
{
|
|
|
|
|
text: "Отмена",
|
|
|
|
|
icon: "ui-icon-cancel",
|
|
|
|
|
click: function() {
|
|
|
|
|
$(this).dialog("close");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#number-group, #number-list').selectmenu({
|
|
|
|
|
width: 200
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-01 21:36:21 +00:00
|
|
|
|
function actionNumber(panel, currentWindow, query) {
|
2023-06-02 23:28:18 +00:00
|
|
|
|
let pattern_number = /^\+7\d{10}$/g;
|
2023-06-01 21:36:21 +00:00
|
|
|
|
|
2023-05-31 22:10:08 +00:00
|
|
|
|
let number = $('#number-number').val();
|
|
|
|
|
let group = $('#number-group').val();
|
|
|
|
|
let list = $('#number-list').val();
|
|
|
|
|
let all_cc = $('#number-all-cc').val();
|
|
|
|
|
let white_cc = $('#number-white-cc').val();
|
|
|
|
|
let black_cc = $('#number-black-cc').val();
|
|
|
|
|
let comment = $('#number-comment').val();
|
2023-06-01 21:36:21 +00:00
|
|
|
|
|
|
|
|
|
let error = false;
|
|
|
|
|
|
2023-06-02 23:28:18 +00:00
|
|
|
|
if (number.match(pattern_number) === null) { noticer.warning("Номер не соответствует формату +7XXXXXXXXXX"); error = true; }
|
|
|
|
|
if (!isNumeric(all_cc)) { noticer.warning("Общее количество звонков должно быть числом"); error = true; }
|
|
|
|
|
if (all_cc < 0) { noticer.warning("Общее количество звонков не может быть отрицательным"); error = true; }
|
|
|
|
|
if (!isNumeric(white_cc)) { noticer.warning("Белое количество звонков должно быть числом"); error = true; }
|
|
|
|
|
if (white_cc < 0) { noticer.warning("Белое количество звонков не может быть отрицательным"); error = true; }
|
|
|
|
|
if (!isNumeric(black_cc)) { noticer.warning("Черное количество звонков должно быть числом"); error = true; }
|
|
|
|
|
if (black_cc < 0) { noticer.warning("Черное количество звонков не может быть отрицательным"); error = true; }
|
2023-06-01 21:36:21 +00:00
|
|
|
|
|
|
|
|
|
if (error) return;
|
|
|
|
|
|
|
|
|
|
request(query, 'json', {
|
|
|
|
|
number: number,
|
|
|
|
|
group: group,
|
|
|
|
|
list: list,
|
|
|
|
|
all_cc: parseInt(all_cc),
|
|
|
|
|
white_cc: parseInt(white_cc),
|
|
|
|
|
black_cc: parseInt(black_cc),
|
|
|
|
|
comment: comment
|
|
|
|
|
}).then(data => {
|
|
|
|
|
if (data.error)
|
|
|
|
|
noticer.error(data.message);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
query == 'write' ? noticer.success(`Номер ${number} был добавлен`) : noticer.success(`Номер ${number} был обновлен`);
|
2023-06-03 18:27:07 +00:00
|
|
|
|
generateListGroupNumbers(panel);
|
2023-06-01 21:36:21 +00:00
|
|
|
|
currentWindow.dialog("close");
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
2023-05-31 22:10:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-01 21:36:21 +00:00
|
|
|
|
function addNumber(panel) {
|
|
|
|
|
request('addnumber', 'text', { group: panel.data("group-name") }).then(data => {
|
|
|
|
|
if (isJSON(data) && JSON.parse(data).error)
|
|
|
|
|
noticer.error(JSON.parse(data).message);
|
|
|
|
|
else {
|
2023-06-03 18:27:07 +00:00
|
|
|
|
showViewNumber(data, [{
|
2023-06-01 21:36:21 +00:00
|
|
|
|
id: "btnSave",
|
|
|
|
|
text: "Добавить",
|
|
|
|
|
icon: "ui-icon-check",
|
|
|
|
|
click: function() {
|
|
|
|
|
actionNumber(panel, $(this), 'writenumber');
|
|
|
|
|
}
|
|
|
|
|
}], "Добавление нового номера");
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function delNumber(panel, currentWindow) {
|
|
|
|
|
let number = $('#number-number').val();
|
|
|
|
|
|
|
|
|
|
let error = false;
|
|
|
|
|
if (!number.length) { noticer.warning('Номер не может быть пуст'); error = true; }
|
|
|
|
|
if (error) return;
|
|
|
|
|
|
|
|
|
|
request('delnumber', 'json', {
|
|
|
|
|
number: number
|
|
|
|
|
}).then(data => {
|
|
|
|
|
if (data.error)
|
|
|
|
|
noticer.error(data.message);
|
|
|
|
|
else {
|
|
|
|
|
noticer.success(`Номер ${number} был удален`);
|
2023-06-03 18:27:07 +00:00
|
|
|
|
generateListGroupNumbers(panel);
|
|
|
|
|
currentWindow.dialog("close");
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************************************************************************
|
|
|
|
|
|
2023-06-03 23:00:19 +00:00
|
|
|
|
Обработка таблицы с SMS
|
2023-06-03 18:27:07 +00:00
|
|
|
|
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
|
|
|
|
function loadSMS() {
|
|
|
|
|
request('listsmsgroups', 'text').then(data => {
|
2023-06-05 16:48:33 +00:00
|
|
|
|
if (isJSON(data) && JSON.parse(data).error)
|
|
|
|
|
noticer.error(JSON.parse(data).message);
|
|
|
|
|
else
|
|
|
|
|
generateListSMSGroups(data);
|
2023-06-03 18:27:07 +00:00
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function generateListSMSGroups(data) {
|
|
|
|
|
if (!$(data).children().length) {
|
2023-06-03 23:00:19 +00:00
|
|
|
|
$("#tabs-sms").html(pEmpty('SMS отсутствуют'));
|
2023-06-03 18:27:07 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("#tabs-sms").html(data);
|
|
|
|
|
$("#accordion-sms").accordion({
|
|
|
|
|
heightStyle: "content",
|
|
|
|
|
create: function( event, ui ) {
|
|
|
|
|
generateListGroupSMS(ui.panel);
|
|
|
|
|
},
|
|
|
|
|
beforeActivate: function( event, ui ) {
|
|
|
|
|
generateListGroupSMS(ui.newPanel);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function generateListGroupSMS(panel) {
|
|
|
|
|
if (!$("#accordion-sms").children().length) {
|
|
|
|
|
noticer.warning("SMS отсутствуют");
|
2023-06-03 23:00:19 +00:00
|
|
|
|
$("#tabs-sms").html(pEmpty('SMS отсутствуют'));
|
2023-06-03 18:27:07 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
request('listgroupsms', 'json', { to: panel.data("to") }).then(data => {
|
2023-06-05 16:48:33 +00:00
|
|
|
|
if (data.error)
|
|
|
|
|
noticer.error(data.message);
|
2023-06-03 18:27:07 +00:00
|
|
|
|
else {
|
|
|
|
|
sms = data;
|
|
|
|
|
showListSMS(panel);
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showListSMS(panel, data = sms.filter(e => e.from.includes($("#search").val()))) {
|
|
|
|
|
(new divNotFoundNumbers).remove();
|
|
|
|
|
let body = panel.find('.body').html('');
|
|
|
|
|
$(data).each((i, j) => {
|
|
|
|
|
let row = $(`<tr class="row" data-sms-id="${j.id}"></tr>`);
|
|
|
|
|
row.append(`<td class="sms-content-width">${j.date}</td>`);
|
|
|
|
|
row.append(`<td class="sms-content-width">${j.from}</td>`);
|
|
|
|
|
row.append(`<td>${j.text}</td>`);
|
|
|
|
|
body.append(row);
|
|
|
|
|
|
|
|
|
|
row.click(function() {
|
|
|
|
|
viewSMS(panel, $(this).data('sms-id'), j.from);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!body.children().length)
|
2023-06-03 23:00:19 +00:00
|
|
|
|
(new divNotFoundNumbers('Нет SMS')).push();
|
2023-06-03 18:27:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function viewSMS(panel, id, number) {
|
|
|
|
|
request('viewsms', 'text', {id: id}).then(data => {
|
|
|
|
|
if (isJSON(data) && JSON.parse(data).error)
|
|
|
|
|
noticer.error(JSON.parse(data).message);
|
|
|
|
|
else {
|
|
|
|
|
showViewSMS(data, [
|
|
|
|
|
{
|
|
|
|
|
id: "btn-delete",
|
|
|
|
|
text: "Удалить",
|
|
|
|
|
icon: "ui-icon-trash",
|
|
|
|
|
click: function() {
|
|
|
|
|
delSMS(panel, $(this));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
], `SMS от ${number}`);
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showViewSMS(data, actionButton, title) {
|
|
|
|
|
let form = $(data);
|
|
|
|
|
|
|
|
|
|
form.appendTo('body').dialog({
|
|
|
|
|
title: title,
|
|
|
|
|
height: 'auto',
|
|
|
|
|
width: 'auto',
|
|
|
|
|
resizable: false,
|
|
|
|
|
modal: true,
|
|
|
|
|
show: { effect: "fade", duration: 500 },
|
|
|
|
|
close: function(event, ui) {
|
|
|
|
|
$(this).dialog('destroy').remove()
|
|
|
|
|
},
|
|
|
|
|
buttons: [
|
|
|
|
|
...actionButton,
|
|
|
|
|
{
|
|
|
|
|
text: "Отмена",
|
|
|
|
|
icon: "ui-icon-cancel",
|
|
|
|
|
click: function() {
|
|
|
|
|
$(this).dialog("close");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function delSMS(panel, currentWindow) {
|
|
|
|
|
let id = $('#sms-content').data('id');
|
|
|
|
|
let from = $('#sms-content').data('from');
|
|
|
|
|
|
|
|
|
|
request('delsms', 'json', {
|
|
|
|
|
id: id
|
|
|
|
|
}).then(data => {
|
|
|
|
|
if (data.error)
|
|
|
|
|
noticer.error(data.message);
|
|
|
|
|
else {
|
|
|
|
|
noticer.success(`SMS от ${from} было удалено`);
|
|
|
|
|
generateListGroupSMS(panel);
|
2023-06-01 21:36:21 +00:00
|
|
|
|
currentWindow.dialog("close");
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-06-03 23:00:19 +00:00
|
|
|
|
|
|
|
|
|
/************************************************************************************
|
|
|
|
|
|
|
|
|
|
Обработка таблицы с USSD
|
|
|
|
|
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
|
|
|
|
function loadUSSD() {
|
|
|
|
|
request('listussdgroups', 'text').then(data => {
|
2023-06-05 16:48:33 +00:00
|
|
|
|
if (isJSON(data) && JSON.parse(data).error)
|
|
|
|
|
noticer.error(JSON.parse(data).message);
|
|
|
|
|
else
|
|
|
|
|
generateListUSSDGroups(data);
|
2023-06-03 23:00:19 +00:00
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function generateListUSSDGroups(data) {
|
|
|
|
|
if (!$(data).children().length) {
|
|
|
|
|
$("#tabs-ussd").html(pEmpty('USSD отсутствуют'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("#tabs-ussd").html(data);
|
|
|
|
|
$("#accordion-ussd").accordion({
|
|
|
|
|
heightStyle: "content",
|
|
|
|
|
create: function( event, ui ) {
|
|
|
|
|
generateListGroupUSSD(ui.panel);
|
|
|
|
|
},
|
|
|
|
|
beforeActivate: function( event, ui ) {
|
|
|
|
|
generateListGroupUSSD(ui.newPanel);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function generateListGroupUSSD(panel) {
|
|
|
|
|
if (!$("#accordion-ussd").children().length) {
|
|
|
|
|
noticer.warning("USSD отсутствуют");
|
|
|
|
|
$("#tabs-ussd").html(pEmpty('USSD отсутствуют'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
request('listgroupussd', 'json', { to: panel.data("to") }).then(data => {
|
2023-06-05 16:48:33 +00:00
|
|
|
|
if (data.error)
|
|
|
|
|
noticer.error(data.message);
|
2023-06-03 23:00:19 +00:00
|
|
|
|
else {
|
|
|
|
|
ussd = data;
|
|
|
|
|
showListUSSD(panel);
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showListUSSD(panel, data = ussd) {
|
|
|
|
|
(new divNotFoundNumbers).remove();
|
|
|
|
|
let body = panel.find('.body').html('');
|
|
|
|
|
$(data).each((i, j) => {
|
|
|
|
|
let row = $(`<tr class="row" data-ussd-id="${j.id}"></tr>`);
|
|
|
|
|
row.append(`<td class="ussd-content-width">${j.date}</td>`);
|
|
|
|
|
row.append(`<td class="ussd-content-width-type">${j.type_comment}</td>`);
|
|
|
|
|
row.append(`<td>${j.text}</td>`);
|
|
|
|
|
body.append(row);
|
|
|
|
|
|
|
|
|
|
row.click(function() {
|
|
|
|
|
viewUSSD(panel, $(this).data('ussd-id'), j.type_comment);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!body.children().length)
|
|
|
|
|
(new divNotFoundNumbers('Нет USSD')).push();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function viewUSSD(panel, id, type) {
|
|
|
|
|
request('viewussd', 'text', {id: id}).then(data => {
|
|
|
|
|
if (isJSON(data) && JSON.parse(data).error)
|
|
|
|
|
noticer.error(JSON.parse(data).message);
|
|
|
|
|
else {
|
|
|
|
|
showViewUSSD(data, [
|
|
|
|
|
{
|
|
|
|
|
id: "btn-delete",
|
|
|
|
|
text: "Удалить",
|
|
|
|
|
icon: "ui-icon-trash",
|
|
|
|
|
click: function() {
|
|
|
|
|
delUSSD(panel, $(this));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
], `USSD: ${type}`);
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showViewUSSD(data, actionButton, title) {
|
|
|
|
|
let form = $(data);
|
|
|
|
|
|
|
|
|
|
form.appendTo('body').dialog({
|
|
|
|
|
title: title,
|
|
|
|
|
height: 'auto',
|
|
|
|
|
width: 'auto',
|
|
|
|
|
resizable: false,
|
|
|
|
|
modal: true,
|
|
|
|
|
show: { effect: "fade", duration: 500 },
|
|
|
|
|
close: function(event, ui) {
|
|
|
|
|
$(this).dialog('destroy').remove()
|
|
|
|
|
},
|
|
|
|
|
buttons: [
|
|
|
|
|
...actionButton,
|
|
|
|
|
{
|
|
|
|
|
text: "Отмена",
|
|
|
|
|
icon: "ui-icon-cancel",
|
|
|
|
|
click: function() {
|
|
|
|
|
$(this).dialog("close");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function delUSSD(panel, currentWindow) {
|
|
|
|
|
let id = $('#ussd-content').data('id');
|
|
|
|
|
|
|
|
|
|
request('delussd', 'json', {
|
|
|
|
|
id: id
|
|
|
|
|
}).then(data => {
|
|
|
|
|
if (data.error)
|
|
|
|
|
noticer.error(data.message);
|
|
|
|
|
else {
|
|
|
|
|
noticer.success(`USSD было удалено`);
|
|
|
|
|
generateListGroupUSSD(panel);
|
|
|
|
|
currentWindow.dialog("close");
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-06-04 18:50:36 +00:00
|
|
|
|
|
|
|
|
|
/************************************************************************************
|
|
|
|
|
|
|
|
|
|
Обработка таблицы информации о сервере
|
|
|
|
|
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
|
|
|
|
function loadServerInfo() {
|
|
|
|
|
request('serverinfo', 'text').then(data => {
|
2023-06-05 16:48:33 +00:00
|
|
|
|
if (isJSON(data) && JSON.parse(data).error)
|
|
|
|
|
noticer.error(JSON.parse(data).message);
|
|
|
|
|
else
|
|
|
|
|
showServerInfo(data);
|
2023-06-04 18:50:36 +00:00
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showServerInfo(data) {
|
|
|
|
|
$("#tabs-server").html(data);
|
|
|
|
|
$("#server-external-number-on").checkboxradio();
|
|
|
|
|
$("#server-transparent-mode").checkboxradio();
|
|
|
|
|
$("#server-button").button({ icon: "ui-icon-disk", disabled: true });
|
|
|
|
|
|
|
|
|
|
$(".server-input").on("change paste cut keydown", () => {
|
|
|
|
|
if ($("#server-button").button( "option", "disabled")) {
|
|
|
|
|
noticer.warning('Некоторые параметры сервера были изменены');
|
|
|
|
|
$("#server-button").button( "option", "disabled", false);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#server-button").click(() => {
|
|
|
|
|
writeServerInfo();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function writeServerInfo() {
|
|
|
|
|
let pattern_number = /^\+7\d{10}$/g;
|
|
|
|
|
|
|
|
|
|
let internal_number = $("#server-internal-number").val();
|
|
|
|
|
let external_number = $("#server-external-number").val();
|
|
|
|
|
let external_number_on = $("#server-external-number-on").is(":checked");
|
|
|
|
|
let transparent_mode = $("#server-transparent-mode").is(":checked");
|
|
|
|
|
|
|
|
|
|
let error = false;
|
|
|
|
|
|
|
|
|
|
if (external_number.match(pattern_number) === null) { noticer.warning("Внешний номер не соответствует формату +7XXXXXXXXXX"); error = true; }
|
|
|
|
|
|
|
|
|
|
if (error) return;
|
|
|
|
|
|
|
|
|
|
request('writeserverinfo', 'json', {
|
|
|
|
|
internal_number: internal_number,
|
|
|
|
|
external_number: external_number,
|
|
|
|
|
external_number_on: external_number_on,
|
|
|
|
|
transparent_mode: transparent_mode
|
|
|
|
|
}).then(data => {
|
|
|
|
|
data.error ?
|
|
|
|
|
noticer.error(data.message) :
|
|
|
|
|
$("#server-button").button( "option", "disabled", true) && noticer.success("Параметры сервера были сохранены")
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
noticer.error(error.message);
|
|
|
|
|
});
|
|
|
|
|
}
|