9913f5dd by Manish Mihsra

Removed loop while picking up sipids

1 parent 08d92f35
......@@ -523,7 +523,7 @@ class KPAMIListen implements IEventListener
$affectedRows = Dialline::where('id', $accountcodearr[3])
->where(function ($query) use($channel) {
$query->where('channel', '=', $channel)
->orWhere('status', '=', 'AutoCall');
->orWhereIn('status', ['AutoCall', 'InHangUp']);
})
->update([
'call_id' => 0,
......@@ -662,33 +662,33 @@ class KPAMIListen implements IEventListener
foreach ($userslist as $ulist) {
$crmcall->user_id=$ulist->id;
}
if($crmcall->client==".")
{
$wakka = new KHRMSLib();
$users=$wakka->searchPhone("mobile",$crmcall->number);
// if($crmcall->client==".")
// {
// $wakka = new KHRMSLib();
// $users=$wakka->searchPhone("mobile",$crmcall->number);
if(!empty($users))
{
$ppldata=unserialize($users[0]['peopledata']);
// if(!empty($users))
// {
// $ppldata=unserialize($users[0]['peopledata']);
$crmcall->crm_id=$users[0]['id'];
$crmcall->number=$users[0]['mobile'];
$crmcall->client=($ppldata['client']?$ppldata['client']:"");
$crmcall->department=($ppldata['department']?$ppldata['department']:"");
// $crmcall->crm_id=$users[0]['id'];
// $crmcall->number=$users[0]['mobile'];
// $crmcall->client=($ppldata['client']?$ppldata['client']:"");
// $crmcall->department=($ppldata['department']?$ppldata['department']:"");
$wakka->setPersonKey($crmcall->crm_id,"dialer_lastcall",date("Y-m-d H:i:s"));
echo $users[0]['id']." -- ID Found\n";
}
else
{
$crmcall->crm_id=0;
$crmcall->client="";
$crmcall->department="";
echo "User Not Found!!\n";
}
// $wakka->setPersonKey($crmcall->crm_id,"dialer_lastcall",date("Y-m-d H:i:s"));
// echo $users[0]['id']." -- ID Found\n";
// }
// else
// {
// $crmcall->crm_id=0;
// $crmcall->client="";
// $crmcall->department="";
// echo "User Not Found!!\n";
// }
$crmcall->save();
}
// $crmcall->save();
// }
$crmcall->userstatus="InboundDROP";
$crmcall->usersubstatus="InboundDROP";
$crmcall->call_flag="Z";
......@@ -1472,14 +1472,14 @@ class KPAMIListen implements IEventListener
{
foreach($diallines as $dialline)
{
$crmcall=CRMCall::where("uniqueid","like","%".$dialline->uniqueid."%")->first();
$crmcall=CRMCall::find($dialline->call_id);
if($crmcall)
{
$crmcalldata=json_decode($crmcall->data,true);
if(!isset($crmcalldata["userbusyfile"]))$crmcalldata["userbusyfile"]=0;
if($dialline->status == $status[1])$this->checkMobileNumberExist($crmcall);
//if($dialline->status == $status[1])$this->checkMobileNumberExist($crmcall);
$sipids=array();
......@@ -1487,40 +1487,36 @@ class KPAMIListen implements IEventListener
{
$mode = "Predictive";
$sipids=Sipid::where('server', '=', $this->sipip)
->where("status", "=", "1")
->where("ready", "=", "1")
->where("prepare_call", "=", "1")
->orderBy("updated_at", "desc")
->get();
$sipid=Sipid::where('server', '=', $this->sipip)
->where("status", "=", "1")
->where("ready", "=", "1")
->where("prepare_call", "=", "1")
->orderBy("updated_at", "desc")
->first();
}
else if($dialline->status == $status[1])
{
$mode = "Incoming";
$sipids=Sipid::where('server', '=', $this->sipip)
->where("status", "=", "1")
->where("ready", "=", "1")
->where("prepare_call", "=", "1")
->orderBy("updated_at", "desc")
->get();
$sipid=Sipid::where('server', '=', $this->sipip)
->where("status", "=", "1")
->where("ready", "=", "1")
->orderBy("updated_at", "desc")
->first();
}
if(!empty($sipids))
if(!empty($sipid))
{
echo "sipids found ";
foreach($sipids as $sipid)
{
$userEntry = User::find($sipid->user);
$userEntry = User::find($sipid->user);
if(!empty($userEntry)){
if($userEntry->current_dialmode != $mode || $sipid->ready != 1) return;
}
$this->connectToAvailableSip($sipid, $dialline, $crmcall, $mode);
if(!empty($userEntry)){
if($userEntry->current_dialmode != $mode || $sipid->ready != 1) continue;
}
$this->connectToAvailableSip($sipid, $dialline, $crmcall, $mode);
}
}
}
......@@ -1542,7 +1538,7 @@ class KPAMIListen implements IEventListener
$crmcall->client=($ppldata['client']?$ppldata['client']:"");
$crmcall->department=($ppldata['department']?$ppldata['department']:"");
$crmcall->call_flag="C";
$wakka->setPersonKey($crmcall->crm_id,"dialer_lastcall",date("Y-m-d H:i:s"));
$wakka->setPersonKey($crmcall->crm_id, "dialer_lastcall", date("Y-m-d H:i:s"), "", $ppldata['client']);
echo $users[0]['id']." -- ID Found\n";
}
else
......@@ -1579,11 +1575,13 @@ class KPAMIListen implements IEventListener
exec("/usr/sbin/asterisk -rx 'core show channel $dialline->channel'",$channelArr);
if(count($channelArr) == 1)
if(count($channelArr) <= 2)
{
Log::useFiles(storage_path()."/logs/Predictive/predictive_".date("Y_m_d").".log");
Log::info($crmcall->id);Log::info($dialline);
$dialline->call_id="0";
$dialline->user_id="0";
$dialline->status="Free";
$dialline->conf="";
$dialline->number="";
......@@ -1593,12 +1591,12 @@ class KPAMIListen implements IEventListener
$dialline->regexstr="";
$dialline->save();
continue;
return;
}
$recfile=$crmcall->newRecFilePath();
//start recording
//start recording
$newqueue=new Kqueue();
$newqueue->recordChannel($dialline->server,$dialline->channel,$recfile);
......@@ -1638,12 +1636,13 @@ class KPAMIListen implements IEventListener
$crmcall->setTs('ts_Recstart',$nowts);
$crmcall->save();
$newqueue=new Kqueue();
$newqueue->sipNotify($sipid,"incomingCall",$crmcall->id,$crmcall->crm_id,$crmcall->number."@".$dialline->channel);
if($crmcall->crm_id>0){
DB::table('records')->where('id',$crmcall->crm_id)->update(['filter_condition'=>'3','usr_id'=>$sipid->user]);
}
$newqueue=new Kqueue();
$newqueue->sipNotify($sipid,"incomingCall",$crmcall->id,$crmcall->crm_id,$crmcall->number."@".$dialline->channel);
}
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!