Created new function to connect calls and modify some small changes
Showing
1 changed file
with
12 additions
and
25 deletions
| ... | @@ -1473,7 +1473,6 @@ class KPAMIListen implements IEventListener | ... | @@ -1473,7 +1473,6 @@ class KPAMIListen implements IEventListener |
| 1473 | 1473 | ||
| 1474 | if($crmcall) | 1474 | if($crmcall) |
| 1475 | { | 1475 | { |
| 1476 | $nowts=microtime(true)*1000; | ||
| 1477 | $crmcalldata=json_decode($crmcall->data,true); | 1476 | $crmcalldata=json_decode($crmcall->data,true); |
| 1478 | if(!isset($crmcalldata["userbusyfile"]))$crmcalldata["userbusyfile"]=0; | 1477 | if(!isset($crmcalldata["userbusyfile"]))$crmcalldata["userbusyfile"]=0; |
| 1479 | 1478 | ||
| ... | @@ -1485,29 +1484,20 @@ class KPAMIListen implements IEventListener | ... | @@ -1485,29 +1484,20 @@ class KPAMIListen implements IEventListener |
| 1485 | { | 1484 | { |
| 1486 | echo "sipids found "; | 1485 | echo "sipids found "; |
| 1487 | 1486 | ||
| 1488 | $first_r=0;$first_w=0;$first_a=0;$allsipids=array(); | ||
| 1489 | |||
| 1490 | foreach($sipids as $sipid) | 1487 | foreach($sipids as $sipid) |
| 1491 | { | 1488 | { |
| 1492 | $clientsarr=json_decode($sipid->clients,true); | 1489 | $this->connectToAvailableSip($sipid, $dialline, $crmcall); |
| 1493 | if($crmcall->client=="")$first_a=$sipid; | 1490 | } |
| 1494 | else | 1491 | } |
| 1495 | { | 1492 | } |
| 1496 | if($clientsarr['a']!="")$clientaarr = explode(",", $clientsarr['a']); | 1493 | } |
| 1497 | if(isset($clientsarr['a'])&&in_array($crmcall->client, $clientaarr))$first_a=$sipid; | ||
| 1498 | if($clientsarr['w']!="")$clientwarr = explode(",", $clientsarr['w']); | ||
| 1499 | if(isset($clientsarr['w'])&&in_array($crmcall->client, $clientwarr))$first_w=$sipid; | ||
| 1500 | if($clientsarr['r']!="")$clientrarr = explode(",", $clientsarr['r']); | ||
| 1501 | if(isset($clientsarr['r'])&&in_array($crmcall->client, $clientrarr))$first_r=$sipid; | ||
| 1502 | } | 1494 | } |
| 1503 | } | 1495 | } |
| 1504 | 1496 | ||
| 1505 | echo "Notifying Total ::".sizeof($allsipids)."\n"; | 1497 | private function connectToAvailableSip($sipid, $dialline, $crmcall) |
| 1506 | 1498 | { | |
| 1507 | $found=false; | 1499 | $nowts=microtime(true)*1000; |
| 1508 | if($first_a)$found=$first_a; | 1500 | $found=$sipid; |
| 1509 | else if($first_w)$found=$first_w; | ||
| 1510 | else if($first_r)$found=$first_r; | ||
| 1511 | 1501 | ||
| 1512 | if($found) | 1502 | if($found) |
| 1513 | { | 1503 | { |
| ... | @@ -1526,7 +1516,7 @@ class KPAMIListen implements IEventListener | ... | @@ -1526,7 +1516,7 @@ class KPAMIListen implements IEventListener |
| 1526 | $userEntry = User::find($found->user); | 1516 | $userEntry = User::find($found->user); |
| 1527 | 1517 | ||
| 1528 | if(!empty($userEntry)){ | 1518 | if(!empty($userEntry)){ |
| 1529 | if($userEntry->current_dialmode != "Predictive" || $found->ready != 1 || $dialline->regexstr != $userEntry->sel_campaign) return; | 1519 | if($userEntry->current_dialmode != "Predictive" || $found->ready != 1) return; |
| 1530 | } | 1520 | } |
| 1531 | 1521 | ||
| 1532 | exec("/usr/sbin/asterisk -rx 'core show channel $dialline->channel'",$channelArr); | 1522 | exec("/usr/sbin/asterisk -rx 'core show channel $dialline->channel'",$channelArr); |
| ... | @@ -1601,11 +1591,8 @@ class KPAMIListen implements IEventListener | ... | @@ -1601,11 +1591,8 @@ class KPAMIListen implements IEventListener |
| 1601 | $newqueue=new Kqueue(); | 1591 | $newqueue=new Kqueue(); |
| 1602 | $newqueue->sipNotify($found,"incomingCall",$crmcall->id,$crmcall->crm_id,$crmcall->number."@".$dialline->channel); | 1592 | $newqueue->sipNotify($found,"incomingCall",$crmcall->id,$crmcall->crm_id,$crmcall->number."@".$dialline->channel); |
| 1603 | } | 1593 | } |
| 1604 | } | 1594 | |
| 1605 | } | 1595 | } |
| 1606 | } | ||
| 1607 | } | ||
| 1608 | } | ||
| 1609 | 1596 | ||
| 1610 | // private function redirectIncoming() | 1597 | // private function redirectIncoming() |
| 1611 | // { | 1598 | // { | ... | ... |
-
Please register or sign in to post a comment