Commit 4b500395 authored by Kulya's avatar Kulya 😊

sip_reg_period_to_10

parent 1b26165d
......@@ -90,6 +90,9 @@ die();
function doCommandAjax($cmd,$r){
switch ($cmd) {
case 'addNewMohFile':
return addNewMohFile($r);
break;
case 'removeInroute':
return removeInroute($r);
break;
......@@ -665,8 +668,12 @@ function saveQueue($data,$r=true){
}
}
$music = (!empty($data["music"])) ? $data["music"] : false;
if(empty($music) && !empty($oQueue["music"])) { $music = $oQueue["music"]; } elseif(empty($music)) {$music = 'default';}
$strategy = (!empty($data["strategy"])) ? $data["strategy"] : false;
if(empty($strategy) && !empty($oQueue["strategy"])) { $strategy = $oQueue["strategy"]; } else {$strategy = 'ringall';}
if(empty($strategy) && !empty($oQueue["strategy"])) { $strategy = $oQueue["strategy"]; } elseif(empty($strategy)) {$strategy = 'ringall';}
$agentannounce_id = (!empty($data["agentannounce_id"])) ? $data["agentannounce_id"] : (!empty($oQueue["agentannounce_id"])) ? $oQueue["agentannounce_id"] : NULL;
$joinannounce_id = (!empty($data["joinannounce_id"])) ? $data["joinannounce_id"] : (!empty($oQueue["joinannounce_id"])) ? $oQueue["joinannounce_id"] : NULL;
......@@ -713,7 +720,7 @@ function saveQueue($data,$r=true){
$fields[] = [$account,'autopausebusy',(!empty($oQueue["autopausebusy"])) ? $oQueue["autopausebusy"] : 'no',0];
$fields[] = [$account,'autopauseunavail',(!empty($oQueue["autopauseunavail"])) ? $oQueue["autopauseunavail"] : 'no',0];
$fields[] = [$account,'music',(!empty($oQueue["music"])) ? $oQueue["music"] : 'default',0];
$fields[] = [$account,'music',$music,0];
//there can be multiple members
......@@ -834,3 +841,67 @@ function makeMembers($members){
return $members;
}
function addNewMohFile( $r=[] ) {
if(empty($r["arfile"])){
return false;
}
global $db,$astman,$amp_conf;
$arFile = $r["arfile"];
$mohdir = '/var/lib/asterisk/moh/';
$uniqName = $arFile["time"];
$newMohDir = $mohdir.$uniqName;
$newMohFileName = $newMohDir."/".$uniqName;
$newMohFile = $newMohFileName.".".$arFile["ext"];
if(!is_dir($newMohDir)){
mkdir($newMohDir,0777);
}
if(!empty($arFile["filepath"]) && file_exists($arFile["filepath"])){
$origFile = $arFile["filepath"];
// copy($arFile["filepath"],$newMohFile);
}
$media = \FreePBX::Media(); //\FreePBX::Music()->Media;
// $media = $fbxMusic->Media();
$media->load($origFile);
$arCodecs = ["alaw","ulaw","g722","wav"];
foreach($arCodecs as $codec) {
$fmpath = $newMohFileName.".".$codec;
if(!file_exists($fmpath)) {
$media->convert($fmpath);
}
}
$db = \FreePBX::Database();
$sql = "INSERT INTO music (`category`, `type`, `application`, `format`) VALUES ('".$uniqName."', 'files', '', '')";
$ob = $db->query($sql);
return $db->lastInsertId();
}
function addCategoryById( $id, $name, $type ) {
$name = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $name);
$name = preg_replace("/\s+|'+|`+|\\+|\/+|\"+|<+|>+|\?+|\*|\.+|&+|\|/","",$name);
$name = basename($name);
$cat = $this->getCategoryByName($name);
if(!empty($cat)) {
$this->message = array(
"type" => "danger",
"message" => _("Category Already Exists")
);
return;
}
$sql = "INSERT INTO music (`id`, `category`, `type`) VALUES (?, ?,?)";
$sth = $this->db->prepare($sql);
$sth->execute(array($id,$name,$type));
if(!file_exists($this->mohpath . "/" . $name)) {
mkdir($this->mohpath . "/" . $name);
}
needreload();
}
\ No newline at end of file
......@@ -28,6 +28,12 @@ document, html, body {
width:100%;
font-family: "OpenSans-Semibold","Helvetica Neue",Arial,Helvetica,sans-serif !important;
}
.alvcontainer{
padding:0 !important;
margin:0 !important;
width: 100% !important;
height: 100% !important;
}
.afilelabel {
/* width: 250px; */
height: 40px;
......@@ -70,6 +76,7 @@ document, html, body {
}
#alv_mainblock{
padding-top: 50px;
height: 100%;
}
.alv_topmenu a.active {
font-weight: bold;
......@@ -83,6 +90,7 @@ document, html, body {
.alv_topmenu{
display: inline-flex;
box-shadow: 0 6px 15px -15px #000;
margin:auto !important;
}
.alv_topmenu:hover {
background-color: #ececff;
......
......@@ -33,6 +33,13 @@ var delOneDid = function(cid,did,me){
});
};
var loadAlovoiceSounds = function(){
loadAloVoiceInfo("alovoice_soundfiles_list",function(sounds){
console.log("--== get sounds RES:",sounds);
});
}
var loadAlVOperators = function(destination_code){
$("#destination_code_container").html('<span>Загрузка...</span>');
loadAloVoiceInfo("alovoice_get_operators_nums",function(operators){
......
......@@ -4,6 +4,7 @@
$().ready(() => {
window.getAllStrateges = function () {
return [
{
......@@ -87,86 +88,98 @@ $().ready(() => {
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>';
});
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 );
loadAloVoiceInfo("alovoice_soundfiles_list",function(sounds){
console.log("--== get sounds RES:",sounds);
if (!queuenum || queuenum < 6000 || queuenum > 6999) {
Swal.showValidationMessage(
`Некорректный номер очереди! <br>требуется от 6000 до 6999`
)
$("#add_queue_inp").addClass("swal2-inputerror");
return false;
}
},
html: ''
var soundsOpts = '';
$.each( sounds, function( key, value ) {
var seltxt = (typeof queue_music != 'undefined' && queue_music==key) ? " seleted" : "";
soundsOpts += '<option value="'+key+'"'+seltxt+'>'+value.title+'</option>';
});
+'<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);
});
var strategyOpts = '';
window.getAllStrateges().forEach(function(elm){
var seltxt = (elm.select) ? " seleted" : "";
strategyOpts += '<option value="'+elm.value+'"'+seltxt+'>'+elm.title+'</option>';
});
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: ''
}
+'<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> '
+'<select id="music" class="swal2-select row mx-0">'
+soundsOpts
+'</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();
var music = $('#music').val();
console.log("Queue SAVEing Params:",queuenum, final_destination, queue_destination_code, queue_strategy, music );
doAloVoiceCmd('saveQueue', {
account: queuenum,
goto: final_destination,
queue_destination_code: queue_destination_code,
strategy: queue_strategy,
music: music
}, function() {
uiLoadingEnd();
// alert(queuenum + ' успешно добавлен! ' + queue);
});
}
});
});
});
})
......
......@@ -10,7 +10,11 @@
position: absolute;
width: 100%;
left: 0;
height: calc(100% - 50px);
}
.queues_incontent{
height: calc(100% - 40px);
}
.queues_agent_icon {
position: absolute;
padding: 2px;
......@@ -19,26 +23,31 @@
width: 22px;
height: 22px;
}
#footer_panel{
width:100%;
}
</style>
<div class="queues_content px-2 pt-5">
<!-- <div class="row" >
<div class="queues_content px-2">
<!-- <div class="row" > pt-5 border
<h3 class="h3 card-body text-center">Звонки</h3>
</div> -->
<div class="row p-1 bg-light border">
<div class="row p-1 bg-light queues_incontent">
<div class="col-8">
<div id="agents"></div>
<div>
<button type="button" class="btn btn-outline-info" id="queues_update">
<i data-feather="rotate-ccw" class="w-2 h-2" width="0.7em" height="0.7em"></i> Обновить
</button>
<button type="button" class="btn btn-outline-primary" id="queues_add">
<i data-feather="plus" class="w-2 h-2" width="0.7em" height="0.7em"></i> Добавить очередь
</button>
</div>
</div>
<div class="col-4" id="queues"></div>
</div>
<div id="footer_panel">
<button type="button" class="btn btn-outline-info" id="queues_update">
<i data-feather="rotate-ccw" class="w-2 h-2" width="0.7em" height="0.7em"></i> Обновить
</button>
<button type="button" class="btn btn-outline-primary" id="queues_add">
<i data-feather="plus" class="w-2 h-2" width="0.7em" height="0.7em"></i> Добавить очередь
</button>
</div>
</div>
......
......@@ -143,27 +143,38 @@ function addNewSoundAccount(){
var soundName = $("#alv_sound_name").val();
if(!soundName){ alert("No Name sound"); return true; }
var saveElements = window.uploadedarfile;
saveElements["restmethod"] = "savealovoiceonesound";
saveElements["title"] = soundName;
var saveElements = window.uploadedarfile;
loadAloVoiceInfo(saveElements,function(res){
console.log("Save RES: ",res);
if(typeof res.time != 'undefined'){
res["id"] = res.time;
res['link'] = window.soundspath + res.name;
$("#alvsounds_table_body").append(makeLineHtml(res));
setTimeout(function(){makePlayers('#snd_plr_'+res.time)},500);
$("#modalCloseBtn").click();
loadAloVoiceInfo({
"cmd": "addNewMohFile",
"arfile": window.uploadedarfile,
},function(res){
console.log("Save RES MOH: ",res);
if(typeof res != 'undefined' && res){
saveElements["restmethod"] = "savealovoiceonesound";
saveElements["title"] = soundName;
saveElements["moh_id"] = res;
loadAloVoiceInfo(saveElements,function(res){
console.log("Save RES: ",res);
if(typeof res.time != 'undefined'){
res["id"] = res.time;
res['link'] = window.soundspath + res.name;
$("#alvsounds_table_body").append(makeLineHtml(res));
setTimeout(function(){makePlayers('#snd_plr_'+res.time)},500);
$("#modalCloseBtn").click();
}
// $("#alv_settings_form").prepend('<div class="alert alert-success" id="savesuccesbox" role="alert">Настройки сохранены!</div>');
// setTimeout(function(){
// $("#savesuccesbox").remove();
// },3000);
});
}
// $("#alv_settings_form").prepend('<div class="alert alert-success" id="savesuccesbox" role="alert">Настройки сохранены!</div>');
// setTimeout(function(){
// $("#savesuccesbox").remove();
// },3000);
});
}
});
......
......@@ -14,6 +14,7 @@ class AloVoiceActions
private $options;
private $client;
private $configs;
private $mohdir;
public function __construct($config,$conn=false) {
//$config = ALVC::getConfigs();
......@@ -41,6 +42,7 @@ class AloVoiceActions
}
$this->configs = $config;
$this->mohdir = "/var/lib/asterisk/moh/";
}
public function doAction() {
......@@ -816,6 +818,9 @@ class AloVoiceActions
public function getAlovoiceSaveSound($arfile=false){
unset($arfile["restmethod"]);
$mohdir = $this->mohdir;
$soundsDir = ALVC::getSoundsPath();
$soundsJSON = $soundsDir.'sounds.json';
$arSounds = [];
......
......@@ -1702,7 +1702,7 @@ AppGUID=00DE6AE6-4E26-EB11-ACBB-6D762EC99F4D
Mailbox=
PhoneNumber=
MWI=1
RegisterPeriod=600
RegisterPeriod=10
ConnectionType=0
NoFallback=0
Alias=0
......
......@@ -1483,6 +1483,10 @@ sessid: 40512ed0288d707e78dc4f7ef25214ef
return $alvActions->getAlovoiceSaveSound($r);
}
private function alovoice_soundfiles_list($r=false) {
$alvActions = new AloVoiceActions($this->config);
return $alvActions->getAlovoiceSoundsList();
}
private function alovoice_sounds_list($r=false) {
$alvActions = new AloVoiceActions($this->config);
return $alvActions->getAlovoiceSounds();
......
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