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 { ...@@ -192,6 +192,8 @@ class DialerController extends Controller {
192 $wakka = new KHRMSLib(); 192 $wakka = new KHRMSLib();
193 193
194 $roclientstr=array(); 194 $roclientstr=array();
195 $authId = Auth::user()->id;
196
195 $oclientlst=$wakka->clientsReadAccess(); 197 $oclientlst=$wakka->clientsReadAccess();
196 if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!=""){$roclientstr[]="'$tclnt'";} 198 if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!=""){$roclientstr[]="'$tclnt'";}
197 if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr=""; 199 if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr="";
...@@ -365,7 +367,7 @@ class DialerController extends Controller { ...@@ -365,7 +367,7 @@ class DialerController extends Controller {
365 367
366 if($dialline) 368 if($dialline)
367 { 369 {
368 $dialline->user_id=Auth::user()->id; 370 $dialline->user_id=$authId;
369 $dialline->number=$callnumber; 371 $dialline->number=$callnumber;
370 $dialline->status="Blocked"; 372 $dialline->status="Blocked";
371 $dialline->regexstr=$client; 373 $dialline->regexstr=$client;
...@@ -405,8 +407,10 @@ class DialerController extends Controller { ...@@ -405,8 +407,10 @@ class DialerController extends Controller {
405 if($users[0]['id']>0){ 407 if($users[0]['id']>0){
406 if($client!='')$records='records_'.$client;else $records='records'; 408 if($client!='')$records='records_'.$client;else $records='records';
407 409
408 DB::table($records)->where('id',$users[0]['id'])->update(['filter_condition'=>'3','usr_id'=>Auth::user()->id]); 410 DB::table($records)->where('id',$users[0]['id'])->update(['filter_condition'=>'3','usr_id'=>$authId]);
409 DB::table('records')->where('id',$users[0]['id'])->update(['usr_id'=>Auth::user()->id]); 411 DB::table('records')->where('id',$users[0]['id'])->update(['usr_id'=>$authId]);
412
413 $ppldata['usr_id']=$authId;
410 } 414 }
411 //start actual calls 415 //start actual calls
412 $ppldata['dialer_lastcall']=date("Y-m-d H:i:s"); 416 $ppldata['dialer_lastcall']=date("Y-m-d H:i:s");
......
...@@ -13,7 +13,7 @@ class KHRMSLib ...@@ -13,7 +13,7 @@ class KHRMSLib
13 public $dblink; 13 public $dblink;
14 public $user=NULL; 14 public $user=NULL;
15 15
16 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"; 16 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";
17 17
18 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"; 18 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";
19 19
...@@ -1914,12 +1914,11 @@ function popMail($userid) ...@@ -1914,12 +1914,11 @@ function popMail($userid)
1914 return $users; 1914 return $users;
1915 }*/ 1915 }*/
1916 1916
1917 //Changes Done By Manish on 13-11-17
1918 function searchPhone($key,$number) 1917 function searchPhone($key,$number)
1919 { 1918 {
1920 $users=array(); 1919 $users=array();
1921 $mobile10=substr($number,-10); 1920 $mobile10=substr($number,-10);
1922 $tusers=$this->getPersons("RIGHT($key,10) = $mobile10", ""); 1921 $tusers=$this->getPersons("RIGHT($key,10) = $mobile10 order by modified desc limit 1", "");
1923 if($tusers) 1922 if($tusers)
1924 { 1923 {
1925 foreach($tusers as $tusr) 1924 foreach($tusers as $tusr)
......
...@@ -658,7 +658,7 @@ class KPAMIListen implements IEventListener ...@@ -658,7 +658,7 @@ class KPAMIListen implements IEventListener
658 $crmcall->statuscode=$cause; 658 $crmcall->statuscode=$cause;
659 $crmcall->substatus=$causetxt; 659 $crmcall->substatus=$causetxt;
660 660
661 if($crmcall->type=="Inbound"&&$crmcall->user_id==0)//InboundDROP 661 if($crmcall->type=="Inbound"&&$crmcall->sipid_id==0)//InboundDROP
662 { 662 {
663 $userslist=User::where('exten','like' ,'%'.$crmcall->did.'%')->get(); 663 $userslist=User::where('exten','like' ,'%'.$crmcall->did.'%')->get();
664 foreach ($userslist as $ulist) { 664 foreach ($userslist as $ulist) {
...@@ -1482,7 +1482,7 @@ class KPAMIListen implements IEventListener ...@@ -1482,7 +1482,7 @@ class KPAMIListen implements IEventListener
1482 { 1482 {
1483 $mode = "Incoming"; 1483 $mode = "Incoming";
1484 1484
1485 $sipid = $this->getSipid($dialline->regexstr); 1485 $sipid = $this->getSipid($dialline->regexstr, $crmcall);
1486 } 1486 }
1487 1487
1488 if(!empty($sipid)) 1488 if(!empty($sipid))
...@@ -1504,7 +1504,7 @@ class KPAMIListen implements IEventListener ...@@ -1504,7 +1504,7 @@ class KPAMIListen implements IEventListener
1504 { 1504 {
1505 $flag = "alert"; 1505 $flag = "alert";
1506 1506
1507 $sipids = $this->getSipid($client, $flag); 1507 $sipids = $this->getSipid($client, $crmcall, $flag);
1508 1508
1509 foreach($sipids as $sipid) 1509 foreach($sipids as $sipid)
1510 { 1510 {
...@@ -1513,12 +1513,16 @@ class KPAMIListen implements IEventListener ...@@ -1513,12 +1513,16 @@ class KPAMIListen implements IEventListener
1513 } 1513 }
1514 } 1514 }
1515 1515
1516 private function getSipid($client, $flag=null) 1516 private function getSipid($client, $crmcall, $flag=null)
1517 { 1517 {
1518 $data = []; 1518 $data = [];
1519 $campaignUserIds = []; 1519 $campaignUserIds = [];
1520 $did = $crmcall->did;
1520 1521
1521 if($client!="")$campaignUserIds = $this->getUsersAvailableInCampaign($client); 1522 if($crmcall->user_id != 0)
1523 $campaignUserIds[] = $crmcall->user_id;
1524 else
1525 $campaignUserIds = $this->getUsersAvailableInCampaign($client, $did);
1522 1526
1523 if($flag == null) 1527 if($flag == null)
1524 { 1528 {
...@@ -1530,18 +1534,9 @@ class KPAMIListen implements IEventListener ...@@ -1530,18 +1534,9 @@ class KPAMIListen implements IEventListener
1530 ->where("ready", "=", "1") 1534 ->where("ready", "=", "1")
1531 ->orderBy("updated_at", "asc") 1535 ->orderBy("updated_at", "asc")
1532 ->first(); 1536 ->first();
1533 }
1534 else
1535 {
1536 $sipid=Sipid::where('server', '=', $this->sipip)
1537 ->where("user", "!=", "0")
1538 ->where("status", "=", "1")
1539 ->where("ready", "=", "1")
1540 ->orderBy("updated_at", "asc")
1541 ->first();
1542 }
1543 1537
1544 $data = $sipid; 1538 $data = $sipid;
1539 }
1545 } 1540 }
1546 else 1541 else
1547 { 1542 {
...@@ -1552,30 +1547,33 @@ class KPAMIListen implements IEventListener ...@@ -1552,30 +1547,33 @@ class KPAMIListen implements IEventListener
1552 ->where("status", "=", "1") 1547 ->where("status", "=", "1")
1553 ->orderBy("updated_at", "asc") 1548 ->orderBy("updated_at", "asc")
1554 ->get(); 1549 ->get();
1555 } 1550
1556 else 1551 $data = $sipids;
1557 {
1558 $sipids=Sipid::where('server', '=', $this->sipip)
1559 ->where("user", "!=", "0")
1560 ->where("status", "=", "1")
1561 ->orderBy("updated_at", "asc")
1562 ->get();
1563 } 1552 }
1564 1553
1565 $data = $sipids;
1566 } 1554 }
1567 1555
1568 return $data; 1556 return $data;
1569 } 1557 }
1570 1558
1571 private function getUsersAvailableInCampaign($client) 1559 private function getUsersAvailableInCampaign($client, $did=null)
1572 { 1560 {
1573 $data = []; 1561 $data = [];
1574 1562
1575 $data = User::where('presence', '=', "1") 1563 if($did == null)
1564 {
1565 $data = User::where('presence', '=', "1")
1576 ->where('sel_campaign', '=', $client) 1566 ->where('sel_campaign', '=', $client)
1577 ->select('id')->get() 1567 ->select('id')->get()
1578 ->toArray(); 1568 ->toArray();
1569 }
1570 else
1571 {
1572 $data = User::where('presence', '=', "1")
1573 ->where('exten', 'like', "%".$did."%")
1574 ->select('id')->get()
1575 ->toArray();
1576 }
1579 1577
1580 return $data; 1578 return $data;
1581 } 1579 }
...@@ -1588,6 +1586,8 @@ class KPAMIListen implements IEventListener ...@@ -1588,6 +1586,8 @@ class KPAMIListen implements IEventListener
1588 { 1586 {
1589 $ppldata=unserialize($users[0]['peopledata']); 1587 $ppldata=unserialize($users[0]['peopledata']);
1590 1588
1589 if(stristr($ppldata['dialer_substatus'], "follow"))$crmcall->user_id = $users[0]['usr_id'];
1590
1591 $crmcall->crm_id=$users[0]['id']; 1591 $crmcall->crm_id=$users[0]['id'];
1592 $crmcall->number=$users[0]['mobile']; 1592 $crmcall->number=$users[0]['mobile'];
1593 $crmcall->client=($ppldata['client']?$ppldata['client']:""); 1593 $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!