diff --git a/agc_2-X/branches/agc_30/lib/Astguiclient/Campaign/Record.pm b/agc_2-X/branches/agc_30/lib/Astguiclient/Campaign/Record.pm index d90339f4..990b36f3 100644 --- a/agc_2-X/branches/agc_30/lib/Astguiclient/Campaign/Record.pm +++ b/agc_2-X/branches/agc_30/lib/Astguiclient/Campaign/Record.pm @@ -5,7 +5,7 @@ use base qw(Class::Accessor::Fast); use Astguiclient::Campaign::Agent; -__PACKAGE__->mk_accessors(qw/ agent active dial_level next_agent /); +__PACKAGE__->mk_accessors(qw/ agent /); =head1 name diff --git a/agc_2-X/branches/agc_30/lib/Astguiclient/DBI.pm b/agc_2-X/branches/agc_30/lib/Astguiclient/DBI.pm deleted file mode 100644 index 1cbc29d3..00000000 --- a/agc_2-X/branches/agc_30/lib/Astguiclient/DBI.pm +++ /dev/null @@ -1,48 +0,0 @@ -package Astguiclient::DBI; - -use strict; -use DBI; - -=head1 NAME - -Astguiclient::DBI - The database. - -=head1 DESCRIPTION - -=head2 connect - -=cut - -sub connect { - my($class, $c) = @_; - - my $dsn = "DBI:mysql:datbase=$c->file->{'Database'}{'DB_name'};host=$c->file->{'Database'}{'Host'};port=$c->file->{'Database'}{'Port'}"; - - return DBI->connect( $dsn, $c->file->{'Database'}{'User'}, $c->file->{'Database'}{'Password'} ); -} - -=head1 AUTHOR - -Jason Yates - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2006 Matt Florell - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -=cut - -1; diff --git a/agc_2-X/branches/agc_30/lib/Astguiclient/VDAD.pm b/agc_2-X/branches/agc_30/lib/Astguiclient/VDAD.pm index f19ecffd..04b6bf71 100644 --- a/agc_2-X/branches/agc_30/lib/Astguiclient/VDAD.pm +++ b/agc_2-X/branches/agc_30/lib/Astguiclient/VDAD.pm @@ -22,128 +22,33 @@ sub new { return bless {}, $class; } -=head2 +=head2 auto_dial =cut -sub call_log { +sub auto_dial { my $self = shift; - my $dbh = $self->dbi; + # Get a list of campaigns which have active agents. + my @campaigns = $self->campaign->find('active_agents'); - if( $self->agi->{'extension'} =~ /h/i ) { - $dbh->do("UPDATE call_log SET end_time = NOW() WHERE uniqueid = ?", undef, $unique_id); - $dbh->do("DELETE FROM live_inbound WHERE uniqueid = ? AND server_ip = ?", undef, $unique_id, $self->file->{'server_ip'}); + foreach my $campaign (@campaigns) { + # Find the number of calls to place for this campaign. + my $num_calls = $campaign->agent->idle() * $campaign->{auto_dial_level}; - #NOTE: Not sure of the logic here. - #"UPDATE park_log set status='HUNGUP',hangup_time='$now_date',parked_sec='$parked_sec',talked_sec='$talked_sec' where uniqueid='$unique_id' and server_ip='$VARserver_ip'"; - #"SELECT UNIX_TIMESTAMP(parked_time),UNIX_TIMESTAMP(grab_time) FROM park_log where uniqueid='$unique_id' and server_ip='$VARserver_ip' LIMIT 1;"; - } else { - $dbh->do("INSERT INTO call_log - (uniqueid,channel,channel_group,type,server_ip,extension, - number_dialed,start_time,end_time,caller_code) - VALUES(?,?,?,?,?,?,?,?,'',?)", - undef, - $unique_id,$channel,$channel_group,$type,$VARserver_ip, - $extension,$number_dialed,$now_date,$now_date_epoch,$callerid - ); + $self->place_calls( $campaign->{campaign_id} ); } } -=head2 vdad_transfer +=head2 place_calls -Runs when a call comes in from the VICIDIAL_auto_dialer. This script will -Send the calls out to the reps that are logged in. - -0 Channel is down and available -1 Channel is down, but reserved -2 Channel is off hook -3 Digits (or equivalent) have been dialed -4 Line is ringing -5 Remote end is ringing -6 Line is up -7 Line is busy +Place calls. =cut -#NOTE: This function isn't nearly complete. -# Is the campaign() basically a singleton? -# Where else is this log functionality? -# Is there other transfer or voicemail calls? -# Where should this campaign method be put? -# Write the campaign first.. -sub vdad_transfer { +sub place_calls { my $self = shift; - my %campaign = $self->campaign($campaign_id); - - # When a call is answered, this timer begins. - my $drop_start_timer; - - # Time for the start of the loop - my $start_time = [gettimeofday] - - # Amount of time you should wait for answer before hanging up(how many rings essentially) - my $call_wait_time = '30' - - TRANSFER: while( tv_interval( $start_time, [gettimeofday] ) > $call_wait_time ) { - my $status = $self->agi->check_status(); - - # Line is down or busy. - if( ( $status < 3 ) || - ( $status == 7 ) ) { - $self->_log_call( $status ); - last; - } elsif( $status == 6 ) { # Line is answered - $start_timer = [gettimeofday]; - } - - $self->_transfer_to_agent(); - - if( tv_interval( $start_timer, [gettimeofday] ) { - $self->_send_to_voicemail(); - last; - } - } - - $self->_log_call( $call_status ); -} - -sub _log_call { - my($self, $call_status) = @_; - - if( lc($call_status) eq 'drop' ) { - $self->dbh->do("DELETE FROM vicidial_auto_calls where callerid = ?", undef, $callerid); - } - - $self->dbh->do("UPDATE vicidial_log set status = ?,end_time = NOW() WHERE uniqueid = ?", undef, $status, $unique_id); - $self->dbh->do("UPDATE vicidial_list set status='DROP' where lead_id = '$CIDlead_id'"); - -} - -sub _send_to_voicemail { - my $self = shift; - - $self->agi->set_context( $ext_context ); - $self->agi->set_extension( $drop_exten ); -} - -sub _transfer_to_agent { - my $self = shift; - - my($conf_exten, $user, $extension) = $self->dbi->selectrow_arary(" - SELECT conf_exten,extension FROM vicidial_live_agents - WHERE status = 'QUEUE' and server_ip = ? and campaign_id = ? and callerid = ? and channel= ? - ORDER BY last_call_time limit 1", - undef, - #XXX - ); - - $self->agi->set_context( $ext_context ); - $self->agi->set_extension( $drop_exten ); - - $dbh->do("UPDATE vicidial_auto_calls set status='XFER' WHERE callerid = ?", undef, $callerid); - } =head1 AUTHOR