19eb3f96 by Manish Mihsra

Added check for user availabe in the campaign and then taking sipid value

1 parent 00ecc086
...@@ -80,7 +80,7 @@ class PredictiveCallHangUp extends Command { ...@@ -80,7 +80,7 @@ class PredictiveCallHangUp extends Command {
80 80
81 $this->updateCrmCallEntry($callId); 81 $this->updateCrmCallEntry($callId);
82 } 82 }
83 elseif($dialline->status == 'AutoCall' && $lastUpdatedTime > ($avgringsec+$breathingTime)) { 83 elseif($dialline->status == 'AutoCall' && $lastUpdatedTime > ($avgringsec+$breathingTime) && $dialline->src_channel != "") {
84 $newqueue->hangupChannelS($dialline->src_channel,$dialline->server); 84 $newqueue->hangupChannelS($dialline->src_channel,$dialline->server);
85 85
86 $this->updateCrmCallEntry($callId); 86 $this->updateCrmCallEntry($callId);
......
...@@ -1481,27 +1481,30 @@ class KPAMIListen implements IEventListener ...@@ -1481,27 +1481,30 @@ class KPAMIListen implements IEventListener
1481 $crmcalldata=json_decode($crmcall->data,true); 1481 $crmcalldata=json_decode($crmcall->data,true);
1482 if(!isset($crmcalldata["userbusyfile"]))$crmcalldata["userbusyfile"]=0; 1482 if(!isset($crmcalldata["userbusyfile"]))$crmcalldata["userbusyfile"]=0;
1483 1483
1484 if($dialline->status == $status[1])$this->checkMobileNumberExist($crmcall); 1484 $sipid=array();
1485
1486 $sipids=array();
1487 1485
1488 if($dialline->status == $status[0]) 1486 if($dialline->status == $status[0])
1489 { 1487 {
1490 $mode = "Predictive"; 1488 $mode = "Predictive";
1491 1489
1490 $campaignUserIds = User::where('sel_campaign', '=', $dialline->regexstr)->select('id')->get()->toArray();
1491
1492 $sipid=Sipid::where('server', '=', $this->sipip) 1492 $sipid=Sipid::where('server', '=', $this->sipip)
1493 ->whereIn("user", $campaignUserIds)
1493 ->where("status", "=", "1") 1494 ->where("status", "=", "1")
1494 ->where("ready", "=", "1") 1495 ->where("ready", "=", "1")
1495 ->where("prepare_call", "=", "1") 1496 ->where("prepare_call", "=", "1")
1496 ->orderBy("updated_at", "asc") 1497 ->orderBy("updated_at", "asc")
1497 ->first(); 1498 ->first();
1498
1499 } 1499 }
1500 else if($dialline->status == $status[1]) 1500 else if($dialline->status == $status[1])
1501 { 1501 {
1502 $mode = "Incoming"; 1502 $mode = "Incoming";
1503 1503
1504 $this->checkMobileNumberExist($crmcall);
1505
1504 $sipid=Sipid::where('server', '=', $this->sipip) 1506 $sipid=Sipid::where('server', '=', $this->sipip)
1507 ->where("user", "!=", "0")
1505 ->where("status", "=", "1") 1508 ->where("status", "=", "1")
1506 ->where("ready", "=", "1") 1509 ->where("ready", "=", "1")
1507 ->orderBy("updated_at", "ssc") 1510 ->orderBy("updated_at", "ssc")
...@@ -1512,12 +1515,6 @@ class KPAMIListen implements IEventListener ...@@ -1512,12 +1515,6 @@ class KPAMIListen implements IEventListener
1512 { 1515 {
1513 echo "sipids found "; 1516 echo "sipids found ";
1514 1517
1515 $userEntry = User::find($sipid->user);
1516
1517 if(!empty($userEntry)){
1518 if($userEntry->current_dialmode != $mode || $sipid->ready != 1) continue;
1519 }
1520
1521 $this->connectToAvailableSip($sipid, $dialline, $crmcall, $mode); 1518 $this->connectToAvailableSip($sipid, $dialline, $crmcall, $mode);
1522 } 1519 }
1523 } 1520 }
...@@ -1592,59 +1589,58 @@ class KPAMIListen implements IEventListener ...@@ -1592,59 +1589,58 @@ class KPAMIListen implements IEventListener
1592 $dialline->channel=""; 1589 $dialline->channel="";
1593 $dialline->regexstr=""; 1590 $dialline->regexstr="";
1594 $dialline->save(); 1591 $dialline->save();
1595 1592 }
1596 return; 1593 else
1597 } 1594 {
1598 1595 $recfile=$crmcall->newRecFilePath();
1599 $recfile=$crmcall->newRecFilePath();
1600 1596
1601 //start recording 1597 //start recording
1602 $newqueue=new Kqueue(); 1598 $newqueue=new Kqueue();
1603 $newqueue->recordChannel($dialline->server,$dialline->channel,$recfile); 1599 $newqueue->recordChannel($dialline->server,$dialline->channel,$recfile);
1604 1600
1605 $newqueue=new Kqueue(); 1601 $newqueue=new Kqueue();
1606 $newqueue->userToConf($sipid); 1602 $newqueue->userToConf($sipid);
1607 1603
1608 $newqueue=new Kqueue(); 1604 $newqueue=new Kqueue();
1609 $newqueue->channelRedirectToExten($sipid->server,$dialline->channel,"1000".$sipid->id,"kstychDialer","1"); 1605 $newqueue->channelRedirectToExten($sipid->server,$dialline->channel,"1000".$sipid->id,"kstychDialer","1");
1610 1606
1611 $dialline->user_id = $sipid->user; 1607 $dialline->user_id = $sipid->user;
1612 $dialline->conf = "1000".$sipid->id; 1608 $dialline->conf = "1000".$sipid->id;
1613 $dialline->save(); 1609 $dialline->save();
1614 1610
1615 $sipid->ready=0; 1611 $sipid->ready=0;
1616 if($mode == "Predictive")$sipid->prepare_call=0; 1612 if($mode == "Predictive")$sipid->prepare_call=0;
1617 $sipid->patched=1; 1613 $sipid->patched=1;
1618 $sipid->save(); 1614 $sipid->save();
1619 1615
1620 $userlog=UserLog::where('user_id','=',$sipid->user)->orderBy("id","DESC")->first(); 1616 $userlog=UserLog::where('user_id','=',$sipid->user)->orderBy("id","DESC")->first();
1621 $ts_Wait=$userlog->getLastTs($sipid->id,$nowts); 1617 $ts_Wait=$userlog->getLastTs($sipid->id,$nowts);
1622 $userlog->save(); 1618 $userlog->save();
1623 1619
1624 $crmcall->user_id=$sipid->user; 1620 $crmcall->user_id=$sipid->user;
1625 $crmcall->sipid_id=$sipid->id; 1621 $crmcall->sipid_id=$sipid->id;
1626 1622
1627 if($ts_Wait<=$crmcall->ts_Wait) //user waiting 1623 if($ts_Wait<=$crmcall->ts_Wait) //user waiting
1628 { 1624 {
1629 $crmcall->ts_Wait=$ts_Wait; 1625 $crmcall->ts_Wait=$ts_Wait;
1630 $crmcall->setTs('ts_Talk',$nowts); 1626 $crmcall->setTs('ts_Talk',$nowts);
1631 } 1627 }
1632 else //call waiting 1628 else //call waiting
1633 { 1629 {
1634 $crmcall->ts_Wait-=($nowts-$ts_Wait); 1630 $crmcall->ts_Wait-=($nowts-$ts_Wait);
1635 $crmcall->setTs('ts_Talk',$nowts); 1631 $crmcall->setTs('ts_Talk',$nowts);
1636 } 1632 }
1637 1633
1638 $crmcall->setTs('ts_Recstart',$nowts); 1634 $crmcall->setTs('ts_Recstart',$nowts);
1639 $crmcall->save(); 1635 $crmcall->save();
1640 1636
1641 $newqueue=new Kqueue(); 1637 $newqueue=new Kqueue();
1642 $newqueue->sipNotify($sipid,"incomingCall",$crmcall->id,$crmcall->crm_id,$crmcall->number."@".$dialline->channel); 1638 $newqueue->sipNotify($sipid,"incomingCall",$crmcall->id,$crmcall->crm_id,$crmcall->number."@".$dialline->channel);
1643 1639
1644 if($crmcall->crm_id>0){ 1640 if($crmcall->crm_id>0){
1645 DB::table('records')->where('id',$crmcall->crm_id)->update(['filter_condition'=>'3','usr_id'=>$sipid->user]); 1641 DB::table('records')->where('id',$crmcall->crm_id)->update(['filter_condition'=>'3','usr_id'=>$sipid->user]);
1642 }
1646 } 1643 }
1647
1648 } 1644 }
1649 } 1645 }
1650 1646
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!