8586b7c4 by Manish Mihsra

Updated Condition and added dialline id in kqueue model

1 parent 689245de
...@@ -498,36 +498,35 @@ class KPAMIListen implements IEventListener ...@@ -498,36 +498,35 @@ class KPAMIListen implements IEventListener
498 } 498 }
499 } 499 }
500 else if($accountcodearr[1]=="a") // Code Added by AmolG: AutoDial 500 else if($accountcodearr[1]=="a") // Code Added by AmolG: AutoDial
501 { 501 {Log::info($accountcodearr);
502 Dialline::where('id', $accountcodearr[3])
503 ->where(function ($query) use($channel) {
504 $query->where('channel', '=', $channel)
505 ->orWhere('status', '=', 'AutoCall');
506 })->update(['status' => "Free",
507 'conf' => "",
508 'number' => "",
509 'uniqueid'=> "",
510 'channel' => "",
511 'regexstr'=> "",
512 'did' => "",
513 ]);
514
502 $crmcall=CRMCall::find($accountcodearr[2]); 515 $crmcall=CRMCall::find($accountcodearr[2]);
503 if($crmcall) 516 if($crmcall)
504 { 517 {
505 $nowts=microtime(true)*1000; 518 $nowts=microtime(true)*1000;
506 519
507 $dialline=Dialline::find($crmcall->dialline_id); 520 $tsip=Sipid::find($crmcall->sipid_id);
508 521
509 if($dialline && ($dialline->channel==$channel || $dialline->status== "AutoCall")) 522 if(!empty($tsip))
510 { 523 {
511 $dialline->status="Free"; 524 $tsip->patched=0;
512 $dialline->conf=""; 525 $tsip->save();
513 $dialline->number=""; 526
514 $dialline->uniqueid=""; 527 $newqueue=new Kqueue();
515 $dialline->channel=""; 528 $newqueue->sipNotify($tsip,"dialerUI","hangup","c",$crmcall->id."~".$crmcall->number."~".base64_encode($channel));
516 $dialline->regexstr=""; 529 }
517 $dialline->did="";
518 $dialline->save();
519
520 $tsip=Sipid::find($crmcall->sipid_id);
521
522 if(!empty($tsip))
523 {
524 $tsip->patched=0;
525 $tsip->save();
526
527 $newqueue=new Kqueue();
528 $newqueue->sipNotify($tsip,"dialerUI","hangup","c",$crmcall->id."~".$crmcall->number."~".base64_encode($channel));
529 }
530 }
531 530
532 $crmcall->setTs('ts_Recend',$nowts); 531 $crmcall->setTs('ts_Recend',$nowts);
533 532
...@@ -1481,17 +1480,9 @@ class KPAMIListen implements IEventListener ...@@ -1481,17 +1480,9 @@ class KPAMIListen implements IEventListener
1481 if($userEntry->current_dialmode != "Predictive" || $found->ready != 1) return; 1480 if($userEntry->current_dialmode != "Predictive" || $found->ready != 1) return;
1482 } 1481 }
1483 1482
1484 exec("/usr/sbin/asterisk -rx 'core show channel $dialline->channel'",$allChnnlsArr); 1483 exec("/usr/sbin/asterisk -rx 'core show channel $dialline->channel'",$channelArr);
1485 $cnt = 0;
1486 foreach($allChnnlsArr as $allChnnls)
1487 {
1488 if(stristr($allChnnls, substr(stripslashes($dialline->channel),0, 20)))
1489 {
1490 $cnt++;
1491 }
1492 }
1493 1484
1494 if($cnt == 0) 1485 if(count($channelArr) == 1)
1495 { 1486 {
1496 Log::useFiles(storage_path()."/logs/Predictive/predictive_".date("Y_m_d").".log"); 1487 Log::useFiles(storage_path()."/logs/Predictive/predictive_".date("Y_m_d").".log");
1497 Log::info($crmcall->id);Log::info($dialline); 1488 Log::info($crmcall->id);Log::info($dialline);
...@@ -1508,6 +1499,8 @@ class KPAMIListen implements IEventListener ...@@ -1508,6 +1499,8 @@ class KPAMIListen implements IEventListener
1508 continue; 1499 continue;
1509 } 1500 }
1510 1501
1502 $recfile=$crmcall->newRecFilePath();
1503
1511 //start recording 1504 //start recording
1512 $newqueue=new Kqueue(); 1505 $newqueue=new Kqueue();
1513 $newqueue->recordChannel($dialline->server,$dialline->channel,$recfile); 1506 $newqueue->recordChannel($dialline->server,$dialline->channel,$recfile);
...@@ -1550,8 +1543,6 @@ class KPAMIListen implements IEventListener ...@@ -1550,8 +1543,6 @@ class KPAMIListen implements IEventListener
1550 1543
1551 } 1544 }
1552 1545
1553 $recfile=$crmcall->newRecFilePath();
1554
1555 $crmcall->setTs('ts_Recstart',$nowts); 1546 $crmcall->setTs('ts_Recstart',$nowts);
1556 $crmcall->save(); 1547 $crmcall->save();
1557 1548
......
...@@ -57,7 +57,7 @@ class Kqueue extends Model{ ...@@ -57,7 +57,7 @@ class Kqueue extends Model{
57 $odata['context']="kstychDialer"; 57 $odata['context']="kstychDialer";
58 $odata['callerid']=$callerid; 58 $odata['callerid']=$callerid;
59 $odata['toext']="1002".$callnumber; 59 $odata['toext']="1002".$callnumber;
60 $odata['account']='m|a|'.$crmcall->id; 60 $odata['account']='m|a|'.$crmcall->id.'|'.$dialline->id;
61 $odata['VARS']['dialstr']=$dialstr; 61 $odata['VARS']['dialstr']=$dialstr;
62 62
63 //originate conf 63 //originate conf
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!