Commit 83d993bd authored by Kulya's avatar Kulya 😊

Test is Admin

parent f338e9c4
......@@ -97,7 +97,7 @@
</div>
</div>
<div class="form-group row">
<!--div class="form-group row">
<div class="form-group ml-4">
<div class="form-check">
<label class="form-check-label" for="autocreateentity">Авто создание лида при вызове</label>
......@@ -109,16 +109,16 @@
</select>
</div>
</div>
</div>
</div-->
<!--div class="form-group row">
<div class="form-group row">
<div class="form-group ml-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="autocreatelead">
<label class="form-check-label" for="autocreatelead">Авто создание лида при вызове</label>
</div>
</div>
</div-->
</div>
<div class="form-group row">
<div class="form-group ml-4">
......
......@@ -1143,6 +1143,7 @@ class AloVoiceConnector
public function returnView(){
$wrap=true;
$req_is_admin = BxRest::call("user.admin");
// var_dump($req_is_admin);
$this->isAdmin = ($req_is_admin["result"]=="1") ? true : false;
$arResult = false;
......
......@@ -308,11 +308,12 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener
$lId = $eventKeys["destlinkedid"];
$uId = $eventKeys["destuniqueid"];
$beginCallTime = (!empty($bxchannels[$eventKeys["linkedid"]]["BX24_begincall"])) ? $bxchannels[$eventKeys["linkedid"]]["BX24_begincall"] : time();
$callRegisterParams = array(
// 'CALL_START_DATE' => date("Y-m-d H:i",$bxchannels[$eventKeys["linkedid"]]["BX24_begincall"] ), //'2016-16-11 10:10',
'CALL_START_DATE' => date("c",$bxchannels[$eventKeys["linkedid"]]["BX24_begincall"] ), //'2016-16-11 10:10',
'CRM_CREATE' => 1, //(!empty($this->config["autocreatelead"]) && !empty($this->config["autocreatelead"]=="false")) ? 0 : 1,
'SHOW' => (!empty($this->config["showcallcard"]) && !empty($this->config["showcallcard"]=="false")) ? 0 : 1,
'CALL_START_DATE' => date("c",$beginCallTime ), //'2016-16-11 10:10',
'CRM_CREATE' => (empty($this->config["autocreatelead"]) || $this->config["autocreatelead"]=="false") ? 0 : 1,
'SHOW' => (empty($this->config["showcallcard"]) && $this->config["showcallcard"]=="false") ? 0 : 1,
'DESC' => "AloVoiceCall"
);
......@@ -328,9 +329,9 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener
$callRegisterParams["CRM_ENTITY_ID"] = $bxchannels[$eventKeys["linkedid"]]["BX24_CRM_ID"];
}
$callRegisterParams["TYPE"] = ($bxchannels[$eventKeys["linkedid"]]["BX24_DIRECTION"]=='INBOUND') ? 2 : 1;
$callRegisterParams["TYPE"] = (!empty($bxchannels[$eventKeys["linkedid"]]["BX24_DIRECTION"]) && $bxchannels[$eventKeys["linkedid"]]["BX24_DIRECTION"]=='OUTCALL') ? 1 : 2;
if( $bxchannels[$eventKeys["linkedid"]]["BX24_DIRECTION"]=='INBOUND' ) {
if( $callRegisterParams["TYPE"]==2 ) {
if( !empty($bxchannels[$eventKeys["linkedid"]]["BX24_EXTEN"]) ){ //) && (is_numeric($eventKeys["BX24_EXTEN"]))
$callRegisterParams["LINE_NUMBER"] = substr($bxchannels[$eventKeys["linkedid"]]["BX24_EXTEN"],-9);
}
......@@ -338,7 +339,7 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener
$callRegisterParams["LINE_NUMBER"] = substr($eventKeys["destcalleridnum"],-9);
}
}
elseif( $bxchannels[$eventKeys["linkedid"]]["BX24_DIRECTION"]=='OUTCALL' ){
elseif( $callRegisterParams["TYPE"]==1 ){
if(is_numeric($eventKeys["calleridnum"])){
$callRegisterParams["LINE_NUMBER"] = $eventKeys["calleridnum"];
}
......@@ -346,7 +347,7 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener
$connLineNum = (!empty($eventKeys["connectedlinenum"])) ? substr($eventKeys["connectedlinenum"],-9) : false;
if($bxchannels[$eventKeys["linkedid"]]["BX24_DIRECTION"]=='OUTCALL'){
if($callRegisterParams["TYPE"]==1){
$callRegisterParams["USER_PHONE_INNER"] = $bxchannels[$eventKeys["linkedid"]]["BX24_CALLERID"];
$callRegisterParams["USER_ID"] = $this->bxusers[$bxchannels[$eventKeys["linkedid"]]["BX24_CALLERID"]]["ID"];
$callRegisterParams["PHONE_NUMBER"] = (is_numeric($connLineNum)) ? $connLineNum : substr($eventKeys["destexten"],-9);
......@@ -544,128 +545,12 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener
}
elseif ($eventName == "Newchannel" && $eventKeys["channelstate"] == "0" && $eventKeys["uniqueid"] != $eventKeys["linkedid"]) {
//$BX_USERID = 1;
self::eLog($eventKeys,"--== INSIDE Newchannel Event Call Handle".$eventKeys["uniqueid"] );
self::eLog($bxchannels[$eventKeys["linkedid"]],"--== INSIDE CHANNEL ALL VARS: ");
$callerIdNumber = (!empty($bxchannels[$eventKeys["linkedid"]]["calleridnum"])) ? $bxchannels[$eventKeys["linkedid"]]["calleridnum"] : false;
//$bxchannels[$eventKeys["linkedid"]] = $eventKeys;
//$bxchannels[$eventKeys["linkedid"]]["BX24_begincall"] = time();
//$curEnt["ASSIGNED_BY"]["USER_PHONE_INNER"]
//$curEnt["ASSIGNED_BY_ID"]["USER_PHONE_INNER"]
//"ASSIGNED_BY":{"ID":"6","TIMEMAN_STATUS":"CLOSED","USER_PHONE_INNER":"1002"
/*
{"result":[
{"CRM_ENTITY_TYPE":"CONTACT","CRM_ENTITY_ID":"242","ASSIGNED_BY_ID":"1","NAME":"Kulya_Test_Uzonline Uzonline_Test","ASSIGNED_BY":{"ID":"1","TIMEMAN_STATUS":"CLOSED","USER_PHONE_INNER":"1200","WORK_PHONE":"","PERSONAL_PHONE":"","PERSONAL_MOBILE":"+998974244100"}},
{"CRM_ENTITY_TYPE":"LEAD","CRM_ENTITY_ID":"288","ASSIGNED_BY_ID":"1","NAME":"998994412860 - \u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0437\u0432\u043e\u043d\u043e\u043a","ASSIGNED_BY":{"ID":"1","TIMEMAN_STATUS":"CLOSED","USER_PHONE_INNER":"1200","WORK_PHONE":"","PERSONAL_PHONE":"","PERSONAL_MOBILE":"+998974244100"}}
],"time":{"start":"1572010218.2746","finish":"1572010218.3882","duration":"0.1136269569397","processing":"0.066923141479492","date_start":"2019-10-25T16:30:18+03:00","date_finish":"2019-10-25T16:30:18+03:00"}}
*/
/* if(!empty($crmEntitySearchResult["result"])){
$curEnt = end($crmEntitySearchResult["result"]);
self::eLog($curEnt,"--== Current CRM Entity on BITRIX");
$crmEntityGetInfoResult = BxRest::call("crm.lead.get",array( 'id' => $curEnt["CRM_ENTITY_ID"] ));
self::eLog($crmEntityGetInfoResult,"--== crmEntityGetInfoResult CALL on BITRIX");
//{"result":{"ID":"288","TITLE":"998994412860 - \u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0437\u0432\u043e\u043d\u043e\u043a","HONORIFIC":"0","NAME":"","SECOND_NAME":"","LAST_NAME":"","COMPANY_TITLE":"","COMPANY_ID":"0","CONTACT_ID":"","IS_RETURN_CUSTOMER":"N","BIRTHDATE":"","SOURCE_ID":"CALL","SOURCE_DESCRIPTION":"\u0417\u0432\u043e\u043d\u043e\u043a \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043b \u043d\u0430 \u043d\u043e\u043c\u0435\u0440: \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435: \u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441 Asterisk.","STATUS_ID":"JUNK","STATUS_DESCRIPTION":"","POST":"","COMMENTS":"","CURRENCY_ID":"RUB","OPPORTUNITY":"0.00","HAS_PHONE":"Y","HAS_EMAIL":"N","HAS_IMOL":"N","ASSIGNED_BY_ID":"1","CREATED_BY_ID":"1","MODIFY_BY_ID":"1","DATE_CREATE":"2019-10-14T17:36:53+03:00","DATE_MODIFY":"2019-10-22T08:15:13+03:00","DATE_CLOSED":"2019-10-22T08:15:13+03:00","STATUS_SEMANTIC_ID":"F","OPENED":"Y","ORIGINATOR_ID":"","ORIGIN_ID":"","ADDRESS":"","ADDRESS_2":"","ADDRESS_CITY":"","ADDRESS_POSTAL_CODE":"","ADDRESS_REGION":"","ADDRESS_PROVINCE":"","ADDRESS_COUNTRY":"","ADDRESS_COUNTRY_CODE":"","UTM_SOURCE":"","UTM_MEDIUM":"","UTM_CAMPAIGN":"","UTM_CONTENT":"","UTM_TERM":"","UF_CRM_SECRET":"3f684","UF_CRM_5D9779809395B":"","PHONE":[{"ID":"1584","VALUE_TYPE":"WORK","VALUE":"+998994412860","TYPE_ID":"PHONE"}]},"time":{"start":"1572012057.2742","finish":"1572012057.3448","duration":"0.070608854293823","processing":"0.026230096817017","date_start":"2019-10-25T17:00:57+03:00","date_finish":"2019-10-25T17:00:57+03:00"}}
} */
/*$searchStaff = BxRest::call("user.search",array(
"FILTER" => array("UF_PHONE_INNER"=>$eventKeys["exten"])
));
self::eLog($searchStaff,"--== searchStaffResult INSIDE SEARCH STAFFS on BITRIX");
*/
/*
$callingNum = preg_replace("/[^0-9]/", '', $callerIdNumber);
$callToNum = preg_replace("/[^0-9]/", '', $eventKeys["exten"]);
$callToLineNum = preg_replace("/[^0-9]/", '', $bxchannels[$eventKeys["linkedid"]]["exten"]);
if(strlen($callingNum)==9){
$callingNum = '+998'.$callingNum;
}
elseif( strlen($callingNum)>9 ){
$callingNum = '+'.$callingNum;
}
if(!empty($bxonusers[$eventKeys["exten"]])){
$callUserId = $bxonusers[$eventKeys["exten"]]["ID"];
}
if((empty($callUserId)) && (!empty($bxonusers[$eventKeys["calleridnum"]]))){
$callUserId = $bxonusers[$eventKeys["calleridnum"]]["ID"];
}
$callerName = '';
$callerBxID = '';
$callerCrmInfo = (!empty($bxchannels[$eventKeys["linkedid"]]["caller_contact"])) ? $bxchannels[$eventKeys["linkedid"]]["caller_contact"] : false;
self::eLog($callerCrmInfo,"--================== INSIDE CALL CHECk CALLER_CONTACT ==============----------------");
if(!empty($callerCrmInfo)){
$callerName = $callerCrmInfo["NAME"].': ';
$callerBxEtype = $callerCrmInfo["CRM_ENTITY_TYPE"]; //$bxchannels[$eventKeys["linkedid"]]["caller_etype"];
$callerBxID = (!empty($callerCrmInfo[$callerBxEtype."_ID"])) ? $callerCrmInfo[$callerBxEtype."_ID"] : ''; //$bxchannels[$eventKeys["linkedid"]]["caller_cid"];
}
self::eLog($bxonusers,"--================== INSIDE CALL REG CHECk USERS ==============----------------");
if(!empty($callUserId)){
$callRegisterParams = array(
'USER_ID' => $callUserId,
'USER_PHONE_INNER' => $callToNum,
'PHONE_NUMBER' => $callingNum, //"+998909954479", //
'TYPE' => 2,
'CALL_START_DATE' => date("Y-m-d H:i:s", time()-7200), //'2016-16-11 10:10',
'CRM_CREATE' => 1, //false //true])
);
// //$BX_USERID = 1;
// self::eLog($eventKeys,"--== INSIDE Newchannel Event Call Handle".$eventKeys["uniqueid"] );
// self::eLog($bxchannels[$eventKeys["linkedid"]],"--== INSIDE CHANNEL ALL VARS: ");
// $callerIdNumber = (!empty($bxchannels[$eventKeys["linkedid"]]["calleridnum"])) ? $bxchannels[$eventKeys["linkedid"]]["calleridnum"] : false;
$fromLink = (!empty($callerBxEtype) && !empty($callerBxID) ) ? "[url=https://4uz.bitrix.ru/crm/".$callerBxEtype."/details/".$callerBxID."/]".$callerName."[/url] " : "";
$callIncomIMMsgResult = BxRest::call("im.notify",array(
'to' => $callUserId,
'message' => "Вх. звонок от: #BR# ".$fromLink." ".$callingNum,
//'TYPE' => "SYSTEM",
));
if(!empty($callToLineNum)){
$callRegisterParams["LINE_NUMBER"] = $callToLineNum;
}
if(!empty($callerBxID)){
$callRegisterParams["CRM_ENTITY_TYPE"] = strtoupper($callerBxEtype);
$callRegisterParams["CRM_ENTITY_ID"] = $callerBxID;
}
self::eLog($callRegisterParams,"--== PARAMS for Register CALL on BITRIX");
$registerResult = BxRest::call("telephony.externalcall.register",$callRegisterParams);
self::eLog($registerResult,"--== Register CALL on BITRIX");
//BX24_USERID BX24_CALLID BX24_begincall
if (!empty($registerResult["result"]["CALL_ID"])) {
$bxCallID = $registerResult["result"]["CALL_ID"];
self::eLog($bxCallID,"--== Registered CALL_ID CHECKING:");
$bxchannels[$eventKeys["uniqueid"]] = array(
'BX24_CALLID' => $bxCallID,
'BX24_FROM_NUMBER' => $callingNum,
'BX24_INNER_PHONE' => $callToNum
);
$bxchannels[$eventKeys["linkedid"]]["callnums"][$callToNum] = $bxCallID;
$bxchannels[$eventKeys["linkedid"]]["calls"][$eventKeys["uniqueid"]] = $bxCallID;
}
if(!empty($bxchannels[$eventKeys["linkedid"]])){
self::eLog($bxchannels[$eventKeys["linkedid"]]["calls"],"--== Registered CALL_ID to Calls:".$eventKeys["linkedid"]);
}
}
*/
}
elseif ( ( $eventName == "Hangup" ) && ($eventKeys["uniqueid"] != $eventKeys["linkedid"])) {
......
......@@ -283,6 +283,59 @@ class AloVoiceRest
]
);
// BX24.callMethod( 'imconnector.send.messages', {
// "LINE": 1,
// "CONNECTOR": "tgclient998944412860",
// "MESSAGES": [
// {
// 'user' : {
// 'id' : "124987160",
// 'name' : "Kulya_124987160",
// 'phone' : "998994412860",
// },
// 'message' : {
// 'id' : 2547263547265,
// 'date' : 1642485811,
// 'text' : "Пробнобное сообщение",
// },
// 'chat' : {
// 'id' : "124987160",
// 'name' : "Kulya_124987160",
// //'url' => htmlspecialchars($_SERVER['HTTP_REFERER']),
// },
// }
// ]
// },function(result){
// console.log(result);
// });
// BX24.callMethod( 'imconnector.send.messages', {
// "LINE": 1,
// "CONNECTOR": "tgclient998944412860",
// "MESSAGES": [
// {
// 'user' : {
// 'id' : "124987168",
// 'name' : "DANIIL NAGAY KAMILEVICH",
// },
// 'message' : {
// 'id' : 2547263547265,
// 'date' : 1642485911,
// 'text' : "Пробнобное сообщение",
// },
// 'chat' : {
// 'id' : "124987168",
// 'name' : "DANIIL NAGAY KAMILEVICH",
// //'url' => htmlspecialchars($_SERVER['HTTP_REFERER']),
// },
// }
// ]
// },function(result){
// console.log(result);
// });
// ALVC::eLog($result,"------ AloVoiceRest :: IncomMsg Bx RES ----------");
// ALVC::eLog($this->config["basedir"],"------ AloVoiceRest :: IncomMsg BaseDIR ----------");
......
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