Added vicidial lead_id and user logging from vicidial values to the NVA recording AGI script
git-svn-id: svn://192.168.202.10@1944 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -6,22 +6,24 @@
|
||||
# ViciDial agent screen
|
||||
#
|
||||
# ; 1. logging output (NONE|STDERR|FILE|BOTH)
|
||||
# ; 2. the ViciDial user ID, if empty it defaults to accountcode(usually phone extension)
|
||||
# ; 2. the ViciDial user ID, if empty it defaults to accountcode(usually phone extension) or vicidial_live_agents user who launched the call
|
||||
# ; 3. log this call in user_call_log (Y|N) default N
|
||||
# ; 4. log this call in call_log (Y|N) default N, ONLY NEEDED FOR INBOUND AND INTERSYSTEM CALLS!!!
|
||||
# ; 5. audio record this call (Y|N) default N
|
||||
# ; 6. double-log this call in call_log (Y|N) default N, ONLY NEEDED FOR INBOUND CALLMENU FORWARDED CALLS!!!
|
||||
#
|
||||
# ;custom dialplan entry example:
|
||||
#exten => _.,1,AGI(agi-NVA_recording.agi,BOTH------Y---N---Y---N)
|
||||
#exten => _.,n,Goto(default,${EXTEN},1)
|
||||
#exten => _.,n,Hangup
|
||||
# ;custom dialplan entry example: (similar to the defaultlog Call Menu)
|
||||
#exten => _X.,1,AGI(agi-NVA_recording.agi,BOTH------Y---N---Y---N)
|
||||
#exten => _X.,n,Goto(default,${EXTEN},1)
|
||||
#exten => _X.,n,Hangup
|
||||
#
|
||||
# ;inbound to agent example:
|
||||
#exten => 5678,1,AGI(agi-NVA_recording.agi,BOTH------Y---Y---Y---N)
|
||||
#exten => 5678,n,Goto(vicidial-auto,5678,1)
|
||||
#exten => 5678,n,Hangup
|
||||
#
|
||||
# ; example of dial prefix of 94 in System Settings Custom Dialplan to default log
|
||||
#exten => _941NXXNXXXXXX,1,Goto(defaultlog,9${EXTEN:2},1)
|
||||
#
|
||||
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
@@ -30,6 +32,7 @@
|
||||
# 100123-1434 - Added double-log option for CallMenu forwarded calls
|
||||
# 120430-2214 - Converted call to Monitor app to be asterisk 1.8 compatible
|
||||
# 130108-1811 - Changes for Asterisk 1.8 compatibility
|
||||
# 130326-1510 - Added lead_id and user logging from vicidial values
|
||||
#
|
||||
|
||||
&get_time_now;
|
||||
@@ -176,6 +179,62 @@ $calleridname =~ s/unknown|\'//gi;
|
||||
if ( (!$callerid) or ($callerid =~ /unknown/) )
|
||||
{$callerid = $calleridname;}
|
||||
|
||||
if ($calleridname =~ /^V\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d|^Y\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d|^M\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d|^D\S\d\d\d\d\d\dW\d\d\d\d\d\d\d\d\d\dW/)
|
||||
{
|
||||
$vla_string='';
|
||||
$call_type='';
|
||||
$lead_id='0';
|
||||
if ($calleridname =~ /^V/)
|
||||
{
|
||||
$lead_id = substr($calleridname, 10, 10);
|
||||
$call_type = 'auto-dial';
|
||||
}
|
||||
if ($calleridname =~ /^Y/)
|
||||
{
|
||||
$lead_id = substr($calleridname, 10, 10);
|
||||
$call_type = 'inbound';
|
||||
}
|
||||
if ($calleridname =~ /^M/)
|
||||
{
|
||||
$lead_id = substr($calleridname, 10, 10);
|
||||
$call_type = 'manual-dial';
|
||||
}
|
||||
if ($calleridname =~ /^D/)
|
||||
{
|
||||
$lead_id = substr($calleridname, 9, 10);
|
||||
$call_type = '3-way';
|
||||
}
|
||||
if (length($call_type) > 0)
|
||||
{
|
||||
$lead_id = ($lead_id + 0);
|
||||
|
||||
$stmtA = "SELECT user,campaign_id FROM vicidial_live_agents where lead_id='$lead_id' order by last_update_time desc limit 1;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
if ($sthArows > 0)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$VLAuser = $aryA[0];
|
||||
$VLAcampaign = $aryA[1];
|
||||
if (length($user) < 1)
|
||||
{$user = $VLAuser;}
|
||||
$vla_string = "Live agent record found: |$VLAuser|$user|$VLAcampaign|";
|
||||
}
|
||||
|
||||
if ($AGILOG) {$agi_string = "Vicidial $call_type call: |$calleridname|$lead_id| $vla_string"; &agi_output;}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($AGILOG) {$agi_string = "Not a Vicidial call: $calleridname"; &agi_output;}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($AGILOG) {$agi_string = "Not a Vicidial call: $calleridname"; &agi_output;}
|
||||
}
|
||||
|
||||
|
||||
if (length($user) > 0)
|
||||
{$accountcode = $user;}
|
||||
|
||||
@@ -197,7 +256,7 @@ if ($record_call =~ /Y/)
|
||||
}
|
||||
|
||||
### insert record into recording_log table ###
|
||||
$stmtA = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,length_in_sec,filename,lead_id,user,location,vicidial_id) values('$channel','$VARserver_ip','$extension','$now_date','$start_epoch','0','$filename','0','$accountcode','$filename','$unique_id');";
|
||||
$stmtA = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,length_in_sec,filename,lead_id,user,location,vicidial_id) values('$channel','$VARserver_ip','$extension','$now_date','$start_epoch','0','$filename','$lead_id','$accountcode','$filename','$unique_id');";
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
}
|
||||
|
||||
@@ -205,7 +264,7 @@ if ($record_call =~ /Y/)
|
||||
if ($log_user_call =~ /Y/)
|
||||
{
|
||||
### insert record into user_call_log table ###
|
||||
$stmtA = "INSERT INTO user_call_log SET user='$accountcode', call_date='$now_date', call_type='PHONE_DIAL', server_ip='$VARserver_ip', phone_number='$extension', number_dialed='$extension', callerid='$callerid', group_alias_id='$unique_id';";
|
||||
$stmtA = "INSERT INTO user_call_log SET user='$accountcode', call_date='$now_date', call_type='PHONE_DIAL', server_ip='$VARserver_ip', phone_number='$extension', number_dialed='$extension', callerid='$callerid', group_alias_id='$unique_id', lead_id='$lead_id';";
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user