Also fixed some issues with db orm. git-svn-id: svn://192.168.202.10@301 3d104415-ff17-0410-8863-d5cf3c621b8a
174 lines
4.5 KiB
Perl
174 lines
4.5 KiB
Perl
package Astguiclient::VDAD;
|
|
|
|
use strict;
|
|
use base qw/Astguiclient Class::Accessor::Fast/;
|
|
|
|
__PACKAGE__->mk_accessor(qw//);
|
|
|
|
=head1 NAME
|
|
|
|
Astguiclient::VDAD - .
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
Give description here
|
|
|
|
=head2 new
|
|
|
|
=cut
|
|
|
|
sub new {
|
|
my $class = shift;
|
|
return bless {}, $class;
|
|
}
|
|
|
|
=head2
|
|
|
|
=cut
|
|
|
|
sub call_log {
|
|
my $self = shift;
|
|
|
|
my $dbh = $self->dbi;
|
|
|
|
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'});
|
|
|
|
#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
|
|
);
|
|
}
|
|
}
|
|
|
|
=head2 vdad_transfer
|
|
|
|
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
|
|
|
|
=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 {
|
|
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
|
|
|
|
Jason Yates <jaywhy@gmail.com>
|
|
|
|
=head1 COPYRIGHT AND LICENSE
|
|
|
|
Copyright (C) 2006 Matt Florell <vicidial@gmail.com>
|
|
|
|
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;
|