From b364940b61823a34499c140590f4d9d6ab7ce55f Mon Sep 17 00:00:00 2001 From: mattf Date: Tue, 19 Jan 2010 14:39:10 +0000 Subject: [PATCH] bug fix 291 change default PRI dial order to 'r' from 'g' for round robin Added development code to DID AGI script git-svn-id: svn://192.168.202.10@1311 3d104415-ff17-0410-8863-d5cf3c621b8a --- .../docs/conf_examples/extensions.conf.sample | 4 +- .../conf_examples/extensions.conf.sample-1.4 | 4 +- .../www/vicidial/AST_agent_status_detail.php | 4 +- agc_2-X/trunk/agi/agi-DID_route.agi | 65 +++++++++++++++---- .../docs/conf_examples/extensions.conf.sample | 4 +- .../conf_examples/extensions.conf.sample-1.4 | 4 +- .../www/vicidial/AST_agent_status_detail.php | 4 +- 7 files changed, 66 insertions(+), 23 deletions(-) diff --git a/agc_2-X/branches/agc_2.2.0/docs/conf_examples/extensions.conf.sample b/agc_2-X/branches/agc_2.2.0/docs/conf_examples/extensions.conf.sample index 69d048eb..8628fe98 100644 --- a/agc_2-X/branches/agc_2.2.0/docs/conf_examples/extensions.conf.sample +++ b/agc_2-X/branches/agc_2.2.0/docs/conf_examples/extensions.conf.sample @@ -4,8 +4,8 @@ writeprotect=no [globals] CONSOLE=Console/dsp ; Console interface for demo -TRUNK=Zap/g1 ; Trunk interface -TRUNKX=Zap/g2 ; 2nd trunk interface +TRUNK=Zap/r1 ; Trunk interface +TRUNKX=Zap/r2 ; 2nd trunk interface TRUNKIAX=IAX2/ASTtest1:test@10.10.10.16:4569 ; IAX trunk interface TRUNKIAX1=IAX2/ASTtest1:test@10.10.10.16:4569 ; IAX trunk interface TRUNKBINFONE=IAX2/1112223333:PASSWORD@iax.binfone.com ; IAX trunk interface diff --git a/agc_2-X/branches/agc_2.2.0/docs/conf_examples/extensions.conf.sample-1.4 b/agc_2-X/branches/agc_2.2.0/docs/conf_examples/extensions.conf.sample-1.4 index 649df169..84a8fe96 100644 --- a/agc_2-X/branches/agc_2.2.0/docs/conf_examples/extensions.conf.sample-1.4 +++ b/agc_2-X/branches/agc_2.2.0/docs/conf_examples/extensions.conf.sample-1.4 @@ -4,8 +4,8 @@ writeprotect=no [globals] CONSOLE=Console/dsp ; Console interface for demo -TRUNK=Zap/g1 ; Trunk interface -TRUNKX=Zap/g2 ; 2nd trunk interface +TRUNK=Zap/r1 ; Trunk interface +TRUNKX=Zap/r2 ; 2nd trunk interface TRUNKIAX=IAX2/ASTtest1:test@10.10.10.16:4569 ; IAX trunk interface TRUNKIAX1=IAX2/ASTtest1:test@10.10.10.16:4569 ; IAX trunk interface TRUNKBINFONE=IAX2/1112223333:PASSWORD@iax.binfone.com ; IAX trunk interface diff --git a/agc_2-X/branches/agc_2.2.0/www/vicidial/AST_agent_status_detail.php b/agc_2-X/branches/agc_2.2.0/www/vicidial/AST_agent_status_detail.php index 216cc490..916bd514 100644 --- a/agc_2-X/branches/agc_2.2.0/www/vicidial/AST_agent_status_detail.php +++ b/agc_2-X/branches/agc_2.2.0/www/vicidial/AST_agent_status_detail.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2010 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -9,6 +9,7 @@ # 90225-2252 - Added CSV download option # 90310-2030 - Admin header # 90508-0644 - Changed to PHP long tags +# 100119-0935 - Fixed bug 291 # @@ -372,6 +373,7 @@ else if ($status_found < 1) { $SstatusesHTML .= " 0 |"; + $SstatusesFILE .= "0,"; } ### END loop through each stat line ### $n++; diff --git a/agc_2-X/trunk/agi/agi-DID_route.agi b/agc_2-X/trunk/agi/agi-DID_route.agi index 9b432a33..d36f09b4 100644 --- a/agc_2-X/trunk/agi/agi-DID_route.agi +++ b/agc_2-X/trunk/agi/agi-DID_route.agi @@ -4,10 +4,12 @@ # # runs when a call comes into an inbound context on a trunk. This script will # send the calls to various places depending on the settings for each DID. -# # # You need to put a line similar to this below in your extensions.conf file in -# the context for where incoming calls go from your trunks: +# the context for where incoming calls go from your trunks (for example, the +# trunkinbound context which is present in the default dialplan): +# +#[trunkinbound] # ;inbound DID catch-all: #exten => _X.,1,AGI(agi-DID_route.agi) # @@ -28,6 +30,7 @@ $script = 'agi-DID_route.agi'; $dtmf_silent_prefix = '7'; $at='@'; $S='*'; +$US='_'; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); @@ -198,6 +201,7 @@ if ($sthArows > 0) $user_unavailable_action = $aryA[11]; $user_route_settings_ingroup = $aryA[12]; $menu_id = $aryA[13]; + $record_call = ''; $DIDs_in_system++; } @@ -227,16 +231,22 @@ if ($sthArows < 1) $user_unavailable_action = $aryA[11]; $user_route_settings_ingroup = $aryA[12]; $menu_id = $aryA[13]; + $record_call = ''; } $sthA->finish(); } -### Log the call +### Log the call to vicidial_did_log $stmtA = "INSERT INTO vicidial_did_log SET uniqueid='$uniqueid',channel='$channel',server_ip='$VARserver_ip',caller_id_number='$callerid',caller_id_name='$calleridname',extension='$extension',call_date='$SQLdate',did_id='$did_id',did_route='$did_route';"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $affected_rowsL = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- DID LOG : |$affected_rowsL|$stmtA|"; &agi_output;} +### Log the call to call_log +$stmtA = "INSERT INTO call_log SET uniqueid='$unique_id', channel='$channel', channel_group='DID_INBOUND', server_ip='$VARserver_ip', type='$type', extension='$extension', number_dialed='$extension', caller_code='$callerid', start_time='$SQLdate', start_epoch='$now_date_epoch';"; +$affected_rowsC = $dbhA->do($stmtA); +if ($AGILOG) {$agi_string = "-- CALL LOG : |$affected_rowsC|$stmtA|"; &agi_output;} + if ($AGILOG) {$did_string = "$SQLdate|$uniqueid|$channel|$extension|$callerid|$calleridname|$did_id|$did_route|"; &did_output;} if ($DIDs_in_system < 1) @@ -246,6 +256,35 @@ if ($DIDs_in_system < 1) exit; } +### if set to record this call, start recording ### +if ($record_call =~ /Y/) + { + $insert_recording_id=''; + $filename = "$tsSQLdate$US$extension$US$callerid"; + ### code to record call goes here ### + + $AGI->exec("Monitor wav|/var/spool/asterisk/monitor/MIX/$filename"); + + ### 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','$SQLdate','now_date_epoch','0','$filename','0','$callerid','$filename','$unique_id');"; + $affected_rowsR = $dbhA->do($stmtA); + if ($affected_rowsR > 0) + { + $stmtB = "select LAST_INSERT_ID() LIMIT 1;"; + $sthA = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $insert_recording_id = $aryA[0]; + } + $sthA->finish(); + } + + if ($AGILOG) {$did_string = "-- RECORDING LOG : |$affected_rowsR|$insert_recording_id|$stmtA|"; &did_output;} + } + ### Grab Server values from the database $cbc=0; $stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$VARserver_ip';"; @@ -256,12 +295,12 @@ while ($sthArows > $cbc) { @aryA = $sthA->fetchrow_array; - $DBvoicemail_dump_exten = "$aryA[0]"; - $DBext_context = "$aryA[1]"; - $DBanswer_transfer_agent = "$aryA[2]"; - $DBSERVER_GMT = "$aryA[3]"; - $DBasterisk_version = "$aryA[4]"; - $DBmax_vicidial_trunks = "$aryA[5]"; + $DBvoicemail_dump_exten = $aryA[0]; + $DBext_context = $aryA[1]; + $DBanswer_transfer_agent = $aryA[2]; + $DBSERVER_GMT = $aryA[3]; + $DBasterisk_version = $aryA[4]; + $DBmax_vicidial_trunks = $aryA[5]; if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} if ($DBext_context) {$ext_context = $DBext_context;} if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} @@ -286,10 +325,10 @@ if ($did_route =~ /PHONE/) if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $dialplan_number = "$aryA[0]"; - $voicemail_id = "$aryA[1]"; - $protocol = "$aryA[2]"; - $ext_context = "$aryA[3]"; + $dialplan_number = $aryA[0]; + $voicemail_id = $aryA[1]; + $protocol = $aryA[2]; + $ext_context = $aryA[3]; } $sthA->finish(); diff --git a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample index 69d048eb..8628fe98 100644 --- a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample +++ b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample @@ -4,8 +4,8 @@ writeprotect=no [globals] CONSOLE=Console/dsp ; Console interface for demo -TRUNK=Zap/g1 ; Trunk interface -TRUNKX=Zap/g2 ; 2nd trunk interface +TRUNK=Zap/r1 ; Trunk interface +TRUNKX=Zap/r2 ; 2nd trunk interface TRUNKIAX=IAX2/ASTtest1:test@10.10.10.16:4569 ; IAX trunk interface TRUNKIAX1=IAX2/ASTtest1:test@10.10.10.16:4569 ; IAX trunk interface TRUNKBINFONE=IAX2/1112223333:PASSWORD@iax.binfone.com ; IAX trunk interface diff --git a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 index 649df169..84a8fe96 100644 --- a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 +++ b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 @@ -4,8 +4,8 @@ writeprotect=no [globals] CONSOLE=Console/dsp ; Console interface for demo -TRUNK=Zap/g1 ; Trunk interface -TRUNKX=Zap/g2 ; 2nd trunk interface +TRUNK=Zap/r1 ; Trunk interface +TRUNKX=Zap/r2 ; 2nd trunk interface TRUNKIAX=IAX2/ASTtest1:test@10.10.10.16:4569 ; IAX trunk interface TRUNKIAX1=IAX2/ASTtest1:test@10.10.10.16:4569 ; IAX trunk interface TRUNKBINFONE=IAX2/1112223333:PASSWORD@iax.binfone.com ; IAX trunk interface diff --git a/agc_2-X/trunk/www/vicidial/AST_agent_status_detail.php b/agc_2-X/trunk/www/vicidial/AST_agent_status_detail.php index 216cc490..916bd514 100644 --- a/agc_2-X/trunk/www/vicidial/AST_agent_status_detail.php +++ b/agc_2-X/trunk/www/vicidial/AST_agent_status_detail.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2010 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -9,6 +9,7 @@ # 90225-2252 - Added CSV download option # 90310-2030 - Admin header # 90508-0644 - Changed to PHP long tags +# 100119-0935 - Fixed bug 291 # @@ -372,6 +373,7 @@ else if ($status_found < 1) { $SstatusesHTML .= " 0 |"; + $SstatusesFILE .= "0,"; } ### END loop through each stat line ### $n++;