Commit 1b26165d authored by Kulya's avatar Kulya 😊

first routing added5

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