Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flexydial
/
hdfc-beu-v2
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
0fa8f57b
authored
2019-07-26 16:02:26 +0000
by
Manish Mihsra
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Created new function to connect calls and modify some small changes
1 parent
3bb592c9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
105 deletions
application/app/Jobs/KPAMIListen.php
application/app/Jobs/KPAMIListen.php
View file @
0fa8f57
...
...
@@ -1473,10 +1473,9 @@ class KPAMIListen implements IEventListener
if
(
$crmcall
)
{
$nowts
=
microtime
(
true
)
*
1000
;
$crmcalldata
=
json_decode
(
$crmcall
->
data
,
true
);
if
(
!
isset
(
$crmcalldata
[
"userbusyfile"
]))
$crmcalldata
[
"userbusyfile"
]
=
0
;
$sipids
=
array
();
$sipids
=
Sipid
::
where
(
'server'
,
'='
,
$this
->
sipip
)
->
where
(
"status"
,
"="
,
"1"
)
->
where
(
"ready"
,
"="
,
"1"
)
->
where
(
"prepare_call"
,
"="
,
"1"
)
->
orderBy
(
"updated_at"
,
"desc"
)
->
get
();
...
...
@@ -1485,127 +1484,115 @@ class KPAMIListen implements IEventListener
{
echo
"sipids found "
;
$first_r
=
0
;
$first_w
=
0
;
$first_a
=
0
;
$allsipids
=
array
();
foreach
(
$sipids
as
$sipid
)
{
$clientsarr
=
json_decode
(
$sipid
->
clients
,
true
);
if
(
$crmcall
->
client
==
""
)
$first_a
=
$sipid
;
else
{
if
(
$clientsarr
[
'a'
]
!=
""
)
$clientaarr
=
explode
(
","
,
$clientsarr
[
'a'
]);
if
(
isset
(
$clientsarr
[
'a'
])
&&
in_array
(
$crmcall
->
client
,
$clientaarr
))
$first_a
=
$sipid
;
if
(
$clientsarr
[
'w'
]
!=
""
)
$clientwarr
=
explode
(
","
,
$clientsarr
[
'w'
]);
if
(
isset
(
$clientsarr
[
'w'
])
&&
in_array
(
$crmcall
->
client
,
$clientwarr
))
$first_w
=
$sipid
;
if
(
$clientsarr
[
'r'
]
!=
""
)
$clientrarr
=
explode
(
","
,
$clientsarr
[
'r'
]);
if
(
isset
(
$clientsarr
[
'r'
])
&&
in_array
(
$crmcall
->
client
,
$clientrarr
))
$first_r
=
$sipid
;
}
}
echo
"Notifying Total ::"
.
sizeof
(
$allsipids
)
.
"
\n
"
;
$found
=
false
;
if
(
$first_a
)
$found
=
$first_a
;
else
if
(
$first_w
)
$found
=
$first_w
;
else
if
(
$first_r
)
$found
=
$first_r
;
if
(
$found
)
{
$alreadyconf
=
Dialline
::
where
(
'server'
,
'='
,
$this
->
sipip
)
->
where
(
"status"
,
"="
,
"Auto"
)
->
where
(
"conf"
,
"="
,
"1000"
.
$found
->
id
)
->
get
();
if
(
sizeof
(
$alreadyconf
)
>
0
)
{
echo
$found
->
id
.
" : Found but Already in Conf!!!
\n
"
;
$found
=
false
;
}
$this
->
connectToAvailableSip
(
$sipid
,
$dialline
,
$crmcall
);
}
if
(
$found
)
{
echo
"sipids :
$found->id
\n
"
;
$userEntry
=
User
::
find
(
$found
->
user
);
if
(
!
empty
(
$userEntry
)){
if
(
$userEntry
->
current_dialmode
!=
"Predictive"
||
$found
->
ready
!=
1
||
$dialline
->
regexstr
!=
$userEntry
->
sel_campaign
)
return
;
}
}
}
}
}
}
exec
(
"/usr/sbin/asterisk -rx 'core show channel
$dialline->channel
'"
,
$channelArr
);
private
function
connectToAvailableSip
(
$sipid
,
$dialline
,
$crmcall
)
{
$nowts
=
microtime
(
true
)
*
1000
;
$found
=
$sipid
;
if
(
count
(
$channelArr
)
==
1
)
{
Log
::
useFiles
(
storage_path
()
.
"/logs/Predictive/predictive_"
.
date
(
"Y_m_d"
)
.
".log"
);
Log
::
info
(
$crmcall
->
id
);
Log
::
info
(
$dialline
);
if
(
$found
)
{
$alreadyconf
=
Dialline
::
where
(
'server'
,
'='
,
$this
->
sipip
)
->
where
(
"status"
,
"="
,
"Auto"
)
->
where
(
"conf"
,
"="
,
"1000"
.
$found
->
id
)
->
get
();
if
(
sizeof
(
$alreadyconf
)
>
0
)
{
echo
$found
->
id
.
" : Found but Already in Conf!!!
\n
"
;
$found
=
false
;
}
}
$dialline
->
status
=
"Free"
;
$dialline
->
conf
=
""
;
$dialline
->
number
=
""
;
$dialline
->
uniqueid
=
""
;
$dialline
->
src_channel
=
""
;
$dialline
->
channel
=
""
;
$dialline
->
regexstr
=
""
;
$dialline
->
save
();
if
(
$found
)
{
echo
"sipids :
$found->id
\n
"
;
continue
;
}
$userEntry
=
User
::
find
(
$found
->
user
);
$recfile
=
$crmcall
->
newRecFilePath
();
if
(
!
empty
(
$userEntry
)){
if
(
$userEntry
->
current_dialmode
!=
"Predictive"
||
$found
->
ready
!=
1
)
return
;
}
//start recording
$newqueue
=
new
Kqueue
();
$newqueue
->
recordChannel
(
$dialline
->
server
,
$dialline
->
channel
,
$recfile
);
exec
(
"/usr/sbin/asterisk -rx 'core show channel
$dialline->channel
'"
,
$channelArr
);
$newqueue
=
new
Kqueue
();
$newqueue
->
userToConf
(
$found
);
if
(
count
(
$channelArr
)
==
1
)
{
Log
::
useFiles
(
storage_path
()
.
"/logs/Predictive/predictive_"
.
date
(
"Y_m_d"
)
.
".log"
);
Log
::
info
(
$crmcall
->
id
);
Log
::
info
(
$dialline
);
$newqueue
=
new
Kqueue
();
$newqueue
->
channelRedirectToExten
(
$found
->
server
,
$dialline
->
channel
,
"1000"
.
$found
->
id
,
"kstychDialer"
,
"1"
);
$dialline
->
status
=
"Free"
;
$dialline
->
conf
=
""
;
$dialline
->
number
=
""
;
$dialline
->
uniqueid
=
""
;
$dialline
->
src_channel
=
""
;
$dialline
->
channel
=
""
;
$dialline
->
regexstr
=
""
;
$dialline
->
save
();
$dialline
->
user_id
=
$found
->
user
;
$dialline
->
conf
=
"1000"
.
$found
->
id
;
$dialline
->
save
();
continue
;
}
$found
->
ready
=
0
;
$found
->
prepare_call
=
0
;
$found
->
patched
=
1
;
$found
->
save
();
$recfile
=
$crmcall
->
newRecFilePath
();
$userlog
=
UserLog
::
where
(
'user_id'
,
'='
,
$found
->
user
)
->
orderBy
(
"id"
,
"DESC"
)
->
first
();
$ts_Wait
=
$userlog
->
getLastTs
(
$found
->
id
,
$nowts
);
$userlog
->
save
();
$crmcall
->
user_id
=
$found
->
user
;
$crmcall
->
sipid_id
=
$found
->
id
;
if
(
$ts_Wait
<=
$crmcall
->
ts_Wait
)
//user waiting
{
$crmcall
->
ts_Wait
=
$ts_Wait
;
$crmcall
->
setTs
(
'ts_Talk'
,
$nowts
);
}
else
//call waiting
{
$crmcall
->
ts_Wait
-=
(
$nowts
-
$ts_Wait
);
$crmcall
->
setTs
(
'ts_Talk'
,
$nowts
);
}
//start recording
$newqueue
=
new
Kqueue
();
$newqueue
->
recordChannel
(
$dialline
->
server
,
$dialline
->
channel
,
$recfile
);
$crmcall
->
sav
e
();
$newqueue
=
new
Kqueu
e
();
$newqueue
->
userToConf
(
$found
);
if
(
$crmcall
->
crm_id
>
0
){
DB
::
table
(
'records'
)
->
where
(
'id'
,
$crmcall
->
crm_id
)
->
update
([
'filter_condition'
=>
'3'
,
'usr_id'
=>
$found
->
user
]);
}
$crmcall
->
setTs
(
'ts_Recstart'
,
$nowts
);
$crmcall
->
save
();
$newqueue
=
new
Kqueue
();
$newqueue
->
sipNotify
(
$found
,
"incomingCall"
,
$crmcall
->
id
,
$crmcall
->
crm_id
,
$crmcall
->
number
.
"@"
.
$dialline
->
channel
);
}
}
}
}
$newqueue
=
new
Kqueue
();
$newqueue
->
channelRedirectToExten
(
$found
->
server
,
$dialline
->
channel
,
"1000"
.
$found
->
id
,
"kstychDialer"
,
"1"
);
$dialline
->
user_id
=
$found
->
user
;
$dialline
->
conf
=
"1000"
.
$found
->
id
;
$dialline
->
save
();
$found
->
ready
=
0
;
$found
->
prepare_call
=
0
;
$found
->
patched
=
1
;
$found
->
save
();
$userlog
=
UserLog
::
where
(
'user_id'
,
'='
,
$found
->
user
)
->
orderBy
(
"id"
,
"DESC"
)
->
first
();
$ts_Wait
=
$userlog
->
getLastTs
(
$found
->
id
,
$nowts
);
$userlog
->
save
();
$crmcall
->
user_id
=
$found
->
user
;
$crmcall
->
sipid_id
=
$found
->
id
;
if
(
$ts_Wait
<=
$crmcall
->
ts_Wait
)
//user waiting
{
$crmcall
->
ts_Wait
=
$ts_Wait
;
$crmcall
->
setTs
(
'ts_Talk'
,
$nowts
);
}
else
//call waiting
{
$crmcall
->
ts_Wait
-=
(
$nowts
-
$ts_Wait
);
$crmcall
->
setTs
(
'ts_Talk'
,
$nowts
);
}
$crmcall
->
save
();
if
(
$crmcall
->
crm_id
>
0
){
DB
::
table
(
'records'
)
->
where
(
'id'
,
$crmcall
->
crm_id
)
->
update
([
'filter_condition'
=>
'3'
,
'usr_id'
=>
$found
->
user
]);
}
$crmcall
->
setTs
(
'ts_Recstart'
,
$nowts
);
$crmcall
->
save
();
$newqueue
=
new
Kqueue
();
$newqueue
->
sipNotify
(
$found
,
"incomingCall"
,
$crmcall
->
id
,
$crmcall
->
crm_id
,
$crmcall
->
number
.
"@"
.
$dialline
->
channel
);
}
}
// private function redirectIncoming()
// {
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment