d3588fc8 by Manish Mihsra

Completed Implementing Predictive Dialing with SQL table attached and changed PA…

…USE mode value from Manual to Paused
1 parent baaad793
...@@ -303,7 +303,6 @@ class CreateCall extends Command { ...@@ -303,7 +303,6 @@ class CreateCall extends Command {
303 $crmcall->user_id=0; 303 $crmcall->user_id=0;
304 $crmcall->sipid_id=0; 304 $crmcall->sipid_id=0;
305 $crmcall->crm_id=$users[0]['id']; 305 $crmcall->crm_id=$users[0]['id'];
306 $crmcall->lan=$users[0]['lan'];
307 $crmcall->client=$users[0]['client']; 306 $crmcall->client=$users[0]['client'];
308 $crmcall->department=$users[0]['department']; 307 $crmcall->department=$users[0]['department'];
309 $crmcall->state='New'; 308 $crmcall->state='New';
......
...@@ -62,7 +62,8 @@ protected $commands = [ ...@@ -62,7 +62,8 @@ protected $commands = [
62 */ 62 */
63 protected function schedule(Schedule $schedule) 63 protected function schedule(Schedule $schedule)
64 { 64 {
65 $schedule->command('KstychDaily')->daily()->withoutOverlapping(); 65 $schedule->command('KstychDaily')->daily()->withoutOverlapping();
66 $schedule->command('UpdateAvgRingSec')->daily()->withoutOverlapping();
66 //$schedule->command('bulkServerUpload')->everyFiveMinutes()->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping(); 67 //$schedule->command('bulkServerUpload')->everyFiveMinutes()->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
67 //$schedule->command('bulkserverupload_data')->everyMinute()->appendOutputTo(storage_path()."/reason/bulkserverupload_data.txt")->withoutOverlapping(); 68 //$schedule->command('bulkserverupload_data')->everyMinute()->appendOutputTo(storage_path()."/reason/bulkserverupload_data.txt")->withoutOverlapping();
68 $schedule->command('bulkserverupload_data')->dailyAt('14:17')->appendOutputTo(storage_path()."/reason/bulkserverupload_data.txt")->withoutOverlapping(); 69 $schedule->command('bulkserverupload_data')->dailyAt('14:17')->appendOutputTo(storage_path()."/reason/bulkserverupload_data.txt")->withoutOverlapping();
......
...@@ -77,6 +77,7 @@ class DialModeController extends Controller { ...@@ -77,6 +77,7 @@ class DialModeController extends Controller {
77 77
78 $data['client'] = $client; 78 $data['client'] = $client;
79 $data['username'] = $username; 79 $data['username'] = $username;
80 $data['callingmodeArr'] = array("Progressive", "Manual", "Incoming", "Predictive");
80 81
81 82
82 return view('layout.module.dialmode.index',$data); 83 return view('layout.module.dialmode.index',$data);
......
...@@ -12,6 +12,7 @@ use App\Models\CRMCallArchive; ...@@ -12,6 +12,7 @@ use App\Models\CRMCallArchive;
12 use App\Models\CRM; 12 use App\Models\CRM;
13 use App\Models\CRMCampaign; 13 use App\Models\CRMCampaign;
14 use App\Models\CRMList; 14 use App\Models\CRMList;
15 use App\Models\Cutoff;
15 use App\Jobs\KHRMSLib; 16 use App\Jobs\KHRMSLib;
16 use App\Models\Sipid; 17 use App\Models\Sipid;
17 use App\Models\Dialline; 18 use App\Models\Dialline;
...@@ -483,6 +484,35 @@ if($action=="addconfcall") ...@@ -483,6 +484,35 @@ if($action=="addconfcall")
483 if($action=="hangupall") 484 if($action=="hangupall")
484 { 485 {
485 $res=0; 486 $res=0;
487 $aUser = Auth::user();
488
489 If($aUser->current_dialmode == "Predictive"){
490 $avgTimeArr = array();
491 $user_id = $aUser->id;
492 $campaign = $aUser->sel_campaign;
493
494 $avgTimeArr = $this->getAvgTimeArray($campaign, $user_id);
495
496 $cutOffUsrArr = Cutoff::where('user_id', '=', $user_id)->where('c_name', '=', $campaign)->get();
497
498 if(count($cutOffUsrArr)){
499 Cutoff::where('user_id', '=', $user_id)->where('c_name', '=', $campaign)->update(
500 ['hangup_time' => date('Y-m-d H:i:s'),
501 'avg_dispo' => $avgTimeArr['avgdisposec']
502 ]);
503 }
504 else
505 {
506 $cutoff = new Cutoff();
507 $cutoff->user_id = $user_id;
508 $cutoff->c_name = $campaign;
509 $cutoff->hangup_time = date('Y-m-d H:i:s');
510 $cutoff->avg_dispo = $avgTimeArr['avgdisposec'];
511 $cutoff->avg_ring = 0;
512 $cutoff->save();
513 }
514 }
515
486 $callid=intval($kstychCall['callid'])+0; 516 $callid=intval($kstychCall['callid'])+0;
487 $crmcall=CRMCall::find($callid); 517 $crmcall=CRMCall::find($callid);
488 if($crmcall&&$crmcall->user_id==Auth::user()->id) 518 if($crmcall&&$crmcall->user_id==Auth::user()->id)
...@@ -836,13 +866,24 @@ if($action=="kCallAction") ...@@ -836,13 +866,24 @@ if($action=="kCallAction")
836 866
837 if($action=="dialerstate") 867 if($action=="dialerstate")
838 { 868 {
839 $ready=0;if($kstychDialer['mDialerState']=="Ready"&&$kstychCall['mCallState']=="Wait")$ready=1; 869 $ready=0;$perpareCall=0;
870 if($kstychDialer['mDialerState']=="Ready"&&$kstychCall['mCallState']=="Wait")
871 {
872 $ready=1;
873 }
874
875 if($kstychDialer['mDialerSubState']=="Predictive"&&$kstychCall['mCallState']=="Wait")
876 {
877 $perpareCall=1;
878 }
879
840 $nowts=microtime(true)*1000; 880 $nowts=microtime(true)*1000;
841 881
842 $sipid=Sipid::find($kstychDialer['phone']); 882 $sipid=Sipid::find($kstychDialer['phone']);
843 if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1) 883 if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1)
844 { 884 {
845 $sipid->ready=$ready; 885 $sipid->ready=$ready;
886 $sipid->prepare_call=$perpareCall;
846 $sipid->save(); 887 $sipid->save();
847 888
848 $userlog=UserLog::where('user_id','=',Auth::user()->id)->orderBy("id","DESC")->first(); 889 $userlog=UserLog::where('user_id','=',Auth::user()->id)->orderBy("id","DESC")->first();
...@@ -852,6 +893,61 @@ if($action=="dialerstate") ...@@ -852,6 +893,61 @@ if($action=="dialerstate")
852 return Response::make(""); 893 return Response::make("");
853 } 894 }
854 895
896 if($action=="usersel")
897 {
898
899 $user = Auth::user();
900 $currDialerState = $kstychDialer['mDialerState'];
901
902 if($kstychDialer['mDialerSubState'] != "")
903 $currDialerState = $kstychDialer['mDialerSubState'];
904
905 DB::table('users')->where('id', Auth::user()->id)->update([
906 'sel_campaign'=>$client,
907 'current_dialmode'=>$currDialerState
908 ]);
909
910 $campaigndata = Sipid::select("clients")->where("user", $user->id)->where("status", "=", 1)->first();
911
912 if($campaigndata)
913 {
914 $campdata= json_decode($campaigndata->clients);
915 $campdata->sel_campaign=$client;
916 Sipid::where("user",$user->id)->update(["clients"=>json_encode($campdata)]);
917 }
918
919 return Response::make("");
920 }
921
922 if($action=="sipcleanup")
923 {
924 $user = Auth::user();
925
926 $sipid = Sipid::where("user", $user->id)->select('id')->first();
927
928 Sipid::where("user", $user->id)->update([
929 "user" => 0,
930 "status" => 0,
931 "ready" => 0,
932 "patched" => 0,
933 "prepare_call" => 0,
934 "confup" => 0,
935 "clients" => ""
936 ]);
937
938 $diallines = Dialline::where('status', '!=', 'Free')->where('conf', '=', "1000".$sipid->id)->get();
939
940 foreach ($diallines as $dialline) {
941 $newqueue=new Kqueue();
942 $newqueue->hangupChannelS($dialline->channel,$dialline->server);
943 }
944
945 if(count($sipid)){
946 exec('/usr/sbin/asterisk -rx "channel request hangup '.$sipid->id.'"');
947 exec('/usr/sbin/asterisk -rx "confbridge kick 1000'.$sipid->id.' all"');
948 }
949 }
950
855 if($action=="spychannel") 951 if($action=="spychannel")
856 { 952 {
857 $sipid=Sipid::find($kstychDialer['phone']); 953 $sipid=Sipid::find($kstychDialer['phone']);
...@@ -1661,4 +1757,16 @@ public function show($id) ...@@ -1661,4 +1757,16 @@ public function show($id)
1661 $tusers=array();foreach($users as $tuser)$tusers[]=$tuser; 1757 $tusers=array();foreach($users as $tuser)$tusers[]=$tuser;
1662 return $tusers; 1758 return $tusers;
1663 } 1759 }
1760
1761 public function getAvgTimeArray($campaign, $user)
1762 {
1763 $avgdisposecObj = CRMCall::select(DB::Raw('(avg(disposec))/1000 as avgdisposec'))->where("client", "=", $campaign)->where("user_id", "=", $user)->orderby("id","desc")->limit(50)->where("type","!=","Inbound")->first();
1764
1765 $avgcallsecObj = CRMCall::select(DB::Raw('(avg(callsec))/1000 as avgcallsec'))->where("client", "=", $campaign)->where("user_id", "=", $user)->orderby("id","desc")->limit(50)->where("type","!=","Inbound")->first();
1766
1767 $returnArray['avgdisposec'] = round($avgdisposecObj->avgdisposec);
1768 $returnArray['avgcallsec'] = round($avgdisposecObj->avgcallsec);
1769
1770 return $returnArray;
1771 }
1664 } 1772 }
......
...@@ -261,7 +261,7 @@ class KPAMIListen implements IEventListener ...@@ -261,7 +261,7 @@ class KPAMIListen implements IEventListener
261 //echo "$accountcode:NewextenEvent : $context:$eventname $channelstate:$channelstatedesc $uniqueid $phonenumber $exten:$priority $channel\n"; 261 //echo "$accountcode:NewextenEvent : $context:$eventname $channelstate:$channelstatedesc $uniqueid $phonenumber $exten:$priority $channel\n";
262 if($context=="kstychDialerINB"&&$exten!="s"&&$priority=="1") 262 if($context=="kstychDialerINB"&&$exten!="s"&&$priority=="1")
263 { 263 {
264 if(strtolower(substr($channel,0,4))=="sip/") 264 if(strtolower(substr($channel,0,4))=="sip1/")
265 { 265 {
266 $dahdispan=''; 266 $dahdispan='';
267 $dahdichannel=''; 267 $dahdichannel='';
...@@ -310,10 +310,20 @@ class KPAMIListen implements IEventListener ...@@ -310,10 +310,20 @@ class KPAMIListen implements IEventListener
310 310
311 if($userStatus=="[]") 311 if($userStatus=="[]")
312 { 312 {
313
314 $newqueue=new Kqueue(); 313 $newqueue=new Kqueue();
315 $newqueue->playbusyfile($dialline->channel,$dialline->server); 314 if( $this->isHoliday() ) {
315 //play holiday file
316 // $newqueue->playholidayfile($dialline->channel,$dialline->server);
317 } elseif( $this->isNonWorkingTime() ) {
318 // play non working hours file
319 $newqueue->playnonworkingfile($dialline->channel,$dialline->server);
320 } else {
321 // play absense file
322 $newqueue->playabsencefile($dialline->channel,$dialline->server);
323 }
324 return;
316 } 325 }
326
317 327
318 $callStat=CRMCall::where("did","like","%".substr($exten,-4)."%")->where("updated_at",">",date("Y-m-d"))->whereIn('state',['DialBegin', 'DialEnd'])->get(); 328 $callStat=CRMCall::where("did","like","%".substr($exten,-4)."%")->where("updated_at",">",date("Y-m-d"))->whereIn('state',['DialBegin', 'DialEnd'])->get();
319 329
...@@ -328,6 +338,24 @@ class KPAMIListen implements IEventListener ...@@ -328,6 +338,24 @@ class KPAMIListen implements IEventListener
328 } 338 }
329 } 339 }
330 } 340 }
341
342
343 function isHoliday() {
344 return false;
345 }
346
347 function isNonWorkingTime() {
348 return ( $this->isSunday() || $this->isNonWorkingHours() );
349 }
350
351 function isSunday() {
352 return (date('N') == 7);
353 }
354
355 function isNonWorkingHours() {
356 return (time() < strtotime('03:30:00') || time() > strtotime('14:30:00'));
357 }
358
331 private function VarSetEvent(EventMessage $event) 359 private function VarSetEvent(EventMessage $event)
332 { 360 {
333 $eventname=$event->getKey("Event"); 361 $eventname=$event->getKey("Event");
...@@ -480,6 +508,88 @@ class KPAMIListen implements IEventListener ...@@ -480,6 +508,88 @@ class KPAMIListen implements IEventListener
480 $crmcall->save(); 508 $crmcall->save();
481 } 509 }
482 } 510 }
511 else if($accountcodearr[1]=="a") // Code Added by AmolG: AutoDial
512 {
513 $crmcall=CRMCall::find($accountcodearr[2]);
514 if($crmcall)
515 {
516 $nowts=microtime(true)*1000;
517
518 $crmcall->setTs('ts_Recend',$nowts);
519
520 $crmcall->state=$eventname;
521 $crmcall->statuscode=$cause;
522 $crmcall->substatus=$causetxt;
523
524
525 if($crmcall->type=="Auto"&&$crmcall->user_id==0)
526 {
527 $crmcall->userstatus="AutoDROP";
528 $crmcall->usersubstatus="AutoDROP";
529 $crmcall->setTs('ts_Talk',$nowts);
530 $crmcall->setTs('ts_Recstart',$nowts);
531 if($crmcall->crm_id>0)
532 {
533 $wakka = new KHRMSLib();
534 $record=$wakka->getPerson($crmcall->crm_id);
535 if($record)
536 {
537 $record["peopledata"]["status"]="Called";
538 $record["peopledata"]["dialer_status"]="AutoDROP";
539 $record["peopledata"]["dialer_substatus"]="AutoDROP";
540 $wakka->setPerson($crmcall->crm_id,$record);
541 }
542 }
543 }
544 if($crmcall->type=="AutoCall")
545 {
546 $crmcall->userstatus="AutoCall";
547 $crmcall->usersubstatus="AutoCall";
548 $crmcall->setTs('ts_Talk',$nowts);
549 $crmcall->setTs('ts_Recstart',$nowts);
550 if($crmcall->crm_id>0)
551 {
552 $wakka = new KHRMSLib();
553 $record=$wakka->getPerson($crmcall->crm_id);
554 if($record)
555 {
556 $record["peopledata"]["status"]="Called";
557 $record["peopledata"]["dialer_status"]="AutoCall";
558 $record["peopledata"]["dialer_substatus"]="AutoCall";
559 $wakka->setPerson($crmcall->crm_id,$record);
560 }
561 }
562 }
563
564 $dialline=Dialline::find($crmcall->dialline_id);
565 if($dialline && ($dialline->channel==$channel || $dialline->status== "AutoCall"))
566 {
567 $dialline->status="Free";
568 $dialline->conf="";
569 $dialline->number="";
570 $dialline->uniqueid="";
571 $dialline->channel="";
572 $dialline->regexstr="";
573 $dialline->save();
574
575 $tsip=Sipid::find($crmcall->sipid_id);
576
577 if(!empty($tsip))
578 {
579 $tsip->patched=0;
580 $tsip->save();
581 }
582
583 $newqueue=new Kqueue();
584 $newqueue->sipNotify($tsip,"dialerUI","hangup","c",$crmcall->id."~".$crmcall->number."~".base64_encode($channel));
585 }
586
587 $crmcall->addEventLog($nowts,"$accountcode:HangupEvent : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel $cause:$causetxt");
588
589 $crmcall->save();
590
591 }
592 }
483 } 593 }
484 } 594 }
485 else 595 else
...@@ -765,6 +875,35 @@ class KPAMIListen implements IEventListener ...@@ -765,6 +875,35 @@ class KPAMIListen implements IEventListener
765 $crmcall->save(); 875 $crmcall->save();
766 } 876 }
767 } 877 }
878 else if($accountcodearr[1]=="a") // Code Added by AmolG: AutoDial
879 {
880 $crmcall=CRMCall::find($accountcodearr[2]);
881 if($crmcall)
882 {
883 $nowts=microtime(true)*1000;
884
885 $crmcall->setTs('ts_Talk',$nowts);
886
887 $crmcall->state=$eventname;
888 $crmcall->status=$dialstatus;
889 $crmcall->uniqueid=$uniqueid;
890
891 $dialline=Dialline::find($crmcall->dialline_id);
892 if($dialline && $dialstatus=="ANSWER")
893 {
894 $dialline->channel=$dchannel;
895 $dialline->uniqueid=$uniqueid;
896 $dialline->status="Auto";
897 $dialline->save();
898 }
899
900 $crmcall->addEventLog($nowts,"$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstatus");
901
902 $crmcall->type="Auto";
903 $crmcall->save();
904 }
905
906 }
768 } 907 }
769 } 908 }
770 } 909 }
...@@ -1031,8 +1170,7 @@ if($crmcall->did=='46130234'){ ...@@ -1031,8 +1170,7 @@ if($crmcall->did=='46130234'){
1031 1170
1032 private function redirectIncoming() 1171 private function redirectIncoming()
1033 { 1172 {
1034 1173 $diallines=Dialline::where('server','=',$this->sipip)->whereIn("status",["Inbound","Auto"])->where("conf","=","")->get();
1035 $diallines=Dialline::where('server','=',$this->sipip)->where("status","=","Inbound")->where("conf","=","")->get();
1036 if($diallines) 1174 if($diallines)
1037 { 1175 {
1038 foreach($diallines as $dialline) 1176 foreach($diallines as $dialline)
...@@ -1090,15 +1228,15 @@ if($crmcall->did=='46130234'){ ...@@ -1090,15 +1228,15 @@ if($crmcall->did=='46130234'){
1090 $sipids=array(); 1228 $sipids=array();
1091 if($crmcall->client!="") 1229 if($crmcall->client!="")
1092 { 1230 {
1093 $sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->where("clients","like","%".$crmcall->client."%")->where("clients","like","%".$crmcall->did."%")->get(); 1231 $sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->where("clients","like","%".$crmcall->client."%")->where("clients","like","%".$crmcall->did."%")->orderBy("updated_at","desc")->get();
1094 } 1232 }
1095 else if($crmcall->did!="") 1233 else if($crmcall->did!="")
1096 { 1234 {
1097 $sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->where("clients","like","%".$crmcall->did."%")->get(); 1235 $sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->where("clients","like","%".$crmcall->did."%")->orderBy("updated_at","desc")->get();
1098 } 1236 }
1099 else 1237 else
1100 { 1238 {
1101 $sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->get();//send to all? 1239 $sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->orderBy("updated_at","desc")->get();//send to all?
1102 } 1240 }
1103 1241
1104 if(!empty($sipids)) 1242 if(!empty($sipids))
...@@ -1109,7 +1247,29 @@ if($crmcall->did=='46130234'){ ...@@ -1109,7 +1247,29 @@ if($crmcall->did=='46130234'){
1109 $first_r=0;$first_w=0;$first_a=0;$allsipids=array(); 1247 $first_r=0;$first_w=0;$first_a=0;$allsipids=array();
1110 foreach($sipids as $sipid) 1248 foreach($sipids as $sipid)
1111 { 1249 {
1112 if($sipid->ready==1) 1250 if($sipid->ready==1&&$sipid->prepare_call==0&&$dialline->status=="Inbound")
1251 {
1252 $clientsarr=json_decode($sipid->clients,true);
1253 if($crmcall->client=="")$first_a=$sipid;
1254 else
1255 {
1256 if($clientsarr['a']!="")$clientaarr = explode(",", $clientsarr['a']);
1257 if(isset($clientsarr['a'])&&in_array($crmcall->client, $clientaarr))$first_a=$sipid;
1258 if($clientsarr['w']!="")$clientwarr = explode(",", $clientsarr['w']);
1259 if(isset($clientsarr['w'])&&in_array($crmcall->client, $clientwarr))$first_w=$sipid;
1260 if($clientsarr['r']!="")$clientrarr = explode(",", $clientsarr['r']);
1261 if(isset($clientsarr['r'])&&in_array($crmcall->client, $clientrarr))$first_r=$sipid;
1262 }
1263 }
1264 else
1265 {
1266 $allsipids[]=$sipid;
1267 }
1268 }
1269
1270 foreach($sipids as $sipid)
1271 {
1272 if($sipid->ready==1&&$sipid->prepare_call==1&&$dialline->status=="Auto")
1113 { 1273 {
1114 $clientsarr=json_decode($sipid->clients,true); 1274 $clientsarr=json_decode($sipid->clients,true);
1115 if($crmcall->client=="")$first_a=$sipid; 1275 if($crmcall->client=="")$first_a=$sipid;
...@@ -1175,6 +1335,8 @@ if($crmcall->did=='46130234'){ ...@@ -1175,6 +1335,8 @@ if($crmcall->did=='46130234'){
1175 $dialline->save(); 1335 $dialline->save();
1176 1336
1177 $found->ready=0; 1337 $found->ready=0;
1338 $found->prepare_call=0;
1339 $found->patched=1;
1178 $found->save(); 1340 $found->save();
1179 1341
1180 $recfile=$crmcall->newRecFilePath(); 1342 $recfile=$crmcall->newRecFilePath();
...@@ -1205,8 +1367,11 @@ if($crmcall->did=='46130234'){ ...@@ -1205,8 +1367,11 @@ if($crmcall->did=='46130234'){
1205 { 1367 {
1206 foreach($allsipids as $tsip) 1368 foreach($allsipids as $tsip)
1207 { 1369 {
1208 $newqueue=new Kqueue(); 1370 if($dialline->status!="Auto")
1209 $newqueue->sipNotify($tsip,"popupalert"," Incoming Calls",$crmcall->number."|".$crmcall->client,$crmcall->did); 1371 {
1372 $newqueue=new Kqueue();
1373 $newqueue->sipNotify($tsip,"popupalert"," Incoming Calls",$crmcall->number."|".$crmcall->client,"");
1374 }
1210 } 1375 }
1211 } 1376 }
1212 else 1377 else
......
1 <?php
2
3 namespace App\Models;
4
5 use Illuminate\Database\Eloquent\Model;
6
7 class Cutoff extends Model
8 {
9 protected $table = 'cut_off_time';
10 }
...@@ -45,6 +45,30 @@ class Kqueue extends Model{ ...@@ -45,6 +45,30 @@ class Kqueue extends Model{
45 $this->data=json_encode($odata); 45 $this->data=json_encode($odata);
46 $this->save(); 46 $this->save();
47 } 47 }
48 public function autoCallOut($callnumber,$callerid,$crmcall,$dialline)
49 {
50 $dialstr = $dialline->dialstr;
51 $server = $dialline->server;
52
53 if($server != '')
54 {
55 $odata=array();$odata['VARS']=array();
56 $odata['fromext']="Local/$callnumber@kstychDialerINB";
57 $odata['context']="kstychDialer";
58 $odata['callerid']=$callerid;
59 $odata['toext']="1002".$callnumber;
60 $odata['account']='m|a|'.$crmcall->id;
61 $odata['VARS']['dialstr']=$dialstr;
62
63 //originate conf
64 $this->type="SIP_".$server;
65 $this->key="originate";
66 $this->status="New";
67 $this->data=json_encode($odata);
68 $this->save();
69 }
70
71 }
48 public function sipOriginate($sipid,$to,$context) 72 public function sipOriginate($sipid,$to,$context)
49 { 73 {
50 $odata=array();$odata['VARS']=array(); 74 $odata=array();$odata['VARS']=array();
...@@ -197,6 +221,24 @@ class Kqueue extends Model{ ...@@ -197,6 +221,24 @@ class Kqueue extends Model{
197 $this->data=json_encode($odata); 221 $this->data=json_encode($odata);
198 $this->save(); 222 $this->save();
199 } 223 }
224
225 public function playnonworkingfile($fromext,$server)
226 {
227 $odata=array();$odata['VARS']=array();
228 $odata['fromext']=$fromext;
229 $odata['context']="kstychPlayNonWorkingFile";
230 $odata['callerid']="";
231 $odata['toext']="2001";
232 $odata['account']="";
233
234 //originate conf
235 $this->type="SIP_".$server;
236 $this->key="Redirect";
237 $this->status="New";
238 $this->data=json_encode($odata);
239 $this->save();
240 }
241
200 public function playbusyfile($fromext,$server) 242 public function playbusyfile($fromext,$server)
201 { 243 {
202 $odata=array();$odata['VARS']=array(); 244 $odata=array();$odata['VARS']=array();
......
...@@ -352,6 +352,32 @@ function astPAMICheck ...@@ -352,6 +352,32 @@ function astPAMICheck
352 fi 352 fi
353 done 353 done
354 } 354 }
355 function createCall
356 {
357 echo "create"
358 AsteriskServers=$(echo $asterisk_slaves | tr "," "\n")
359 for server in $AsteriskServers
360 do
361 IFS=':' read -r -a ServerArr <<< "$server"
362
363 if ! screen -list | grep -q "CreateCall_$app_domain${ServerArr[0]}"; then
364 /usr/bin/screen -d -m -S CreateCall_$app_domain${ServerArr[0]} bash -c "cd $app_path/application/;php $app_path/application/artisan CreateCall"
365 fi
366 done
367 }
368 function hangUpCall
369 {
370 echo "hang"
371 AsteriskServers=$(echo $asterisk_slaves | tr "," "\n")
372 for server in $AsteriskServers
373 do
374 IFS=':' read -r -a ServerArr <<< "$server"
375
376 if ! screen -list | grep -q "HangUpCall_$app_domain${ServerArr[0]}"; then
377 /usr/bin/screen -d -m -S HangUpCall_$app_domain${ServerArr[0]} bash -c "cd $app_path/application/;php $app_path/application/artisan PredictiveCallHangUp"
378 fi
379 done
380 }
355 function waitForLock 381 function waitForLock
356 { 382 {
357 if [ ! -f /tmp/cronsh-$app_domain.lock ]; then 383 if [ ! -f /tmp/cronsh-$app_domain.lock ]; then
...@@ -412,6 +438,8 @@ if [ "$OSNAME" == "Fedora" ] && [ $OSVER -gt 21 ] ; then ...@@ -412,6 +438,8 @@ if [ "$OSNAME" == "Fedora" ] && [ $OSVER -gt 21 ] ; then
412 sshdCheck 438 sshdCheck
413 dailyTasks 439 dailyTasks
414 astPAMICheck 440 astPAMICheck
441 createCall
442 hangUpCall
415 fi 443 fi
416 clearLock 444 clearLock
417 cd $app_path/application;php artisan schedule:run 445 cd $app_path/application;php artisan schedule:run
......
...@@ -831,8 +831,10 @@ function resetDialer() ...@@ -831,8 +831,10 @@ function resetDialer()
831 var dialerResetForceState=kstychDialer['mDialerState']; 831 var dialerResetForceState=kstychDialer['mDialerState'];
832 var dialerResetForceSubState=kstychDialer['mDialerSubState']; 832 var dialerResetForceSubState=kstychDialer['mDialerSubState'];
833 833
834 dialerResetForceState="Progressive";//Hardcoded TODO change to config 834 if(dialerResetForceSubState != "Predictive"){
835 dialerResetForceSubState=""; 835 dialerResetForceState="Progressive";//Hardcoded TODO change to config
836 dialerResetForceSubState="";
837 }
836 838
837 if(kstychCall['userstatus']=="AUTOWRAPUP") 839 if(kstychCall['userstatus']=="AUTOWRAPUP")
838 { 840 {
......
...@@ -678,7 +678,12 @@ $(document).click(function(e){ ...@@ -678,7 +678,12 @@ $(document).click(function(e){
678 }); 678 });
679 679
680 window.onbeforeunload = function(){ 680 window.onbeforeunload = function(){
681 if(kstychAppObject['user']['id']==0)return ; 681 if(kstychAppObject['user']['id']==0) {
682 return ;
683 }
684 else {
685 doAjax("dialer?action=sipcleanup");
686 }
682 if(lastvarUrl.indexOf("author")<0)return ; 687 if(lastvarUrl.indexOf("author")<0)return ;
683 else return 'Are you sure you want to leave?'; 688 else return 'Are you sure you want to leave?';
684 }; 689 };
......
...@@ -417,6 +417,7 @@ $("#currentstatus_select").val('<?=$currentStatus?>'); ...@@ -417,6 +417,7 @@ $("#currentstatus_select").val('<?=$currentStatus?>');
417 function campaignSelect() 417 function campaignSelect()
418 { 418 {
419 var dashlet="Dialer"; 419 var dashlet="Dialer";
420 client = $('#tcampaign_select').val();
420 doAjax("dashboard/dashlet?module="+dashlet+"&client="+$("#tcampaign_select").val(),"","DashletT-"+dashlet,"ajax_dashlet_"+dashlet,"singlefail","GET"); 421 doAjax("dashboard/dashlet?module="+dashlet+"&client="+$("#tcampaign_select").val(),"","DashletT-"+dashlet,"ajax_dashlet_"+dashlet,"singlefail","GET");
421 422
422 savedialermode(); 423 savedialermode();
......
...@@ -42,9 +42,7 @@ foreach($allusers as $user){ ...@@ -42,9 +42,7 @@ foreach($allusers as $user){
42 <div class='container'> 42 <div class='container'>
43 43
44 <select id='dialmodeassign' class=select2multi multiple="" style="width: 30%;"> 44 <select id='dialmodeassign' class=select2multi multiple="" style="width: 30%;">
45 <option value="Progressive">Progressive</option> 45 <?php foreach($callingmodeArr as $callingmode){;echo "<option value='$callingmode'>$callingmode</option>";} ?>
46 <option value="Manual">Manual</option>
47 <option value="Incoming">Incoming</option>
48 </select> 46 </select>
49 47
50 <select id='username' class=select2multi multiple="" style="width: 30%;"> 48 <select id='username' class=select2multi multiple="" style="width: 30%;">
......
...@@ -35,6 +35,10 @@ $yemaxcarryleaves=base64_encode(Input::get("yemaxcarryleaves")); ...@@ -35,6 +35,10 @@ $yemaxcarryleaves=base64_encode(Input::get("yemaxcarryleaves"));
35 35
36 $trackerfields=base64_encode(Input::get("trackerfields")); 36 $trackerfields=base64_encode(Input::get("trackerfields"));
37 37
38 if(Input::get("autodial_pacing")){
39 $autodial=base64_encode(Input::get("autodial_pacing"));
40 }
41
38 $developerparam=base64_encode(str_replace('\n',"\n",Input::get("developerparam"))); 42 $developerparam=base64_encode(str_replace('\n',"\n",Input::get("developerparam")));
39 43
40 44
...@@ -70,6 +74,7 @@ $mvalue.="yrsickleaves~$yrsickleaves|"; ...@@ -70,6 +74,7 @@ $mvalue.="yrsickleaves~$yrsickleaves|";
70 $mvalue.="yrannualleaves~$yrannualleaves|"; 74 $mvalue.="yrannualleaves~$yrannualleaves|";
71 $mvalue.="yemaxcarryleaves~$yemaxcarryleaves|"; 75 $mvalue.="yemaxcarryleaves~$yemaxcarryleaves|";
72 $mvalue.="developerparam~$developerparam|"; 76 $mvalue.="developerparam~$developerparam|";
77 $mvalue.="autodialercampaign~$autodial|";
73 78
74 $mvalue.="trackerfields~$trackerfields|"; 79 $mvalue.="trackerfields~$trackerfields|";
75 80
......
...@@ -96,6 +96,8 @@ if($client!="") ...@@ -96,6 +96,8 @@ if($client!="")
96 echo "<p><label class='label-small_new' style='width:15%'>AnnualMaxCarryLeaves :</label><input type=text class='form_new form_new_amend' name=yemaxcarryleaves id=yemaxcarryleaves value='".($mastersdata["yemaxcarryleaves"])."'></p>"; 96 echo "<p><label class='label-small_new' style='width:15%'>AnnualMaxCarryLeaves :</label><input type=text class='form_new form_new_amend' name=yemaxcarryleaves id=yemaxcarryleaves value='".($mastersdata["yemaxcarryleaves"])."'></p>";
97 97
98 echo "<p><label class='label-small_new' style='width:15%'>Parameters</label><textarea rows=8 id='developerparam' style='font-size:12px;width:85%'>".($mastersdata["developerparam"])."</textarea></p>"; 98 echo "<p><label class='label-small_new' style='width:15%'>Parameters</label><textarea rows=8 id='developerparam' style='font-size:12px;width:85%'>".($mastersdata["developerparam"])."</textarea></p>";
99
100 echo "<p><label class='label-small_new' style='width:15%'>Autodial Ratio</label><input type=text class='form_new form_new_amend' name='autodial_pacing' id='autodial_pacing' style='font-size:12px;width:15%' value='".($mastersdata["autodialercampaign"])."'></p>";
99 101
100 102
101 103
......
...@@ -73,14 +73,14 @@ if(Input::has("reportsubmit")) ...@@ -73,14 +73,14 @@ if(Input::has("reportsubmit"))
73 73
74 // $finputarr=Input::get("fieldsarr"); 74 // $finputarr=Input::get("fieldsarr");
75 $finputarr=$_POST["fieldsarr"]; 75 $finputarr=$_POST["fieldsarr"];
76 array_unshift($finputarr,'id');
77
78 $selectedfields=$_POST["selectedfields"]; 76 $selectedfields=$_POST["selectedfields"];
79 array_unshift($selectedfields,'EmpID');
80
81 77
82 78
83 if(is_array($finputarr))foreach($finputarr as $eachfield)$fieldsarr[]=$eachfield; 79 if(is_array($finputarr)){foreach($finputarr as $eachfield)
80 $fieldsarr[]=$eachfield;
81 array_unshift($finputarr,'id');
82 array_unshift($selectedfields,'EmpID');
83 }
84 else {echo "Please Select List of fields In report.";return;} 84 else {echo "Please Select List of fields In report.";return;}
85 85
86 $reporttype=Input::get("reporttype"); 86 $reporttype=Input::get("reporttype");
...@@ -134,6 +134,7 @@ if($savereportname!="") ...@@ -134,6 +134,7 @@ if($savereportname!="")
134 $userreports[$savereportname]=base64_encode(json_encode(Input::all())); 134 $userreports[$savereportname]=base64_encode(json_encode(Input::all()));
135 $wakka->SetBBBUserData("UserSavedReports",$userreports); 135 $wakka->SetBBBUserData("UserSavedReports",$userreports);
136 } 136 }
137
137 $usersarr=$wakka->getPersonsdownloadreport($filterstr); 138 $usersarr=$wakka->getPersonsdownloadreport($filterstr);
138 139
139 foreach($usersarr as $r => $userdata) 140 foreach($usersarr as $r => $userdata)
...@@ -141,26 +142,26 @@ foreach($usersarr as $r => $userdata) ...@@ -141,26 +142,26 @@ foreach($usersarr as $r => $userdata)
141 $ppldata[]=unserialize($userdata['peopledata']); 142 $ppldata[]=unserialize($userdata['peopledata']);
142 } 143 }
143 144
144 // dd($ppldata); 145 if (is_array($ppldata)){
146
145 for ($i=0; $i <count($ppldata) ; $i++) { 147 for ($i=0; $i <count($ppldata) ; $i++) {
146 148
147 for ($j=0; $j <count($finputarr) ; $j++) { 149 for ($j=0; $j <count($finputarr) ; $j++) {
148 if ($ppldata[$i] != false){
149 150
150 if (array_key_exists ($finputarr[$j], $ppldata[$i])) { 151 if ($ppldata[$i] != false){
151 152
153 if (array_key_exists ($finputarr[$j], $ppldata[$i])) {
152 $usersdata[$i][$finputarr[$j]]=$ppldata[$i][$finputarr[$j]]; 154 $usersdata[$i][$finputarr[$j]]=$ppldata[$i][$finputarr[$j]];
153 155
154 }else if (! array_key_exists ($finputarr[$j], $ppldata[$i])) 156 }else if (! array_key_exists ($finputarr[$j], $ppldata[$i]))
155 { 157 {
156 $usersdata[$i][$finputarr[$j]] = ""; 158 $usersdata[$i][$finputarr[$j]] = "";
157
158 } 159 }
159 } 160 }
160 } 161 }
161 162
162 } 163 }
163 164 }
164 165
165 $headerexcel = []; 166 $headerexcel = [];
166 foreach($finputarr as $cachekey) 167 foreach($finputarr as $cachekey)
...@@ -171,7 +172,6 @@ if ($ppldata[$i] != false){ ...@@ -171,7 +172,6 @@ if ($ppldata[$i] != false){
171 $headerexcel[$cachekey] = 'string'; //$headerexcel2[] = $cachekey => 'string'; 172 $headerexcel[$cachekey] = 'string'; //$headerexcel2[] = $cachekey => 'string';
172 } 173 }
173 } 174 }
174 // dd($headerexcel2);
175 $filename = "MainReport.xlsx"; 175 $filename = "MainReport.xlsx";
176 header('Content-disposition: attachment; filename="'.XLSXWriter::sanitize_filename($filename).'"'); 176 header('Content-disposition: attachment; filename="'.XLSXWriter::sanitize_filename($filename).'"');
177 header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); 177 header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
...@@ -182,12 +182,15 @@ if ($ppldata[$i] != false){ ...@@ -182,12 +182,15 @@ if ($ppldata[$i] != false){
182 $writer = new XLSXWriter(); 182 $writer = new XLSXWriter();
183 $styles1 = array( 'font'=>'Arial','font-size'=>10,'font-style'=>'bold', 'fill'=>'#eee', 'halign'=>'center', 'border'=>'left,right,top,bottom'); 183 $styles1 = array( 'font'=>'Arial','font-size'=>10,'font-style'=>'bold', 'fill'=>'#eee', 'halign'=>'center', 'border'=>'left,right,top,bottom');
184 $writer->writeSheetHeader('Sheet1', $headerexcel,$styles1,['freeze_rows'=>1, 'freeze_columns'=>1]); 184 $writer->writeSheetHeader('Sheet1', $headerexcel,$styles1,['freeze_rows'=>1, 'freeze_columns'=>1]);
185 $writer->writeSheetRow('Sheet1', $selectedfields,$styles1 ); 185 $writer->writeSheetRow('Sheet1', $selectedfields,$styles1 );
186
187 if($usersdata){
186 188
187 foreach($usersdata as $row) 189 foreach($usersdata as $row)
188 { 190 {
189 $writer->writeSheetRow('Sheet1', $row, $row_options = ['height'=>15]); 191 $writer->writeSheetRow('Sheet1', $row, $row_options = ['height'=>15]);
190 } 192 }
193 }
191 $writer->writeToStdOut(); 194 $writer->writeToStdOut();
192 195
193 return; 196 return;
......
...@@ -453,6 +453,7 @@ function saveCompanies() ...@@ -453,6 +453,7 @@ function saveCompanies()
453 453
454 454
455 vardata+="&developerparam="+encodeURIComponent($("#developerparam").val()); 455 vardata+="&developerparam="+encodeURIComponent($("#developerparam").val());
456 vardata+="&autodial_pacing="+encodeURIComponent($("#autodial_pacing").val());
456 457
457 doAjax("hr?action=CompanyMaster", vardata, "searchresults"); 458 doAjax("hr?action=CompanyMaster", vardata, "searchresults");
458 } 459 }
......
...@@ -215,12 +215,12 @@ function createSearchRecordDiv(divid) ...@@ -215,12 +215,12 @@ function createSearchRecordDiv(divid)
215 <li style='background:#36bc9b'><a href="#" onclick='updateDialerState("dialer","mDialerState","Ready","mDialerSubState","Incoming");savedialermode();return false;'><b>Incoming</b></a></li> 215 <li style='background:#36bc9b'><a href="#" onclick='updateDialerState("dialer","mDialerState","Ready","mDialerSubState","Incoming");savedialermode();return false;'><b>Incoming</b></a></li>
216 <?php } if(in_array('Predictive',$userdialmode)){?> 216 <?php } if(in_array('Predictive',$userdialmode)){?>
217 217
218 <li style='background:#36bc9b'><a href="#" onclick='updateDialerState("dialer","mDialerState","Ready","mDialerSubState","Predictive");savedialermode();return false;'><b>Incoming</b></a></li> 218 <li style='background:#68cc9e'><a href="#" onclick='updateDialerState("dialer","mDialerState","Ready","mDialerSubState","Predictive");savedialermode();return false;'><b>Predictive</b></a></li>
219 <?php } ?> 219 <?php } ?>
220 220
221 <!--<li><a href="#" onclick='updateDialerState("dialer","mDialerState","DialNext");return false;'><b>DialNext</b></a></li>--> 221 <!--<li><a href="#" onclick='updateDialerState("dialer","mDialerState","DialNext");return false;'><b>DialNext</b></a></li>-->
222 222
223 <li><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","Manual");savedialermode();return false;'><b>Paused</b></a></li> 223 <li><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","Paused");savedialermode();return false;'><b>Paused</b></a></li>
224 224
225 225
226 <li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","AgentBriefing");savedialermode();return false;'><b>AgentBriefing</b></a></li> 226 <li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","AgentBriefing");savedialermode();return false;'><b>AgentBriefing</b></a></li>
......
1
2
3 CREATE TABLE `cut_off_time` (
4 `id` int(11) NOT NULL,
5 `created_at` datetime NOT NULL,
6 `updated_at` datetime NOT NULL,
7 `user_id` int(11) NOT NULL,
8 `hangup_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
9 `avg_dispo` int(11) NOT NULL,
10 `avg_ring` int(11) NOT NULL,
11 `c_id` int(11) NOT NULL,
12 `c_name` varchar(20) NOT NULL
13 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
14
15
16 ALTER TABLE `cut_off_time`
17 ADD PRIMARY KEY (`id`);
18
19 ALTER TABLE `cut_off_time`
20 MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
21
22 ALTER TABLE `diallines` ADD `user_id` INT NOT NULL AFTER `server`;
23
24 ALTER TABLE `sipids` ADD `patched` TINYINT(1) NOT NULL AFTER `ready`, ADD `prepare_call` TINYINT(1) NOT NULL AFTER `patched`;
25
26 ALTER TABLE `users` ADD `sel_campaign` VARCHAR(50) NOT NULL AFTER `dialmode_assign`, ADD `current_dialmode` VARCHAR(20) NOT NULL AFTER `sel_campaign`, CHANGE `dialmode_assign` `dialmode_assign` VARCHAR(200) NOT NULL;
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!