Commit 1b26165d authored by Kulya's avatar Kulya 😊

first routing added5

parent a7db3f2b
......@@ -633,9 +633,36 @@ function saveQueue($data,$r=true){
$password = (!empty($data["password"])) ? $data["password"] : (!empty($oQueue["password"])) ? $oQueue["password"] : "";
$prefix = (!empty($data["prefix"])) ? $data["prefix"] : (!empty($oQueue["prefix"])) ? $oQueue["prefix"] : "";
$goto = (!empty($data["goto"])) ? $data["goto"] : false;
if(empty($goto)) {
$goto = (!empty($oQueue["goto"])) ? $oQueue["goto"] : "app-blackhole,hangup,1";
if(!empty($data["queue_destination_code"])){
if($data["goto"] == "ext-queues"){
$goto = $data["goto"].','.$data["queue_destination_code"].',1';
}
if($data["goto"] == "from-did-direct"){
$goto = $data["goto"].','.$data["queue_destination_code"].',1';
}
if($data["goto"] == "timeconditions"){
$goto = $data["goto"].',1,1';
}
if(empty($goto)){
return ["error" => "Направление не верная"];
}
}
elseif($data["goto"] == "timeconditions"){
$goto = $data["goto"].',1,1';
}
elseif($data["goto"] == "hangup"){
$goto = 'app-blackhole,hangup,1';
}
elseif($data["goto"] == "vm"){
$goto = 'ext-local,vms1098,1';
}
else {
$goto = (!empty($data["goto"])) ? $data["goto"] : false;
if(empty($goto)) {
$goto = (!empty($oQueue["goto"])) ? $oQueue["goto"] : "app-blackhole,hangup,1";
}
}
$strategy = (!empty($data["strategy"])) ? $data["strategy"] : false;
......
......@@ -38,35 +38,36 @@ $().ready(() => {
];
}
window.getAllGotos = function () {
var result = [
// {
// title: "Не выбрано",
// value: "",
// },
{
title: "Завершить звонок",
value: "app-blackhole,hangup,1",
select: true
},
{
title: "Голосовая почта",
value: "ext-local,vms1098,1",
},
];
// res = res.map(function(d) {
// return {
// title: "Очередь: " + d[0],
// value: "ext-queues," + d[0] + ",1",
// };
// });
// result = [...result, ...res];
return result;
}
window.final_destination_change = function(me){
var route_dest = $(me).val();
console.log("--== Changed dest: ", route_dest);
if(route_dest=="from-did-direct" || route_dest=="ext-queues"){
$("#final_destination_code_container").html('<span>Загрузка...</span>');
var method = (route_dest=="from-did-direct") ? "alovoice_get_operators_nums" : "alovoice_get_allqueues";
loadAloVoiceInfo(method,function(elems){
$("#final_destination_code_container").html('');
$("#final_destination_code_container").append('<select id="queue_destination_code" class="form-control inrouteinp">...</select>');
$.each( elems, function( num, elem ) {
var selexttxt = (typeof destination_code != 'undefined' && destination_code==num) ? ' selected' : '';
if(route_dest=="from-did-direct"){
$("#queue_destination_code").append( '<option value="'+num+'"'+selexttxt+'>'+num+' - '+elem.NAME+' '+elem.LAST_NAME+'</option>' );
}
else {
$("#queue_destination_code").append( '<option value="'+num+'"'+selexttxt+'>'+num+' - '+elem+'</option>' );
}
});
});
}
else {
$("#final_destination_code_container").html("");
}
}
feather.replace()
......@@ -76,75 +77,97 @@ $().ready(() => {
$('#queues_add').on('click', function () {
var currGoto = '';
var gotosOpts = '';
window.getAllGotos().forEach(function(elm){
var seltxt = (elm.select) ? " seleted" : "";
gotosOpts += '<option value="'+elm.value+'"'+seltxt+'>'+elm.title+'</option>';
});
var strategyOpts = '';
window.getAllStrateges().forEach(function(elm){
var seltxt = (elm.select) ? " seleted" : "";
strategyOpts += '<option value="'+elm.value+'"'+seltxt+'>'+elm.title+'</option>';
});
var gotosOpts = '<option>Выберите направление...</option>';
doAloVoiceCmd('loadDestinationsList', {}, function(dests) {
swal.fire({
title: 'Введите номер очереди',
showCancelButton: true,
cancelButtonText: 'Отмена',
preConfirm: () => {
var queuenum = $('#add_queue_inp').val();
var final_destination = $('#final_destination').val();
var queue_strategy = $('#queue_strategy').val();
var queuenum = queuenum.replace(/\D+/g, '');
console.log("Queue Params:",queuenum, final_destination, queue_strategy );
if (queuenum && (queuenum < 6000 || queuenum > 6999)) {
Swal.showValidationMessage(
`Некорректный номер очереди! <br>требуется от 6000 до 6999`
)
return false;
}
},
html: ''
console.log("--===Loaded Dests:",dests);
$.each( dests, function( key, value ) {
var seltxt = (key=="hangup") ? " seleted" : "";
console.log("--===Each goto:",key, value);
gotosOpts += '<option value="'+key+'"'+seltxt+'>'+value+'</option>';
});
// console.log("--===Loaded gotosOpts:",gotosOpts);
// window.getAllGotos().forEach(function(elm){
// var seltxt = (elm.select) ? " seleted" : "";
// gotosOpts += '<option value="'+elm.value+'"'+seltxt+'>'+elm.title+'</option>';
// });
var strategyOpts = '';
window.getAllStrateges().forEach(function(elm){
var seltxt = (elm.select) ? " seleted" : "";
strategyOpts += '<option value="'+elm.value+'"'+seltxt+'>'+elm.title+'</option>';
});
+'<input id="add_queue_inp" class="swal2-input row mx-0" type="text">'
+'<div class="row"></div>'
+'<h2 class="swal2-title">Направление при не ответе: </h2> '
swal.fire({
title: 'Введите номер очереди',
showCancelButton: true,
cancelButtonText: 'Отмена',
preConfirm: () => {
var queuenum = $('#add_queue_inp').val();
var final_destination = $('#final_destination').val();
var queue_strategy = $('#queue_strategy').val();
var queuenum = queuenum.replace(/\D+/g, '');
console.log("Queue Params:",queuenum, final_destination, queue_strategy );
if (!queuenum || queuenum < 6000 || queuenum > 6999) {
Swal.showValidationMessage(
`Некорректный номер очереди! <br>требуется от 6000 до 6999`
)
$("#add_queue_inp").addClass("swal2-inputerror");
return false;
}
},
html: ''
+'<select id="final_destination" class="swal2-select row mx-0">'
+gotosOpts
+'</select>'
+'<h2 class="swal2-title">Правила приёма звонок: </h2> '
+'<select id="queue_strategy" class="swal2-select row mx-0">'
+strategyOpts
+'</select>'
,
}).then((result) => {
if (result.isConfirmed) {
uiLoading();
var queuenum = $('#add_queue_inp').val();
var final_destination = $('#final_destination').val();
var queue_strategy = $('#queue_strategy').val();
console.log("Queue SAVEing Params:",queuenum, final_destination, queue_strategy );
doAloVoiceCmd('saveQueue', {
account: queuenum,
goto: final_destination,
strategy: queue_strategy
}, function() {
uiLoadingEnd();
// alert(queuenum + ' успешно добавлен! ' + queue);
});
}
+'<input id="add_queue_inp" class="swal2-input row mx-0" type="text">'
+'<div class="row"></div>'
+'<h2 class="swal2-title">Правила приёма звонок: </h2> '
+'<select id="queue_strategy" class="swal2-select row mx-0">'
+strategyOpts
+'</select>'
+'<h2 class="swal2-title">Все время ожидание в очереди (сек): </h2> '
+'<input id="queue_maxwait" class="swal2-input row mx-0" type="number" value="0"> <small>0 - Неограничено</small>'
+'<h2 class="swal2-title">Направление при не ответе: </h2> '
+'<select id="final_destination" class="swal2-select row mx-0" onChange="final_destination_change(this)">'
+gotosOpts
+'</select>'
+'<div id="final_destination_code_container"></div>'
,
}).then((result) => {
if (result.isConfirmed) {
uiLoading();
var queuenum = $('#add_queue_inp').val();
var final_destination = $('#final_destination').val();
var queue_destination_code = $('#queue_destination_code').val();
var queue_strategy = $('#queue_strategy').val();
console.log("Queue SAVEing Params:",queuenum, final_destination, queue_destination_code, queue_strategy );
doAloVoiceCmd('saveQueue', {
account: queuenum,
goto: final_destination,
queue_destination_code: queue_destination_code,
strategy: queue_strategy
}, function() {
uiLoadingEnd();
// alert(queuenum + ' успешно добавлен! ' + queue);
});
}
});
});
})
......
......@@ -217,8 +217,8 @@ class AloVoiceActions
foreach( $QueueStatusEvents as $qevnt){
$qKeys = $qevnt->getKeys();
if(!empty($qKeys["queue"]) && $qKeys["queue"] != "default"){
$arQueues[$qKeys["queue"]] = $qKeys;
// $arQueues[$qKeys["queue"]] = $qKeys["strategy"];
$arQueues[$qKeys["queue"]] = $qKeys["strategy"];
// $arQueues[$qKeys["queue"]] = $qKeys;
// $arQueues[] = $qKeys["queue"];
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment