e261c73c by Manish Mihsra

Added inbound call logic when follow up tagged by same agent

1 parent 3d274f1f
......@@ -192,6 +192,8 @@ class DialerController extends Controller {
$wakka = new KHRMSLib();
$roclientstr=array();
$authId = Auth::user()->id;
$oclientlst=$wakka->clientsReadAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!=""){$roclientstr[]="'$tclnt'";}
if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr="";
......@@ -365,7 +367,7 @@ class DialerController extends Controller {
if($dialline)
{
$dialline->user_id=Auth::user()->id;
$dialline->user_id=$authId;
$dialline->number=$callnumber;
$dialline->status="Blocked";
$dialline->regexstr=$client;
......@@ -405,8 +407,10 @@ class DialerController extends Controller {
if($users[0]['id']>0){
if($client!='')$records='records_'.$client;else $records='records';
DB::table($records)->where('id',$users[0]['id'])->update(['filter_condition'=>'3','usr_id'=>Auth::user()->id]);
DB::table('records')->where('id',$users[0]['id'])->update(['usr_id'=>Auth::user()->id]);
DB::table($records)->where('id',$users[0]['id'])->update(['filter_condition'=>'3','usr_id'=>$authId]);
DB::table('records')->where('id',$users[0]['id'])->update(['usr_id'=>$authId]);
$ppldata['usr_id']=$authId;
}
//start actual calls
$ppldata['dialer_lastcall']=date("Y-m-d H:i:s");
......
......@@ -13,7 +13,7 @@ class KHRMSLib
public $dblink;
public $user=NULL;
public $EMPCacheCols="mobile,emailid,altphone1,altphone2,altphone3,altphone4,altphone5,altphone6,altphone7,altphone8,altphone9,altphone10,client,status,clientinternalid,dialer_status,dialer_substatus,dialer_callback,dialer_remarks,dialer_flag,dialer_lastcall,priority,crmlist_id,group,bttc,service_vs_product,resolution,satisfaction,final_call_assessment,question,mf_isa,DOB,other_information,agreementid,applied_amount,city,comp_code,company,completeddate,cust_id,cust_name,customer_name,disb_date,emi_hl,eqty_amt,foir,ins_amt,int_rate,irr,loan_amount,location,mf_amt,nth,offer_amt,outstanding,pf,ph_mob,ph_off,ph_res,pl_offer,proc_fee,product_flag,profile_new,rank,segment,tenure,tu_application_id,ucic_id,filler1,filler2,filler3,filler4,filler5,filler6,filler7,filler8,filler9,filler10,filler11,filler12,filler13,filler14,filler15,dialer_appointment";
public $EMPCacheCols="mobile,emailid,altphone1,altphone2,altphone3,altphone4,altphone5,altphone6,altphone7,altphone8,altphone9,altphone10,client,status,clientinternalid,dialer_status,dialer_substatus,dialer_callback,dialer_remarks,dialer_flag,dialer_lastcall,priority,crmlist_id,group,bttc,service_vs_product,resolution,satisfaction,final_call_assessment,question,mf_isa,DOB,other_information,agreementid,applied_amount,city,comp_code,company,completeddate,cust_id,cust_name,customer_name,disb_date,emi_hl,eqty_amt,foir,ins_amt,int_rate,irr,loan_amount,location,mf_amt,nth,offer_amt,outstanding,pf,ph_mob,ph_off,ph_res,pl_offer,proc_fee,product_flag,profile_new,rank,segment,tenure,tu_application_id,ucic_id,filler1,filler2,filler3,filler4,filler5,filler6,filler7,filler8,filler9,filler10,filler11,filler12,filler13,filler14,filler15,dialer_appointment,usr_id";
public $USRCacheCols="id,username,password,fullname,email,status,organization,group,data,presence,timezone,invisible,usertype,diskuse,source,meta,lteam,lteam2,supervisor,created_at,updated_at,remember_token,passwordreset,number1,number2,exten,extencontext,manager";
......@@ -1914,12 +1914,11 @@ function popMail($userid)
return $users;
}*/
//Changes Done By Manish on 13-11-17
function searchPhone($key,$number)
{
$users=array();
$mobile10=substr($number,-10);
$tusers=$this->getPersons("RIGHT($key,10) = $mobile10", "");
$tusers=$this->getPersons("RIGHT($key,10) = $mobile10 order by modified desc limit 1", "");
if($tusers)
{
foreach($tusers as $tusr)
......
......@@ -658,7 +658,7 @@ class KPAMIListen implements IEventListener
$crmcall->statuscode=$cause;
$crmcall->substatus=$causetxt;
if($crmcall->type=="Inbound"&&$crmcall->user_id==0)//InboundDROP
if($crmcall->type=="Inbound"&&$crmcall->sipid_id==0)//InboundDROP
{
$userslist=User::where('exten','like' ,'%'.$crmcall->did.'%')->get();
foreach ($userslist as $ulist) {
......@@ -1482,7 +1482,7 @@ class KPAMIListen implements IEventListener
{
$mode = "Incoming";
$sipid = $this->getSipid($dialline->regexstr);
$sipid = $this->getSipid($dialline->regexstr, $crmcall);
}
if(!empty($sipid))
......@@ -1504,7 +1504,7 @@ class KPAMIListen implements IEventListener
{
$flag = "alert";
$sipids = $this->getSipid($client, $flag);
$sipids = $this->getSipid($client, $crmcall, $flag);
foreach($sipids as $sipid)
{
......@@ -1513,12 +1513,16 @@ class KPAMIListen implements IEventListener
}
}
private function getSipid($client, $flag=null)
private function getSipid($client, $crmcall, $flag=null)
{
$data = [];
$campaignUserIds = [];
$did = $crmcall->did;
if($client!="")$campaignUserIds = $this->getUsersAvailableInCampaign($client);
if($crmcall->user_id != 0)
$campaignUserIds[] = $crmcall->user_id;
else
$campaignUserIds = $this->getUsersAvailableInCampaign($client, $did);
if($flag == null)
{
......@@ -1530,19 +1534,10 @@ class KPAMIListen implements IEventListener
->where("ready", "=", "1")
->orderBy("updated_at", "asc")
->first();
}
else
{
$sipid=Sipid::where('server', '=', $this->sipip)
->where("user", "!=", "0")
->where("status", "=", "1")
->where("ready", "=", "1")
->orderBy("updated_at", "asc")
->first();
}
$data = $sipid;
}
}
else
{
if(!empty($campaignUserIds))
......@@ -1552,30 +1547,33 @@ class KPAMIListen implements IEventListener
->where("status", "=", "1")
->orderBy("updated_at", "asc")
->get();
}
else
{
$sipids=Sipid::where('server', '=', $this->sipip)
->where("user", "!=", "0")
->where("status", "=", "1")
->orderBy("updated_at", "asc")
->get();
}
$data = $sipids;
}
}
return $data;
}
private function getUsersAvailableInCampaign($client)
private function getUsersAvailableInCampaign($client, $did=null)
{
$data = [];
if($did == null)
{
$data = User::where('presence', '=', "1")
->where('sel_campaign', '=', $client)
->select('id')->get()
->toArray();
}
else
{
$data = User::where('presence', '=', "1")
->where('exten', 'like', "%".$did."%")
->select('id')->get()
->toArray();
}
return $data;
}
......@@ -1588,6 +1586,8 @@ class KPAMIListen implements IEventListener
{
$ppldata=unserialize($users[0]['peopledata']);
if(stristr($ppldata['dialer_substatus'], "follow"))$crmcall->user_id = $users[0]['usr_id'];
$crmcall->crm_id=$users[0]['id'];
$crmcall->number=$users[0]['mobile'];
$crmcall->client=($ppldata['client']?$ppldata['client']:"");
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!