08d92f35 by Manish Mihsra

Made some correction in connecteing the call

1 parent c4d3920b
...@@ -1465,6 +1465,7 @@ class KPAMIListen implements IEventListener ...@@ -1465,6 +1465,7 @@ class KPAMIListen implements IEventListener
1465 { 1465 {
1466 //TODO: Need to create static values for modes 1466 //TODO: Need to create static values for modes
1467 $status = array('Auto', 'Inbound'); //NOTE: Be Careful before changing indexes 1467 $status = array('Auto', 'Inbound'); //NOTE: Be Careful before changing indexes
1468 $mode = "";
1468 1469
1469 $diallines=Dialline::where('server','=',$this->sipip)->whereIn("status", $status)->where("conf","=","")->get(); 1470 $diallines=Dialline::where('server','=',$this->sipip)->whereIn("status", $status)->where("conf","=","")->get();
1470 if($diallines) 1471 if($diallines)
...@@ -1482,12 +1483,29 @@ class KPAMIListen implements IEventListener ...@@ -1482,12 +1483,29 @@ class KPAMIListen implements IEventListener
1482 1483
1483 $sipids=array(); 1484 $sipids=array();
1484 1485
1486 if($dialline->status == $status[0])
1487 {
1488 $mode = "Predictive";
1489
1490 $sipids=Sipid::where('server', '=', $this->sipip)
1491 ->where("status", "=", "1")
1492 ->where("ready", "=", "1")
1493 ->where("prepare_call", "=", "1")
1494 ->orderBy("updated_at", "desc")
1495 ->get();
1496
1497 }
1498 else if($dialline->status == $status[1])
1499 {
1500 $mode = "Incoming";
1501
1485 $sipids=Sipid::where('server', '=', $this->sipip) 1502 $sipids=Sipid::where('server', '=', $this->sipip)
1486 ->where("status", "=", "1") 1503 ->where("status", "=", "1")
1487 ->where("ready", "=", "1") 1504 ->where("ready", "=", "1")
1488 if($dialline->status == $status[0])->where("prepare_call", "=", "1") 1505 ->where("prepare_call", "=", "1")
1489 ->orderBy("updated_at", "desc") 1506 ->orderBy("updated_at", "desc")
1490 ->get(); 1507 ->get();
1508 }
1491 1509
1492 if(!empty($sipids)) 1510 if(!empty($sipids))
1493 { 1511 {
...@@ -1498,10 +1516,10 @@ class KPAMIListen implements IEventListener ...@@ -1498,10 +1516,10 @@ class KPAMIListen implements IEventListener
1498 $userEntry = User::find($sipid->user); 1516 $userEntry = User::find($sipid->user);
1499 1517
1500 if(!empty($userEntry)){ 1518 if(!empty($userEntry)){
1501 if(!array_search($userEntry->current_dialmode, $status) || $sipid->ready != 1) return; 1519 if($userEntry->current_dialmode != $mode || $sipid->ready != 1) return;
1502 } 1520 }
1503 1521
1504 $this->connectToAvailableSip($sipid, $dialline, $crmcall); 1522 $this->connectToAvailableSip($sipid, $dialline, $crmcall, $mode);
1505 } 1523 }
1506 } 1524 }
1507 } 1525 }
...@@ -1541,7 +1559,7 @@ class KPAMIListen implements IEventListener ...@@ -1541,7 +1559,7 @@ class KPAMIListen implements IEventListener
1541 } 1559 }
1542 } 1560 }
1543 1561
1544 private function connectToAvailableSip($sipid, $dialline, $crmcall) 1562 private function connectToAvailableSip($sipid, $dialline, $crmcall, $mode)
1545 { 1563 {
1546 $nowts=microtime(true)*1000; 1564 $nowts=microtime(true)*1000;
1547 1565
...@@ -1595,7 +1613,7 @@ class KPAMIListen implements IEventListener ...@@ -1595,7 +1613,7 @@ class KPAMIListen implements IEventListener
1595 $dialline->save(); 1613 $dialline->save();
1596 1614
1597 $sipid->ready=0; 1615 $sipid->ready=0;
1598 if($dialline->status == $status[0])$sipid->prepare_call=0; 1616 if($mode == "Predictive")$sipid->prepare_call=0;
1599 $sipid->patched=1; 1617 $sipid->patched=1;
1600 $sipid->save(); 1618 $sipid->save();
1601 1619
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!