exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Dial(SIP/204,20,m(default)tw)
exten => s,n,Dial(SIP/trunk_name/7909xxxxxxx,40,m(default)tw)
#===============================================================================
#
# FILE: followme.pm
#
# DESCRIPTION: Модуль, который выдает текущий транк на исход, а так же выдает
# номер мобильного в follow me
#
# FILES: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: YOUR NAME (),
# ORGANIZATION:
# VERSION: 1.0
# CREATED: 04/22/2015 11:58:36 AM
# REVISION: ---
#===============================================================================
use strict;
use warnings;
use DBI;
package Followme;
our $dbh_ast =
DBI->connect( 'dbi:mysql:dbname=asterisk;host=localhost', 'dbuser', 'pass' ) or die;
sub new {
my ( $class, %self ) = @_;
bless \%self, $class;
return \%self;
}
sub get_followme {
my $self = shift;
my $ext = $self->{ext};
my $sql = 'SELECT `grplist` FROM `findmefollow` WHERE `grpnum`
LIKE ? AND `grplist` LIKE ?';
my ($followme_phone) = $dbh_ast->selectrow_array( $sql, undef, $ext, $ext . '-%' );
if ($followme_phone) {
$self->{followme_phone} = substr $followme_phone, 5, -1;
return $self->{followme_phone};
}
else {
return undef;
}
}
sub get_current_trunk {
my $self = shift;
my $sql = 'SELECT t.name, t.dialoutprefix
FROM `outbound_route_trunks` o, `trunks` t
WHERE t.disabled LIKE "off"
AND o.trunk_id = t.trunkid
ORDER BY o.seq ASC
LIMIT 0 , 1';
my ( $trunk_name, $dialoutprefix ) = $dbh_ast->selectrow_array($sql);
$self->{dialoutprefix} = $dialoutprefix;
return $trunk_name.'/'.$dialoutprefix.$self->{followme_phone};
}
1;
use Followme;
my $f = Followme->new( ext => "100" );
if ( $f->get_followme() ) {
my $followme = $f->get_current_trunk();
$AGI->exec( 'Dial', 'SIP/' . $followme . ',40,m(default)tw' );
}