e10aa96d by G Manojkumar

Added new context for after hrs

1 parent 7002a035
...@@ -306,28 +306,52 @@ class KPAMIListen implements IEventListener ...@@ -306,28 +306,52 @@ class KPAMIListen implements IEventListener
306 $crmcall->data=json_encode($tdata); 306 $crmcall->data=json_encode($tdata);
307 $crmcall->save(); 307 $crmcall->save();
308 308
309
310 $newqueue=new Kqueue();
311
312 if( $this->isHoliday() ) {
313
314 // TODO: Handle Holidays here
315 } elseif( $this->isNonWorkingTime() ) {
316
317 $newqueue->playafterhrsfile($dialline->channel,$dialline->server);
318 } else {
309 $userStatus=User::where("updated_at",">",date("Y-m-d"))->where("exten","like","%".substr($exten,-4)."%")->where("usertype","!=","Admin")->where('presence', '=', '1')->select('*')->get(); 319 $userStatus=User::where("updated_at",">",date("Y-m-d"))->where("exten","like","%".substr($exten,-4)."%")->where("usertype","!=","Admin")->where('presence', '=', '1')->select('*')->get();
310 320
311 if($userStatus=="[]") 321 if($userStatus=="[]")
312 { 322 {
313
314 $newqueue=new Kqueue();
315 $newqueue->playabsencefile($dialline->channel,$dialline->server); 323 $newqueue->playabsencefile($dialline->channel,$dialline->server);
316 } 324 } else {
317
318 $callStat=CRMCall::where("did","like","%".substr($exten,-4)."%")->where("updated_at",">",date("Y-m-d"))->whereIn('state',['DialBegin', 'DialEnd'])->get(); 325 $callStat=CRMCall::where("did","like","%".substr($exten,-4)."%")->where("updated_at",">",date("Y-m-d"))->whereIn('state',['DialBegin', 'DialEnd'])->get();
319 326
320 if($callStat!="[]") 327 if($callStat!="[]")
321 { 328 {
322
323 $newqueue=new Kqueue();
324 $newqueue->playbusyfile($dialline->channel,$dialline->server); 329 $newqueue->playbusyfile($dialline->channel,$dialline->server);
325 } 330 }
331 }
332 }
333
326 334
327 } 335 }
328 } 336 }
329 } 337 }
330 } 338 }
339 function isHoliday() {
340 return false;
341 }
342
343 function isNonWorkingTime() {
344 return ( $this->isSunday() || $this->isNonWorkingHours() );
345 }
346
347 function isSunday() {
348 return (date('N') == 7);
349 }
350
351 function isNonWorkingHours() {
352 return (time() < strtotime('03:30:00') || time() > strtotime('13:30:00'));
353 }
354
331 private function VarSetEvent(EventMessage $event) 355 private function VarSetEvent(EventMessage $event)
332 { 356 {
333 $eventname=$event->getKey("Event"); 357 $eventname=$event->getKey("Event");
...@@ -1000,25 +1024,31 @@ class KPAMIListen implements IEventListener ...@@ -1000,25 +1024,31 @@ class KPAMIListen implements IEventListener
1000 $crmcall->data=json_encode($tdata); 1024 $crmcall->data=json_encode($tdata);
1001 $crmcall->save(); 1025 $crmcall->save();
1002 1026
1027 $newqueue=new Kqueue();
1028
1029 if( $this->isHoliday() ) {
1030
1031 // TODO: Handle Holidays here
1032 } elseif( $this->isNonWorkingTime() ) {
1033
1034 $newqueue->playafterhrsfile($dialline->channel,$dialline->server);
1035 } else {
1003 $userStatus=User::where("updated_at",">",date("Y-m-d"))->where("exten","like","%".substr($exten,-4)."%")->where("usertype","!=","Admin")->where('presence', '=', '1')->select('*')->get(); 1036 $userStatus=User::where("updated_at",">",date("Y-m-d"))->where("exten","like","%".substr($exten,-4)."%")->where("usertype","!=","Admin")->where('presence', '=', '1')->select('*')->get();
1004 1037
1005 if($userStatus=="[]") 1038 if($userStatus=="[]")
1006 { 1039 {
1007 1040 $newqueue->playabsencefile($dialline->channel,$dialline->server);
1008 $newqueue=new Kqueue(); 1041 } else {
1009 $newqueue->playbusyfile($dialline->channel,$dialline->server);
1010 }
1011
1012 $callStat=CRMCall::where("did","like","%".substr($exten,-4)."%")->where("updated_at",">",date("Y-m-d"))->whereIn('state',['DialBegin', 'DialEnd'])->get(); 1042 $callStat=CRMCall::where("did","like","%".substr($exten,-4)."%")->where("updated_at",">",date("Y-m-d"))->whereIn('state',['DialBegin', 'DialEnd'])->get();
1013 1043
1014 if($callStat!="[]") 1044 if($callStat!="[]")
1015 { 1045 {
1016
1017 $newqueue=new Kqueue();
1018 $newqueue->playbusyfile($dialline->channel,$dialline->server); 1046 $newqueue->playbusyfile($dialline->channel,$dialline->server);
1019 } 1047 }
1020 } 1048 }
1021 } 1049 }
1050 }
1051 }
1022 1052
1023 } 1053 }
1024 1054
......
...@@ -229,11 +229,11 @@ class Kqueue extends Model{ ...@@ -229,11 +229,11 @@ class Kqueue extends Model{
229 $this->data=json_encode($odata); 229 $this->data=json_encode($odata);
230 $this->save(); 230 $this->save();
231 } 231 }
232 public function playhangupfile($fromext,$server) 232 public function playafterhrsfile($fromext,$server)
233 { 233 {
234 $odata=array();$odata['VARS']=array(); 234 $odata=array();$odata['VARS']=array();
235 $odata['fromext']=$fromext; 235 $odata['fromext']=$fromext;
236 $odata['context']="kstychPlayHangFile"; 236 $odata['context']="kstychAfterFile";
237 $odata['callerid']=""; 237 $odata['callerid']="";
238 $odata['toext']="3001"; 238 $odata['toext']="3001";
239 $odata['account']=""; 239 $odata['account']="";
......
...@@ -40,18 +40,25 @@ exten => _1002XXX!,n,Hangup ...@@ -40,18 +40,25 @@ exten => _1002XXX!,n,Hangup
40 40
41 [kstychDialerINB] 41 [kstychDialerINB]
42 exten => _X!,1,Answer 42 exten => _X!,1,Answer
43 exten => _X!,n,GotoIfTime(12:58-03:58,mon-sat?aftrhrs,1) 43 ;exten => _X!,n,GotoIfTime(12:58-03:58,mon-sat?aftrhrs,1)
44 exten => _X!,n,GotoIfTime(00:00-23:59,sun?afterhrs,1) 44 ;exten => _X!,n,GotoIfTime(00:00-23:59,sun?afterhrs,1)
45 exten => _X!,n,Set(CONFBRIDGE(user,music_on_hold_when_empty)=yes) 45 exten => _X!,n,Set(CONFBRIDGE(user,music_on_hold_when_empty)=yes)
46 exten => _X!,n,MixMonitor(/var/spool/asterisk/astrec/${STRFTIME(${EPOCH},,%Y/%m/%d)}/inb/inbound_${STRFTIME(${EPOCH},Asia/Kolkata,%Y%m%d-%H%M%S)}_${CALLERID(num)}_${EXTEN}_${UNIQUEID}.gsm,av(0)V(0)) 46 exten => _X!,n,MixMonitor(/var/spool/asterisk/astrec/${STRFTIME(${EPOCH},,%Y/%m/%d)}/inb/inbound_${STRFTIME(${EPOCH},Asia/Kolkata,%Y%m%d-%H%M%S)}_${CALLERID(num)}_${EXTEN}_${UNIQUEID}.gsm,av(0)V(0))
47 exten => _X!,n,ConfBridge(${CHANNEL}) 47 exten => _X!,n,ConfBridge(${CHANNEL})
48 exten => _X!,n,Hangup 48 exten => _X!,n,Hangup
49 49
50 exten => aftrhrs,1,Playback(/var/lib/asterisk/sounds/audio_holiday_vrm_V2) 50 ;exten => aftrhrs,1,Playback(/var/lib/asterisk/sounds/audio_holiday_vrm_V2)
51 exten => aftrhrs,n,Hangup 51 ;exten => aftrhrs,n,Hangup
52
53 ;exten => afterhrs,1,Playback(/var/lib/asterisk/sounds/audio_holiday_vrm_V2)
54 ;exten => aftrhrs,n,Hangup
55
56 [kstychAfterFile]
57 exten => 3001,1,Answer
58 exten => 3001,n,Playback(silence/1)
59 exten => 3001,n,Playback(/var/lib/asterisk/sounds/audio_holiday_vrm_V2)
60 exten => 3001,n,Hangup
52 61
53 exten => afterhrs,1,Playback(/var/lib/asterisk/sounds/audio_holiday_vrm_V2)
54 exten => aftrhrs,n,Hangup
55 62
56 [kstychPlayFile] 63 [kstychPlayFile]
57 exten => 1001,1,Answer 64 exten => 1001,1,Answer
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!