Removed loop while picking up sipids
Showing
1 changed file
with
44 additions
and
45 deletions
| ... | @@ -523,7 +523,7 @@ class KPAMIListen implements IEventListener | ... | @@ -523,7 +523,7 @@ class KPAMIListen implements IEventListener |
| 523 | $affectedRows = Dialline::where('id', $accountcodearr[3]) | 523 | $affectedRows = Dialline::where('id', $accountcodearr[3]) |
| 524 | ->where(function ($query) use($channel) { | 524 | ->where(function ($query) use($channel) { |
| 525 | $query->where('channel', '=', $channel) | 525 | $query->where('channel', '=', $channel) |
| 526 | ->orWhere('status', '=', 'AutoCall'); | 526 | ->orWhereIn('status', ['AutoCall', 'InHangUp']); |
| 527 | }) | 527 | }) |
| 528 | ->update([ | 528 | ->update([ |
| 529 | 'call_id' => 0, | 529 | 'call_id' => 0, |
| ... | @@ -662,33 +662,33 @@ class KPAMIListen implements IEventListener | ... | @@ -662,33 +662,33 @@ class KPAMIListen implements IEventListener |
| 662 | foreach ($userslist as $ulist) { | 662 | foreach ($userslist as $ulist) { |
| 663 | $crmcall->user_id=$ulist->id; | 663 | $crmcall->user_id=$ulist->id; |
| 664 | } | 664 | } |
| 665 | if($crmcall->client==".") | 665 | // if($crmcall->client==".") |
| 666 | { | 666 | // { |
| 667 | $wakka = new KHRMSLib(); | 667 | // $wakka = new KHRMSLib(); |
| 668 | $users=$wakka->searchPhone("mobile",$crmcall->number); | 668 | // $users=$wakka->searchPhone("mobile",$crmcall->number); |
| 669 | 669 | ||
| 670 | if(!empty($users)) | 670 | // if(!empty($users)) |
| 671 | { | 671 | // { |
| 672 | $ppldata=unserialize($users[0]['peopledata']); | 672 | // $ppldata=unserialize($users[0]['peopledata']); |
| 673 | 673 | ||
| 674 | $crmcall->crm_id=$users[0]['id']; | 674 | // $crmcall->crm_id=$users[0]['id']; |
| 675 | $crmcall->number=$users[0]['mobile']; | 675 | // $crmcall->number=$users[0]['mobile']; |
| 676 | $crmcall->client=($ppldata['client']?$ppldata['client']:""); | 676 | // $crmcall->client=($ppldata['client']?$ppldata['client']:""); |
| 677 | $crmcall->department=($ppldata['department']?$ppldata['department']:""); | 677 | // $crmcall->department=($ppldata['department']?$ppldata['department']:""); |
| 678 | 678 | ||
| 679 | $wakka->setPersonKey($crmcall->crm_id,"dialer_lastcall",date("Y-m-d H:i:s")); | 679 | // $wakka->setPersonKey($crmcall->crm_id,"dialer_lastcall",date("Y-m-d H:i:s")); |
| 680 | echo $users[0]['id']." -- ID Found\n"; | 680 | // echo $users[0]['id']." -- ID Found\n"; |
| 681 | } | 681 | // } |
| 682 | else | 682 | // else |
| 683 | { | 683 | // { |
| 684 | $crmcall->crm_id=0; | 684 | // $crmcall->crm_id=0; |
| 685 | $crmcall->client=""; | 685 | // $crmcall->client=""; |
| 686 | $crmcall->department=""; | 686 | // $crmcall->department=""; |
| 687 | echo "User Not Found!!\n"; | 687 | // echo "User Not Found!!\n"; |
| 688 | } | 688 | // } |
| 689 | 689 | ||
| 690 | $crmcall->save(); | 690 | // $crmcall->save(); |
| 691 | } | 691 | // } |
| 692 | $crmcall->userstatus="InboundDROP"; | 692 | $crmcall->userstatus="InboundDROP"; |
| 693 | $crmcall->usersubstatus="InboundDROP"; | 693 | $crmcall->usersubstatus="InboundDROP"; |
| 694 | $crmcall->call_flag="Z"; | 694 | $crmcall->call_flag="Z"; |
| ... | @@ -1472,14 +1472,14 @@ class KPAMIListen implements IEventListener | ... | @@ -1472,14 +1472,14 @@ class KPAMIListen implements IEventListener |
| 1472 | { | 1472 | { |
| 1473 | foreach($diallines as $dialline) | 1473 | foreach($diallines as $dialline) |
| 1474 | { | 1474 | { |
| 1475 | $crmcall=CRMCall::where("uniqueid","like","%".$dialline->uniqueid."%")->first(); | 1475 | $crmcall=CRMCall::find($dialline->call_id); |
| 1476 | 1476 | ||
| 1477 | if($crmcall) | 1477 | if($crmcall) |
| 1478 | { | 1478 | { |
| 1479 | $crmcalldata=json_decode($crmcall->data,true); | 1479 | $crmcalldata=json_decode($crmcall->data,true); |
| 1480 | if(!isset($crmcalldata["userbusyfile"]))$crmcalldata["userbusyfile"]=0; | 1480 | if(!isset($crmcalldata["userbusyfile"]))$crmcalldata["userbusyfile"]=0; |
| 1481 | 1481 | ||
| 1482 | if($dialline->status == $status[1])$this->checkMobileNumberExist($crmcall); | 1482 | //if($dialline->status == $status[1])$this->checkMobileNumberExist($crmcall); |
| 1483 | 1483 | ||
| 1484 | $sipids=array(); | 1484 | $sipids=array(); |
| 1485 | 1485 | ||
| ... | @@ -1487,36 +1487,33 @@ class KPAMIListen implements IEventListener | ... | @@ -1487,36 +1487,33 @@ class KPAMIListen implements IEventListener |
| 1487 | { | 1487 | { |
| 1488 | $mode = "Predictive"; | 1488 | $mode = "Predictive"; |
| 1489 | 1489 | ||
| 1490 | $sipids=Sipid::where('server', '=', $this->sipip) | 1490 | $sipid=Sipid::where('server', '=', $this->sipip) |
| 1491 | ->where("status", "=", "1") | 1491 | ->where("status", "=", "1") |
| 1492 | ->where("ready", "=", "1") | 1492 | ->where("ready", "=", "1") |
| 1493 | ->where("prepare_call", "=", "1") | 1493 | ->where("prepare_call", "=", "1") |
| 1494 | ->orderBy("updated_at", "desc") | 1494 | ->orderBy("updated_at", "desc") |
| 1495 | ->get(); | 1495 | ->first(); |
| 1496 | 1496 | ||
| 1497 | } | 1497 | } |
| 1498 | else if($dialline->status == $status[1]) | 1498 | else if($dialline->status == $status[1]) |
| 1499 | { | 1499 | { |
| 1500 | $mode = "Incoming"; | 1500 | $mode = "Incoming"; |
| 1501 | 1501 | ||
| 1502 | $sipids=Sipid::where('server', '=', $this->sipip) | 1502 | $sipid=Sipid::where('server', '=', $this->sipip) |
| 1503 | ->where("status", "=", "1") | 1503 | ->where("status", "=", "1") |
| 1504 | ->where("ready", "=", "1") | 1504 | ->where("ready", "=", "1") |
| 1505 | ->where("prepare_call", "=", "1") | ||
| 1506 | ->orderBy("updated_at", "desc") | 1505 | ->orderBy("updated_at", "desc") |
| 1507 | ->get(); | 1506 | ->first(); |
| 1508 | } | 1507 | } |
| 1509 | 1508 | ||
| 1510 | if(!empty($sipids)) | 1509 | if(!empty($sipid)) |
| 1511 | { | 1510 | { |
| 1512 | echo "sipids found "; | 1511 | echo "sipids found "; |
| 1513 | 1512 | ||
| 1514 | foreach($sipids as $sipid) | ||
| 1515 | { | ||
| 1516 | $userEntry = User::find($sipid->user); | 1513 | $userEntry = User::find($sipid->user); |
| 1517 | 1514 | ||
| 1518 | if(!empty($userEntry)){ | 1515 | if(!empty($userEntry)){ |
| 1519 | if($userEntry->current_dialmode != $mode || $sipid->ready != 1) return; | 1516 | if($userEntry->current_dialmode != $mode || $sipid->ready != 1) continue; |
| 1520 | } | 1517 | } |
| 1521 | 1518 | ||
| 1522 | $this->connectToAvailableSip($sipid, $dialline, $crmcall, $mode); | 1519 | $this->connectToAvailableSip($sipid, $dialline, $crmcall, $mode); |
| ... | @@ -1525,7 +1522,6 @@ class KPAMIListen implements IEventListener | ... | @@ -1525,7 +1522,6 @@ class KPAMIListen implements IEventListener |
| 1525 | } | 1522 | } |
| 1526 | } | 1523 | } |
| 1527 | } | 1524 | } |
| 1528 | } | ||
| 1529 | 1525 | ||
| 1530 | private function checkMobileNumberExist($crmcall) | 1526 | private function checkMobileNumberExist($crmcall) |
| 1531 | { | 1527 | { |
| ... | @@ -1542,7 +1538,7 @@ class KPAMIListen implements IEventListener | ... | @@ -1542,7 +1538,7 @@ class KPAMIListen implements IEventListener |
| 1542 | $crmcall->client=($ppldata['client']?$ppldata['client']:""); | 1538 | $crmcall->client=($ppldata['client']?$ppldata['client']:""); |
| 1543 | $crmcall->department=($ppldata['department']?$ppldata['department']:""); | 1539 | $crmcall->department=($ppldata['department']?$ppldata['department']:""); |
| 1544 | $crmcall->call_flag="C"; | 1540 | $crmcall->call_flag="C"; |
| 1545 | $wakka->setPersonKey($crmcall->crm_id,"dialer_lastcall",date("Y-m-d H:i:s")); | 1541 | $wakka->setPersonKey($crmcall->crm_id, "dialer_lastcall", date("Y-m-d H:i:s"), "", $ppldata['client']); |
| 1546 | echo $users[0]['id']." -- ID Found\n"; | 1542 | echo $users[0]['id']." -- ID Found\n"; |
| 1547 | } | 1543 | } |
| 1548 | else | 1544 | else |
| ... | @@ -1579,11 +1575,13 @@ class KPAMIListen implements IEventListener | ... | @@ -1579,11 +1575,13 @@ class KPAMIListen implements IEventListener |
| 1579 | 1575 | ||
| 1580 | exec("/usr/sbin/asterisk -rx 'core show channel $dialline->channel'",$channelArr); | 1576 | exec("/usr/sbin/asterisk -rx 'core show channel $dialline->channel'",$channelArr); |
| 1581 | 1577 | ||
| 1582 | if(count($channelArr) == 1) | 1578 | if(count($channelArr) <= 2) |
| 1583 | { | 1579 | { |
| 1584 | Log::useFiles(storage_path()."/logs/Predictive/predictive_".date("Y_m_d").".log"); | 1580 | Log::useFiles(storage_path()."/logs/Predictive/predictive_".date("Y_m_d").".log"); |
| 1585 | Log::info($crmcall->id);Log::info($dialline); | 1581 | Log::info($crmcall->id);Log::info($dialline); |
| 1586 | 1582 | ||
| 1583 | $dialline->call_id="0"; | ||
| 1584 | $dialline->user_id="0"; | ||
| 1587 | $dialline->status="Free"; | 1585 | $dialline->status="Free"; |
| 1588 | $dialline->conf=""; | 1586 | $dialline->conf=""; |
| 1589 | $dialline->number=""; | 1587 | $dialline->number=""; |
| ... | @@ -1593,7 +1591,7 @@ class KPAMIListen implements IEventListener | ... | @@ -1593,7 +1591,7 @@ class KPAMIListen implements IEventListener |
| 1593 | $dialline->regexstr=""; | 1591 | $dialline->regexstr=""; |
| 1594 | $dialline->save(); | 1592 | $dialline->save(); |
| 1595 | 1593 | ||
| 1596 | continue; | 1594 | return; |
| 1597 | } | 1595 | } |
| 1598 | 1596 | ||
| 1599 | $recfile=$crmcall->newRecFilePath(); | 1597 | $recfile=$crmcall->newRecFilePath(); |
| ... | @@ -1638,12 +1636,13 @@ class KPAMIListen implements IEventListener | ... | @@ -1638,12 +1636,13 @@ class KPAMIListen implements IEventListener |
| 1638 | $crmcall->setTs('ts_Recstart',$nowts); | 1636 | $crmcall->setTs('ts_Recstart',$nowts); |
| 1639 | $crmcall->save(); | 1637 | $crmcall->save(); |
| 1640 | 1638 | ||
| 1639 | $newqueue=new Kqueue(); | ||
| 1640 | $newqueue->sipNotify($sipid,"incomingCall",$crmcall->id,$crmcall->crm_id,$crmcall->number."@".$dialline->channel); | ||
| 1641 | |||
| 1641 | if($crmcall->crm_id>0){ | 1642 | if($crmcall->crm_id>0){ |
| 1642 | DB::table('records')->where('id',$crmcall->crm_id)->update(['filter_condition'=>'3','usr_id'=>$sipid->user]); | 1643 | DB::table('records')->where('id',$crmcall->crm_id)->update(['filter_condition'=>'3','usr_id'=>$sipid->user]); |
| 1643 | } | 1644 | } |
| 1644 | 1645 | ||
| 1645 | $newqueue=new Kqueue(); | ||
| 1646 | $newqueue->sipNotify($sipid,"incomingCall",$crmcall->id,$crmcall->crm_id,$crmcall->number."@".$dialline->channel); | ||
| 1647 | } | 1646 | } |
| 1648 | } | 1647 | } |
| 1649 | 1648 | ... | ... |
-
Please register or sign in to post a comment