Commit 4b500395 authored by Kulya's avatar Kulya 😊

sip_reg_period_to_10

parent 1b26165d
...@@ -90,6 +90,9 @@ die(); ...@@ -90,6 +90,9 @@ die();
function doCommandAjax($cmd,$r){ function doCommandAjax($cmd,$r){
switch ($cmd) { switch ($cmd) {
case 'addNewMohFile':
return addNewMohFile($r);
break;
case 'removeInroute': case 'removeInroute':
return removeInroute($r); return removeInroute($r);
break; break;
...@@ -665,8 +668,12 @@ function saveQueue($data,$r=true){ ...@@ -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; $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; $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; $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){ ...@@ -713,7 +720,7 @@ function saveQueue($data,$r=true){
$fields[] = [$account,'autopausebusy',(!empty($oQueue["autopausebusy"])) ? $oQueue["autopausebusy"] : 'no',0]; $fields[] = [$account,'autopausebusy',(!empty($oQueue["autopausebusy"])) ? $oQueue["autopausebusy"] : 'no',0];
$fields[] = [$account,'autopauseunavail',(!empty($oQueue["autopauseunavail"])) ? $oQueue["autopauseunavail"] : '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 //there can be multiple members
...@@ -834,3 +841,67 @@ function makeMembers($members){ ...@@ -834,3 +841,67 @@ function makeMembers($members){
return $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 { ...@@ -28,6 +28,12 @@ document, html, body {
width:100%; width:100%;
font-family: "OpenSans-Semibold","Helvetica Neue",Arial,Helvetica,sans-serif !important; 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 { .afilelabel {
/* width: 250px; */ /* width: 250px; */
height: 40px; height: 40px;
...@@ -70,6 +76,7 @@ document, html, body { ...@@ -70,6 +76,7 @@ document, html, body {
} }
#alv_mainblock{ #alv_mainblock{
padding-top: 50px; padding-top: 50px;
height: 100%;
} }
.alv_topmenu a.active { .alv_topmenu a.active {
font-weight: bold; font-weight: bold;
...@@ -83,6 +90,7 @@ document, html, body { ...@@ -83,6 +90,7 @@ document, html, body {
.alv_topmenu{ .alv_topmenu{
display: inline-flex; display: inline-flex;
box-shadow: 0 6px 15px -15px #000; box-shadow: 0 6px 15px -15px #000;
margin:auto !important;
} }
.alv_topmenu:hover { .alv_topmenu:hover {
background-color: #ececff; background-color: #ececff;
......
...@@ -33,6 +33,13 @@ var delOneDid = function(cid,did,me){ ...@@ -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){ var loadAlVOperators = function(destination_code){
$("#destination_code_container").html('<span>Загрузка...</span>'); $("#destination_code_container").html('<span>Загрузка...</span>');
loadAloVoiceInfo("alovoice_get_operators_nums",function(operators){ loadAloVoiceInfo("alovoice_get_operators_nums",function(operators){
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
$().ready(() => { $().ready(() => {
window.getAllStrateges = function () { window.getAllStrateges = function () {
return [ return [
{ {
...@@ -87,86 +88,98 @@ $().ready(() => { ...@@ -87,86 +88,98 @@ $().ready(() => {
console.log("--===Each goto:",key, value); console.log("--===Each goto:",key, value);
gotosOpts += '<option value="'+key+'"'+seltxt+'>'+value+'</option>'; 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({ loadAloVoiceInfo("alovoice_soundfiles_list",function(sounds){
title: 'Введите номер очереди', console.log("--== get sounds RES:",sounds);
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 );
var soundsOpts = '';
if (!queuenum || queuenum < 6000 || queuenum > 6999) { $.each( sounds, function( key, value ) {
Swal.showValidationMessage( var seltxt = (typeof queue_music != 'undefined' && queue_music==key) ? " seleted" : "";
`Некорректный номер очереди! <br>требуется от 6000 до 6999` soundsOpts += '<option value="'+key+'"'+seltxt+'>'+value.title+'</option>';
) });
$("#add_queue_inp").addClass("swal2-inputerror");
return false;
}
},
html: ''
+'<input id="add_queue_inp" class="swal2-input row mx-0" type="text">' var strategyOpts = '';
window.getAllStrateges().forEach(function(elm){
+'<div class="row"></div>' var seltxt = (elm.select) ? " seleted" : "";
strategyOpts += '<option value="'+elm.value+'"'+seltxt+'>'+elm.title+'</option>';
+'<h2 class="swal2-title">Правила приёма звонок: </h2> ' });
+'<select id="queue_strategy" class="swal2-select row mx-0">' swal.fire({
+strategyOpts title: 'Введите номер очереди',
+'</select>' showCancelButton: true,
cancelButtonText: 'Отмена',
+'<h2 class="swal2-title">Все время ожидание в очереди (сек): </h2> ' preConfirm: () => {
var queuenum = $('#add_queue_inp').val();
+'<input id="queue_maxwait" class="swal2-input row mx-0" type="number" value="0"> <small>0 - Неограничено</small>' var final_destination = $('#final_destination').val();
var queue_strategy = $('#queue_strategy').val();
+'<h2 class="swal2-title">Направление при не ответе: </h2> ' var queuenum = queuenum.replace(/\D+/g, '');
+'<select id="final_destination" class="swal2-select row mx-0" onChange="final_destination_change(this)">' console.log("Queue Params:",queuenum, final_destination, queue_strategy );
+gotosOpts
+'</select>'
if (!queuenum || queuenum < 6000 || queuenum > 6999) {
+'<div id="final_destination_code_container"></div>' Swal.showValidationMessage(
`Некорректный номер очереди! <br>требуется от 6000 до 6999`
, )
}).then((result) => { $("#add_queue_inp").addClass("swal2-inputerror");
if (result.isConfirmed) { return false;
uiLoading(); }
var queuenum = $('#add_queue_inp').val(); },
var final_destination = $('#final_destination').val(); html: ''
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);
});
} +'<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 @@ ...@@ -10,7 +10,11 @@
position: absolute; position: absolute;
width: 100%; width: 100%;
left: 0; left: 0;
height: calc(100% - 50px);
} }
.queues_incontent{
height: calc(100% - 40px);
}
.queues_agent_icon { .queues_agent_icon {
position: absolute; position: absolute;
padding: 2px; padding: 2px;
...@@ -19,26 +23,31 @@ ...@@ -19,26 +23,31 @@
width: 22px; width: 22px;
height: 22px; height: 22px;
} }
#footer_panel{
width:100%;
}
</style> </style>
<div class="queues_content px-2 pt-5"> <div class="queues_content px-2">
<!-- <div class="row" > <!-- <div class="row" > pt-5 border
<h3 class="h3 card-body text-center">Звонки</h3> <h3 class="h3 card-body text-center">Звонки</h3>
</div> --> </div> -->
<div class="row p-1 bg-light border"> <div class="row p-1 bg-light queues_incontent">
<div class="col-8"> <div class="col-8">
<div id="agents"></div> <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>
<div class="col-4" id="queues"></div> <div class="col-4" id="queues"></div>
</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> </div>
......
...@@ -143,27 +143,38 @@ function addNewSoundAccount(){ ...@@ -143,27 +143,38 @@ function addNewSoundAccount(){
var soundName = $("#alv_sound_name").val(); var soundName = $("#alv_sound_name").val();
if(!soundName){ alert("No Name sound"); return true; } if(!soundName){ alert("No Name sound"); return true; }
var saveElements = window.uploadedarfile;
saveElements["restmethod"] = "savealovoiceonesound"; var saveElements = window.uploadedarfile;
saveElements["title"] = soundName;
loadAloVoiceInfo(saveElements,function(res){ loadAloVoiceInfo({
console.log("Save RES: ",res); "cmd": "addNewMohFile",
if(typeof res.time != 'undefined'){ "arfile": window.uploadedarfile,
res["id"] = res.time; },function(res){
res['link'] = window.soundspath + res.name; console.log("Save RES MOH: ",res);
$("#alvsounds_table_body").append(makeLineHtml(res)); if(typeof res != 'undefined' && res){
setTimeout(function(){makePlayers('#snd_plr_'+res.time)},500); saveElements["restmethod"] = "savealovoiceonesound";
$("#modalCloseBtn").click(); 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 ...@@ -14,6 +14,7 @@ class AloVoiceActions
private $options; private $options;
private $client; private $client;
private $configs; private $configs;
private $mohdir;
public function __construct($config,$conn=false) { public function __construct($config,$conn=false) {
//$config = ALVC::getConfigs(); //$config = ALVC::getConfigs();
...@@ -41,6 +42,7 @@ class AloVoiceActions ...@@ -41,6 +42,7 @@ class AloVoiceActions
} }
$this->configs = $config; $this->configs = $config;
$this->mohdir = "/var/lib/asterisk/moh/";
} }
public function doAction() { public function doAction() {
...@@ -816,6 +818,9 @@ class AloVoiceActions ...@@ -816,6 +818,9 @@ class AloVoiceActions
public function getAlovoiceSaveSound($arfile=false){ public function getAlovoiceSaveSound($arfile=false){
unset($arfile["restmethod"]); unset($arfile["restmethod"]);
$mohdir = $this->mohdir;
$soundsDir = ALVC::getSoundsPath(); $soundsDir = ALVC::getSoundsPath();
$soundsJSON = $soundsDir.'sounds.json'; $soundsJSON = $soundsDir.'sounds.json';
$arSounds = []; $arSounds = [];
......
...@@ -1702,7 +1702,7 @@ AppGUID=00DE6AE6-4E26-EB11-ACBB-6D762EC99F4D ...@@ -1702,7 +1702,7 @@ AppGUID=00DE6AE6-4E26-EB11-ACBB-6D762EC99F4D
Mailbox= Mailbox=
PhoneNumber= PhoneNumber=
MWI=1 MWI=1
RegisterPeriod=600 RegisterPeriod=10
ConnectionType=0 ConnectionType=0
NoFallback=0 NoFallback=0
Alias=0 Alias=0
......
...@@ -1483,6 +1483,10 @@ sessid: 40512ed0288d707e78dc4f7ef25214ef ...@@ -1483,6 +1483,10 @@ sessid: 40512ed0288d707e78dc4f7ef25214ef
return $alvActions->getAlovoiceSaveSound($r); 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) { private function alovoice_sounds_list($r=false) {
$alvActions = new AloVoiceActions($this->config); $alvActions = new AloVoiceActions($this->config);
return $alvActions->getAlovoiceSounds(); 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