Thread: [Astpp-commit] SF.net SVN: astpp: [2127] trunk
Brought to you by:
darrenkw
From: <dar...@us...> - 2007-09-19 01:37:31
|
Revision: 2127 http://astpp.svn.sourceforge.net/astpp/?rev=2127&view=rev Author: darrenkw Date: 2007-09-18 18:37:31 -0700 (Tue, 18 Sep 2007) Log Message: ----------- 1. Removed the old "enh-config" support as this is no longer needed. 2. Added support to refill regular accounts with a calling card. Modified Paths: -------------- trunk/Makefile trunk/astpp-admin.cgi trunk/astpp-ani-map.agi trunk/astpp-authorize.agi trunk/astpp-auto-admin.cgi trunk/astpp-callback-register.agi trunk/astpp-callback.agi trunk/astpp-callback.cgi trunk/astpp-callingcards-daily.pl trunk/astpp-callingcards.agi trunk/astpp-common.pl trunk/astpp-device-monitor.pl trunk/astpp-did-map.agi trunk/astpp-email-incoming.pl trunk/astpp-generate-invoices.pl trunk/astpp-ip-map.agi trunk/astpp-lcr.agi trunk/astpp-low-balance.pl trunk/astpp-manager-variables.agi trunk/astpp-pricelist.cgi trunk/astpp-rate-engine.pl trunk/astpp-refill.agi trunk/astpp-refill.cgi trunk/astpp-update-balance.pl trunk/astpp-users.cgi Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/Makefile 2007-09-19 01:37:31 UTC (rev 2127) @@ -42,9 +42,9 @@ install -m 644 -o $(OWNER) -g $(GROUP) style.css $(DESTDIR)$(WWWDIR)/html/_astpp/ install -m 644 -o $(OWNER) -g $(GROUP) menu.js $(DESTDIR)$(WWWDIR)/html/_astpp/ # Install Sample Configuration Files - install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.reseller-config.conf $(DESTDIR)$(ASTPPDIR)/sample.reseller-config.conf +# install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.reseller-config.conf $(DESTDIR)$(ASTPPDIR)/sample.reseller-config.conf install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-config.conf $(DESTDIR)$(ASTPPDIR)/sample.astpp-config.conf - install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-enh-config.conf $(DESTDIR)$(ASTPPDIR)/sample.astpp-enh-config.conf +# install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-enh-config.conf $(DESTDIR)$(ASTPPDIR)/sample.astpp-enh-config.conf install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-dialplan.conf $(DESTDIR)$(ASTERISKDIR)/sample.astpp-dialplan.conf install_samples: Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/astpp-admin.cgi 2007-09-19 01:37:31 UTC (rev 2127) @@ -58,7 +58,7 @@ print STDERR "Interface language is set to: " . $ENV{LANGUAGE} . "\n"; bindtextdomain( "astpp", "/usr/local/share/locale" ); textdomain("astpp"); -use vars qw(@output $astpp_db $params $enh_config +use vars qw(@output $astpp_db $params $config $status $config $limit $accountinfo $freepbx_db $rt_db $openser_db); my $starttime = [gettimeofday]; @@ -142,7 +142,7 @@ my @timezones = DateTime::TimeZone->all_names; @timezones = sort(@timezones); my ( - $rt_db, $astpp_db, $config, $enh_config, $params, + $rt_db, $astpp_db, $config, $config, $params, $param, $cdr_db, $agile_db, $body, $menu, $status, $msg, $loginstat, @modes, $openser_db ); @@ -185,7 +185,7 @@ $accountinfo = &get_account( $astpp_db, $params->{username} ); $params->{logintype} = $accountinfo->{type}; } - if ( !$params->{username} && $enh_config->{auth} eq $params->{password} ) { + if ( !$params->{username} && $config->{auth} eq $params->{password} ) { $status .= gettext("Successful Login!") . "<br>"; $count = 1; print header( -cookie => [ $cookie, $cookie1 ] ); @@ -205,7 +205,7 @@ if $config->{debug} == 1; print STDERR gettext("ASTPP-PASS:") . " $params->{password}\n" if $config->{debug} == 1; - print STDERR gettext("ASTPP-AUTHCODE:") . " $enh_config->{auth}\n" + print STDERR gettext("ASTPP-AUTHCODE:") . " $config->{auth}\n" if $config->{debug} == 1; print STDERR gettext("ASTPP-USER-COUNT:") . " $count" if $config->{debug} == 1; @@ -239,7 +239,7 @@ $params->{logintype} = $accountinfo->{type}; } } - if ( !$params->{username} && $enh_config->{auth} eq $params->{password} ) { + if ( !$params->{username} && $config->{auth} eq $params->{password} ) { $count = 1; $params->{logintype} = 2; } @@ -257,7 +257,7 @@ if $config->{debug} == 1 && $params->{username}; print STDERR gettext("ASTPP-PASS:") . " $params->{password}\n" if $config->{debug} == 1 && $params->{password}; - print STDERR gettext("ASTPP-AUTHCODE:") . " $enh_config->{auth}\n" + print STDERR gettext("ASTPP-AUTHCODE:") . " $config->{auth}\n" if $config->{debug} == 1; print STDERR gettext("ASTPP-USER-COUNT:") . " $count" if $config->{debug} == 1; @@ -651,7 +651,7 @@ sub build_reporting() { my ($body); return gettext("ASTPP Database Not Available!") . "<br>" unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + $cdr_db = &cdr_connect_db( $config, @output ); return gettext("Asterisk CDR Database Not Available!") . "<br>" unless $cdr_db; @@ -699,7 +699,7 @@ my ( $body, $id ); return gettext("Cannot display stats until database is configured") unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + $cdr_db = &cdr_connect_db( $config, @output ); return gettext("Cannot display stats until database is configured") unless $cdr_db; my ( undef, undef, undef, $day, $mnth, $yr ) = localtime(); @@ -919,11 +919,11 @@ ); return gettext("Cannot display stats until database is configured") unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + $cdr_db = &cdr_connect_db( $config, @output ); return gettext("Cannot display stats until database is configured") unless $cdr_db; if ( $params->{limit} < 1 || !$params->{limit} ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } my ( undef, undef, undef, $day, $mnth, $yr ) = localtime(); @@ -1341,7 +1341,7 @@ return gettext("Cannot view account until pricelists configured") unless @pricelists; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - $results_per_page = $enh_config->{results_per_page}; + $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( $params->{logintype} == 1 || $params->{logintype} == 5 @@ -1451,7 +1451,7 @@ $number = $params->{numberlist}; } $status .= - &remove_did( $astpp_db, $config, $enh_config, $params->{DID}, + &remove_did( $astpp_db, $config, $params->{DID}, $number ); $params->{action} = gettext("Information..."); } @@ -1463,7 +1463,7 @@ $number = $params->{numberlist}; } $status .= - &purchase_did( $astpp_db, $config, $enh_config, $params->{did_list}, + &purchase_did( $astpp_db, $config, $params->{did_list}, $number ); $params->{action} = gettext("Information..."); } @@ -2181,14 +2181,14 @@ } sub generatecallingcards() { - my ( $params, $config, $enh_config ) = @_; + my ( $params, $config ) = @_; my ( $status, $description, $pricelistdata, $number, $count ); $status = ""; $description = gettext("Account Setup"); $count = 0; if ( $config->{email} eq "YES" ) { - open( EMAIL, "| $enh_config->{mailprog} -t" ) - || die "Error - could not write to $enh_config->{mailprog}\n"; + open( EMAIL, "| $config->{mailprog} -t" ) + || die "Error - could not write to $config->{mailprog}\n"; print EMAIL"From: $config->{company_email}\n"; print EMAIL "Subject: $config->{company_name} New Account Created\n"; print EMAIL"To: $config->{emailadd}\n"; @@ -2200,7 +2200,7 @@ print STDERR "BRAND: $params->{brand}\n" if $config->{debug} == 1; while ( $count < $params->{count} ) { my ( $number, $pin ) = - &add_callingcard( $astpp_db, $config, $enh_config, $brandinfo, + &add_callingcard( $astpp_db, $config, $config, $brandinfo, $params->{status}, $params->{value} * 100, $params->{account}, $brandinfo->{pin} ); $count++; @@ -2218,26 +2218,26 @@ } sub generate_accounts() { - my ( $params, $config, $enh_config ) = @_; + my ( $params, $config ) = @_; my ( $status, $description, $pricelistdata, $cardlist ); $description = gettext("Account Setup"); $cardlist = &get_account_including_closed( $astpp_db, $params->{number} ); if ( !$cardlist->{number} ) { - &addaccount( $astpp_db, $config, $enh_config, $params ); + &addaccount( $astpp_db, $config, $params ); if ( $params->{accounttype} == 1 ) { &add_pricelist( $astpp_db, $params->{number}, 6, 0, $params->{number} ); - &add_reseller( $astpp_db, $config, $enh_config, $params->{number}, + &add_reseller( $astpp_db, $config, $params->{number}, $params->{posttoexternal} ); } if ( $params->{accounttype} == 5 ) { &add_pricelist( $astpp_db, $params->{number}, 6, 0, $params->{number} ); - &add_reseller( $astpp_db, $config, $enh_config, $params->{number}, + &add_reseller( $astpp_db, $config, $params->{number}, $params->{posttoexternal} ); } if ( $config->{email} == 1 && $params->{accounttype} == 0 ) { - &email_add_user( $astpp_db, '', $config, $params, $enh_config ); + &email_add_user( $astpp_db, '', $config, $params ); } my $timestamp = &prettytimestamp; $astpp_db->do( @@ -2283,7 +2283,7 @@ } if ( $config->{email} == 1 ) { &email_reactivate_account( $astpp_db, '', $config, $params, - $enh_config ); + ); } } else { @@ -2319,30 +2319,30 @@ $params->{count} = 1; $params->{pennies} = 0; $params->{number} = $params->{customnum}; - $status .= &generate_accounts( $params, $config, $enh_config ); + $status .= &generate_accounts( $params, $config ); my $accountinfo = &get_account( $astpp_db, $params->{number} ); ### Here we add support to add IAX and SIP devices at account creation. if ( $params->{SIP} ) { - $enh_config->{rt_sip_type} = $params->{devicetype}; + $config->{rt_sip_type} = $params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $name = &finduniquesip_rt( $params->{number} ); $status .= &add_sip_user_rt( $rt_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} ); $status .= "<br>"; } - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { my $name = - &finduniquesip_freepbx( $freepbx_db, $config, $enh_config, + &finduniquesip_freepbx( $freepbx_db, $config, $params->{number} ); $status .= &add_sip_user_freepbx( $freepbx_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} @@ -2352,7 +2352,7 @@ if ( $config->{openser} == 1 ) { $status .= $status .= &add_sip_user_openser( $openser_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params ); @@ -2360,26 +2360,26 @@ } } if ( $params->{IAX2} ) { - $enh_config->{rt_iax_type} = $params->{devicetype}; + $config->{rt_iax_type} = $params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { my $name = - &finduniqueiax_freepbx( $freepbx_db, $config, $enh_config, + &finduniqueiax_freepbx( $freepbx_db, $config, $params->{number} ); $status .= &add_iax_user_freepbx( $freepbx_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} ); $status .= "<br>"; } - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $name = &finduniqueiax_rt( $params->{number} ); $status .= &add_iax_user_rt( $rt_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} @@ -2455,7 +2455,7 @@ return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0; } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); } @@ -2953,7 +2953,7 @@ elsif ( $params->{status} eq gettext("DELETED") ) { $params->{status} = 2; } - $status .= &generatecallingcards( $params, $config, $enh_config ); + $status .= &generatecallingcards( $params, $config ); } $body = start_multipart_form; $body .= "<table class=\"default\">"; @@ -3289,7 +3289,7 @@ my $inactive = gettext("INACTIVE"); my $deleted = gettext("DELETED"); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; - $results_per_page = $enh_config->{results_per_page}; + $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } $body = "<table class=\"default\"><tr class=\"header\"><td>"; $body .= @@ -3879,11 +3879,11 @@ sub build_list_errors() { my ( $results, $body, $status, $count, $pageno, $pagesrequired ); $count = 0; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + $cdr_db = &cdr_connect_db( $config, @output ); return gettext("Cannot list errors until database is configured!") . "\n" unless $cdr_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } my $sql = $cdr_db->prepare( "SELECT * FROM cdr WHERE cost = 'error' OR " @@ -4698,7 +4698,7 @@ return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { @@ -5629,7 +5629,7 @@ my ( $sql, $record, $valid, $count, $tmp, $pagesrequired, $pageno ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -6018,7 +6018,7 @@ @providerlist ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -6838,7 +6838,7 @@ @providerlist ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -7486,7 +7486,7 @@ } return gettext("Pricelists Do NOT Exist!") . "\n" unless @pricelists; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { @@ -7987,7 +7987,7 @@ my $template = HTML::Template->new( filename => '/var/lib/astpp/templates/counters-list.tpl' ); - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" || $results_per_page < 2 ) { $results_per_page = 25; } @@ -8085,7 +8085,7 @@ my ( $sql, $record, $count, $tmp, $pageno, $pagesrequired ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -8377,7 +8377,7 @@ my @providerlist = &list_providers($astpp_db); return gettext("No Providers Exist!") . "\n" unless @providerlist; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { @@ -8733,7 +8733,7 @@ $count++; $body .= "<td>$trunkinfo->{name}" . "</td><td>$trunkinfo->{tech}"; if ( $trunkinfo->{tech} eq "SIP" - && $enh_config->{users_dids_rt} == 1 ) + && $config->{users_dids_rt} == 1 ) { $body .= "</td><td><a href=\"astpp-admin.cgi?mode=" @@ -8817,7 +8817,7 @@ my ( $sql, $record, $count, $tmp, $pageno, $pagesrequired ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -8830,7 +8830,7 @@ $params->{count} = 1; $params->{pennies} = 0; $params->{number} = $params->{customnum}; - $status .= &generate_accounts( $params, $config, $enh_config ); + $status .= &generate_accounts( $params, $config ); $params->{action} = gettext("Information..."); } if ( $params->{action} eq gettext("Information...") ) { @@ -8944,7 +8944,7 @@ @trunklist ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -9597,24 +9597,20 @@ sub initialize() { $config = &load_config(); $status .= gettext("Main Configuration Unavailable!") unless $config; - $enh_config = &load_config_enh(); - $status .= gettext("Enhanced Configuration Unavailable!") - unless $enh_config; - $astpp_db = &connect_db( $config, $enh_config, @output ); + $astpp_db = &connect_db( $config, @output ); $status .= gettext("ASTPP Database Unavailable!") unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); - $status .= gettext("Asterisk CDR Database Unavailable!") unless $cdr_db; $config = &load_config_db( $astpp_db, $config ) if $astpp_db; - $enh_config = &load_config_enh_db( $astpp_db, $enh_config ); + $cdr_db = &cdr_connect_db( $config, @output ); + $status .= gettext("Asterisk CDR Database Unavailable!") unless $cdr_db; if ( $config->{enablelcr} == 1 ) { push @modes, gettext("LCR"); } - if ( $enh_config->{users_dids_rt} == 1 ) { - $rt_db = &rt_connect_db( $config, $enh_config, @output ); + if ( $config->{users_dids_rt} == 1 ) { + $rt_db = &rt_connect_db( $config, @output ); push @modes, gettext("Switch Config"); } - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @modes = sort @modes; @@ -9630,7 +9626,7 @@ my ( $deviceinfo, $sql ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); } @@ -9642,17 +9638,17 @@ $number = param('numberlist'); } my $name = &finduniquesip_rt($number); - $enh_config->{rt_sip_type} = $params->{devicetype}; + $config->{rt_sip_type} = $params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { $status .= - &add_sip_user_rt( $rt_db, $config, $enh_config, $name, + &add_sip_user_rt( $rt_db, $config, $name, $params->{secret}, $params->{context}, $number, $params ); $status .= "<br>"; } if ( $config->{openser} == 1 ) { $status .= - &add_sip_user_openser( $openser_db, $config, $enh_config, $name, + &add_sip_user_openser( $openser_db, $config, $name, $params->{secret}, $params->{context}, $number, $params ); $status .= "<br>"; } @@ -9661,7 +9657,7 @@ elsif ( $params->{action} eq gettext("Delete...") ) { if ( &del_sip_user_rt( - $rt_db, $config, $enh_config, $params->{devicename} + $rt_db, $config, $params->{devicename} ) ) { @@ -9678,7 +9674,7 @@ } elsif ( $params->{action} eq gettext("Save...") ) { my $tmp = - "UPDATE $enh_config->{rt_sip_table} SET" + "UPDATE $config->{rt_sip_table} SET" . " callerid=" . $rt_db->quote( $params->{clid} ) . ", " . " accountcode=" @@ -9703,7 +9699,7 @@ . " secret=" . $rt_db->quote( $params->{secret} ) . ", " . " type=" - . $rt_db->quote( $enh_config->{rt_sip_type} ) . ", " + . $rt_db->quote( $config->{rt_sip_type} ) . ", " . " name=" . $rt_db->quote( $params->{name} ) . ", " . " username=" @@ -9763,7 +9759,7 @@ . popup_menu( -name => "devicetype", -values => \@devicetypes, - -default => $enh_config->{rt_sip_type} + -default => $config->{rt_sip_type} ) . "</td><td>" . textfield( @@ -9782,7 +9778,7 @@ my @accountlist = &list_accounts($astpp_db); $sql = $rt_db->prepare( - "SELECT * FROM $enh_config->{rt_sip_table} WHERE name = " + "SELECT * FROM $config->{rt_sip_table} WHERE name = " . $rt_db->quote( $params->{devicename} ) ); $sql->execute || return gettext("Something is wrong with the SIP users database!") @@ -9982,7 +9978,7 @@ . gettext("Action") . "</td></tr> "; - my $tmp = "SELECT name FROM " . $enh_config->{rt_sip_table}; + my $tmp = "SELECT name FROM " . $config->{rt_sip_table}; $sql = $rt_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the SIP users database!") @@ -9994,7 +9990,7 @@ $sql->finish; $sql = $rt_db->prepare( -"SELECT * FROM $enh_config->{rt_sip_table} ORDER BY accountcode limit $params->{limit} , $results_per_page" +"SELECT * FROM $config->{rt_sip_table} ORDER BY accountcode limit $params->{limit} , $results_per_page" ); $sql->execute || return gettext("Something is wrong with the SIP users database!") @@ -10095,7 +10091,7 @@ print STDERR "SIPID: $sipid\n" if $config->{debug} == 1; $sql = $rt_db->prepare( - "SELECT COUNT(*) FROM $enh_config->{rt_sip_table} WHERE name = " + "SELECT COUNT(*) FROM $config->{rt_sip_table} WHERE name = " . $rt_db->quote($sipid) ); $sql->execute; $record = $sql->fetchrow_hashref; @@ -10113,7 +10109,7 @@ my ( $deviceinfo, $sql ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); } @@ -10125,17 +10121,17 @@ $number = param('numberlist'); } my $name = &finduniqueiax_rt($number); - $enh_config->{rt_iax_type} = $params->{devicetype}; + $config->{rt_iax_type} = $params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; $status .= - &add_iax_user_rt( $rt_db, $config, $enh_config, $name, + &add_iax_user_rt( $rt_db, $config, $name, $params->{secret}, $params->{context}, $number, $params ); $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Delete...") ) { if ( &del_sip_user_rt( - $rt_db, $config, $enh_config, $params->{devicename} + $rt_db, $config, $params->{devicename} ) ) { @@ -10149,7 +10145,7 @@ } elsif ( $params->{action} eq gettext("Save...") ) { my $tmp = - "UPDATE $enh_config->{rt_iax_table} SET" + "UPDATE $config->{rt_iax_table} SET" . " callerid=" . $rt_db->quote( $params->{clid} ) . ", " . " accountcode=" @@ -10228,7 +10224,7 @@ . popup_menu( -name => "devicetype", -values => \@devicetypes, - -default => $enh_config->{rt_iax_type} + -default => $config->{rt_iax_type} ) . "</td><td>" . textfield( @@ -10247,7 +10243,7 @@ my @accountlist = &list_accounts($astpp_db); $sql = $rt_db->prepare( - "SELECT * FROM $enh_config->{rt_iax_table} WHERE name = " + "SELECT * FROM $config->{rt_iax_table} WHERE name = " . $rt_db->quote( $params->{devicename} ) ); $sql->execute || return gettext("Something is wrong with the IAX users database!") @@ -10413,7 +10409,7 @@ . gettext("Action") . "</td></tr> "; - my $tmp = "SELECT name FROM " . $enh_config->{rt_iax_table}; + my $tmp = "SELECT name FROM " . $config->{rt_iax_table}; $sql = $rt_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the IAX users database!") @@ -10425,7 +10421,7 @@ $sql->finish; $sql = $rt_db->prepare( -"SELECT * FROM $enh_config->{rt_iax_table} ORDER BY accountcode limit $params->{limit} , $results_per_page" +"SELECT * FROM $config->{rt_iax_table} ORDER BY accountcode limit $params->{limit} , $results_per_page" ); $sql->execute || return gettext("Something is wrong with the IAX users database!") @@ -10523,7 +10519,7 @@ print STDERR "IAXID: $iaxid\n" if $config->{debug} == 1; $sql = $rt_db->prepare( - "SELECT COUNT(*) FROM $enh_config->{rt_iax_table} WHERE name = " + "SELECT COUNT(*) FROM $config->{rt_iax_table} WHERE name = " . $rt_db->quote($iaxid) ); $sql->execute; $record = $sql->fetchrow_hashref; @@ -10541,13 +10537,13 @@ ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - $results_per_page = $enh_config->{results_per_page}; + $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); } if ( $params->{action} eq gettext("Insert...") ) { my $tmp = - "INSERT INTO $enh_config->{rt_extensions_table} (context," + "INSERT INTO $config->{rt_extensions_table} (context," . "exten,priority,app,appdata) VALUES (" . $rt_db->quote( $params->{context} ) . ", " . $rt_db->quote( $params->{exten} ) . ", " @@ -10568,7 +10564,7 @@ } elsif ( $params->{action} eq gettext("Delete...") ) { my $tmp = - "DELETE FROM $enh_config->{rt_extensions_table} WHERE " . "id = " + "DELETE FROM $config->{rt_extensions_table} WHERE " . "id = " . $rt_db->quote( $params->{id} ); if ( $rt_db->do($tmp) ) { $status .= @@ -10581,7 +10577,7 @@ } elsif ( $params->{action} eq gettext("Save...") ) { my $tmp = - "UPDATE $enh_config->{rt_extensions_table} SET" + "UPDATE $config->{rt_extensions_table} SET" . " context=" . $rt_db->quote( $params->{context} ) . ", " . " exten=" @@ -10657,7 +10653,7 @@ elsif ( $params->{action} eq gettext("Edit...") ) { $sql = $rt_db->prepare( - "SELECT * FROM $enh_config->{rt_extensions_table} WHERE id = " + "SELECT * FROM $config->{rt_extensions_table} WHERE id = " . $rt_db->quote( $params->{id} ) ); $sql->execute || return gettext("Something is wrong with the dialplan database!") @@ -10749,7 +10745,7 @@ . gettext("Action") . "</td></tr> "; - my $tmp = "SELECT id FROM " . $enh_config->{rt_extensions_table}; + my $tmp = "SELECT id FROM " . $config->{rt_extensions_table}; $sql = $rt_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the SIP users database!") @@ -10761,7 +10757,7 @@ $sql->finish; $sql = $rt_db->prepare( -"SELECT * FROM $enh_config->{rt_extensions_table} ORDER BY context, exten, priority " +"SELECT * FROM $config->{rt_extensions_table} ORDER BY context, exten, priority " . "limit $params->{limit} , $results_per_page" ); $sql->execute || return gettext("Something is wrong with the dialplan database!") @@ -10852,7 +10848,7 @@ } $params->{accounttype} = 5; $params->{number} = $params->{callshop_name}; - $status .= &generate_accounts( $params, $config, $enh_config ); + $status .= &generate_accounts( $params, $config ); my $callshop_data = $astpp_db->do( "SELECT * FROM callshops WHERE name = " . $astpp_db->quote( $params->{callshop_name} ) ); @@ -10983,33 +10979,33 @@ $status .= gettext("No Reseller Name Set! Error!"); } elsif ( $params->{action} eq gettext("Generate Booth") ) { - $status .= &generate_accounts( $params, $config, $enh_config ); + $status .= &generate_accounts( $params, $config ); my $accountinfo = &get_account( $astpp_db, $params->{number} ); $astpp_db->do( "UPDATE cdrs SET status = 1 WHERE cardnum = " . $astpp_db->quote( $params->{number} ) . " LIMIT 1" ); if ( $params->{SIP} ) { print STDERR gettext("Adding SIP Device!") if $config->{debug} == 1; - $enh_config->{rt_sip_type} = "friend"; #$params->{devicetype}; + $config->{rt_sip_type} = "friend"; #$params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $name = &finduniquesip_rt( $params->{number} ); $status .= &add_sip_user_rt( $rt_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} ); $status .= "<br>"; } - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { my $name = - &finduniquesip_freepbx( $freepbx_db, $config, $enh_config, + &finduniquesip_freepbx( $freepbx_db, $config, $params->{number} ); &add_sip_user_freepbx( $freepbx_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} @@ -11019,7 +11015,7 @@ if ( $config->{openser} == 1 ) { $status .= &add_sip_user_openser( $openser_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params ); @@ -11029,26 +11025,26 @@ if ( $params->{IAX2} ) { print STDERR gettext("Adding IAX2 Device!") if $config->{debug} == 1; - $enh_config->{rt_iax_type} = "friend"; #$params->{devicetype}; + $config->{rt_iax_type} = "friend"; #$params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { my $name = - &finduniqueiax_freepbx( $freepbx_db, $config, $enh_config, + &finduniqueiax_freepbx( $freepbx_db, $config, $config, $params->{number} ); $status .= &add_iax_user_freepbx( $freepbx_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} ); $status .= "<br>"; } - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $name = &finduniqueiax_rt( $params->{number} ); $status .= &add_iax_user_rt( $rt_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} @@ -11166,49 +11162,49 @@ #If this account doesn't exist we don't go through the rest if ( $accountinfo->{number} ) { - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { print STDERR "NUMBER: $accountinfo->{number} CC: $accountinfo->{cc}" if $config->{debug} == 1; my @iax_devicelist = - &list_iax_account_rt( $rt_db, $config, $enh_config, + &list_iax_account_rt( $rt_db, $config, $accountinfo->{number}, $accountinfo->{cc} ); foreach my $name (@iax_devicelist) { - &del_iax_user_rt( $rt_db, $config, $enh_config, $name ); + &del_iax_user_rt( $rt_db, $config, $name ); $status .= gettext("Removing IAX device:") . " " . $name . "<br>"; } my @sip_devicelist = - &list_sip_account_rt( $rt_db, $config, $enh_config, + &list_sip_account_rt( $rt_db, $config, $accountinfo->{number}, $accountinfo->{cc} ); foreach my $name (@sip_devicelist) { - &del_sip_user_rt( $rt_db, $config, $enh_config, $name ); + &del_sip_user_rt( $rt_db, $config, $name ); $status .= gettext("Removing SIP device:") . " " . $name . "<br>"; } } - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { print STDERR "NUMBER: $accountinfo->{number} CC: $accountinfo->{cc}" if $config->{debug} == 1; my @iax_devicelist = - &list_iax_account_amp( $freepbx_db, $config, $enh_config, + &list_iax_account_amp( $freepbx_db, $config, $accountinfo->{number}, $accountinfo->{cc} ); foreach my $name (@iax_devicelist) { - &del_iax_user_rt( $freepbx_db, $config, $enh_config, + &del_iax_user_rt( $freepbx_db, $config, $name ); $status .= gettext("Removing IAX device:") . " " . $name . "<br>"; } my @sip_devicelist = - &list_sip_account_amp( $freepbx_db, $config, $enh_config, + &list_sip_account_amp( $freepbx_db, $config, $accountinfo->{number}, $accountinfo->{cc} ); foreach my $name (@sip_devicelist) { - &del_sip_user_rt( $freepbx_db, $config, $enh_config, + &del_sip_user_rt( $freepbx_db, $config, $name ); $status .= gettext("Removing SIP device:") . " " . $name . "<br>"; @@ -11259,10 +11255,10 @@ $row{call_count} = $record->{"COUNT(*)"}; $row{currency} = $boothinfo->{currency}; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $tmp = "SELECT name FROM " - . $enh_config->{rt_sip_table} + . $config->{rt_sip_table} . " WHERE accountcode = " . $rt_db->quote( $boothinfo->{cc} ) . " LIMIT 1"; @@ -11273,7 +11269,7 @@ $sql->finish; $tmp = "SELECT name FROM " - . $enh_config->{rt_iax_table} + . $config->{rt_iax_table} . " WHERE accountcode = " . $rt_db->quote( $boothinfo->{cc} ) . " LIMIT 1"; @@ -11408,19 +11404,19 @@ my $accountinfo = &get_account( $astpp_db, $params->{booth_name} ); my ( $invoiceno, $callshop_data ); $callshop_data = &get_callshop( $astpp_db, $accountinfo->{reseller} ); - $enh_config->{osc_db} = $callshop_data->{osc_dbname}; - $enh_config->{osc_user} = $callshop_data->{osc_dbuser}; - $enh_config->{osc_host} = $callshop_data->{osc_dbhost}; - $enh_config->{osc_pass} = $callshop_data->{osc_dbpass}; + $config->{osc_db} = $callshop_data->{osc_dbname}; + $config->{osc_user} = $callshop_data->{osc_dbuser}; + $config->{osc_host} = $callshop_data->{osc_dbhost}; + $config->{osc_pass} = $callshop_data->{osc_dbpass}; $params->{action} = gettext("View Booths"); - if ( $enh_config->{externalbill} eq "oscommerce" ) { + if ( $config->{externalbill} eq "oscommerce" ) { if ( $accountinfo->{posttoexternal} == 1 ) { print STDERR gettext("Connecting to OSCommerce."); - my $osc_db = &osc_connect_db( $config, $enh_config ); + my $osc_db = &osc_connect_db( $config ); print STDERR gettext("Generating Invoice"); $invoiceno = - &osc_charges( $astpp_db, $osc_db, $config, $enh_config, + &osc_charges( $astpp_db, $osc_db, $config, $params->{booth_name} ); } } @@ -11454,10 +11450,10 @@ } if ( $params->{action} eq gettext("View Booth") ) { my $accountinfo = &get_account( $astpp_db, $params->{booth_name} ); - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $tmp = "SELECT name,secret FROM " - . $enh_config->{rt_sip_table} + . $config->{rt_sip_table} . " WHERE accountcode = " . $rt_db->quote( $accountinfo->{cc} ) . " LIMIT 1"; @@ -11468,7 +11464,7 @@ $sql->finish; $tmp = "SELECT name,secret FROM " - . $enh_config->{rt_iax_table} + . $config->{rt_iax_table} . " WHERE accountcode = " . $rt_db->quote( $accountinfo->{cc} ) . " LIMIT 1"; @@ -11480,7 +11476,7 @@ } my @chargelist = &list_cdrs_account( $cdr_db, $accountinfo->{number}, $accountinfo->{cc} ); - &processlist( $astpp_db, $cdr_db, $enh_config, $config, @chargelist ) + &processlist( $astpp_db, $cdr_db, $config, @chargelist ) ; # Bill as many calls as we can. $status .= gettext("We rated as many CDRS as we could") . "<br>"; $tmp = @@ -11581,13 +11577,10 @@ # reload databases other than the astpp one. $config = &load_config_reseller_db( $astpp_db, $config, $params->{username} ); - $enh_config = - &load_config_reseller_db( $astpp_db, $enh_config, - $params->{username} ); - $freepbx_db = &freepbx_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_amp} == 1; - $rt_db = &rt_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_rt} == 1; + $freepbx_db = &freepbx_connect_db( $config, @output ) + if $config->{users_dids_amp} == 1; + $rt_db = &rt_connect_db( $config, @output ) + if $config->{users_dids_rt} == 1; print STDERR "ASTPP RESELLER LOGIN\n" if $config->{debug} == 1; @modes = ( gettext("Accounts"), gettext("Rates"), @@ -11605,7 +11598,7 @@ ); my @DIDs = ( gettext("Manage DIDs") ); - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @modes = sort @modes; @@ -11625,10 +11618,10 @@ if ( $config->{enablelcr} == 1 ) { push @modes, gettext("LCR"); } - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { push @modes, gettext("Switch Config"); } - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @@ -11660,7 +11653,7 @@ gettext("Accounts"), gettext("DIDs"), gettext("Statistics"), gettext("Home") ); - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @modes = sort @modes; @@ -11676,21 +11669,18 @@ elsif ( $params->{logintype} == 5 ) { # CallShop Login $config = &load_config_reseller_db( $astpp_db, $config, $params->{username} ); - $enh_config = - &load_config_reseller_db( $astpp_db, $enh_config, - $params->{username} ); - $freepbx_db = &freepbx_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_amp} == 1; - $rt_db = &rt_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_rt} == 1; - $osc_db = &osc_connect_db( $config, $enh_config, @output ) - if $enh_config->{externalbill} eq "oscommerce"; + $freepbx_db = &freepbx_connect_db( $config, @output ) + if $config->{users_dids_amp} == 1; + $rt_db = &rt_connect_db( $config, @output ) + if $config->{users_dids_rt} == 1; + $osc_db = &osc_connect_db( $config, $config, @output ) + if $config->{externalbill} eq "oscommerce"; print STDERR "ASTPP CALLSHOP LOGIN\n" if $config->{debug} == 1; @modes = ( gettext("Booths"), gettext("Home"), gettext("Routes"), gettext("Pricelists") ); - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @modes = sort @modes; @@ -11710,7 +11700,7 @@ $body = &build_body( $params->{mode} ); $menu = &build_menu_ts( @modes, $params->{mode} ); $menu .= start_form; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { $status .= gettext("Realtime Database Unavailable!") unless $rt_db; } } Modified: trunk/astpp-ani-map.agi =================================================================== --- trunk/astpp-ani-map.agi 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/astpp-ani-map.agi 2007-09-19 01:37:31 UTC (rev 2127) @@ -19,7 +19,7 @@ use POSIX qw(ceil floor); use POSIX qw(strftime); use strict; -use vars qw(@output $verbose $SIG $astpp_db $config $enh_config $AGI); +use vars qw(@output $verbose $SIG $astpp_db $config $AGI); @output = ( "STDERR", "LOGFILE" ); $verbose = 2; require "/usr/local/astpp/astpp-common.pl"; @@ -28,10 +28,8 @@ sub initialize() { $SIG{HUP} = 'ignore_hup'; $config = &load_config(); - $enh_config = &load_config_enh(); - $astpp_db = &connect_db( $config, $enh_config, @output ); + $astpp_db = &connect_db( $config, @output ); $config = &load_config_db($astpp_db,$config); - $enh_config = &load_config_enh_db($astpp_db,$enh_config); } sub ignore_hup { Modified: trunk/astpp-authorize.agi =================================================================== --- trunk/astpp-authorize.agi 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/astpp-authorize.agi 2007-09-19 01:37:31 UTC (rev 2127) @@ -79,7 +79,7 @@ use DBI; use Asterisk::AGI; use strict; -use vars qw(@output $config $enh_config $astpp_db $verbosity $AGI); +use vars qw(@output $config $astpp_db $verbosity $AGI); use Locale::gettext_pp qw(:locale_h); require "/usr/local/astpp/astpp-common.pl"; $ENV{LANGUAGE} = "en"; # de, es, br - whatever @@ -96,10 +96,8 @@ $AGI->set_variable( 'ASTPP', '1' ); $AGI->verbose( "$accountcode, $phoneno", $verbosity ); $config = &load_config(); -$enh_config = &load_config_enh(); -$astpp_db = &connect_db( $config, $enh_config, @output ); +$astpp_db = &connect_db( $config, @output ); $config = &load_config_db($astpp_db,$config); -$enh_config = &load_config_enh_db($astpp_db,$enh_config); my $carddata = &get_account( $astpp_db, $accountcode ); # Fetch all the account info from the db. if ( !$carddata->{number} ) { # Check to see if the account exists. If not then exit. @@ -124,7 +122,7 @@ } print STDERR "\nFINDING LIMIT FOR: $carddata->{number}\n" if $config->{debug} == 1; -($callstatus, $maxlength) = &max_length($astpp_db, $config, $enh_config, $carddata, $phoneno); +($callstatus, $maxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist},$carddata ); print STDERR "Minimum Charge on call = $routeinfo->{cost}" if $config->{debug} == 1; my $minimumcharge = $routeinfo->{cost}; @@ -135,7 +133,7 @@ $carddata = &get_account( $astpp_db, $carddata->{reseller} ); push @reseller_list, $carddata->{number}; print STDERR "ADDING $carddata->{number} to the list of resellers for this account\n" if $config->{debug} == 1; - my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $enh_config, $carddata, $phoneno); + my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist},$carddata ); if ($resellercallstatus != 1) { $carddata->{reseller} = ""; Modified: trunk/astpp-auto-admin.cgi =================================================================== --- trunk/astpp-auto-admin.cgi 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/astpp-auto-admin.cgi 2007-09-19 01:37:31 UTC (rev 2127) @@ -105,7 +105,7 @@ use Asterisk::Manager; use lib './lib', '../lib'; use strict; -use vars qw($enh_config $config $astpp_db $agile_db $params @output +use vars qw($config $astpp_db $agile_db $params @output $rt_db $freepbx_db $status); require "/usr/local/astpp/astpp-common.pl"; $ENV{LANGUAGE} = "en"; # de, es, br - whatever @@ -161,8 +161,8 @@ $params->{sweep} = $sweep; $params->{credit_limit} = $creditlimit; $params->{password} = $password; - &addaccount( $astpp_db, $config, $enh_config, $params ); - &email_add_user($astpp_db,'', $config, $params, $enh_config); + &addaccount( $astpp_db, $config, $params ); + &email_add_user($astpp_db,'', $config, $params); } else { $astpp_db->do( "UPDATE accounts SET status = 1 WHERE number = " @@ -171,7 +171,7 @@ . $astpp_db->quote($customnum) . " WHERE number = " . $astpp_db->quote($customnum) ); - &email_refill_account($astpp_db,'', $config, $params, $enh_config); + &email_refill_account($astpp_db,'', $config, $params); } my $timestamp = &prettytimestamp; $astpp_db->do( @@ -188,16 +188,13 @@ sub initialize() { my ($reseller) = @_; $config = &load_config; - $enh_config = &load_config_enh; - $astpp_db = &connect_db( $config, $enh_config, @output ); + $astpp_db = &connect_db( $config, @output ); $config = &load_config_db($astpp_db,$config); - $enh_config = &load_config_enh_db($astpp_db,$enh_config); $config = &load_config_reseller_db($astpp_db,$config,$params->{username}) if ($reseller); - $enh_config = $config if ($reseller); - $freepbx_db = &freepbx_connect_db($config, $enh_config, @output) - if $enh_config->{users_dids_amp} == 1; - $rt_db = &rt_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_rt} == 1; + $freepbx_db = &freepbx_connect_db($config, @output) + if $config->{users_dids_amp} == 1; + $rt_db = &rt_connect_db( $config, @output ) + if $config->{users_dids_rt} == 1; } ############## Asterisk Manager Handling ############ sub astmanager_reload() { @@ -239,7 +236,7 @@ $params->{quantity} = 1; } if ( $params->{prepend} ne "" ) { - $enh_config->{service_prepend} = $params->{prepend}; + $config->{service_prepend} = $params->{prepend}; } if ( $params->{brand} ne "" ) { $config->{default_brand} = $params->{brand}; @@ -254,7 +251,7 @@ $params->{language} = $config->{language}; } # OSCommerce specific adjustments -if ($enh_config->{externalbill} eq "oscommerce") { +if ($config->{externalbill} eq "oscommerce") { $params->{service} = $params->{invoice}; $params->{email} = $params->{emailadd}; } @@ -270,14 +267,14 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); } -if ( $enh_config->{service_prepend} eq "" ) { +if ( $config->{service_prepend} eq "" ) { my $passedlength = length( $params->{service} ); - my $requiredchars = $enh_config->{service_length} - $passedlength; - my $prepend = substr( $enh_config->{service_filler}, 0, $requiredchars ); + my $requiredchars = $config->{service_length} - $passedlength; + my $prepend = substr( $config->{service_filler}, 0, $requiredchars ); $params->{extension} = $prepend . $params->{service}; } else { - $params->{extension} = $enh_config->{service_prepend} . $params->{service}; + $params->{extension} = $config->{service_prepend} . $params->{service}; } # We use a random number 5 digis long for a password @@ -296,7 +293,7 @@ $config->{default_context} = $config_reseller->{default_context}; $config->{default_brand} = $config_reseller->{new_user_brand}; $params->{user} = $config_reseller->{account_prepend} . $params->{user}; - $enh_config->{auth} = $config_reseller->{auth}; + $config->{auth} = $config_reseller->{auth}; $config->{company_email} = $config_reseller->{company_name}; $config->{company_name} = $config_reseller->{company_name}; $config->{company_website} = $config_reseller->{company_website}; @@ -312,7 +309,7 @@ } ########## Check for the correct Auth Code########### -if ( $params->{auth} ne $enh_config->{auth} ) { +if ( $params->{auth} ne $config->{auth} ) { print STDERR gettext("INVALID AUTH KEY"); print "/n" . gettext("Received Authkey:") . "'" . $params->{auth} . "'"; exit(0); @@ -325,81 +322,82 @@ if ( $params->{function} eq "add_device" ) { while ( $count < $params->{quantity} ) { $count++; - if ($enh_config->{users_dids_rt} == 1) { - &add_sip_user_rt( $rt_db, $config, $enh_config, $params->{extension}, + if ($config->{users_dids_rt} == 1) { + &add_sip_user_rt( $rt_db, $config, $params->{extension}, $params->{secret}, $config->{default_context}, $params->{user}, $params ) if $params->{type} eq "SIP"; - &add_iax_user_rt( $rt_db, $config, $enh_config, + &add_iax_user_rt( $rt_db, $config, $params->{extension}, $params->{secret}, $config->{default_context}, $params->{user} ) if $params->{type} eq "IAX"; - } elsif ($enh_config->{users_dids_amp} == 1) { - &add_sip_user_freepbx( $freepbx_db, $config, $enh_config, $params->{extension}, + } elsif ($config->{users_dids_amp} == 1) { + &add_sip_user_freepbx( $freepbx_db, $config, $params->{extension}, $params->{secret}, $config->{default_context}, $params->{user}, $params ) if $params->{type} eq "SIP"; - &add_iax_user_freepbx($freepbx_db, $config, $enh_config, + &add_iax_user_freepbx($freepbx_db, $config, $params->{extension}, $params->{secret}, $config->{default_context}, $params->{user} ) if $params->{type} eq "IAX"; } - &email_add_user($astpp_db, '', $config, $params, $enh_config, $params->{type}, + &email_add_user($astpp_db, '', $config, $params, $params->{type}, $params->{secret}, $params->{extension} ) if $config->{user_email} == 1; } } elsif ( $params->{function} eq "unsuspend" ) { - if ($enh_config->{users_dids_rt} == 1) { - &update_context_sip_user_rt( $rt_db, $enh_config, $params->{extension}, + if ($config->{users_dids_rt} == 1) { + &update_context_sip_user_rt( $rt_db, $config, $params->{extension}, +i $config->{default_context} ) if $params->{type} eq "SIP"; - &update_context_iax_user_rt( $rt_db, $enh_config, $params->{extension}, + &update_context_iax_user_rt( $rt_db, $config, $params->{extension}, $config->{default_context} ) if $params->{type} eq "IAX"; - } elsif ($enh_config->{users_dids_amp} == 1) { - &update_context_sip_user_freepbx( $freepbx_db, $enh_config, $params->{extension}, + } elsif ($config->{users_dids_amp} == 1) { + &update_context_sip_user_freepbx( $freepbx_db, $config, $params->{extension}, $config->{default_context} ) if $params->{type} eq "SIP"; - &update_context_iax_user_freepbx( $freepbx_db, $enh_config, $params->{extension}, + &update_context_iax_user_freepbx( $freepbx_db, $config, $params->{extension}, $config->{default_context} ) if $params->{type} eq "IAX"; } } elsif ( $params->{function} eq "delete" ) { - if ($enh_config->{users_dids_rt} == 1) { - &del_sip_user_rt( $rt_db, $enh_config, $params->{extension} ) + if ($config->{users_dids_rt} == 1) { + &del_sip_user_rt( $rt_db, $config, $params->{extension} ) if $params->{type} eq "SIP"; - &del_iax_user_rt( $rt_db, $enh_config, $params->{extension} ) + &del_iax_user_rt( $rt_db, $config, $params->{extension} ) if $params->{type} eq "IAX"; - } elsif ($enh_config->{users_dids_amp} == 1) { - &del_sip_user_freepbx( $freepbx_db, $enh_config, $params->{extension} ) + } elsif ($config->{users_dids_amp} == 1) { + &del_sip_user_freepbx( $freepbx_db, $config, $params->{extension} ) if $params->{type} eq "SIP"; - &del_iax_user_freepbx( $freepbx_db, $enh_config, $params->{extension} ) + &del_iax_user_freepbx( $freepbx_db, $config, $params->{extension} ) if $params->{type} eq "IAX"; } - &email_del_user($astpp_db, '', $config, $params, $enh_config ) + &email_del_user($astpp_db, '', $config, $params ) if $config->{user_email} == 1; } elsif ( $params->{function} eq "suspend" ) { - if ($enh_config->{users_dids_rt} == 1) { - &update_context_sip_user_rt( $rt_db, $config, $enh_config, + if ($config->{users_dids_rt} == 1) { + &update_context_sip_user_rt( $rt_db, $config, $params->{extension}, "suspended" ) if $params->{type} eq "SIP"; - &update_context_iax_user_rt( $rt_db, $config, $enh_config, + &update_context_iax_user_rt( $rt_db, $config, $params->{extension}, "suspended" ) if $params->{type} eq "IAX"; - } elsif ($enh_config->{users_dids_amp} == 1) { - &update_context_sip_user_freepbx( $freepbx_db, $config, $enh_config, + } elsif ($config->{users_dids_amp} == 1) { + &update_context_sip_user_freepbx( $freepbx_db, $config, $params->{extension}, "suspended" ) if $params->{type} eq "SIP"; - &update_context_iax_user_freepbx( $freepbx_db, $config, $enh_config, + &update_context_iax_user_freepbx( $freepbx_db, $config, $params->{extension}, "suspended" ) if $params->{type} eq "IAX"; } - &email_del_user($astpp_db, '', $config, $params, $enh... [truncated message content] |
From: <son...@us...> - 2007-10-25 19:34:42
|
Revision: 2135 http://astpp.svn.sourceforge.net/astpp/?rev=2135&view=rev Author: sonalikh Date: 2007-10-25 12:34:44 -0700 (Thu, 25 Oct 2007) Log Message: ----------- Fixed SF Bug ID: 1820203 Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-update-balance.pl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-09-27 11:20:49 UTC (rev 2134) +++ trunk/astpp-admin.cgi 2007-10-25 19:34:44 UTC (rev 2135) @@ -2116,7 +2116,7 @@ print STDERR "BRAND: $params->{brand}\n" if $config->{debug} == 1; while ( $count < $params->{count} ) { my ( $number, $pin ) = - &add_callingcard( $astpp_db, $config, $config, $brandinfo, + &add_callingcard( $astpp_db, $config, $brandinfo, $params->{status}, $params->{value} * 100, $params->{account}, $brandinfo->{pin} ); $count++; Modified: trunk/astpp-update-balance.pl =================================================================== --- trunk/astpp-update-balance.pl 2007-09-27 11:20:49 UTC (rev 2134) +++ trunk/astpp-update-balance.pl 2007-10-25 19:34:44 UTC (rev 2135) @@ -79,9 +79,8 @@ ## Update calling cards and expire them and mark them as being empty. # $astpp_db->do("UPDATE callingcards SET status = 2 WHERE value - used <= 0"); -$astpp_db->do("UPDATE callingcards SET status = 2 WHERE expiry <= NOW()"); +$astpp_db->do("UPDATE callingcards SET status = 2 WHERE expiry <= NOW() AND expiry != '0000-00-00 00:00:00'"); - if ( $params->{sweep} == 0 ) { #Here comes our daily maintenance. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-01 04:20:53
|
Revision: 2136 http://astpp.svn.sourceforge.net/astpp/?rev=2136&view=rev Author: darrenkw Date: 2007-10-31 21:20:57 -0700 (Wed, 31 Oct 2007) Log Message: ----------- Patch regarding: [ 1820633 ] Calling Card ${BRAND} variable has no effect Modified Paths: -------------- trunk/astpp-callingcards.agi trunk/samples/sample.astpp-dialplan.conf Modified: trunk/astpp-callingcards.agi =================================================================== --- trunk/astpp-callingcards.agi 2007-10-25 19:34:44 UTC (rev 2135) +++ trunk/astpp-callingcards.agi 2007-11-01 04:20:57 UTC (rev 2136) @@ -654,7 +654,7 @@ exit(0); } ################# Program Starts Here ################################# -my ( $cardnum, $pin, $destination, $connectsurcharge, $perminsurcharge ) = +my ( $cardnum, $pin, $destination, $connectsurcharge, $perminsurcharge, $brand ) = @ARGV; %input = $AGI->ReadParse(); my ( $retries, $cardinfo, $numberinfo, $pricelistinfo, @outboundroutes, Modified: trunk/samples/sample.astpp-dialplan.conf =================================================================== --- trunk/samples/sample.astpp-dialplan.conf 2007-10-25 19:34:44 UTC (rev 2135) +++ trunk/samples/sample.astpp-dialplan.conf 2007-11-01 04:20:57 UTC (rev 2136) @@ -50,7 +50,7 @@ exten => 1,1,AGI(astpp-ani-map.agi,${CALLERID(number)},"ANI","ACCOUNT") exten => 1,n,Set(CARDNUMBER=${ANI_ACCOUNT}) exten => 1,n,GotoIf($["${ACCOUNT}"]?:60) -exten => 1,n,DeadAGI(astpp-callingcards.agi,${CARDNUMBER},${PIN},${DESTINATION},${CONNECTSURCHARGE},${PERMINUTESURCHARGE}) +exten => 1,n,DeadAGI(astpp-callingcards.agi,${CARDNUMBER},${PIN},${DESTINATION},${CONNECTSURCHARGE},${PERMINUTESURCHARGE},${BRAND}) exten => 1,n,GotoIf($["${NEWCALL}" = "1"]?4) exten => 2,1,AGI(astpp-ani-map.agi,${CALLERID(number)},"ANI") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-01 06:01:54
|
Revision: 2139 http://astpp.svn.sourceforge.net/astpp/?rev=2139&view=rev Author: darrenkw Date: 2007-10-31 23:01:57 -0700 (Wed, 31 Oct 2007) Log Message: ----------- Resolve issue where the list of "counters" for packages was throwing an error over a missing template. Modified Paths: -------------- trunk/astpp-admin.cgi Added Paths: ----------- trunk/templates/counters-list.tpl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-01 05:17:42 UTC (rev 2138) +++ trunk/astpp-admin.cgi 2007-11-01 06:01:57 UTC (rev 2139) @@ -7992,9 +7992,8 @@ else { $pagination = gettext("Page 1 of 1"); } - $template->param( pagination => $pagination ); - $template->param( status => $status ); $template->param( counter_list => \@counter_list ); + $template->param( pagination => $pagination ); return $template->output; } Added: trunk/templates/counters-list.tpl =================================================================== --- trunk/templates/counters-list.tpl (rev 0) +++ trunk/templates/counters-list.tpl 2007-11-01 06:01:57 UTC (rev 2139) @@ -0,0 +1,26 @@ +<table class="default"> + <tr class="header"> + <td colspan=10>List Package Counters with time in them</td> + </tr> + <tr class="header"> + <td>ID</td> + <td>Package Name</td> + <td>Account Name</td> + <td>Seconds Used</td> + </tr> + <TMPL_LOOP NAME="counter_list"> + <TR> + <TD><TMPL_VAR NAME="id"></TD> + <TD><TMPL_VAR NAME="package"></TD> + <TD><TMPL_VAR NAME="account"></TD> + <TD><TMPL_VAR NAME="seconds"></TD> + </TR> + </TMPL_LOOP> +</table> + +<table> + <tr> + <td><TMPL_VAR NAME="pagination"></td> + </tr> + </table> +</form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-01 05:17:41
|
Revision: 2138 http://astpp.svn.sourceforge.net/astpp/?rev=2138&view=rev Author: darrenkw Date: 2007-10-31 22:17:42 -0700 (Wed, 31 Oct 2007) Log Message: ----------- Patch Regarding: http://www.astpp.org/bugtracker/?do=details&task_id=274 FS#274 . table cdrs should have pricelist, pattern, notes Modified Paths: -------------- trunk/astpp-common.pl Added Paths: ----------- trunk/sql/astpp-2007-10-31.sql Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-01 04:29:12 UTC (rev 2137) +++ trunk/astpp-common.pl 2007-11-01 05:17:42 UTC (rev 2138) @@ -1982,23 +1982,27 @@ # Write cdr to the ASTPP cdr database. This is also used to apply charges and credits to an account. sub write_account_cdr() { - my ( $astpp_db, $account, $amount, $description, $timestamp, $answeredtime, $uniqueid, $clid ) + my ( $astpp_db, $account, $amount, $description, $timestamp, $answeredtime, $uniqueid, $clid, $pricelist, $pattern ) = @_; # The amount shall be passed in 100ths of a penny. my ( $sql, $status ); $description = "" if !$timestamp; + $pricelist = "" if !$pricelist; + $pattern = "" if !$pattern; $answeredtime = "0" if !$answeredtime; $uniqueid = "N/A" if $uniqueid eq "" || !$uniqueid; $clid = "N/A" if $clid eq "" || !$clid; $timestamp = &prettytimestamp if !$timestamp; my $tmp = -"INSERT INTO cdrs (uniqueid, cardnum, callednum, debit, billseconds, callstart,callerid) VALUES (" +"INSERT INTO cdrs (uniqueid, cardnum, callednum, debit, billseconds, callstart,callerid,pricelist,pattern) VALUES (" . $astpp_db->quote($uniqueid) . ", " . $astpp_db->quote($account) . "," . $astpp_db->quote($description) . ", " . $astpp_db->quote($amount) . ", " . $astpp_db->quote($answeredtime) . ", " . $astpp_db->quote($timestamp) . ", " - . $astpp_db->quote($clid) . ")"; + . $astpp_db->quote($clid) . "," + . $astpp_db->quote($pricelist) . "," + . $astpp_db->quote($pattern) . ")"; if ( $astpp_db->do($tmp) ) { $status = "POSTED CDR: $account in the amount of: " . $amount / 10000 . "\n"; @@ -2168,7 +2172,7 @@ my ( $astpp_db, $config, $uniqueid, $account, $clid, $dest, $disp, $seconds, $cost, $callstart, - $postexternal, $trunk, $notes + $postexternal, $trunk, $notes,$pricelist,$pattern ) = @_; @@ -2176,10 +2180,12 @@ my ( $tmp, $status ); $trunk = gettext("N/A") if ( !$trunk ); $uniqueid = gettext("N/A") if ( !$uniqueid ); + $pricelist = gettext("N/A") if ( !$pricelist ); + $pattern = gettext("N/A") if ( !$pattern ); $status = 0; $tmp = "INSERT INTO cdrs(uniqueid,cardnum,callerid,callednum,trunk,disposition,billseconds," - . "debit,callstart,status,notes) VALUES (" + . "debit,callstart,status,notes,pricelist,pattern) VALUES (" . $astpp_db->quote($uniqueid) . ", " . $astpp_db->quote($account) . ", " . $astpp_db->quote($clid) . ", " @@ -2190,7 +2196,9 @@ . $astpp_db->quote($cost) . ", " . $astpp_db->quote($callstart) . ", " . $astpp_db->quote($status) . ", " - . $astpp_db->quote($notes) . ")"; + . $astpp_db->quote($notes) . "," + . $astpp_db->quote($pricelist) . "," + . $astpp_db->quote($pattern) . ")"; print STDERR "$tmp\n"; $astpp_db->do($tmp); } @@ -3749,7 +3757,7 @@ $cdrinfo->{disposition}, $cdrinfo->{billsec}, $cost, $cdrinfo->{calldate}, "", $cdrinfo->{trunk}, - $notes + $notes,$numdata->{pricelist}, $numdata->{pattern} ) if $config->{posttoastpp} == 1; &print_csv( Added: trunk/sql/astpp-2007-10-31.sql =================================================================== --- trunk/sql/astpp-2007-10-31.sql (rev 0) +++ trunk/sql/astpp-2007-10-31.sql 2007-11-01 05:17:42 UTC (rev 2138) @@ -0,0 +1,1259 @@ +DROP TABLE IF EXISTS `routes`; +CREATE TABLE routes ( +id INTEGER NOT NULL AUTO_INCREMENT, +pattern CHAR(40), +comment CHAR(80), +connectcost INTEGER NOT NULL, +includedseconds INTEGER NOT NULL, +cost INTEGER NOT NULL, +pricelist CHAR(80), +inc INTEGER, +reseller CHAR(50) default NULL, +precedence INT(4) NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), +KEY `pattern` (`pattern`), +KEY `pricelist` (`pricelist`), +KEY `reseller` (`reseller`), +KEY `status` (`status`) +); + +DROP TABLE IF EXISTS `pricelists`; +CREATE TABLE pricelists ( +name CHAR(40) NOT NULL, +markup INTEGER NOT NULL DEFAULT 0, +inc INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +reseller CHAR(50) default NULL, +PRIMARY KEY (`name`) +); + +DROP TABLE IF EXISTS `callingcardbrands`; +CREATE TABLE callingcardbrands ( +name CHAR(40) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +validfordays CHAR(4) NOT NULL DEFAULT '', +pin INTEGER NOT NULL DEFAULT 0, +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `pricelist` (`pricelist`) +); + +DROP TABLE IF EXISTS `callingcardcdrs`; +CREATE TABLE callingcardcdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(50) NOT NULL DEFAULT '', +clid CHAR(80) NOT NULL DEFAULT '', +destination CHAR(40) NOT NULL DEFAULT '', +disposition CHAR(20)NOT NULL DEFAULT '', +callstart CHAR(40) NOT NULL DEFAULT '', +seconds INTEGER NOT NULL DEFAULT 0, +debit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +credit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +status INTEGER DEFAULT 0 NOT NULL, +uniqueid VARCHAR(32) NOT NULL DEFAULT '', +notes CHAR(80) NOT NULL DEFAULT '', +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `cardnumber` (`cardnumber`) +); + +DROP TABLE IF EXISTS `trunks`; +CREATE TABLE trunks ( +name VARCHAR(30) NOT NULL, +tech CHAR(10) NOT NULL DEFAULT '', +path CHAR(40) NOT NULL DEFAULT '', +provider CHAR(100) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +dialed_modify TEXT NOT NULL DEFAULT '', +resellers TEXT NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +maxchannels INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (`name`), + KEY `provider` (`provider`), + KEY `provider_2` (`provider`) +); + +DROP TABLE IF EXISTS `outbound_routes`; +CREATE TABLE outbound_routes ( +pattern CHAR(40), +id INTEGER NOT NULL AUTO_INCREMENT, +comment CHAR(80) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +trunk CHAR(80) NOT NULL DEFAULT '', +inc CHAR(10) NOT NULL DEFAULT '', +strip CHAR(40) NOT NULL DEFAULT '', +prepend CHAR(40) NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +resellers TEXT NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `trunk` (`trunk`), + KEY `pattern` (`pattern`) +); + +DROP TABLE IF EXISTS `dids`; +CREATE TABLE dids ( +number CHAR(40) NOT NULL, +account CHAR(50) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +monthlycost INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +inc CHAR(10) NOT NULL DEFAULT '', +extensions CHAR(180) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +provider CHAR(40) NOT NULL DEFAULT '', +country CHAR (80)NOT NULL DEFAULT '', +province CHAR (80) NOT NULL DEFAULT '', +city CHAR (80) NOT NULL DEFAULT '', +prorate int(1) NOT NULL default 0, +setup int(11) NOT NULL default 0, +limittime int(1) NOT NULL default 1, +disconnectionfee INT(11) NOT NULL default 0, +variables TEXT NOT NULL DEFAULT '', +options varchar(40) default NULL, +maxchannels int(4) NOT NULL default 0, +chargeonallocation int(1) NOT NULL default 1, +allocation_bill_status int(1) NOT NULL default 0, +dial_as CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `account` (`account`) +); + +DROP TABLE IF EXISTS `accounts`; +CREATE TABLE accounts ( +cc CHAR(20) NOT NULL DEFAULT '', +number CHAR(50) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(24) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +credit INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +creation TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +pin INTEGER NOT NULL DEFAULT 0, +credit_limit INTEGER NOT NULL DEFAULT 0, +posttoexternal INTEGER NOT NULL DEFAULT 0, +balance DECIMAL(20,6) NOT NULL DEFAULT 0, +password CHAR(80) NOT NULL DEFAULT '', +first_name CHAR(40) NOT NULL DEFAULT '', +middle_name CHAR(40) NOT NULL DEFAULT '', +last_name CHAR(40) NOT NULL DEFAULT '', +company_name CHAR(40) NOT NULL DEFAULT '', +address_1 CHAR(80) NOT NULL DEFAULT '', +address_2 CHAR(80) NOT NULL DEFAULT '', +address_3 CHAR(80) NOT NULL DEFAULT '', +postal_code CHAR(12) NOT NULL DEFAULT '', +province CHAR(40) NOT NULL DEFAULT '', +city CHAR(80) NOT NULL DEFAULT '', +country CHAR(40) NOT NULL DEFAULT '', +telephone_1 CHAR(40) NOT NULL DEFAULT '', +telephone_2 CHAR(40) NOT NULL DEFAULT '', +fascimile CHAR(40) NOT NULL DEFAULT '', +email CHAR(80) NOT NULL DEFAULT '', +language CHAR(2) NOT NULL DEFAULT '', +currency CHAR(3) NOT NULL DEFAULT '', +maxchannels INTEGER DEFAULT 1 NOT NULL, +routing_technique INT(4) NOT NULL DEFAULT 0, +dialed_modify TEXT NOT NULL DEFAULT '', +type INTEGER DEFAULT 0, +tz CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +DROP TABLE IF EXISTS `counters`; +CREATE TABLE counters ( +id INTEGER NOT NULL AUTO_INCREMENT, +package CHAR(40) NOT NULL DEFAULT '', +account VARCHAR(50) NOT NULL, +seconds INTEGER NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +DROP TABLE IF EXISTS `callingcards`; +CREATE TABLE callingcards ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(20) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +value INTEGER NOT NULL DEFAULT 0, +used INTEGER NOT NULL DEFAULT 0, +brand VARCHAR(20) NOT NULL DEFAULT '', +created DATETIME, +firstused DATETIME, +expiry DATETIME, +validfordays CHAR(4) NOT NULL DEFAULT '', +inuse INTEGER NOT NULL DEFAULT 0, +pin CHAR(20), +account VARCHAR(50) NOT NULL DEFAULT '', +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +maint_day INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +timeused INTEGER NOT NULL DEFAULT 0, +invoice CHAR(20) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `brand` (`brand`) +); + +CREATE TABLE charge_to_account ( +id INTEGER NOT NULL AUTO_INCREMENT, +charge_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(50) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +CREATE TABLE queue_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +queue_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE pbx_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +pbx_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE extension_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +extension_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE cdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +uniqueid varchar(32) NOT NULL DEFAULT '', +cardnum CHAR(50), +callerid CHAR(80), +callednum varchar(80) NOT NULL DEFAULT '', +billseconds INT DEFAULT 0 NOT NULL, +trunk VARCHAR(30), +disposition varchar(45) NOT NULL DEFAULT '', +callstart varchar(80) NOT NULL DEFAULT '', +debit DECIMAL (20,6) NOT NULL DEFAULT 0, +credit DECIMAL (20,6) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 0 NOT NULL, +notes CHAR(80), +provider CHAR(50), +cost DECIMAL(20,6) NOT NULL DEFAULT 0, +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `cardnum` (`cardnum`), + KEY `provider` (`provider`), + KEY `trunk` (`trunk`), + KEY `uniqueid` (`uniqueid`), + KEY `status` (`status`) +); + +CREATE TABLE packages ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +pattern CHAR(40) NOT NULL DEFAULT '', +includedseconds INTEGER NOT NULL DEFAULT 0, +reseller VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE ani_map ( +number char(20) NOT NULL, +account char(50) NOT NULL default '', +status int(11) NOT NULL default '0', +context varchar(20) NOT NULL, + PRIMARY KEY (`number`), +KEY `account` (`account`) +); + +CREATE TABLE `ip_map` ( +ip char(15) NOT NULL default '', +account char(20) NOT NULL default '', +prefix varchar(20) NULL, +context varchar(20) NOT NULL, +PRIMARY KEY (`ip`,`prefix`), +KEY `account` (`account`) +); + +CREATE TABLE charges ( +id INTEGER NOT NULL AUTO_INCREMENT, +pricelist CHAR(40) NOT NULL DEFAULT '', +description VARCHAR(80) NOT NULL DEFAULT '', +charge INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +reseller CHAR(40) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`) +); + +CREATE TABLE manager_action_variables ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(60) NOT NULL DEFAULT '', +value CHAR(60) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE callingcard_stats ( +uniqueid VARCHAR(48) NOT NULL, +total_time VARCHAR(48) NOT NULL, +billable_time VARCHAR(48) NOT NULL, +timestamp DATETIME NULL, +PRIMARY KEY (`uniqueid`) +); + +CREATE TABLE system ( +name VARCHAR(48) NULL, +value VARCHAR(255) NULL, +comment VARCHAR(255) NULL, +timestamp DATETIME NULL, +reseller VARCHAR(48) NULL, +brand VARCHAR(48) NULL, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `brand` (`brand`) +); + + +INSERT INTO system (name, value, comment) VALUES ( +'callout_accountcode','admin','Call Files: What accountcode should we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'lcrcontext', +'astpp-outgoing', +'This is the Local context we use to route our outgoing calls through esp for callbacks'); + + +INSERT INTO system (name, value, comment) VALUES ( +'maxretries', +'3', +'Call Files: How many times do we retry?'); + +INSERT INTO system (name, value, comment) VALUES ( +'retrytime', +'30', +'Call Files: How long do we wait between retries?'); + +INSERT INTO system (name, value, comment) VALUES ( +'waittime', +'15', +'Call Files: How long do we wait before the initial call?'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidname', +'Private', +'Call Files: Outgoing CallerID Name'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidnumber', +'0000000000', +'Call Files: Outgoing CallerID Number'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_context', +'astpp-callingcards', +'Call Files: For callingcards what context do we end up in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_extension', 's', +'Call Files: For callingcards what extension do we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser_dbengine', '0', +'For now this must be MySQL'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser', '0', +'Use OPENSER? 1 for yes or 0 for no'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbname', '0', +'OPENSER Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbuser', '0', +'OPENSER Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbhost', '0', +'OPENSER Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbpass', '0', +'OPENSER Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_domain', NULL, +'OPENSER Domain', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_email', 'em...@as...', +'Email address that email should appear to be from', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_dir', '/etc/asterisk', +'Which directory are asterisk configuration files stored in?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_website', 'http://www.astpp.org', +'Link to your company website', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_name', 'ASTPP.ORG', +'The name of your company. Used in emails.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'email', '1', +'Send out email? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'user_email', '1', +'Email user on account changes? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'debug', '0', +'Enable debugging output? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'emailadd', 'em...@as...', +'Administrator email address', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'startingdigit', '0', +'The digit that all calling cards must start with. 0=disabled', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'enablelcr', '1', +'Use least cost routing 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'log_file', '/var/log/astpp/astpp.log', +'ASTPP Log file', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key_home', 'http://www.astpp.org/astpp.pub', +'Asterisk RSA Key location (optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rate_engine_csv_file', '/var/log/astpp/astpp.csv', +'CSV File for call rating data', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'csv_dir', '/var/log/astpp/', +'CSV File Directory', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_brand', 'default', +'Default pricelist. If a price is not found in the customers pricelist we check this one.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'new_user_brand', 'default', +'What is the default pricelist for new customers?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_context', 'custom-astpp', +'What is the default context for new devices?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cardlength', '10', +'Number of digits in calling cards and cc codes.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_server', 'voip.astpp.org', +'Your default voip server. Used in outgoing email.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'currency', 'CAD', +'Name of the currency you use', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'iax_port', '4569', +'Default IAX2 Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sip_port', '5060', +'Default SIP Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'ipaddr', 'dynamic', +'Default IP Address for new devices', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key', 'astpp.pub', +'Asterisk RSA Key Name (Optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pinlength', '6', +'For those calling cards that are using pins this is the number of digits it will have.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'credit_limit', '0', +'Default credit limit in dollars.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints', '4', +'How many decimal points do we bill to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'max_free_length', '100', +'What is the maximum length (in minutes) of calls that are at no charge?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'trackvendorcharges', '1', +'Do we track the amount of money we spend with specific providers? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_logo', 'http://www.astpp.org/logo.png', +'', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_slogan', 'Welcome to ASTPP', +'', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'version', '1.5Beta', 'ASTPP Version', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_language', 'en', 'Default ASTPP Language',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'card_retries','3', 'How many retries do we allow for calling card numbers?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pin_retries','3', 'How many retries do we allow for pins?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'number_retries','3','How many retries do we allow calling card users when dialing a number?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'booth_context','callshop_booth','Please enter the default context for a callshop booth.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards_max_length','9000','What is the maximum length (in ms) of a callingcard call?',''); +-- +-- This is where the old "enh-config" settings start +-- + +INSERT INTO system (name, value, comment, timestamp) VALUES ('results_per_page','30','How many results per page do we should in the web interface?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astpp_dir','/var/lib/astpp','Where do the astpp configs live?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'auth','a23asudf9810-zalkj32423','This is the override authorization code and will allow access to the system.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_dbengine','MySQL','Database type for Asterisk(tm) -Realtime',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbengine','MySQL','Database type for the cdr database',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_dbengine','MySQL','Database type for OSCommerce',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbengine','MySQL','Database type for AgileBill(tm)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_dbengine','MySQL','Database type for FreePBX',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'externalbill','oscommerce','Please specify the external billing application to use. If you are not using any then leave it blank. Valid options are "agile" and "oscommerce".',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards','1','Do you wish to enable calling cards? 1 for yes and 2 for no.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astcdr','1','Change this one at your own peril. If you switch it off, calls will not be marked as billed in asterisk once they are billed.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'posttoastpp','1','Change this one at your own peril. If you switch it off, calls will not be written to astpp when they are calculated.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sleep','10','How long shall the rating engine sleep after it has been notified of a hangup? (in seconds)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_amp','0','If this is enabled, ASTPP will create users and DIDs in the FreePBX (www.freepbx.org) database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_rt','1','If this is enabled, ASTPP will create users and DIDs in the Asterisk Realtime database.',''); + +INSERT INTO system (name, value, comment) VALUES ( +'service_prepend','778',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_length,','7',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_filler','4110000',''); + +INSERT INTO system (name, value, comment) VALUES ( +'asterisk_cdr_table','cdr','Which table of the Asterisk(TM) database are the cdrs in?' +); + +-- AgileBill(Trademark of AgileCo) Settings: +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_db','agile','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_site_id','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_charge_status','0','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_taxable','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbprefix','_','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_service_prepend','778','',''); + +-- OSCommerce Settings (www.oscommerce.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_db','oscommerce','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_pass','password','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_product_id','99999999','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_payment_method','"Charge"','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_order_status','1','',''); + +-- FreePBX Settings (www.freepbx.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_db','asterisk','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_pass','passw0rd','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_dtmfmode','rfc2833','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_callgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_pickupgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_notransfer','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_qualify','yes','',''); + +-- Asterisk -realtime Settings +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_db','realtime','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_insecure','very','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_type','friend','',''); +INSERT INTO system (name, value, comment) VALUES ( +'rt_voicemail_table','voicemail_users',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_rate_announce','1','Do we want the calling cards script to announce the rate on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_timelimit_announce','1','Do we want the calling cards script to announce the timelimit on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_cancelled_prompt','1','Do we want the calling cards script to announce that the call was cancelled?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_menu','1','Do we want the calling cards script to present a menu before exiting?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_connection_prompt','1','Do we want the calling cards script to announce that it is connecting the call?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_pin_input_timeout','15000','How long do we wait when entering the calling card pin? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_number_input_timeout','15000','How long do we wait when entering the calling card number? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_dial_input_timeout','15000','How long do we wait when entering the destination number in calling cards? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_general_input_timeout','15000','How long do we wait for input in general menus? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_welcome_file','silence/1','What do we play for a welcome file?'); + +-- +-- Enough Configuration settings +-- + +DROP TABLE IF EXISTS `countrycode`; +CREATE TABLE `countrycode` ( + `country` varchar(255) NOT NULL, + PRIMARY KEY (`country`), + KEY `country` (`country`) +); + +INSERT INTO `countrycode` (`country`) VALUES + ('Afghanistan'), + ('Alaska'), + ('Albania'), + ('Algeria'), + ('AmericanSamoa'), + ('Andorra'), + ('Angola'), + ('Antarctica'), + ('Argentina'), + ('Armenia'), + ('Aruba'), + ('Ascension'), + ('Australia'), + ('Austria'), + ('Azerbaijan'), + ('Bahrain'), + ('Bangladesh'), + ('Belarus'), + ('Belgium'), + ('Belize'), + ('Benin'), + ('Bhutan'), + ('Bolivia'), + ('Bosnia & Herzegovina'), + ('Botswana'), + ('Brazil'), + ('Brunei Darussalam'), + ('Bulgaria'), + ('Burkina Faso'), + ('Burundi'), + ('Cambodia'), + ('Cameroon'), + ('Canadda'), + ('Cape Verde Islands'), + ('Central African Republic'), + ('Chad'), + ('Chile'), + ('China'), + ('Colombia'), + ('Comoros'), + ('Congo'), + ('Cook Islands'), + ('Costa Rica'), + ('Croatia'), + ('Cuba'), + ('Cuba Guantanamo Bay'), + ('Cyprus'), + ('Czech Republic'), + ('Denmark'), + ('Diego Garcia'), + ('Djibouti'), + ('Dominican Republic'), + ('East Timor'), + ('Ecuador'), + ('Egypt'), + ('El Salvador'), + ('Equatorial Guinea'), + ('Eritrea'), + ('Estonia'), + ('Ethiopia'), + ('Faroe Islands'); +INSERT INTO `countrycode` (`country`) VALUES + ('Fiji Islands'), + ('Finland'), + ('France'), + ('French Guiana'), + ('French Polynesia'), + ('Gabonese Republic'), + ('Gambia'), + ('Georgia'), + ('Germany'), + ('Ghana'), + ('Gibraltar'), + ('Greece'), + ('Greenland'), + ('Guadeloupe'), + ('Guam'), + ('Guatemala'), + ('Guinea'), + ('Guyana'), + ('Haiti'), + ('Honduras'), + ('Hong Kong'), + ('Hungary'), + ('Iceland'), + ('India'), + ('Indonesia'), + ('Iran'), + ('Iraq'), + ('Ireland'), + ('Israel'), + ('Italy'), + ('Jamaica'), + ('Japan'), + ('Jordan'), + ('Kazakstan'), + ('Kenya'), + ('Kiribati'), + ('Kuwait'), + ('Kyrgyz Republic'), + ('Laos'), + ('Latvia'), + ('Lebanon'), + ('Lesotho'), + ('Liberia'), + ('Libya'), + ('Liechtenstein'), + ('Lithuania'), + ('Luxembourg'), + ('Macao'), + ('Madagascar'), + ('Malawi'), + ('Malaysia'), + ('Maldives'), + ('Mali Republic'), + ('Malta'), + ('Marshall Islands'), + ('Martinique'), + ('Mauritania'), + ('Mauritius'), + ('MayotteIsland'), + ('Mexico'), + ('Midway Islands'), + ('Moldova'), + ('Monaco'), + ('Mongolia'), + ('Morocco'); +INSERT INTO `countrycode` (`country`) VALUES + ('Mozambique'), + ('Myanmar'), + ('Namibia'), + ('Nauru'), + ('Nepal'), + ('Netherlands'), + ('Netherlands Antilles'), + ('New Caledonia'), + ('New Zealand'), + ('Nicaragua'), + ('Niger'), + ('Nigeria'), + ('Niue'), + ('Norfolk Island'), + ('North Korea'), + ('Norway'), + ('Oman'), + ('Pakistan'), + ('Palau'), + ('Palestinian Settlements'), + ('Panama'), + ('PapuaNew Guinea'), + ('Paraguay'), + ('Peru'), + ('Philippines'), + ('Poland'), + ('Portugal'), + ('Puerto Rico'), + ('Qatar'), + ('RéunionIsland'), + ('Romania'), + ('Russia'), + ('Rwandese Republic'), + ('San Marino'), + ('São Tomé and Principe'), + ('Saudi Arabia'), + ('Senegal '), + ('Serbia and Montenegro'), + ('Seychelles Republic'), + ('Sierra Leone'), + ('Singapore'), + ('Slovak Republic'), + ('Slovenia'), + ('Solomon Islands'), + ('Somali Democratic Republic'), + ('South Africa'), + ('South Korea'), + ('Spain'), + ('Sri Lanka'), + ('St Kitts - Nevis'), + ('St. Helena'), + ('St. Lucia'), + ('St. Pierre & Miquelon'), + ('St. Vincent & Grenadines'), + ('Sudan'); +INSERT INTO `countrycode` (`country`) VALUES + ('Suriname'), + ('Swaziland'), + ('Sweden'), + ('Switzerland'), + ('Syria'), + ('Taiwan'), + ('Tajikistan'), + ('Tanzania'), + ('Thailand'), + ('Togolese Republic'), + ('Tokelau'), + ('Tonga Islands'), + ('Trinidad & Tobago'), + ('Tunisia'), + ('Turkey'), + ('Turkmenistan'), + ('Tuvalu'), + ('Uganda'), + ('Ukraine'), + ('United Arab Emirates'), + ('United Kingdom'), + ('United States of America'), + ('Uruguay'), + ('Uzbekistan'), + ('Vanuatu'), + ('Venezuela'), + ('Vietnam'), + ('Wake Island'), + ('Wallisand Futuna Islands'), + ('Western Samoa'), + ('Yemen'), + ('Zambia'), + ('Zimbabwe'); + +DROP TABLE IF EXISTS `currency`; +CREATE TABLE `currency` ( + `Currency` varchar(3) NOT NULL default '', + `CurrencyName` varchar(40) NOT NULL default '', + PRIMARY KEY (`Currency`) +); + +INSERT INTO `currency` (`Currency`,`CurrencyName`) VALUES + ('USD','US Dollars'), + ('CAD','Canadian Dollars'), + ('AUD','Australian Dollars'); + +CREATE TABLE `language` ( + `language` varchar(5) NOT NULL, + `languagename` varchar(40) NOT NULL, + `active` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`language`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `language` (`language`,`languagename`,`active`) VALUES + ('en','English',1), + ('fr','French',1), + ('de','German',1); + +CREATE TABLE `resellers` ( + name varchar(40) NOT NULL default '', + status int(11) NOT NULL default '1', + posttoexternal int(11) NOT NULL default '0', + agile_site_id int(11) NOT NULL default '0', + config_file char(80) NOT NULL default 'reseller.conf', + companyname varchar(255) default NULL, + slogan varchar(255) default NULL, + footer varchar(255) default NULL, + pricelist varchar(255) default NULL, + currency varchar(255) default NULL, + logo varchar(255) default NULL, + website varchar(255) default NULL, + adminemail varchar(255) default NULL, + salesemail varchar(255) default NULL, + phone varchar(45) default NULL, + fax varchar(45) default NULL, + address1 varchar(255) default NULL, + address2 varchar(255) default NULL, + city varchar(255) default NULL, + state varchar(255) default NULL, + postcode varchar(255) default NULL, + country varchar(255) default NULL, + defaultbrand varchar(45) NOT NULL default 'default', + defaultcurrency varchar(45) NOT NULL default 'USD', + defaultcredit varchar(45) NOT NULL default '0.00', + externalbill varchar(45) NOT NULL default '', + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +CREATE TABLE templates ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +reseller VARCHAR(45) NOT NULL default '', +template TEXT NOT NULL default '', + PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +INSERT INTO templates (name,template) VALUES +('voip_account_refilled','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been refilled. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('voip_reactivate_account','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been reactivated. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_add_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been added. +Your Username is -- $vars->{extension} -- +Your Password is -- $vars->{secret} -- +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('add_sip_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In sip.conf: +[$config->{company_name}-in] +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=from-pstn +accountcode=$config->{company_name} +[$config->{company_name}] +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid= <555-555-5555> +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +In the [globals] section add: +register => $vars->{user}:password@$config->{asterisk_server}'); + +INSERT INTO templates (name,template) VALUES +('add_iax_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In iax.conf: +At the bottom of the file add: +[$config->{company_name}-in] +;trunk=yes ;optional .. only works if you have a zaptel or ztdummy driver running +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=incoming +accountcode=$config->{company_name} ;for call tracking in the cdr +[$config->{company_name}] +;to simplify and config outgoing calls +;trunk=yes ;optional .. only works if you have a zaptel driver running +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid=<555-555-5555> ;only the number will really be used +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_remove_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP Termination with $config->{company_name} has been removed +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_calling_card','You have added a $vars->{pricelist} callingcard in the amount of $vars->{pennies} cents. +Card Number $cc Pin: $pin +Thanks for your patronage. +The $config->{company_name} sales team'); + +INSERT INTO templates (name,template) VALUES +('email_add_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been added +The number is: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team +Here is a sample setup which would call a few sip phones with incoming calls: +[incoming] +exten => _1$did,1,Wait(2) +exten => _1$did,2,Dial(SIP/2201&SIP/2202,15,Ttm) ; dial a couple of phones for 15 secs +exten => _1$did,3,Voicemail(u1000) ; go to unavailable voicemail (vm box 1000) +exten => _1$did,103,Voicemail(b1000) ; go to busy voicemail (vm box 1000)'); + +INSERT INTO templates (name,template) VALUES +('email_remove_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been removed +The number was: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_new_invoice','Invoice # $invoice in the amount of \$$total has been added to your account. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_low_balance','Your VOIP account with $config->{company_name} has a balance of \$$balance. +Please visit our website to refill your account to ensure uninterrupted service. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +CREATE TABLE `sweeplist` ( + `Id` int(10) unsigned NOT NULL default '0', + `sweep` varchar(45) NOT NULL default '', + PRIMARY KEY (`Id`) +); + +INSERT INTO sweeplist (Id,sweep) VALUES +(0,'daily'), +(1,'weekly'), +(2,'monthly'), +(3,'quarterly'), +(4,'semi-annually'), +(5,'annually') +; + +CREATE TABLE userlevels ( +userlevelid int(11) NOT NULL, +userlevelname varchar(50) NOT NULL, +PRIMARY KEY (`userlevelid`) +); + +INSERT INTO `userlevels` (`userlevelid`,`userlevelname`) VALUES + (-1,'Administrator'), + (0,'Anonymous'), + (1,'Reseller'), + (2,'Admin'), + (3,'Vendor'), + (4,'Customer Service'), + (5,'Users'); + +CREATE TABLE reseller_pricing ( +id INTEGER NOT NULL AUTO_INCREMENT, +reseller VARCHAR(50) NOT NULL, +type INTEGER NOT NULL DEFAULT 1, +monthlycost INTEGER NOT NULL DEFAULT 0, +prorate INTEGER NOT NULL DEFAULT 0, +setup INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +note VARCHAR(50) NOT NULL DEFAULT '', +disconnectionfee INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +inc CHAR(10) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE callshops ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(50) NOT NULL, +osc_dbname VARCHAR(50) NOT NULL DEFAULT '', +osc_dbpass VARCHAR(50) NOT NULL DEFAULT '', +osc_dbuser VARCHAR(50) NOT NULL DEFAULT '', +osc_dbhost VARCHAR(50) NOT NULL DEFAULT '', +osc_site VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), +KEY `name` (`name`) +); + +CREATE TABLE extensions_status ( +id INTEGER NOT NULL AUTO_INCREMENT, +tech VARCHAR(6) NULL, +extension VARCHAR(20) NULL, +number VARCHAR(255) NULL, +status VARCHAR(255) NULL, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +PRIMARY KEY (`id`), +KEY `extension` (`extension`)); + +CREATE TABLE activity_logs ( +id INTEGER NOT NULL AUTO_INCREMENT, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +message TEXT NOT NULL DEFAULT '', +user VARCHAR(50), +PRIMARY KEY (`id`)); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-02 02:31:38
|
Revision: 2141 http://astpp.svn.sourceforge.net/astpp/?rev=2141&view=rev Author: darrenkw Date: 2007-11-01 19:24:30 -0700 (Thu, 01 Nov 2007) Log Message: ----------- Patch Regarding: [ 1820671 ] HTML::TEmplate die_on_bad_params => 0 Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-users.cgi trunk/sql/astpp-2007-10-31.sql Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-01 06:15:04 UTC (rev 2140) +++ trunk/astpp-admin.cgi 2007-11-02 02:24:30 UTC (rev 2141) @@ -1470,7 +1470,7 @@ sub build_homepage() { my $template = - HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl' ); + HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); if ( $params->{logintype} == 1 || $params->{logintype} == 5 @@ -1560,7 +1560,7 @@ ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-info.tpl' ); + filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); return gettext("Cannot view account until database is configured") unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { @@ -2039,7 +2039,7 @@ my ( $body, $total, $count, $reseller, @accountdetaillist ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-list.tpl' ); + filename => '/var/lib/astpp/templates/account-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); my $yes = gettext("YES"); my $no = gettext("NO"); return gettext("Cannot view account until database is configured") @@ -2216,7 +2216,7 @@ my ( @pricelists, $status, $body ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-create.tpl' ); + filename => '/var/lib/astpp/templates/account-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); return gettext("Database is NOT configured!") . " \n" unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { @@ -5442,7 +5442,7 @@ $accountinfo ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-remove.tpl' ); + filename => '/var/lib/astpp/templates/account-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); if ( $params->{action} eq gettext("Deactivate...") ) { if ( $params->{number} ne "" ) { $number = $params->{number}; @@ -5501,7 +5501,7 @@ my ( $status, $body, $number, $reseller ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-process-payment.tpl' ); + filename => '/var/lib/astpp/templates/account-process-payment.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); return gettext("Database not configured!") unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $reseller = $params->{username}; @@ -7904,7 +7904,7 @@ my (@counter_list); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/counters-list.tpl' ); + filename => '/var/lib/astpp/templates/counters-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" || $results_per_page < 2 ) { $results_per_page = 25; @@ -9484,7 +9484,7 @@ my ( $tmp, $template, @configuration_list ); $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/configuration-list.tpl' ); + filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); if ( $params->{logintype} == 2 ) { $tmp = "SELECT * FROM system"; } @@ -10754,7 +10754,7 @@ sub build_add_callshop() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/callshop-create.tpl' ); + filename => '/var/lib/astpp/templates/callshop-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); if ( $params->{action} eq gettext("Add...") ) { if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $params->{pricelist} = $params->{username}; @@ -10812,7 +10812,7 @@ sub build_remove_callshop() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/callshop-remove.tpl' ); + filename => '/var/lib/astpp/templates/callshop-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); my ( @callshops, $tmp ); if ( $params->{logintype} == 1 ) { @callshops = &list_callshops_reseller( $astpp_db, $params->{username} ); @@ -10867,7 +10867,7 @@ my ( $template, $currency, $pricelist, $language, $status ); $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-create.tpl' ); + filename => '/var/lib/astpp/templates/booth-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); $params->{reseller} = $params->{username}; $currency = popup_menu( -name => "currency", @@ -11045,7 +11045,7 @@ sub build_remove_booth() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-remove.tpl' ); + filename => '/var/lib/astpp/templates/booth-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); my ( @booth_list, $accountinfo ); ######## # Decide which booth name to use. The one in the box has priority over the selected list one. @@ -11292,7 +11292,7 @@ my $template = HTML::Template::Expr->new( - filename => '/var/lib/astpp/templates/booths-list.tpl' ); + filename => '/var/lib/astpp/templates/booths-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); $template->param( booth_list => \@booths ); return $template->output; } @@ -11442,7 +11442,7 @@ } my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-view.tpl' ); + filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); $template->param( booth_name => $params->{booth_name} ); my $balance = &accountbalance( $astpp_db, $params->{booth_name} ) / 10000; my $unrated = &count_unrated_cdrs_account( $cdr_db, $accountinfo->{number}, @@ -11462,7 +11462,7 @@ ###################Start of Application ################### &initialize(); my $template = - HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl' ); + HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); foreach my $param ( param() ) { $params->{$param} = param($param); print STDERR "$param $params->{$param}\n" if $config->{debug} == 1; Modified: trunk/astpp-users.cgi =================================================================== --- trunk/astpp-users.cgi 2007-11-01 06:15:04 UTC (rev 2140) +++ trunk/astpp-users.cgi 2007-11-02 02:24:30 UTC (rev 2141) @@ -226,7 +226,7 @@ $cost, $pagesrequired, $record, $debit, $credit, $pageno, $credit_limit ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-account-info.tpl'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); return gettext("Cannot view account until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -421,7 +421,7 @@ $cardstat, $cardinfo, $count, $sql, $value, $used, $pageno, $pagesrequired); my (@cdr_list, @card_list); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-list-callingcards.tpl'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-list-callingcards.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); my $no = gettext("NO"); my $yes = gettext("YES"); my $active = gettext("ACTIVE"); @@ -587,7 +587,7 @@ sub build_dids() { my ( $total, $body, $status, $description, $pricelist, $pageno, $pagesrequired ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-dids.tpl'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-dids.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); return gettext("Cannot view DIDs until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -783,7 +783,7 @@ sub build_ani_map() { my ( @ani_list,$total, $body, $status, $description, $pricelist, $pageno, $pagesrequired ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-map-ani.tpl'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-map-ani.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); return gettext("Not available until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -881,7 +881,7 @@ $ENV{LANGUAGE} = $cardinfo->{language}; print STDERR gettext("Interface language is set to:") . " $ENV{LANGUAGE}\n" if $config->{debug} == 1; -my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-main.tpl'); +my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); my ($body, $menu); if ( $loginstat == 1 && $params->{mode} ne gettext("Download")) { $params->{mode} = gettext("Home") Modified: trunk/sql/astpp-2007-10-31.sql =================================================================== --- trunk/sql/astpp-2007-10-31.sql 2007-11-01 06:15:04 UTC (rev 2140) +++ trunk/sql/astpp-2007-10-31.sql 2007-11-02 02:24:30 UTC (rev 2141) @@ -555,6 +555,9 @@ INSERT INTO system (name, value, comment, timestamp) VALUES ( 'callingcards_max_length','9000','What is the maximum length (in ms) of a callingcard call?',''); + +INSERT INTO system (name,value,comment,timestamp) VALUES ( +'template_die_on_bad_params','0','Should HTML::Template die on bad parameters?',''); -- -- This is where the old "enh-config" settings start -- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-02 05:13:05
|
Revision: 2147 http://astpp.svn.sourceforge.net/astpp/?rev=2147&view=rev Author: darrenkw Date: 2007-11-01 22:13:00 -0700 (Thu, 01 Nov 2007) Log Message: ----------- Resolve issues with Packages and Counters. Also fixed incorrect formatting of "template_die_on_bad_param" variable. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-common.pl trunk/astpp-users.cgi trunk/templates/counters-list.tpl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-02 04:25:04 UTC (rev 2146) +++ trunk/astpp-admin.cgi 2007-11-02 05:13:00 UTC (rev 2147) @@ -1470,7 +1470,7 @@ sub build_homepage() { my $template = - HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); if ( $params->{logintype} == 1 || $params->{logintype} == 5 @@ -1560,7 +1560,7 @@ ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); return gettext("Cannot view account until database is configured") unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { @@ -2039,7 +2039,7 @@ my ( $body, $total, $count, $reseller, @accountdetaillist ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/account-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); my $yes = gettext("YES"); my $no = gettext("NO"); return gettext("Cannot view account until database is configured") @@ -2216,7 +2216,7 @@ my ( @pricelists, $status, $body ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/account-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); return gettext("Database is NOT configured!") . " \n" unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { @@ -5442,7 +5442,7 @@ $accountinfo ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/account-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); if ( $params->{action} eq gettext("Deactivate...") ) { if ( $params->{number} ne "" ) { $number = $params->{number}; @@ -5501,7 +5501,7 @@ my ( $status, $body, $number, $reseller ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-process-payment.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/account-process-payment.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); return gettext("Database not configured!") unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $reseller = $params->{username}; @@ -7904,7 +7904,7 @@ my (@counter_list); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/counters-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/counters-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" || $results_per_page < 2 ) { $results_per_page = 25; @@ -7960,7 +7960,7 @@ # END OF PAGINATION CODE while ( my $counterinfo = $sql->fetchrow_hashref ) { print STDERR "COUNTER: " . $counterinfo->{id} if $config->{debug} == 1; - my ($row); + my (%row); # $row{} = $name; # $row{balance} = $balance / 10000; @@ -7969,7 +7969,7 @@ $row{package} = $counterinfo->{package}; $row{account} = $counterinfo->{account}; $row{seconds} = $counterinfo->{seconds}; - push( @counter_list, $counterinfo ); + push( @counter_list, \%row ); } if ( $total_entries >= 1 ) { #This section only applies if we have more than 1 page. @@ -9485,7 +9485,7 @@ my ( $tmp, $template, @configuration_list ); $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); if ( $params->{logintype} == 2 ) { $tmp = "SELECT * FROM system"; } @@ -10755,7 +10755,7 @@ sub build_add_callshop() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/callshop-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/callshop-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); if ( $params->{action} eq gettext("Add...") ) { if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $params->{pricelist} = $params->{username}; @@ -10813,7 +10813,7 @@ sub build_remove_callshop() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/callshop-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/callshop-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); my ( @callshops, $tmp ); if ( $params->{logintype} == 1 ) { @callshops = &list_callshops_reseller( $astpp_db, $params->{username} ); @@ -10868,7 +10868,7 @@ my ( $template, $currency, $pricelist, $language, $status ); $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/booth-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); $params->{reseller} = $params->{username}; $currency = popup_menu( -name => "currency", @@ -11046,7 +11046,7 @@ sub build_remove_booth() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/booth-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); my ( @booth_list, $accountinfo ); ######## # Decide which booth name to use. The one in the box has priority over the selected list one. @@ -11293,7 +11293,7 @@ my $template = HTML::Template::Expr->new( - filename => '/var/lib/astpp/templates/booths-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/booths-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); $template->param( booth_list => \@booths ); return $template->output; } @@ -11443,7 +11443,7 @@ } my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); $template->param( booth_name => $params->{booth_name} ); my $balance = &accountbalance( $astpp_db, $params->{booth_name} ) / 10000; my $unrated = &count_unrated_cdrs_account( $cdr_db, $accountinfo->{number}, @@ -11463,7 +11463,7 @@ ###################Start of Application ################### &initialize(); my $template = - HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); foreach my $param ( param() ) { $params->{$param} = param($param); print STDERR "$param $params->{$param}\n" if $config->{debug} == 1; Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-02 04:25:04 UTC (rev 2146) +++ trunk/astpp-common.pl 2007-11-02 05:13:00 UTC (rev 2147) @@ -1036,6 +1036,7 @@ my ( $connect, $cost, $answeredtime, $increment, $inc_seconds ) = @_; print STDERR "Connect: $connect Cost: $cost Answered: $answeredtime \n"; print STDERR " Inc: $increment included: $inc_seconds \n"; + if ($answeredtime > 0) { my ($total_seconds); $total_seconds = ( $answeredtime - $inc_seconds ) / $increment if $inc_seconds; $total_seconds = ( $answeredtime ) / $increment if !$inc_seconds; @@ -1049,6 +1050,10 @@ print STDERR "Increment: $increment Total Increments: $total_seconds\n"; print STDERR "Bill Seconds: $billseconds Total cost is $cost\n"; return $cost; + } else { + print STDERR "NO CHARGE - ANSWEREDTIME = 0\n"; + return 0; + } } # Return a list of all trunk names. Used mostly for menus. @@ -3686,28 +3691,35 @@ my $counter = &get_counter( $astpp_db, $package->{name}, $carddata->{number} ); - my $difference; + my $difference; if ( !$counter->{id}) { my $tmp = "INSERT INTO counters (package,account) VALUES (" . $astpp_db->quote( $package->{name} ) . ", " . $astpp_db->quote( $carddata->{number} ) . ")"; - print STDERR $tmp . "/n"; + print STDERR $tmp . "/n" if $config->{debug} == 1; $astpp_db->do($tmp); $counter = &get_counter( $astpp_db, $package->{name}, $carddata->{number} ); } if ( $package->{includedseconds} > $counter->{seconds}) { - $cdrinfo->{billsec} = $cdrinfo->{billsec} - ($package->{includedseconds} - $counter -->{seconds}); + my $availableseconds = $package->{includedseconds} - $counter->{seconds}; + my $freeseconds; + if ($availableseconds >= $cdrinfo->{billsec}) { + $freeseconds = $cdrinfo->{billsec}; + $cdrinfo->{billsec} = 0; + } else { + $freeseconds = $availableseconds; + $cdrinfo->{billsec} = $cdrinfo->{billsec} - $availableseconds; + } my $tmp = "UPDATE counters SET seconds = " . $astpp_db->quote( - $counter->{seconds} + $difference ) + $counter->{seconds} + $freeseconds ) . " WHERE id = " . $astpp_db->quote( $counter->{id} ); - print STDERR $tmp . "/n"; + print STDERR $tmp . "/n" if $config->{debug} == 1; $astpp_db->do($tmp); } } Modified: trunk/astpp-users.cgi =================================================================== --- trunk/astpp-users.cgi 2007-11-02 04:25:04 UTC (rev 2146) +++ trunk/astpp-users.cgi 2007-11-02 05:13:00 UTC (rev 2147) @@ -226,7 +226,7 @@ $cost, $pagesrequired, $record, $debit, $credit, $pageno, $credit_limit ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); return gettext("Cannot view account until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -421,7 +421,7 @@ $cardstat, $cardinfo, $count, $sql, $value, $used, $pageno, $pagesrequired); my (@cdr_list, @card_list); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-list-callingcards.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-list-callingcards.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); my $no = gettext("NO"); my $yes = gettext("YES"); my $active = gettext("ACTIVE"); @@ -587,7 +587,7 @@ sub build_dids() { my ( $total, $body, $status, $description, $pricelist, $pageno, $pagesrequired ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-dids.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-dids.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'}); return gettext("Cannot view DIDs until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -783,7 +783,7 @@ sub build_ani_map() { my ( @ani_list,$total, $body, $status, $description, $pricelist, $pageno, $pagesrequired ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-map-ani.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-map-ani.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); return gettext("Not available until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -881,7 +881,7 @@ $ENV{LANGUAGE} = $cardinfo->{language}; print STDERR gettext("Interface language is set to:") . " $ENV{LANGUAGE}\n" if $config->{debug} == 1; -my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); +my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); my ($body, $menu); if ( $loginstat == 1 && $params->{mode} ne gettext("Download")) { $params->{mode} = gettext("Home") Modified: trunk/templates/counters-list.tpl =================================================================== --- trunk/templates/counters-list.tpl 2007-11-02 04:25:04 UTC (rev 2146) +++ trunk/templates/counters-list.tpl 2007-11-02 05:13:00 UTC (rev 2147) @@ -22,5 +22,10 @@ <tr> <td><TMPL_VAR NAME="pagination"></td> </tr> +<tr> + <td> + <TMPL_VAR NAME="status"> + </td> +</tr> </table> </form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-03 03:07:20
|
Revision: 2149 http://astpp.svn.sourceforge.net/astpp/?rev=2149&view=rev Author: darrenkw Date: 2007-11-02 20:07:15 -0700 (Fri, 02 Nov 2007) Log Message: ----------- Resolved: [ 1820671 ] HTML::TEmplate die_on_bad_params => 0 Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-callingcards.agi trunk/astpp-users.cgi trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-02 05:39:54 UTC (rev 2148) +++ trunk/astpp-admin.cgi 2007-11-03 03:07:15 UTC (rev 2149) @@ -50,7 +50,9 @@ use Time::HiRes qw( gettimeofday tv_interval ); use Data::Paginate; use DateTime; -use DateTime::TimeZone +use DateTime::TimeZone; +use ASTPP; + ; # We use DateTime::TimeZone to show users cdrs in their own timezones. require "/usr/local/astpp/astpp-common.pl"; @@ -60,8 +62,13 @@ textdomain("astpp"); use vars qw(@output $astpp_db $params $config $status $config $limit $accountinfo - $freepbx_db $rt_db $openser_db); + $freepbx_db $rt_db $openser_db $ASTPP); my $starttime = [gettimeofday]; +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to +be. +$ASTPP->set_asterisk_agi($AGI); +$ASTPP->set_pagination_script("astpp-admin.cgi"); my @Home = ( gettext("Home Page") ); my @Accounts = ( gettext("Create Account"), gettext("Process Payment"), @@ -1470,7 +1477,7 @@ sub build_homepage() { my $template = - HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); if ( $params->{logintype} == 1 || $params->{logintype} == 5 @@ -1560,7 +1567,7 @@ ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); return gettext("Cannot view account until database is configured") unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { @@ -2039,7 +2046,7 @@ my ( $body, $total, $count, $reseller, @accountdetaillist ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/account-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params}); my $yes = gettext("YES"); my $no = gettext("NO"); return gettext("Cannot view account until database is configured") @@ -2216,7 +2223,7 @@ my ( @pricelists, $status, $body ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/account-create.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); return gettext("Database is NOT configured!") . " \n" unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { @@ -5442,7 +5449,7 @@ $accountinfo ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/account-remove.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); if ( $params->{action} eq gettext("Deactivate...") ) { if ( $params->{number} ne "" ) { $number = $params->{number}; @@ -5501,7 +5508,7 @@ my ( $status, $body, $number, $reseller ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-process-payment.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/account-process-payment.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); return gettext("Database not configured!") unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $reseller = $params->{username}; @@ -7901,14 +7908,26 @@ } sub build_counters() { - my (@counter_list); + my ($tmp,@counter_list); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/counters-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/counters-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" || $results_per_page < 2 ) { $results_per_page = 25; } + if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { + $tmp = + "SELECT * FROM pricelists WHERE status < 2 AND reseller = " + . $astpp_db->quote( $params->{username} ); + } + else { + $tmp = + "SELECT * FROM pricelists WHERE status < 2 AND reseller IS NULL"; + } + my $sql = $astpp_db->do($sql); + print STDERR $tmp if $config->{debug} == 1; + $sql = $astpp_db->prepare($tmp); ## START PAGINATION CODE # set total_entries *once* then pass it around # in the object's links from then on for efficiency: @@ -9485,7 +9504,7 @@ my ( $tmp, $template, @configuration_list ); $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); if ( $params->{logintype} == 2 ) { $tmp = "SELECT * FROM system"; } @@ -10755,7 +10774,7 @@ sub build_add_callshop() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/callshop-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/callshop-create.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); if ( $params->{action} eq gettext("Add...") ) { if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $params->{pricelist} = $params->{username}; @@ -10813,7 +10832,7 @@ sub build_remove_callshop() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/callshop-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/callshop-remove.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); my ( @callshops, $tmp ); if ( $params->{logintype} == 1 ) { @callshops = &list_callshops_reseller( $astpp_db, $params->{username} ); @@ -10868,7 +10887,7 @@ my ( $template, $currency, $pricelist, $language, $status ); $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/booth-create.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); $params->{reseller} = $params->{username}; $currency = popup_menu( -name => "currency", @@ -11046,7 +11065,7 @@ sub build_remove_booth() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/booth-remove.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); my ( @booth_list, $accountinfo ); ######## # Decide which booth name to use. The one in the box has priority over the selected list one. @@ -11293,7 +11312,7 @@ my $template = HTML::Template::Expr->new( - filename => '/var/lib/astpp/templates/booths-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/booths-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); $template->param( booth_list => \@booths ); return $template->output; } @@ -11443,7 +11462,7 @@ } my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); $template->param( booth_name => $params->{booth_name} ); my $balance = &accountbalance( $astpp_db, $params->{booth_name} ) / 10000; my $unrated = &count_unrated_cdrs_account( $cdr_db, $accountinfo->{number}, @@ -11463,7 +11482,8 @@ ###################Start of Application ################### &initialize(); my $template = - HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl', + die_on_bad_params => $config->{template_die_on_bad_params} ); foreach my $param ( param() ) { $params->{$param} = param($param); print STDERR "$param $params->{$param}\n" if $config->{debug} == 1; Modified: trunk/astpp-callingcards.agi =================================================================== --- trunk/astpp-callingcards.agi 2007-11-02 05:39:54 UTC (rev 2148) +++ trunk/astpp-callingcards.agi 2007-11-03 03:07:15 UTC (rev 2149) @@ -438,6 +438,7 @@ . $astpp_db->quote($answeredtime) . ", " . $astpp_db->quote($charge) . ")"; $astpp_db->do($sql); + $ASTPP->debug( debug => "$sql", verbosity => $verbosity ); $ASTPP->debug( debug => "Resetting CDR Variables", verbosity => $verbosity ); $AGI->set_variable( "\"ANSWEREDTIME\"", "0" ); $AGI->set_variable( "\"DIALEDTIME\"", "0" ); Modified: trunk/astpp-users.cgi =================================================================== --- trunk/astpp-users.cgi 2007-11-02 05:39:54 UTC (rev 2148) +++ trunk/astpp-users.cgi 2007-11-03 03:07:15 UTC (rev 2149) @@ -226,7 +226,7 @@ $cost, $pagesrequired, $record, $debit, $credit, $pageno, $credit_limit ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-account-info.tpl', die_on_bad_params => $config->{template_die_on_bad_params}); return gettext("Cannot view account until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -421,7 +421,7 @@ $cardstat, $cardinfo, $count, $sql, $value, $used, $pageno, $pagesrequired); my (@cdr_list, @card_list); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-list-callingcards.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-list-callingcards.tpl', die_on_bad_params => $config->{template_die_on_bad_params}); my $no = gettext("NO"); my $yes = gettext("YES"); my $active = gettext("ACTIVE"); @@ -587,7 +587,7 @@ sub build_dids() { my ( $total, $body, $status, $description, $pricelist, $pageno, $pagesrequired ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-dids.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'}); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-dids.tpl', die_on_bad_params => $config->{template_die_on_bad_params}); return gettext("Cannot view DIDs until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -783,7 +783,7 @@ sub build_ani_map() { my ( @ani_list,$total, $body, $status, $description, $pricelist, $pageno, $pagesrequired ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-map-ani.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-map-ani.tpl', die_on_bad_params => $config->{template_die_on_bad_params}); return gettext("Not available until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -881,7 +881,7 @@ $ENV{LANGUAGE} = $cardinfo->{language}; print STDERR gettext("Interface language is set to:") . " $ENV{LANGUAGE}\n" if $config->{debug} == 1; -my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); +my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-main.tpl', die_on_bad_params => $config->{template_die_on_bad_params}); my ($body, $menu); if ( $loginstat == 1 && $params->{mode} ne gettext("Download")) { $params->{mode} = gettext("Home") Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2007-11-02 05:39:54 UTC (rev 2148) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2007-11-03 03:07:15 UTC (rev 2149) @@ -4,6 +4,7 @@ use strict; use warnings; use DBI; +use Data::Paginate; require Exporter; @@ -37,6 +38,7 @@ _asterisk_agi => $_[3], _cdr_db => $_[4], _verbosity_item_level => $arg{verbosity_item_level} || 1, + _pagination_script => $arg{pagination_script} || "astpp-admin.cgi", }, $class; } @@ -44,6 +46,7 @@ sub set_asterisk_agi { $_[0]->{_asterisk_agi} } #Sets the verbosity level. sub set_astpp_db { $_[0]->{_astpp_db} } #Sets the verbosity level. sub set_cdr_db {$_[0]->{_cdr_db} } #Sets the verbosity level. +sub set_pagination_script {$_[00]->{_pagination_script} } sub debug #Prints debugging if appropriate @@ -59,6 +62,43 @@ return 0; } +sub pagination #Returns the pagination html code to assist with navigation. +{ +my ($self, %arg) = @_; + # We are using Data::Paginate for the real tough stuff. + # Therefore we need to pass the Data::Paginate stuff + # as well as the total number of pages. + # total_entries = Total number of pages. + # pagination_script = Script name. + # mode = What mode do we want. + # pgr = Pass along Data::Paginate + # ve = + # navi_html = + # last_page = + # First we decide if we have multiple pages... + if ($arg{total_entries} > 1) { + my $html; + $html = + "<a href=\"" . $self->{_pagination_script} . "?mode=" + . $arg{mode} . "&ve=" + . $arg{ve} . "&te=" + . $arg{total_entries} + . "&pg=1\">" + . gettext("First Page") + . "</a> | " + . scalar $arg{navi_html} + . "<a href=\"" . $self->{_pagination_script} . "?mode=" + . $arg{mode} . "&ve=" + . $arg{ve} . "&te=" + . $arg{total_entries} . "&pg=" + . $arg{last_page} . "\">" + . gettext("Last Page") . "</a>"; + return $html; + } + else { + return gettext("Page 1 of 1"); + } +} # Preloaded methods go here. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-03 21:35:25
|
Revision: 2150 http://astpp.svn.sourceforge.net/astpp/?rev=2150&view=rev Author: darrenkw Date: 2007-11-03 14:35:25 -0700 (Sat, 03 Nov 2007) Log Message: ----------- Many minor fixes. Moved some of the get_pricelist subroutines to the perl module. Also, added more pagination support directly in the perl module. Also corrected the issues with bug: [ 1800044 ] Debug Packages. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-callingcards.agi trunk/astpp-common.pl trunk/modules/ASTPP/lib/ASTPP.pm trunk/templates/account-info.tpl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-03 03:07:15 UTC (rev 2149) +++ trunk/astpp-admin.cgi 2007-11-03 21:35:25 UTC (rev 2150) @@ -42,7 +42,7 @@ use Locale::gettext_pp qw(:locale_h); use Data::Dumper; use lib './lib', '../lib'; -#use warnings; +use warnings; use Asterisk::Manager; use Text::CSV; use HTML::Template; @@ -65,8 +65,7 @@ $freepbx_db $rt_db $openser_db $ASTPP); my $starttime = [gettimeofday]; $ASTPP = ASTPP->new; -$ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to -be. +$ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to be. $ASTPP->set_asterisk_agi($AGI); $ASTPP->set_pagination_script("astpp-admin.cgi"); my @Home = ( gettext("Home Page") ); @@ -536,6 +535,10 @@ if $params->{mode} eq gettext("Reseller Report"); return &build_reseller_user_report() if $params->{mode} eq gettext("User Report"); + return &build_packages() + if $params->{mode} eq gettext("Packages"); + return &build_counters() + if $params->{mode} eq gettext("Counters"); return &build_homepage() if $params->{mode} eq gettext("Home Page") @@ -1096,7 +1099,7 @@ return gettext("Cannot display reports until database is configured") unless $cdr_db; - return gettext("Comming Soon!"); + return gettext("Coming Soon!"); } # End of code changes by Sonia Ali Khan. @@ -1570,13 +1573,7 @@ filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); return gettext("Cannot view account until database is configured") unless $astpp_db; - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } - +@pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); return gettext("Cannot view account until pricelists configured") unless @pricelists; @@ -1873,7 +1870,7 @@ -values => \%applyablecharges )); - my (@account_did_list); + my (@account_did_list,$sql,$pagination); my @did_list = &list_dids_account( $astpp_db, $accountinfo->{number} ); foreach my $did_info (@did_list) { my (%row); @@ -1894,7 +1891,7 @@ "SELECT * FROM ani_map WHERE account = " . $astpp_db->quote( $accountinfo->{'number'} ) . " ORDER BY number"; - my $sql = $astpp_db->prepare($tmp); + $sql = $astpp_db->prepare($tmp); $sql->execute; my @account_ani_list; while ( my $record = $sql->fetchrow_hashref ) { @@ -1923,60 +1920,25 @@ } $template->param( account_ip_list => \@account_ip_list); $template->param( currency => $currency[0]); - ## START PAGINATION CODE - # set total_entries *once* then pass it around - # in the object's links from then on for efficiency: + ($sql, $pagination) = + $ASTPP->pagination( sql_select => "SELECT * FROM cdrs WHERE cardnum =" + . $astpp_db->quote( $accountinfo->{number} ) + . "and status IN (NULL, '', 0, 1)" + . " ORDER BY callstart DESC ", + sql_count => "SELECT COUNT(*) FROM cdrs WHERE cardnum =" + . $astpp_db->quote( $accountinfo->{number} ) + . "and status IN (NULL, '', 0, 1)", + results_per_page=> $config->{results_per_page}, + ve => $params->{ve}, + te => $params->{ee}, - my $verify = CGI::param('ve') || ''; - my $total_entries = int( CGI::param('te') ); - my $te_match = - $total_entries - ? Digest::MD5::md5_hex("unique_cypher-$total_entries-$where") - : ''; - if ( !$total_entries || $verify ne $te_match ) { - - # its not ok so re-fetch - $tmp = - "SELECT COUNT(*) FROM cdrs WHERE cardnum =" - . $astpp_db->quote( $accountinfo->{number} ) - . "and status IN (NULL, '', 0, 1)" - . " ORDER BY callstart DESC"; + ); + my $results = $astpp_db->prepare($sql); + $results->execute; $sql = $astpp_db->prepare($tmp); $sql->execute; - $record = $sql->fetchrow_hashref; - $total_entries = $record->{"COUNT(*)"}; - $sql->finish; - $te_match = Digest::MD5::md5_hex("unique_cypher-$total_entries-$where"); - } - if ( $total_entries <= 0 ) { $total_entries = 1; } - my $pgr = Data::Paginate->new( - { - 'start_array_index_at_zero' => 1, - 'total_entries' => $total_entries, - 'entries_per_page' => $results_per_page, - 'total_entries_verify_param_value' => $te_match - } - ); - - # only SELECT current page's records: - if ( $total_entries > $pgr->get_entries_on_this_page() ) { - $tmp = - "SELECT * FROM cdrs WHERE cardnum =" - . $astpp_db->quote( $accountinfo->{number} ) - . "and status IN (NULL, '', 0, 1)" - . " ORDER BY callstart DESC " - . " LIMIT ". ($pgr->get_first() - 1) . ", " . $pgr->get_entries_on_this_page(); - } else { - $tmp = - "SELECT * FROM cdrs WHERE cardnum =" - . $astpp_db->quote( $accountinfo->{'number'} ) - . "and status IN (NULL, '', 0, 1)" - . " ORDER BY callstart DESC "; - } - $sql = $astpp_db->prepare($tmp); - $sql->execute; my @account_cdr_list; - while ( my $record = $sql->fetchrow_hashref ) { + while ( my $record = $results->fetchrow_hashref ) { my %row; if (!$record->{callerid}) { $row{callerid} = gettext("N/A"); @@ -1984,11 +1946,14 @@ $row{callerid} = $record->{callerid}; } if (!$record->{uniqueid}) { $row{uniqueid} = gettext("N/A");} else { $row{uniqueid} = $record->{uniqueid};} - if (!$record->{disposition}) {$row{disposition} = gettext("N/A");} else {$row{disposition} = $record->{dispositio}; } + if (!$record->{disposition}) {$row{disposition} = gettext("N/A");} else {$row{disposition} = $record->{disposition}; } if (!$record->{notes}) { $row{notes} = ""; } else { $row{notes} = $record->{notes} ;} if (!$record->{callstart}) { $row{callstart} = ""; } else { $row{callstart} = $record->{callstart}; } if (!$record->{callednum}) { $row{callednum} = ""; } else {$row{callednum} = $record->{callednum};} if (!$record->{billseconds}) { $row{billseconds} = ""; } else { $row{billseconds} = $record->{billseconds};} + if (!$record->{cost}) { $row{cost} = ""; } else { $row{cost} = $record->{cost};} + $row{profit} = sprintf( "%.6f", ($record->{debit} - $record->{cost})/10000); + $row{cost} = sprintf( "%.6f", $row{cost}); if ( $record->{debit} ) { $row{debit} = $record->{debit} / 10000; @@ -2007,30 +1972,7 @@ push(@account_cdr_list, \%row); } $template->param( account_cdr_list => \@account_cdr_list); - if ( $total_entries => 1 ) - { #This section only applies if we have more than 1 page. - $pagination = - "<a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") . "&ve=" - . $params->{ve} . "&te=" - . $total_entries - . "&pg=1\">" - . gettext("First Page") - . "</a> | "; - $pagination .= scalar $pgr->get_navi_html(); - $pagination .= - "<a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") . "&ve=" - . $params->{ve} . "&te=" - . $total_entries . "&pg=" - . $pgr->get_last_page() . "\">" - . gettext("Last Page") . "</a>"; - } - else { - $pagination = gettext("Page 1 of 1"); - } - - $template->param( pagination => $pagination ); + $template->param( pagination => $pagination ); } else { $status .= @@ -2226,12 +2168,7 @@ filename => '/var/lib/astpp/templates/account-create.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); return gettext("Database is NOT configured!") . " \n" unless $astpp_db; - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); return gettext("Please configure 'Pricelists'") . "\n" unless @pricelists; if ( $params->{action} eq gettext("Generate Account") ) { @@ -2370,12 +2307,7 @@ my $active = gettext("ACTIVE"); my $inactive = gettext("INACTIVE"); my $deleted = gettext("DELETED"); - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0; } @@ -2859,6 +2791,9 @@ sub build_create_card() { my ( @pricelists, $status, $body, @brands ); + my $template = + HTML::Template->new( + filename => '/var/lib/astpp/templates/callingcards-create.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); return gettext("Database is NOT configured!") . " \n" unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { @brands = &list_cc_brands_reseller( $astpp_db, $params->{username} ); @@ -2879,41 +2814,10 @@ } $status .= &generatecallingcards( $params, $config ); } - $body = start_multipart_form; - $body .= "<table class=\"default\">"; - $body .= "<tr class=\"header\"><td>"; - $body .= - gettext("Account Number") - . "</td><td>" - . gettext("Brand") - . "</td><td>" - . gettext("Value in pennies") - . "</td><td>" - . gettext("Quantity") - . "</td><td>" - . gettext("Status") - . "</td></tr>" - . "<tr class=\"rowone\"><td>" - . hidden( -name => "mode", -value => gettext("Create Card") ) - . textfield( -name => "account", -size => 20 ) - . "</td><td>" - . popup_menu( -name => "brand", -values => \@brands ) - . "</td><td>" - . textfield( -name => "value", -size => 8 ) - . "</td><td>" - . textfield( -name => "count", -size => 8 ) - . "</td><td>" - . popup_menu( - -name => "status", - -values => \@cardstatus - ) - . "</td><td>" - . "</td></tr><tr><td>" - . submit( - -name => 'action', - -value => gettext("Generate Card(s)") - ) . "</td></tr></table>"; - return $body; + $template->param(brand_list => popup_menu( -name=>"brand", -values => \@brands)); + $template->param(status_list => popup_menu( -name => "status", -values => \@cardstatus)); + $template->param(status => $status); + return $template->output; } sub build_update_card_status() { @@ -2925,12 +2829,7 @@ else { @brands = &list_cc_brands($astpp_db); } - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); return gettext("Please configure 'Pricelists'!") . "\n" unless @pricelists; if ( $params->{action} eq gettext("Update Status on Card(s)") ) { @@ -4338,12 +4237,7 @@ else { $number = $params->{number}; } - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); my @resellerlist = &list_resellers($astpp_db); unshift( @resellerlist, "" ); $accountinfo = &get_account( $astpp_db, $number ); @@ -4646,12 +4540,7 @@ $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Add...") ) { - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); return gettext("Please configure 'Pricelists'!") . "\n" unless @pricelists; push @pricelists, ""; @@ -4698,12 +4587,7 @@ "; } elsif ( $params->{action} eq gettext("Edit...") ) { - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); return gettext("Please configure 'Pricelists'!") . "\n" unless @pricelists; push @pricelists, ""; @@ -7403,12 +7287,7 @@ sub build_routes() { my ( @pricelists, $sql, $count, $tmp ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); return gettext("Pricelists Do NOT Exist!") . "\n" unless @pricelists; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } my $results_per_page = $config->{results_per_page}; @@ -7684,12 +7563,7 @@ $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Add...") ) { - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); $body = start_form . "<table class=\"default\">" . "<tr class=\"header\"><td colspan=2>" @@ -7908,110 +7782,41 @@ } sub build_counters() { - my ($tmp,@counter_list); + my ($tmp,@counter_list,$sql_select,$sql_count); my $template = HTML::Template->new( filename => '/var/lib/astpp/templates/counters-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); - my $results_per_page = $config->{results_per_page}; - if ( $results_per_page eq "" || $results_per_page < 2 ) { - $results_per_page = 25; + if ( $params->{logintype} == 2 ) { + $sql_select = "SELECT counters.id AS id, packages.name AS name,counters.account AS account, counters.seconds AS seconds, counters.status AS status FROM counters,packages WHERE package IN(SELECT id FROM packages WHERE pricelist IN (SELECT name from pricelists WHERE reseller IS NULL)) AND counters.package = packages.id;"; + $sql_count = "SELECT COUNT(*) FROM counters WHERE package IN(SELECT id FROM packages WHERE pricelist IN (SELECT name from pricelists WHERE reseller IS NULL)) AND counters.package = packages.id;"; } - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - $tmp = - "SELECT * FROM pricelists WHERE status < 2 AND reseller = " - . $astpp_db->quote( $params->{username} ); + elsif ( $params->{logintype} == 1 ) { + $sql_select = + "SELECT counters.id AS id, packages.name AS name,counters.account AS account, counters.seconds AS seconds, counters.status AS status FROM counters,packages WHERE package IN(SELECT id FROM packages WHERE pricelist IN(SELECT name FROM pricelists WHERE reseller = " + . $astpp_db->quote( $params->{username} ) . ")) AND counters.package = packages.id;"; + $sql_count = + "SELECT COUNT(*) FROM counters WHERE package IN(SELECT id FROM packages WHERE pricelist IN(SELECT name FROM pricelists WHERE reseller = " + . $astpp_db->quote( $params->{username} ) . ") AND counters.package = packages.id;"; } - else { - $tmp = - "SELECT * FROM pricelists WHERE status < 2 AND reseller IS NULL"; - } - my $sql = $astpp_db->do($sql); - print STDERR $tmp if $config->{debug} == 1; - $sql = $astpp_db->prepare($tmp); - ## START PAGINATION CODE - # set total_entries *once* then pass it around - # in the object's links from then on for efficiency: - - my $verify = CGI::param('ve') || ''; - my $total_entries = int( CGI::param('te') ); - my $te_match = - $total_entries - ? Digest::MD5::md5_hex("unique_cypher-$total_entries-$where") - : ''; - if ( !$total_entries || $verify ne $te_match ) { - - # its not ok so re-fetch - $sql = $astpp_db->prepare("SELECT COUNT(*) FROM counters"); - $sql->execute; - $record = $sql->fetchrow_hashref; - $total_entries = $record->{"COUNT(*)"}; - $sql->finish; - $te_match = Digest::MD5::md5_hex("unique_cypher-$total_entries-$where"); - } - - #if ($te_match <= 0) { $te_match = 0; } - if ( $total_entries <= 0 ) { $total_entries = 1; } - - # otherwise its all ok so use it - my $pgr = Data::Paginate->new( - { - 'start_array_index_at_zero' => 1, - 'total_entries' => $total_entries, - 'entries_per_page' => $results_per_page, - 'total_entries_verify_param_value' => $te_match - } - ); - - # only SELECT current page's records: - if ( $total_entries > $pgr->get_entries_on_this_page() ) { - $sql = - "SELECT * FROM counters ORDER BY id LIMIT " - . ( $pgr->get_first() - 1 ) . ", " - . $pgr->get_entries_on_this_page(); - } - else { - $sql = "SELECT * FROM counters ORDER BY id"; - } - print STDERR $sql if $config->{debug} == 1; - $sql = $astpp_db->prepare($sql); - $sql->execute; - - # END OF PAGINATION CODE - while ( my $counterinfo = $sql->fetchrow_hashref ) { + my ($sql, $pagination) = + $ASTPP->pagination( sql_select => $sql_select, + sql_count => $sql_count, + results_per_page=> $config->{results_per_page}, + ve => $params->{ve}, + te => $params->{ee}, + + ); + my $results = $astpp_db->prepare($sql); + $results->execute; + while ( my $counterinfo = $results->fetchrow_hashref ) { print STDERR "COUNTER: " . $counterinfo->{id} if $config->{debug} == 1; my (%row); - - # $row{} = $name; - # $row{balance} = $balance / 10000; - # $row{call_count} = $record->{"COUNT(*)"}; $row{id} = $counterinfo->{id}; - $row{package} = $counterinfo->{package}; + $row{package} = $counterinfo->{name}; $row{account} = $counterinfo->{account}; $row{seconds} = $counterinfo->{seconds}; push( @counter_list, \%row ); } - if ( $total_entries >= 1 ) - { #This section only applies if we have more than 1 page. - $pagination = - "<a href=\"astpp-admin.cgi?mode=" - . gettext("Counters") . "&ve=" - . $params->{ve} . "&te=" - . $total_entries - . "&pg=1\">" - . gettext("First Page") - . "</a> | "; - $pagination .= scalar $pgr->get_navi_html(); - $pagination .= - "<a href=\"astpp-admin.cgi?mode=" - . gettext("Counters") . "&ve=" - . $params->{ve} . "&te=" - . $total_entries . "&pg=" - . $pgr->get_last_page() . "\">" - . gettext("Last Page") . "</a>"; - } - else { - $pagination = gettext("Page 1 of 1"); - } $template->param( counter_list => \@counter_list ); $template->param( pagination => $pagination ); return $template->output; @@ -8020,72 +7825,33 @@ sub build_packages() { my ( $sql, $record, $count, $tmp, $pageno, $pagesrequired ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; + my $template = + HTML::Template->new( + filename => '/var/lib/astpp/templates/packages-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); if ( $params->{limit} < 1 ) { $params->{limit} = 0 } my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } - if ( !$params->{action} ) { - $params->{action} = gettext("Information..."); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); + $template->param( pricelists => popup_menu( + -name => 'pricelist', + -values => \@pricelists + )); if ( $params->{action} eq gettext("Edit...") ) { - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } - $tmp = + $tmp = "SELECT * FROM packages WHERE id = " . $astpp_db->quote( $params->{id} ); $sql = $astpp_db->prepare($tmp); $sql->execute; $record = $sql->fetchrow_hashref; $sql->finish; - $body = start_form; - $body .= - "<table class=\"default\">" - . "<tr class=\"header\"><td>" - . hidden( -name => "mode", -value => gettext("Packages") ) - . hidden( -name => "id", -value => $params->{id} ) - . gettext("Counter Name") - . "</td><td>" - . gettext("Pricelist") - . "</td><td>" - . gettext("Pattern") - . "</td><td>" - . gettext("Included Seconds") - . "</td><td>" - . gettext("Action") - . "</td></tr>"; - $body .= "<tr><td>" - . textfield( - -name => 'name', - -size => 20, - -default => $record->{name} - ) - . "</td><td>" - . popup_menu( - -name => 'pricelist', + $template->param(id => $params->{id} ); + $template->param(current_name => $record->{name} ); + $template->param(edit_pricelists => popup_menu( + -name => 'edit_pricelist', -values => \@pricelists, - -default => $record->{pricelist} - ) - . "</td><td>" - . textfield( - -name => 'pattern', - -size => 30, - -default => $record->{pattern} - ) - . "</td><td>" - . textfield( - -name => 'includedseconds', - -size => 6, - -default => $record->{includedseconds} - ) - . "</td><td>" - . submit( -name => 'action', -value => gettext("Save...") ) - . "</td></tr> -</table> -"; - return $body; + -default => $record->{pricelist} )); + $template->param(current_pattern => $record->{pattern}); + $template->param(current_includedseconds => $record->{includedseconds}); } elsif ( $params->{action} eq gettext("Insert...") ) { my $tmp = @@ -8111,13 +7877,14 @@ } elsif ( $params->{action} eq gettext("Save...") ) { my $tmp = - "UPDATE pricelists SET" . " name=" - . $astpp_db->quote( $params->{name} ) . ", " . " inc=" - . $astpp_db->quote( $params->{inc} ) . ", " - . " markup=" - . $astpp_db->quote( $params->{markup} ) + "UPDATE packages SET name= " + . $astpp_db->quote( $params->{edit_name} ) . ", pricelist = " + . $astpp_db->quote( $params->{edit_pricelist} ) . ", pattern=" + . $astpp_db->quote( $params->{edit_pattern} ) . ", includedseconds=" + . $astpp_db->quote( $params->{edit_includedseconds} ) . " WHERE id = " . $astpp_db->quote( $params->{id} ); + print STDERR $tmp if $config->{debug} == 1; if ( $astpp_db->do($tmp) ) { $status .= gettext("Package: ") @@ -8129,7 +7896,6 @@ gettext("Package: ") . $params->{name} . gettext(" Failed to Update!"); - print STDERR $tmp if $config->{debug} == 1; } $params->{action} = gettext("Information..."); } @@ -8152,158 +7918,44 @@ } $params->{action} = gettext("Information..."); } - elsif ( $params->{action} eq gettext("Add...") ) { - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = ( $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } - $body = start_form; - $body .= - "<table class=\"default\">" - . "<tr class=\"header\"><td>" - . hidden( -name => "mode", -value => gettext("Packages") ) - . gettext("Counter Name") - . "</td><td>" - . gettext("Pricelist") - . "</td><td>" - . gettext("Pattern") - . "</td><td>" - . gettext("Included Seconds") - . "</td><td>" - . gettext("Action") - . "</td></tr> -"; - $body .= "<tr><td>" - . textfield( - -name => 'name', - -size => 20 - ) - . "</td><td>" - . popup_menu( - -name => 'pricelist', - -values => \@pricelists - ) - . "</td><td>" - . textfield( - -name => 'pattern', - -size => 30 - ) - . "</td><td>" - . textfield( - -name => 'includedseconds', - -size => 6 - ) - . "</td><td>" - . submit( -name => 'action', -value => gettext("Insert...") ) - . "</td></tr> -</table> -"; - return $body; + if ( $params->{logintype} == 2 ) { + $sql_select = + "SELECT * FROM packages WHERE status < 2 AND pricelist IN(SELECT name FROM pricelists WHERE reseller IS NULL) ORDER BY id"; + $sql_count = + "SELECT * FROM packages WHERE status < 2 AND pricelist IN(SELECT name FROM pricelists WHERE reseller IS NULL) ORDER BY id"; } - if ( $params->{action} eq gettext("Information...") ) { - $body = start_form; - $body .= - "<table class=\"default\">" - . "<tr><td>" - . submit( -name => 'action', -value => gettext("Add...") ) - . "</td></tr> -" - . "<tr class=\"header\"><td>" - . hidden( -name => "mode", -value => gettext("Packages") ) - . gettext("Counter Name") - . "</td><td>" - . gettext("Pricelist") - . "</td><td>" - . gettext("Pattern") - . "</td><td>" - . gettext("Included Seconds") - . "</td><td>" - . gettext("Action") - . "</td></tr> -"; - $tmp = "SELECT * FROM packages WHERE status < 2"; - $sql = $astpp_db->prepare($tmp); - $sql->execute - || return gettext("Something is wrong with the ASTPP database!") - . "\n"; - my $results = $sql->rows; - my $pagesrequired = ceil( $results / $results_per_page ); - print gettext("Pages Required:") . " $pagesrequired\n" - if ( $config->{debug} == 1 ); - $sql->finish; - $sql = - $astpp_db->prepare( -"SELECT * FROM packages WHERE status < 2 ORDER BY name limit $params->{limit} , $results_per_page" - ); - $sql->execute - || return gettext("Something is wrong with the ASTPP database!") - . "\n"; - $count = 0; - - while ( my $packageinfo = $sql->fetchrow_hashref ) { - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $count++; - $body .= - "<td>$packageinfo->{name}" - . "</td><td>$packageinfo->{pricelist}" - . "</td><td>$packageinfo->{pattern}" - . "</td><td>$packageinfo->{includedseconds}" - . "</td><td><a href=\"astpp-admin.cgi?mode=" - . gettext("Packages") - . "&action=" - . gettext("Edit...") . "&id=" - . $packageinfo->{id} . "\">" - . gettext("Edit...") . "</a>" - . " <a href=\"astpp-admin.cgi?mode=" - . gettext("Packages") - . "&action=" - . gettext("Deactivate...") . "&id=" - . $packageinfo->{id} . "\">" - . gettext("Deactivate...") . "</a>" - . "</td></tr>"; - } - $body .= "</table>"; - for ( my $i = 0 ; $i <= $pagesrequired - 1 ; $i++ ) { - if ( $i == 0 ) { - if ( $params->{limit} != 0 ) { - $body .= - "<a href=\"astpp-admin.cgi?mode=" - . gettext("Packages") - . "&limit=0\">"; - $body .= $i + 1; - $body .= "</a>"; - } - else { - $body .= $i + 1; - } - } - if ( $i > 0 ) { - if ( $params->{limit} != ( $i * $results_per_page ) ) { - $body .= - "<a href=\"astpp-admin.cgi?mode=" - . gettext("Packages") - . "&limit="; - $body .= ( $i * $results_per_page ); - $body .= "\">\n"; - $body .= $i + 1 . "</a>"; - } - else { - $pageno = $i + 1; - $body .= " |"; - } - } - } - $body .= ""; - $body .= - gettext("Page") . " $pageno " . gettext("of") . " $pagesrequired"; + elsif ( $params->{logintype} == 1 ) { + $sql_select = + "SELECT * FROM packages WHERE status < 2 AND pricelist IN(SELECT name FROM pricelists WHERE reseller = " + . $astpp_db->quote( $params->{username} ) . ") ORDER BY id"; + $sql_count = + "SELECT * FROM packages WHERE status < 2 AND pricelist IN(SELECT name FROM pricelists WHERE reseller = " + . $astpp_db->quote( $params->{username} ) . ") ORDER BY id"; } + my ($sql, $pagination) = + $ASTPP->pagination( sql_select => $sql_select, + sql_count => $sql_count, + results_per_page=> $config->{results_per_page}, + ve => $params->{ve}, + te => $params->{ee}, + + ); + my $results = $astpp_db->prepare($sql); + $results->execute; + while ( my $packageinfo = $results->fetchrow_hashref ) { + print STDERR "PACKAGE: " . $packgeinfo->{id} if $config->{debug} == 1; + my (%row); + $row{id} = $packageinfo->{id}; + $row{name} = $packageinfo->{name}; + $row{pattern} = $packageinfo->{pattern}; + $row{pricelist} = $packageinfo->{pricelist}; + $row{includedseconds} = $packageinfo->{includedseconds}; + push( @package_list, \%row ); + } + $template->param( package_list => \@package_list ); + $template->param( pagination => $pagination ); + $template->param( status => $status ); + return $template->output; return $body; } @@ -9418,12 +9070,7 @@ sub build_calc_charge() { my ( $status, $body, $cost, $length, $increment ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = ( $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); if ( $params->{action} eq gettext("Price Call...") ) { my $branddata = &get_pricelist( $astpp_db, $params->{pricelist} ); my $numdata = &get_route( $astpp_db, $config, $params->{phonenumber}, @@ -9552,6 +9199,9 @@ } @modes = sort @modes; push @currency, $config->{currency}; + $ASTPP->set_astpp_db($astpp_db); + $ASTPP->set_cdr_db($cdr_db); +# $ASTPP->set_config(\%config); } ############### Integration with Realtime starts here ####################### @@ -10898,12 +10548,7 @@ -values => \@language, -default => $config->{default_language} ); - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); $pricelists = popup_menu( -name => "pricelist", -values => \@pricelists @@ -11546,6 +11191,7 @@ '1' => gettext("Reseller"), '5' => gettext("CallShop") ); + $params->{logged_in_reseller} = $params->{username}; } elsif ( $params->{logintype} == 2 ) { print STDERR "ASTPP ADMINISTRATOR LOGIN\n" if $config->{debug} == 1; @@ -11578,6 +11224,7 @@ '4' => gettext("Customer Service"), '5' => gettext("CallShop") ); + $params->{logged_in_reseller} = ""; } elsif ( $params->{logintype} == 3 ) { # Vendor Login - Vendors are only allowed to look at stuff that pertains to them. Modified: trunk/astpp-callingcards.agi =================================================================== --- trunk/astpp-callingcards.agi 2007-11-03 03:07:15 UTC (rev 2149) +++ trunk/astpp-callingcards.agi 2007-11-03 21:35:25 UTC (rev 2150) @@ -58,6 +58,7 @@ } $cdr_db = &cdr_connect_db( $config, @output ); $ASTPP->set_cdr_db($cdr_db); + $ASTPP->set_config($config); $sound = &define_sounds($astpp_db); } Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-03 03:07:15 UTC (rev 2149) +++ trunk/astpp-common.pl 2007-11-03 21:35:25 UTC (rev 2150) @@ -3121,7 +3121,7 @@ . $astpp_db->quote($number) . " RLIKE pattern AND pricelist = " . $astpp_db->quote( $carddata->{pricelist} ) - . " ORDER BY LENGTH(pattern) DESC" ); + . " ORDER BY LENGTH(pattern) DESC LIMIT 1" ); $sql->execute; $record = $sql->fetchrow_hashref; $sql->finish; @@ -3663,7 +3663,7 @@ sub rating() { # This routine recieves a specific cdr and takes care of rating it and of marking it as rated. It bills resellers as appropriate. my ( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, @output ) = @_; my ( $increment, $numdata, $package, $notes, $status ); - print STDERR "----------------------\n"; + print STDERR "----------------------------------------------------------------\n"; print STDERR "uniqueid: $cdrinfo->{uniqueid}, cardno: $carddata->{number}, phoneno: $cdrinfo->{dst}, Userfield: $cdrinfo->{userfield}\n"; print STDERR @@ -3678,7 +3678,7 @@ if $config->{astcdr} == 1; print STDERR "ERROR - ERROR - ERROR - ERROR - ERROR \n"; print STDERR "NO MATCHING PATTERN\n"; - print STDERR "----------------------\n"; + print STDERR "----------------------------------------------------------------\n"; } else { print STDERR "FOUND A MATCHING PATTERN.\n"; @@ -3687,21 +3687,22 @@ "pricelistData: $branddata->{name} $branddata->{markup} $branddata->{inc} $branddata->{status}\n"; my $package = &get_package( $astpp_db, $carddata, $cdrinfo->{dst} ); - if ($package->{name}) { + if ($package->{id}) { my $counter = - &get_counter( $astpp_db, $package->{name}, + &get_counter( $astpp_db, $package->{id}, $carddata->{number} ); my $difference; if ( !$counter->{id}) { my $tmp = "INSERT INTO counters (package,account) VALUES (" - . $astpp_db->quote( $package->{name} ) . ", " + . $astpp_db->quote( $package->{id} ) . ", " . $astpp_db->quote( $carddata->{number} ) . ")"; - print STDERR $tmp . "/n" if $config->{debug} == 1; + print STDERR "/n" . $tmp . "/n" if $config->{debug} == 1; $astpp_db->do($tmp); $counter = - &get_counter( $astpp_db, $package->{name}, + &get_counter( $astpp_db, $package->{id}, $carddata->{number} ); + print STDERR "JUST CREATED COUNTER: $counter->{id}\n" if $config->{debug} == 1; } if ( $package->{includedseconds} > $counter->{seconds}) { my $availableseconds = $package->{includedseconds} - $counter->{seconds}; @@ -3859,10 +3860,10 @@ } elsif ( $cdrinfo->{accountcode} ) { $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata); - $cdrinfo = $savedcdrinfo; if ( $status == 1 ) { my $previous_account = $carddata->{number}; while ( $carddata->{reseller} ne "" ) { +# my $cdrinfo = &get_cdr( $cdr_db, $uniqueid ); # my $reseller = $carddata->{reseller}; print STDERR "Charge $uniqueid to $carddata->{reseller}" if $config->{debug} == 1; $carddata = &get_account( $astpp_db, $carddata->{reseller} ); Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2007-11-03 03:07:15 UTC (rev 2149) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2007-11-03 21:35:25 UTC (rev 2150) @@ -33,22 +33,49 @@ { my ($class,%arg) = @_; bless { - _astpp_db => $_[1], - _verbosity_level => $arg{verbosity_level} || 1, - _asterisk_agi => $_[3], - _cdr_db => $_[4], - _verbosity_item_level => $arg{verbosity_item_level} || 1, - _pagination_script => $arg{pagination_script} || "astpp-admin.cgi", + _astpp_db => $_[1], + _verbosity => $arg{verbosity_level} || 1, + _asterisk_agi => $_[3], + _cdr_db => $_[4], + _verbosity_item_level => $arg{verbosity_item_level} || 1, + _script => $arg{script} || "astpp-admin.cgi", + _config => $_[7], }, $class; } +sub set_verbosity_level { $_[0]->{_verbosity_level} } #Sets the verbosity level. sub set_verbosity { $_[0]->{_verbosity_level} } #Sets the verbosity level. -sub set_asterisk_agi { $_[0]->{_asterisk_agi} } #Sets the verbosity level. -sub set_astpp_db { $_[0]->{_astpp_db} } #Sets the verbosity level. -sub set_cdr_db {$_[0]->{_cdr_db} } #Sets the verbosity level. -sub set_pagination_script {$_[00]->{_pagination_script} } +sub set_astpp_db +{ + my ($self, $astpp_db) = @_; + $self->{_astpp_db} = $astpp_db if $astpp_db; +} +sub set_cdr_db +{ + my ($self, $cdr_db) = @_; + $self->{_cdr_db} = $cdr_db if $cdr_db; +} + +sub set_asterisk_agi +{ + my ($self, $asterisk_agi) = @_; + $self->{_asterisk_agi} = $asterisk_agi if $asterisk_agi; +} + +sub set_pagination_script #Set the location of the script we are working in. +{ + my ($self, $script) = @_; + $self->{_script} = $script if $script; +} + +#sub set_config +#{ +# my ($self, %config_hash) = @_; +# $self->{_config} = %config_hash if %config_hash; +#} + sub debug #Prints debugging if appropriate # { @@ -64,43 +91,110 @@ sub pagination #Returns the pagination html code to assist with navigation. { -my ($self, %arg) = @_; + my ($self, %arg) = @_; # We are using Data::Paginate for the real tough stuff. # Therefore we need to pass the Data::Paginate stuff # as well as the total number of pages. - # total_entries = Total number of pages. - # pagination_script = Script name. + # # mode = What mode do we want. - # pgr = Pass along Data::Paginate - # ve = - # navi_html = - # last_page = + # sql = SQL to select what we want without the limit commands. + # + # Check to see if there is a parameter called "results_per_page" set. If it's set it overrides our defaults. + if (!$arg{results_per_page} || $arg{results_per_page} > 1 ) { + $arg{results_per_page} = 25; + } + ## START PAGINATION CODE + # set total_entries *once* then pass it around + # in the object's links from then on for efficiency: + my ($record,$sql); + my $verify = $arg{ve} || ''; + my $total_entries = int( $arg{te} ); + my $te_match = $total_entries + ? Digest::MD5::md5_hex("unique_cypher-$total_entries-$arg{sql_check}") : ''; + if ( !$total_entries || $verify ne $te_match ) { + # its not ok so re-fetch + $sql = $self->{_astpp_db}->prepare($arg{sql_count}); + $sql->execute; + $record = $sql->fetchrow_hashref; + $total_entries = $record->{"COUNT(*)"}; + $sql->finish; + $te_match = Digest::MD5::md5_hex("unique_cypher-$total_entries-$arg{sql_check}"); + } + + #if ($te_match <= 0) { $te_match = 0; } + if ( $total_entries <= 0 ) { $total_entries = 1; } + + # otherwise its all ok so use it + my $pgr = Data::Paginate->new( + { + 'start_array_index_at_zero' => 1, + 'total_entries' => $total_entries, + 'entries_per_page' => $arg{results_per_page}, + 'total_entries_verify_param_value' => $te_match + } + ); + + # only SELECT current page's records: + if ( $total_entries > $pgr->get_entries_on_this_page() ) { + $sql = + $arg{sql_select} . " LIMIT " + . ( $pgr->get_first() - 1 ) . ", " + . $pgr->get_entries_on_this_page(); + } + else { + $sql = $arg{sql_select}; + } + # First we decide if we have multiple pages... + if ($arg{total_entries} > 1) { my $html; $html = - "<a href=\"" . $self->{_pagination_script} . "?mode=" + "<a href=\"" . $self->{_script} . "?mode=" . $arg{mode} . "&ve=" . $arg{ve} . "&te=" - . $arg{total_entries} + . $total_entries . "&pg=1\">" - . gettext("First Page") + . "First Page" . "</a> | " - . scalar $arg{navi_html} - . "<a href=\"" . $self->{_pagination_script} . "?mode=" + . scalar $pgr->get_navi_html() + . "<a href=\"" . $self->{_script} . "?mode=" . $arg{mode} . "&ve=" . $arg{ve} . "&te=" . $arg{total_entries} . "&pg=" . $arg{last_page} . "\">" - . gettext("Last Page") . "</a>"; - return $html; + . "Last Page" . "</a>"; + return ($sql,$html); } else { - return gettext("Page 1 of 1"); + return ($sql,"Page 1 of 1"); } } +sub list_pricelists +{ + my ($self, %arg) = @_; # Return a list of all pricelists either for the appropriate reseller or without reseller. + my ( $sql, @pricelistlist, $row, $tmp ); + if ( !$arg{reseller} || $arg{reseller} eq "") { + $tmp = + "SELECT name FROM pricelists WHERE status < 2 AND reseller IS NULL ORDER BY name"; + } + else { + $tmp = + "SELECT name FROM pricelists WHERE status < 2 AND reseller = " + . $self->{_astpp_db}->quote($arg{reseller}) + . " ORDER BY name"; + } + $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + while ( $row = $sql->fetchrow_hashref ) { + push @pricelistlist, $row->{name}; + } + $sql->finish; + return @pricelistlist; +} + # Preloaded methods go here. 1; Modified: trunk/templates/account-info.tpl =================================================================== --- trunk/templates/account-info.tpl 2007-11-03 03:07:15 UTC (rev 2149) +++ trunk/templates/account-info.tpl 2007-11-03 21:35:25 UTC (rev 2150) @@ -183,12 +183,13 @@ <td>Date & Time</td> <td>Caller*ID</td> <td>Called Number</td> - <td>Trunk</td> <td>Disposition</td> <td>Billable Seconds</td> <td>Charge</td> <td>Credit</td> <td>Notes</td> + <td>Cost</td> + <td>Profit</td> </tr> <TMPL_LOOP NAME="account_cdr_list"> <TR> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-03 22:03:18
|
Revision: 2151 http://astpp.svn.sourceforge.net/astpp/?rev=2151&view=rev Author: darrenkw Date: 2007-11-03 15:03:16 -0700 (Sat, 03 Nov 2007) Log Message: ----------- Resolved a bug that was trying to incorrectly pass a hash to the ASTPP module. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-callingcards.agi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-03 21:35:25 UTC (rev 2150) +++ trunk/astpp-admin.cgi 2007-11-03 22:03:16 UTC (rev 2151) @@ -423,11 +423,6 @@ return &build_admin_vendor_report() if $params->{mode} eq gettext("Vendor Report"); -# return &build_add_booth() if $params->{mode} eq gettext("Create Booth"); -# return &build_remove_booth() if $params->{mode} eq gettext("Remove Booth"); -# return &build_list_booths() if $params->{mode} eq gettext("List Booths"); -# return &build_view_booth() if $params->{mode} eq gettext("View Booth"); - return &build_homepage() if $params->{mode} eq gettext("Home Page") || $params->{mode} eq gettext("Home") @@ -552,9 +547,6 @@ elsif ( $params->{logintype} == 5 ) { #Call Shop Login return &build_pricelists() if $params->{mode} eq gettext("Pricelists"); return &build_routes() if $params->{mode} eq gettext("Routes"); - -# return &build_add_callshop() if $params->{mode} eq gettext("Create CallShop"); -# return &build_remove_callshop() if $params->{mode} eq gettext("Remove CallShop"); return &build_add_booth() if $params->{mode} eq gettext("Create Booth"); return &build_remove_booth() if $params->{mode} eq gettext("Remove Booth"); @@ -9153,12 +9145,12 @@ HTML::Template->new( filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); if ( $params->{logintype} == 2 ) { - $tmp = "SELECT * FROM system"; + $tmp = "SELECT * FROM system ORDER BY reseller,name"; } elsif ( $params->{logintype} == 1 ) { $tmp = "SELECT * FROM system WHERE reseller = " - . $astpp_db->quote( $params->{username} ); + . $astpp_db->quote( $params->{username} ) . " ORDER BY name"; } print STDERR $tmp if $config->{debug} == 1; my $sql = $astpp_db->prepare($tmp); @@ -9201,7 +9193,6 @@ push @currency, $config->{currency}; $ASTPP->set_astpp_db($astpp_db); $ASTPP->set_cdr_db($cdr_db); -# $ASTPP->set_config(\%config); } ############### Integration with Realtime starts here ####################### Modified: trunk/astpp-callingcards.agi =================================================================== --- trunk/astpp-callingcards.agi 2007-11-03 21:35:25 UTC (rev 2150) +++ trunk/astpp-callingcards.agi 2007-11-03 22:03:16 UTC (rev 2151) @@ -58,7 +58,6 @@ } $cdr_db = &cdr_connect_db( $config, @output ); $ASTPP->set_cdr_db($cdr_db); - $ASTPP->set_config($config); $sound = &define_sounds($astpp_db); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-03 22:29:22
|
Revision: 2152 http://astpp.svn.sourceforge.net/astpp/?rev=2152&view=rev Author: darrenkw Date: 2007-11-03 15:29:23 -0700 (Sat, 03 Nov 2007) Log Message: ----------- Resolve bug #305 Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-common.pl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-03 22:03:16 UTC (rev 2151) +++ trunk/astpp-admin.cgi 2007-11-03 22:29:23 UTC (rev 2152) @@ -6373,7 +6373,8 @@ . "</td><td>" . popup_menu( -name => 'account', - -values => \@accountlist + -values => \@accountlist, + -default => "" ) . "</td><td>" . textfield( Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-03 22:03:16 UTC (rev 2151) +++ trunk/astpp-common.pl 2007-11-03 22:29:23 UTC (rev 2152) @@ -4014,7 +4014,7 @@ sub update_list_cards() { my ($astpp_db, $config, $sweep) = @_; my ( $sql, @cardlist, $row ); - if ( $sweep eq "" ) { + if (!$sweep || $sweep eq "" ) { $sql = $astpp_db->prepare( "SELECT number FROM accounts WHERE status < 2 AND reseller IN (NULL,'') AND posttoexternal = 0 " @@ -4445,14 +4445,14 @@ sub calc_charges() { my ($astpp_db, $config, $cardno, @output) = @_; - my $cost; + my $cost = 0; my @chargelist = &get_charges($astpp_db, $config, $cardno); foreach my $id (@chargelist) { print STDERR "ID: $id\n" if $config->{debug} == 1; my $chargeinfo = &get_astpp_cdr( $astpp_db, $id ); - $cost = $cost + $chargeinfo->{debit}; + $cost = $cost + $chargeinfo->{debit} if $chargeinfo->{debit}; print STDERR "Debit: $chargeinfo->{debit} Credit: $chargeinfo->{credit}\n" if $config->{debug} == 1; - $cost = $cost - $chargeinfo->{credit}; + $cost = $cost - $chargeinfo->{credit} if $chargeinfo->{credit}; &markbilled( $astpp_db, $id, 1 ); } return $cost; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-03 23:06:09
|
Revision: 2153 http://astpp.svn.sourceforge.net/astpp/?rev=2153&view=rev Author: darrenkw Date: 2007-11-03 16:06:13 -0700 (Sat, 03 Nov 2007) Log Message: ----------- Start with enhanced logging. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-03 22:29:23 UTC (rev 2152) +++ trunk/astpp-admin.cgi 2007-11-03 23:06:13 UTC (rev 2153) @@ -65,7 +65,7 @@ $freepbx_db $rt_db $openser_db $ASTPP); my $starttime = [gettimeofday]; $ASTPP = ASTPP->new; -$ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to be. +$ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. $ASTPP->set_asterisk_agi($AGI); $ASTPP->set_pagination_script("astpp-admin.cgi"); my @Home = ( gettext("Home Page") ); @@ -220,14 +220,10 @@ $status .= gettext("Login Failed") . "<br>"; print header(); } - print STDERR gettext("ASTPP-USER:") . " $params->{username}\n" - if $config->{debug} == 1; - print STDERR gettext("ASTPP-PASS:") . " $params->{password}\n" - if $config->{debug} == 1; - print STDERR gettext("ASTPP-AUTHCODE:") . " $config->{auth}\n" - if $config->{debug} == 1; - print STDERR gettext("ASTPP-USER-COUNT:") . " $count" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-USER:") . " $params->{username}"); + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-PASS:") . " $params->{password}"); + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-AUTHCODE:") . " $config->{auth}"); + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-USER-COUNT:") . " $count"); return ( $params->{mode}, $count ); } @@ -272,13 +268,13 @@ $status .= gettext("Login Failed") . "<br>"; $count = 0; } - print STDERR gettext("ASTPP-USER:") . " $params->{username}\n" + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-USER:") . " $params->{username}") if $config->{debug} == 1 && $params->{username}; - print STDERR gettext("ASTPP-PASS:") . " $params->{password}\n" + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-PASS:") . " $params->{password}") if $config->{debug} == 1 && $params->{password}; - print STDERR gettext("ASTPP-AUTHCODE:") . " $config->{auth}\n" + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-AUTHCODE:") . " $config->{auth}") if $config->{debug} == 1; - print STDERR gettext("ASTPP-USER-COUNT:") . " $count" + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-USER-COUNT:") . " $count") if $config->{debug} == 1; print header(); return $count; @@ -305,9 +301,7 @@ my ($selected) = @_; my ( $tmp, $body, $x ); my $i = 0; - print STDERR "START OF MENU" if $config->{debug} == 1; foreach $tmp (@modes) { - print STDERR $tmp . "\n" if $config->{debug} == 1; $body .= "<div class=\"ts_ddm\" name=tt$i id=tt$i style=\"visibility:hidden;width:200;background-color:#CCCCFF;\"onMouseover=\"clearhidemenu()\" onMouseout=\"dynamichide(event)\"><table width=100\% border=0 cellspacing=0 cellpadding=0>"; my $j = 0; @@ -334,9 +328,6 @@ sub build_body() { if ( $params->{logintype} == 2 ) { #Admin Login - - # return &build_configure() - # if $params->{mode} eq gettext("Configuration"); return &build_providers() if $params->{mode} eq gettext("Providers"); return &build_trunks() if $params->{mode} eq gettext("Trunks"); return &build_outbound_routes() @@ -991,7 +982,7 @@ my ($bth,$dst,$idd,$atmpt,$cmplt,$asr,$acd,$mcd,$act,$bill,$price,$cost); my $query = "CREATE TEMPORARY TABLE $table SELECT * FROM cdrs WHERE uniqueid != '' AND $where"; $sth = $astpp_db->do($query) || return gettext("Something is wrong with astpp database"). "\n"; - print STDERR " SQL: $query \n " if $config->{debug} == 1; + $ASTPP->debug( user => $param->{username}, debug => " SQL: $query ");; my $sql = $astpp_db->prepare("SELECT DISTINCT cardnum AS $name FROM $table"); $sql->execute() || return gettext("Something is wrong with astpp database"). "\n"; @@ -1041,7 +1032,6 @@ $in = substr($in,0,-1) if length($in) > 0; $sql3->finish; - print STDERR " SQL: SELECT SUM(duration) AS actual FROM cdr WHERE uniqueid IN ($in) \n " if $config->{debug} == 1; my $sql4 = $cdr_db->prepare("SELECT SUM(duration) AS actual FROM cdr WHERE uniqueid IN ($in)"); $sql4->execute() || return gettext("Something is wrong with cdr database"). "\n"; my $row4 = $sql4->fetchrow_hashref(); @@ -1156,7 +1146,7 @@ and calldate <= " . $cdr_db->quote($ed) . " and (dstchannel like '$row->{tech}/$row->{path}%' or dstchannel like '$row->{tech}\[$row->{path}\]%' ) "; - print STDERR " SQL: $sql1 \n " if $config->{debug} == 1; + $ASTPP->debug( user => $param->{username}, debug => " SQL: $sql1 \n "); my $sth1 = $cdr_db->prepare($sql1); $sth1->execute(); my $ref1 = $sth1->fetchrow_hashref(); @@ -1172,7 +1162,7 @@ or dstchannel like '$row->{tech}\[$row->{path}\]%' ) "; my $sth2 = $cdr_db->prepare($sql2); - print STDERR " SQL: $sql2 \n " if $config->{debug} == 1; + $ASTPP->debug( user => $param->{username}, debug =>" SQL: $sql2"); $sth2->execute(); my $ref2 = $sth2->fetchrow_hashref(); $sth2->finish; @@ -1185,7 +1175,7 @@ or dstchannel like '$row->{tech}\[$row->{path}\]%' ) "; my $sth3 = $cdr_db->prepare($sql3); - print STDERR " SQL: $sql3 \n " if $config->{debug} == 1; + $ASTPP->debug( user => $param->{username}, debug =>" SQL: $sql3"); $sth3->execute(); my $ref3 = $sth3->fetchrow_hashref(); $sth3->finish; Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2007-11-03 22:29:23 UTC (rev 2152) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2007-11-03 23:06:13 UTC (rev 2153) @@ -34,7 +34,7 @@ my ($class,%arg) = @_; bless { _astpp_db => $_[1], - _verbosity => $arg{verbosity_level} || 1, + _verbosity_level => $arg{verbosity_level} || 1, _asterisk_agi => $_[3], _cdr_db => $_[4], _verbosity_item_level => $arg{verbosity_item_level} || 1, @@ -44,7 +44,7 @@ } sub set_verbosity_level { $_[0]->{_verbosity_level} } #Sets the verbosity level. -sub set_verbosity { $_[0]->{_verbosity_level} } #Sets the verbosity level. +sub set_verbosity { $_[0]->{_verbosity_level} } #Sets the verbosity level. One of these needs to be deprecated. sub set_astpp_db { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-17 23:15:23
|
Revision: 2160 http://astpp.svn.sourceforge.net/astpp/?rev=2160&view=rev Author: darrenkw Date: 2007-11-17 15:15:16 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Resolved: [ 1827828 ] SIP user not created due to type = NULL Also resolved an issue preventing pricelists from showing when creating a callshop. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/templates/account-create.tpl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-17 22:28:28 UTC (rev 2159) +++ trunk/astpp-admin.cgi 2007-11-17 23:15:16 UTC (rev 2160) @@ -2252,6 +2252,13 @@ ) ); $template->param( + devicetype => popup_menu( + -name => "devicetype", + -values => \@devicetypes, + -default => $config->{rt_sip_type} + ) + ); + $template->param( sweep_menu => popup_menu( -name => "sweep", -values => \%sweeplist ) ); $template->param( default_context => $config->{default_context} ); $template->param( @@ -10543,7 +10550,7 @@ -values => \@language, -default => $config->{default_language} ); - @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); $pricelists = popup_menu( -name => "pricelist", -values => \@pricelists @@ -11273,6 +11280,7 @@ '4' => gettext("Customer Service"), '5' => gettext("CallShops") ); + $params->{logged_in_reseller} = $params->{username}; } else { Modified: trunk/templates/account-create.tpl =================================================================== --- trunk/templates/account-create.tpl 2007-11-17 22:28:28 UTC (rev 2159) +++ trunk/templates/account-create.tpl 2007-11-17 23:15:16 UTC (rev 2160) @@ -60,7 +60,8 @@ <tr class="rowtwo"> <td><input type="text" name="postal_code" size="20" /></td> <td><input type="text" name="province" size="20" /></td> - <td colspan=2><TMPL_VAR NAME="country_menu"></td> + <td colspan=2><TMPL_VAR NAME="country_menu"></td> + <td><TMPL_VAR NAME="devicetype"></td> </tr> <tr class="header"> <td>Telephone #1</td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-18 00:26:30
|
Revision: 2161 http://astpp.svn.sourceforge.net/astpp/?rev=2161&view=rev Author: darrenkw Date: 2007-11-17 16:26:27 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Resolved: FS#335 ?\194?\151 Show list of SIP and IAX2 accounts in "View Details" Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-common.pl trunk/templates/account-info.tpl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-17 23:15:16 UTC (rev 2160) +++ trunk/astpp-admin.cgi 2007-11-18 00:26:27 UTC (rev 2161) @@ -1915,6 +1915,59 @@ } $template->param( account_ip_list => \@account_ip_list); $template->param( currency => $currency[0]); + +## List the SIP/IAX2 devices belonging to this account. ## + my @account_device_list; + if ($rt_db) { + my @sip_names = &list_sip_account_rt($rt_db,$config,$accountinfo->{number}, $accountinfo->{cc}); + my @iax_names = &list_iax_account_rt($rt_db,$config,$accountinfo->{number}, $accountinfo->{cc}); + foreach my $name (@sip_names) { + my $deviceinfo = &get_sip_account_rt($rt_db,$config,$name); + my %row; + $row{tech} = "SIP"; + $row{type} = $deviceinfo->{type}; + $row{username} = $deviceinfo->{username}; + $row{secret} = $deviceinfo->{secret}; + $row{context} = $deviceinfo->{context}; + push(@account_device_list, \%row); + } + foreach my $name (@iax_names) { + my $deviceinfo = &get_iax_account_rt($rt_db,$config,$name); + my %row; + $row{tech} = "IAX2"; + $row{type} = $deviceinfo->{type}; + $row{username} = $deviceinfo->{username}; + $row{secret} = $deviceinfo->{secret}; + $row{context} = $deviceinfo->{context}; + push(@account_device_list, \%row); + } + } + if ($freepbx_db) { + my @sip_names = &list_sip_account_freepbx($freepbx_db,$config,$accountinfo->{number}, $accountinfo->{cc}); + my @iax_names = &list_iax_account_freepbx($freepbx_db,$config,$accountinfo->{number}, $accountinfo->{cc}); + foreach my $name (@sip_names) { + my $deviceinfo = &get_sip_account_freepbx($freepbx_db,$config,$name); + my %row; + $row{tech} = "SIP"; + $row{type} = $deviceinfo->{type}; + $row{username} = $deviceinfo->{username}; + $row{secret} = $deviceinfo->{secret}; + $row{context} = $deviceinfo->{context}; + push(@account_device_list, \%row); + } + foreach my $name (@iax_names) { + my $deviceinfo = &get_iax_account_freepbx($freepbx_db,$config,$name); + my %row; + $row{tech} = "IAX2"; + $row{type} = $deviceinfo->{type}; + $row{username} = $deviceinfo->{username}; + $row{secret} = $deviceinfo->{secret}; + $row{context} = $deviceinfo->{context}; + push(@account_device_list, \%row); + } + } + $template->param(account_device_list => \@account_device_list); +### End Section ### ($sql, $pagination) = $ASTPP->pagination( sql_select => "SELECT * FROM cdrs WHERE cardnum =" . $astpp_db->quote( $accountinfo->{number} ) @@ -9197,6 +9250,9 @@ $rt_db = &rt_connect_db( $config, @output ); push @modes, gettext("Switch Config"); } + if ( $config->{users_dids_amp} == 1 ) { + $freepbx_db = &freepbx_connect_db( $config, @output ); + } if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-17 23:15:16 UTC (rev 2160) +++ trunk/astpp-common.pl 2007-11-18 00:26:27 UTC (rev 2161) @@ -2341,10 +2341,10 @@ sub list_sip_account_rt() { my ( $rt_db, $config, $name, $cc) = @_; my ($tmp,$row, $sql, @devicelist); -# if ($config->{debug} == 1) { + if ($config->{debug} == 1) { print STDERR "NAME: $name"; print STDERR "CC: $cc"; -# } + } $tmp = "SELECT name FROM $config->{rt_sip_table} WHERE accountcode IN (" . $rt_db->quote($name) . "," . $rt_db->quote($cc) . ")"; @@ -2358,6 +2358,30 @@ return @devicelist; } +sub get_sip_account_rt() { + my ($rt_db,$config,$name) = @_; + my $tmp = "SELECT * FROM $config->{rt_sip_table} WHERE name = " + . $rt_db->quote($name) . " LIMIT 1"; + print STDERR "$tmp\n" if $config->{debug} == 1; + my $sql = $rt_db->prepare($tmp); + $sql->execute; + my $record = $sql->fetchrow_hashref; + $sql->finish; + return $record; +} + +sub get_iax_account_rt() { + my ($rt_db,$config,$name) = @_; + my $tmp = "SELECT * FROM $config->{rt_iax_table} WHERE name = " + . $rt_db->quote($name) . " LIMIT 1"; + print STDERR "$tmp\n" if $config->{debug} == 1; + my $sql = $rt_db->prepare($tmp); + $sql->execute; + my $record = $sql->fetchrow_hashref; + $sql->finish; + return $record; +} + # Add a SIP user to the asterisk realtime DB. sub add_sip_user_rt() { my ( $rt_dbh, $config, $name, $secret, $context, $username, @@ -2598,6 +2622,83 @@ ####### OpenSER Integration Ends ############### ####### FreePBX subroutines start here ########### +sub get_iax_account_freepbx(){ + my ($freepbx_db,$config,$name) = @_; + my ($tmp,$record,$sql,$deviceinfo); + $tmp = "SELECT value FROM $config->{freepbx_iax_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'context' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{context} = $record; + $tmp = "SELECT value FROM $config->{freepbx_iax_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'secret' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{secret} = $record; + $tmp = "SELECT value FROM $config->{freepbx_iax_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'type' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{type} = $record; + $tmp = "SELECT value FROM $config->{freepbx_iax_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'username' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{username} = $record; + return $deviceinfo; +} + +sub get_sip_account_freepbx(){ + my ($freepbx_db,$config,$name) = @_; + my ($tmp,$record,$sql,$deviceinfo); + $tmp = "SELECT value FROM $config->{freepbx_sip_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'context' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{context} = $record; + $tmp = "SELECT value FROM $config->{freepbx_sip_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'secret' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{secret} = $record; + $tmp = "SELECT value FROM $config->{freepbx_sip_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'type' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{type} = $record; + $tmp = "SELECT value FROM $config->{freepbx_sip_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'username' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{username} = $record; + return $deviceinfo; +} + + # Return a list of sip devices belong to a specific account sub list_sip_account_freepbx() { my ( $freepbx_db, $config, $name, $cc) = @_; Modified: trunk/templates/account-info.tpl =================================================================== --- trunk/templates/account-info.tpl 2007-11-17 23:15:16 UTC (rev 2160) +++ trunk/templates/account-info.tpl 2007-11-18 00:26:27 UTC (rev 2161) @@ -176,7 +176,30 @@ <td><input name="action" value="Post Charge..." type="submit"></td> </tr> </table> + +<table class="default"> + <tr class="header"> + <td colspan=5>IAX2 & SIP Accounts</td> + </tr> + <tr class="header"> + <td>Tech</td> + <td>Type</td> + <td>Username</td> + <td>Password</td> + <td>Context</td> + </tr> + <TMPL_LOOP NAME="account_device_list"> + <tr> + <td><TMPL_VAR NAME="tech"></td> + <td><TMPL_VAR NAME="type"></td> + <td><TMPL_VAR NAME="username"></td> + <td><TMPL_VAR NAME="secret"></td> + <td><TMPL_VAR NAME="context"></td> + </tr> + </TMPL_LOOP> +</table> + <table class="default"> <tr class="header"> <td>UniqueID</td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-18 03:13:11
|
Revision: 2163 http://astpp.svn.sourceforge.net/astpp/?rev=2163&view=rev Author: darrenkw Date: 2007-11-17 19:13:07 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Added call hangup capabilities. Modified Paths: -------------- trunk/astpp-common.pl trunk/templates/booths-list.tpl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-18 03:12:44 UTC (rev 2162) +++ trunk/astpp-common.pl 2007-11-18 03:13:07 UTC (rev 2163) @@ -3488,6 +3488,18 @@ return (1, $maxlength); } +sub hangup_call() { + my ($astpp_db,$config,$channel) = @_; + use Asterisk::Manager; + my $astman = new Asterisk::Manager; + $astman->user($config->{astman_user}); + $astman->secret($config->{astman_secret}); + $astman->host($config->{astman_host}); + $astman->connect || die $astman->error . "\n"; + my %callout = ( Action => 'Hangup', Channel => $channel); + print STDERR $astman->sendcommand(%callout); +} + # Perfrom callout using the Asterisk Manager Interface. sub perform_callout() { my ($astpp_db,$config,$number,$lcrcontext,$accountcode,$maxretries,$waittime,$retrytime,$clidname,$clidnumber,$context,$extension,%variables) = @_; @@ -3522,36 +3534,11 @@ ActionID => $actionid, Variable => "ACTIONID=$actionid", Priority => '1' ); -# foreach my $variable (@variables) { -# print STDERR "SET: $variable->{name} - $variable->{value} \n"; -# %callout->{Variable} = "$variable->{name}=$variable->{value}"; -# } foreach my $key (keys %callout) { - print STDERR "Key: $key Value: " . $callout{$key} . "\n"; + print STDERR "Key: $key Value: " . $callout{$key} . "\n"; } -print STDERR $astman->sendcommand(%callout); - - -# use Asterisk::Outgoing; -# my $out = new Asterisk::Outgoing; -# my $channel = "Local\/" . $number . "\@$lcrcontext"; -# $out->setvariable( 'Channel', $channel ); -# $out->setvariable( 'MaxRetries', $maxretries ); -# $out->setvariable( 'RetryTime', $retrytime ); -# $out->setvariable( 'WaitTime', $waittime ); -# $out->setvariable( "context", $context ); -# $out->setvariable( "extension", $extension ); -# $out->setvariable( "CallerID", "<$clidname> $clidnumber" ); -# $out->setvariable( "SetVar", "ACCOUNTCODE = $accountcode "); -# foreach my $variable (@variables) { -# print STDERR "SET: $variable->{name} - $variable->{value} /n"; -# $out->setvariable( "Set", "$variable->{name} = $variable->{value}" ); -# $out->setvariable( "SetVar", "$variable->{name} = $variable->{value}" ); -# } -# $out->outtime( time() + 15 ); -# $out->create_outgoing; -# print STDERR "Created Call to: $number\n"; + print STDERR $astman->sendcommand(%callout); } # Check to see if a calling card is ok to use. Modified: trunk/templates/booths-list.tpl =================================================================== --- trunk/templates/booths-list.tpl 2007-11-18 03:12:44 UTC (rev 2162) +++ trunk/templates/booths-list.tpl 2007-11-18 03:13:07 UTC (rev 2163) @@ -25,7 +25,8 @@ <TD><TMPL_VAR NAME="callstart"></TD> <TD><TMPL_VAR NAME="number"></TD> <TD><TMPL_VAR NAME="status"></TD> - <TD> <a href="astpp-admin.cgi?mode=List Booths&action=Deactivate Booth&booth_name=<TMPL_VAR NAME="name">">Deactivate Booth</a> + <TD> <a href="astpp-admin.cgi?mode=List Booths&action=Hangup Call&channel=<TMPL_VAR NAME="channel">">Hangup Call</a> + <a href="astpp-admin.cgi?mode=List Booths&action=Deactivate Booth&booth_name=<TMPL_VAR NAME="name">">Deactivate Booth</a> <a href="astpp-admin.cgi?mode=List Booths&action=Restore Booth&booth_name=<TMPL_VAR NAME="name">">Restore Booth</a> </TD> </TR> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-19 09:47:40
|
Revision: 2167 http://astpp.svn.sourceforge.net/astpp/?rev=2167&view=rev Author: darrenkw Date: 2007-11-19 01:47:43 -0800 (Mon, 19 Nov 2007) Log Message: ----------- Added a couple of sound files. Also corrected the error in astpp-callingcards.agi. Asterisk cannot handle the amount of debugging I was throwing at it through the agi interface so I turned that off. Modified Paths: -------------- trunk/astpp-callingcards.agi trunk/sounds/astpp-phonenum.gsm trunk/sounds/astpp-this-card-has-a-balance-of.gsm Modified: trunk/astpp-callingcards.agi =================================================================== --- trunk/astpp-callingcards.agi 2007-11-18 05:18:03 UTC (rev 2166) +++ trunk/astpp-callingcards.agi 2007-11-19 09:47:43 UTC (rev 2167) @@ -40,7 +40,7 @@ $AGI->set_variable( 'ASTPP', '1' ); $ASTPP = ASTPP->new; $ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to be. -$ASTPP->set_asterisk_agi($AGI); +#$ASTPP->set_asterisk_agi($AGI); sub initialize() { $SIG{HUP} = 'ignore_hup'; # We ignore the HUP command that Asterisk sends on a call hangup. Modified: trunk/sounds/astpp-phonenum.gsm =================================================================== (Binary files differ) Modified: trunk/sounds/astpp-this-card-has-a-balance-of.gsm =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-12-29 04:58:19
|
Revision: 2171 http://astpp.svn.sourceforge.net/astpp/?rev=2171&view=rev Author: darrenkw Date: 2007-12-28 20:58:01 -0800 (Fri, 28 Dec 2007) Log Message: ----------- Commit Realtime Rating Engine cleanups by Sonia Kahn Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-common.pl trunk/astpp-rate-engine.pl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-12-29 04:26:16 UTC (rev 2170) +++ trunk/astpp-admin.cgi 2007-12-29 04:58:01 UTC (rev 2171) @@ -1529,7 +1529,7 @@ ); $template->param( dids => &count_dids( $astpp_db, "" ) ); $template->param( - unbilled_cdrs => &count_unbilled_cdrs( $cdr_db, $accounts ) ); + unbilled_cdrs => &count_unbilled_cdrs( $config, $cdr_db, $accounts ) ); } elsif ( $params->{logintype} == 2 && $astpp_db && $cdr_db ) { $template->param( @@ -1550,7 +1550,7 @@ $template->param( total_owing => &accounts_total_balance($astpp_db,"")/10000 ); $template->param( dids => &count_dids( $astpp_db, "" ) ); $template->param( - unbilled_cdrs => &count_unbilled_cdrs( $cdr_db, "NULL,''" ) ); + unbilled_cdrs => &count_unbilled_cdrs( $config, $cdr_db, "NULL,''" ) ); } return $template->output; @@ -11083,9 +11083,9 @@ $iax2_login = $sql->fetchrow_hashref; $sql->finish; } - my @chargelist = &list_cdrs_account( $cdr_db, $accountinfo->{number}, + my @chargelist = &list_cdrs_account( $config, $cdr_db, $accountinfo->{number}, $accountinfo->{cc} ); - &processlist( $astpp_db, $cdr_db, $config, @chargelist ) + &processlist( $astpp_db, $cdr_db, $config, \@chargelist ) ; # Bill as many calls as we can. $status .= gettext("We rated as many CDRS as we could") . "<br>"; $tmp = @@ -11137,7 +11137,7 @@ filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); $template->param( booth_name => $params->{booth_name} ); my $balance = &accountbalance( $astpp_db, $params->{booth_name} ) / 10000; - my $unrated = &count_unrated_cdrs_account( $cdr_db, $accountinfo->{number}, + my $unrated = &count_unrated_cdrs_account( $config, $cdr_db, $accountinfo->{number}, $accountinfo->{cc} ); $ASTPP->debug( user=> $param->{username}, debug => $balance); $template->param( unrated_cdrs => $unrated ); Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-12-29 04:26:16 UTC (rev 2170) +++ trunk/astpp-common.pl 2007-12-29 04:58:01 UTC (rev 2171) @@ -1417,21 +1417,21 @@ # Select a specific cdr from the Asterisk(tm) cdr table. sub get_cdr() { - my ( $cdr_db, $uniqueid,$rating,$dst ) = @_; + my ( $config, $cdr_db, $uniqueid,$rating,$dst ) = @_; my ( $sql, $cdrdata ); if ($dst) { $sql = $cdr_db->prepare( - "SELECT * FROM cdr WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND dst = " . $cdr_db->quote($dst) . " ORDER BY cost DESC LIMIT 1" ); + "SELECT * FROM $config->{asterisk_cdr_table} WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND dst = " . $cdr_db->quote($dst) . " ORDER BY cost DESC LIMIT 1" ); } elsif ($rating) { $sql = $cdr_db->prepare( - "SELECT * FROM cdr WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND cost in ('error','none') ORDER BY cost DESC LIMIT 1" ); + "SELECT * FROM $config->{asterisk_cdr_table} WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND cost in ('error','none') ORDER BY cost DESC LIMIT 1" ); } else { $sql = $cdr_db->prepare( - "SELECT * FROM cdr WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " ORDER by cost DESC LIMIT 1" ); + "SELECT * FROM $config->{asterisk_cdr_table} WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " ORDER by cost DESC LIMIT 1" ); } $sql->execute; $cdrdata = $sql->fetchrow_hashref; @@ -1441,8 +1441,8 @@ # Update the cost of a cdr in the Asterisk(tm) cdr table. This is used to denote a cdr that has been rated. sub save_ast_cdr() { - my ( $cdr_db, $uniqueid, $cost,$dst ) = @_; - $cdr_db->do( "UPDATE cdr SET cost = " + my ( $config, $cdr_db, $uniqueid, $cost,$dst ) = @_; + $cdr_db->do( "UPDATE $config->{asterisk_cdr_table} SET cost = " . $cdr_db->quote($cost) . "WHERE uniqueid = " . $cdr_db->quote($uniqueid) @@ -1455,11 +1455,11 @@ # used to select cdrs that have not been billed which have value "none" or those that the rating engine ran # into a problem with which are marked "error". sub list_cdrs_status() { - my ( $cdr_db, $default ) = @_; + my ( $config, $cdr_db, $default ) = @_; my ( $sql, @cdrlist, $row ); $sql = $cdr_db->prepare( - "SELECT * FROM cdr WHERE cost = " . $cdr_db->quote($default) ); + "SELECT * FROM $config->{asterisk_cdr_table} WHERE cost = " . $cdr_db->quote($default) ); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { push @cdrlist, $row->{uniqueid}; @@ -1469,11 +1469,11 @@ # Select all the unbilled CDRS belonging to a specific account. This is mostly used by booths. sub list_cdrs_account() { - my ( $cdr_db, $account, $cc ) = @_; + my ( $config, $cdr_db, $account, $cc ) = @_; my ( $sql, @cdrlist, $row ); $sql = $cdr_db->prepare( - "SELECT * FROM cdr WHERE cost IN ('none', 'error') AND accountcode IN (" . $cdr_db->quote($account) . ", " . $cdr_db->quote($cc) . ") AND disposition REGEXP 'ANSWE.*'"); + "SELECT * FROM $config->{asterisk_cdr_table} WHERE cost IN ('none', 'error') AND accountcode IN (" . $cdr_db->quote($account) . ", " . $cdr_db->quote($cc) . ") AND disposition REGEXP 'ANSWE.*'"); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { push @cdrlist, $row->{uniqueid}; @@ -1484,8 +1484,8 @@ # Update the cost of a cdr in the Asterisk(tm) cdr table. This is used to denote a cdr that has been tagged # to a vendor. sub save_ast_cdr_vendor() { - my ( $cdr_db, $uniqueid, $cost,$dst ) = @_; - $cdr_db->do( "UPDATE cdr SET vendor = " + my ( $config, $cdr_db, $uniqueid, $cost,$dst ) = @_; + $cdr_db->do( "UPDATE $config->{asterisk_cdr_table} SET vendor = " . $cdr_db->quote($cost) . "WHERE uniqueid = " . $cdr_db->quote($uniqueid) @@ -1498,11 +1498,11 @@ # used to select cdrs that have not been tagged to a vendor which have value "none" or those that the rating engine ran # into a problem with which are marked "error". sub list_cdrs_status_vendor() { - my ( $cdr_db, $default ) = @_; + my ( $config, $cdr_db, $default ) = @_; my ( $sql, @cdrlist, $row ); $sql = $cdr_db->prepare( - "SELECT * FROM cdr WHERE vendor = " . $cdr_db->quote($default) ); + "SELECT * FROM $config->{asterisk_cdr_table} WHERE vendor = " . $cdr_db->quote($default) ); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { push @cdrlist, $row->{uniqueid}; @@ -2174,38 +2174,37 @@ # Write ASTPP cdr. I think this one is mostly deprecated but should probably be completely removed. sub post_cdr() { - my ( - $astpp_db, $config, $uniqueid, $account, $clid, - $dest, $disp, $seconds, $cost, $callstart, - $postexternal, $trunk, $notes,$pricelist,$pattern - ) - = @_; + my ( + $astpp_db, $config, $uniqueid, $account, $clid, + $dest, $disp, $seconds, $cost, $callstart, + $postexternal, $trunk, $notes,$pricelist,$pattern + ) = @_; - # The cost is passed in 100ths of a penny. - my ( $tmp, $status ); - $trunk = gettext("N/A") if ( !$trunk ); - $uniqueid = gettext("N/A") if ( !$uniqueid ); - $pricelist = gettext("N/A") if ( !$pricelist ); - $pattern = gettext("N/A") if ( !$pattern ); - $status = 0; - $tmp = -"INSERT INTO cdrs(uniqueid,cardnum,callerid,callednum,trunk,disposition,billseconds," - . "debit,callstart,status,notes,pricelist,pattern) VALUES (" - . $astpp_db->quote($uniqueid) . ", " - . $astpp_db->quote($account) . ", " - . $astpp_db->quote($clid) . ", " - . $astpp_db->quote($dest) . ", " - . $astpp_db->quote($trunk) . ", " - . $astpp_db->quote($disp) . ", " - . $astpp_db->quote($seconds) . ", " - . $astpp_db->quote($cost) . ", " - . $astpp_db->quote($callstart) . ", " - . $astpp_db->quote($status) . ", " - . $astpp_db->quote($notes) . "," - . $astpp_db->quote($pricelist) . "," - . $astpp_db->quote($pattern) . ")"; - print STDERR "$tmp\n"; - $astpp_db->do($tmp); +# The cost is passed in 100ths of a penny. + my ( $tmp, $status ); + $trunk = gettext("N/A") if ( !$trunk ); + $uniqueid = gettext("N/A") if ( !$uniqueid ); + $pricelist = gettext("N/A") if ( !$pricelist ); + $pattern = gettext("N/A") if ( !$pattern ); + $status = 0; + $tmp = + "INSERT INTO cdrs(uniqueid,cardnum,callerid,callednum,trunk,disposition,billseconds," + . "debit,callstart,status,notes,pricelist,pattern) VALUES (" + . $astpp_db->quote($uniqueid) . ", " + . $astpp_db->quote($account) . ", " + . $astpp_db->quote($clid) . ", " + . $astpp_db->quote($dest) . ", " + . $astpp_db->quote($trunk) . ", " + . $astpp_db->quote($disp) . ", " + . $astpp_db->quote($seconds) . ", " + . $astpp_db->quote($cost) . ", " + . $astpp_db->quote($callstart) . ", " + . $astpp_db->quote($status) . ", " + . $astpp_db->quote($notes) . "," + . $astpp_db->quote($pricelist) . "," + . $astpp_db->quote($pattern) . ")"; + print STDERR "$tmp\n"; + $astpp_db->do($tmp); } ############### Integration with AgileBill starts here ################## @@ -3267,10 +3266,10 @@ # Return a list of unbilled cdrs from the Asterisk(TM) cdr database. sub count_unbilled_cdrs() { - my ($cdr_db,$account) = @_; + my ($config, $cdr_db,$account) = @_; my ( $sql, $count, $record ); $sql = - $cdr_db->prepare( "SELECT COUNT(*) FROM cdr WHERE cost = 'error' OR " + $cdr_db->prepare( "SELECT COUNT(*) FROM $config->{asterisk_cdr_table} WHERE cost = 'error' OR " . "accountcode IN (" . $account . ") AND cost ='none'" ); $sql->execute; $record = $sql->fetchrow_hashref; @@ -3358,11 +3357,11 @@ # List unrated CDRS per account sub count_unrated_cdrs_account() { - my ( $cdr_db, $account, $cc ) = @_; + my ( $config, $cdr_db, $account, $cc ) = @_; my ( $sql, @cdrlist, $record, $count ); $sql = $cdr_db->prepare( - "SELECT COUNT(*) FROM cdr WHERE cost IN ('none', 'error') AND accountcode IN (" . $cdr_db->quote($account) . ", " . $cdr_db->quote($cc) . ")"); + "SELECT COUNT(*) FROM $config->{asterisk_cdr_table} WHERE cost IN ('none', 'error') AND accountcode IN (" . $cdr_db->quote($account) . ", " . $cdr_db->quote($cc) . ")"); $sql->execute; $record = $sql->fetchrow_hashref; $count = $record->{"COUNT(*)"}; @@ -3748,21 +3747,18 @@ } sub rating() { # This routine recieves a specific cdr and takes care of rating it and of marking it as rated. It bills resellers as appropriate. - my ( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, @output ) = @_; + my ( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, $vars, @output ) = @_; my ( $increment, $numdata, $package, $notes, $status ); print STDERR "----------------------------------------------------------------\n"; print STDERR -"uniqueid: $cdrinfo->{uniqueid}, cardno: $carddata->{number}, phoneno: $cdrinfo->{dst}, Userfield: $cdrinfo->{userfield}\n"; + "uniqueid: $cdrinfo->{uniqueid}, cardno: $carddata->{number}, phoneno: $cdrinfo->{dst}, Userfield: $cdrinfo->{userfield}\n"; print STDERR -"disposition: $cdrinfo->{disposition} Pricelist: $carddata->{pricelist} reseller: $carddata->{reseller}\n"; + "disposition: $cdrinfo->{disposition} Pricelist: $carddata->{pricelist} reseller: $carddata->{reseller}\n"; if ( $cdrinfo->{disposition} =~ /^ANSWERED$/ ) { - $numdata = - &get_route( $astpp_db, $config, $cdrinfo->{dst}, - $carddata->{pricelist}, $carddata, $cdrinfo->{userfield} ); + $numdata = &get_route( $astpp_db, $config, $cdrinfo->{dst}, $carddata->{pricelist}, $carddata, $cdrinfo->{userfield} ); print STDERR "PATTERN: $numdata->{pattern}"; if ( !$numdata->{pattern} ) { - &save_ast_cdr( $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ) - if $config->{astcdr} == 1; + &save_ast_cdr( $config, $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; print STDERR "ERROR - ERROR - ERROR - ERROR - ERROR \n"; print STDERR "NO MATCHING PATTERN\n"; print STDERR "----------------------------------------------------------------\n"; @@ -3771,28 +3767,23 @@ print STDERR "FOUND A MATCHING PATTERN.\n"; my $branddata = &get_pricelist( $astpp_db, $carddata->{pricelist} ); print STDERR -"pricelistData: $branddata->{name} $branddata->{markup} $branddata->{inc} $branddata->{status}\n"; + "pricelistData: $branddata->{name} $branddata->{markup} $branddata->{inc} $branddata->{status}\n"; $package = &get_package( $astpp_db, $carddata, $cdrinfo->{dst} ); - if ($package->{id}) { - my $counter = - &get_counter( $astpp_db, $package->{id}, - $carddata->{number} ); + if ($package->{id}) { + my $counter = &get_counter( $astpp_db, $package->{id}, $carddata->{number} ); my $difference; - if ( !$counter->{id}) { - my $tmp = - "INSERT INTO counters (package,account) VALUES (" - . $astpp_db->quote( $package->{id} ) . ", " - . $astpp_db->quote( $carddata->{number} ) . ")"; + if ( !$counter->{id}) { + my $tmp = "INSERT INTO counters (package,account) VALUES (" + . $astpp_db->quote( $package->{id} ) . ", " + . $astpp_db->quote( $carddata->{number} ) . ")"; print STDERR "/n" . $tmp . "/n" if $config->{debug} == 1; - $astpp_db->do($tmp); - $counter = - &get_counter( $astpp_db, $package->{id}, - $carddata->{number} ); + $astpp_db->do($tmp); + $counter = &get_counter( $astpp_db, $package->{id}, $carddata->{number} ); print STDERR "JUST CREATED COUNTER: $counter->{id}\n" if $config->{debug} == 1; - } - if ( $package->{includedseconds} > $counter->{seconds}) { - my $availableseconds = $package->{includedseconds} - $counter->{seconds}; + } + if ( $package->{includedseconds} > $counter->{seconds}) { + my $availableseconds = $package->{includedseconds} - $counter->{seconds}; my $freeseconds; if ($availableseconds >= $cdrinfo->{billsec}) { $freeseconds = $cdrinfo->{billsec}; @@ -3801,23 +3792,18 @@ $freeseconds = $availableseconds; $cdrinfo->{billsec} = $cdrinfo->{billsec} - $availableseconds; } - my $tmp = - "UPDATE counters SET seconds = " - . $astpp_db->quote( - $counter->{seconds} + $freeseconds ) - . " WHERE id = " - . $astpp_db->quote( $counter->{id} ); + my $tmp = "UPDATE counters SET seconds = " + . $astpp_db->quote( $counter->{seconds} + $freeseconds ) + . " WHERE id = " + . $astpp_db->quote( $counter->{id} ); print STDERR $tmp . "/n" if $config->{debug} == 1; - $astpp_db->do($tmp); - } - } + $astpp_db->do($tmp); + } + } if ( $branddata->{markup} ne "" && $branddata->{markup} != 0 ) { - $numdata->{connectcost} = - $numdata->{connectcost} * - ( ( $branddata->{markup} / 10000 ) + 1 ); - $numdata->{cost} = - $numdata->{cost} * ( ( $branddata->{markup} / 10000 ) + 1 ); + $numdata->{connectcost} = $numdata->{connectcost} * ( ( $branddata->{markup} / 10000 ) + 1 ); + $numdata->{cost} = $numdata->{cost} * ( ( $branddata->{markup} / 10000 ) + 1 ); } if ( $numdata->{inc} > 0 ) { $increment = $numdata->{inc}; @@ -3826,24 +3812,22 @@ $increment = $branddata->{inc}; } print STDERR -"$numdata->{connectcost}, $numdata->{cost}, $cdrinfo->{billsec}, $increment, $numdata->{includedseconds}"; + "$numdata->{connectcost}, $numdata->{cost}, $cdrinfo->{billsec}, $increment, $numdata->{includedseconds}"; my $cost = &calc_call_cost( - $numdata->{connectcost}, $numdata->{cost}, - $cdrinfo->{billsec}, $increment, - $numdata->{includedseconds} - ); + $numdata->{connectcost}, $numdata->{cost}, + $cdrinfo->{billsec}, $increment, + $numdata->{includedseconds} + ); $cost = sprintf( "%." . $config->{decimalpoints} . "f", $cost ); print STDERR "Matching pattern is $numdata->{pattern}\n"; - #Blocks all signals so that the program cannot be killed while writing costs. +#Blocks all signals so that the program cannot be killed while writing costs. my $sigset = POSIX::SigSet->new; my $blockset = POSIX::SigSet->new( SIGINT, SIGQUIT, SIGCHLD ); - sigprocmask( SIG_BLOCK, $blockset, $sigset ) - or die "Could not block INT,QUIT,CHLD signals: $!\n"; - &save_ast_cdr( $cdr_db, $cdrinfo->{uniqueid}, $cost,$cdrinfo->{dst} ) - if $config->{astcdr} == 1; + sigprocmask( SIG_BLOCK, $blockset, $sigset ) or die "Could not block INT,QUIT,CHLD signals: $!\n"; + &save_ast_cdr( $config, $cdr_db, $cdrinfo->{uniqueid}, $cost,$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; if ( $cdrinfo->{accountcode} ne $carddata->{number} && $cdrinfo->{accountcode} ne $carddata->{cc}) { $notes = $cdrinfo->{accountcode} . "|" . $numdata->{comment} . "|" . $numdata->{pattern}; } @@ -3851,29 +3835,28 @@ $notes = "|" . $numdata->{comment} . "|" . $numdata->{pattern}; } &post_cdr( - $astpp_db, $config, - $cdrinfo->{uniqueid}, $carddata->{number}, - $cdrinfo->{src}, $cdrinfo->{dst}, - $cdrinfo->{disposition}, $cdrinfo->{billsec}, - $cost, $cdrinfo->{calldate}, - "", $cdrinfo->{trunk}, - $notes,$numdata->{pricelist}, $numdata->{pattern} - ) - if $config->{posttoastpp} == 1; + $astpp_db, $config, + $cdrinfo->{uniqueid}, $carddata->{number}, + $cdrinfo->{src}, $cdrinfo->{dst}, + $cdrinfo->{disposition}, $cdrinfo->{billsec}, + $cost, $cdrinfo->{calldate}, + "", $cdrinfo->{trunk}, + $notes,$numdata->{pricelist}, $numdata->{pattern} + ) + if $config->{posttoastpp} == 1; &print_csv( - $config, $carddata->{number}, $cdrinfo->{disposition}, - $cdrinfo->{calldate}, $cdrinfo->{dst}, - $cdrinfo->{billsec}, $cost, - $carddata->{reseller}, $cdrinfo, @output - ); + $config, $carddata->{number}, $cdrinfo->{disposition}, + $cdrinfo->{calldate}, $cdrinfo->{dst}, + $cdrinfo->{billsec}, $cost, + $carddata->{reseller}, $cdrinfo, @output + ); sigprocmask( SIG_SETMASK, $sigset ) # Restore the passing of signals - or die "Could not restore INT,QUIT,CHLD signals: $!\n"; # - $status = 1; + or die "Could not restore INT,QUIT,CHLD signals: $!\n"; # + $status = 1; } } else { - &save_ast_cdr( $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ) - if $config->{astcdr} == 1; + &save_ast_cdr( $config, $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; print STDERR "ERROR - ERROR - ERROR - ERROR - ERROR \n"; print STDERR "DISPOSITION: $cdrinfo->{disposition} \n"; print STDERR "UNIQUEID: $cdrinfo->{uniqueid} \n"; @@ -3891,8 +3874,8 @@ } sub vendor_not_billed() { # Prints the information on calls where the "vendor" field is either none or error. - my ($cdr_db) = @_; - my $tmp = "SELECT * FROM cdr WHERE vendor IN ('none','error')"; + my ($config, $cdr_db) = @_; + my $tmp = "SELECT * FROM $config->{asterisk_cdr_table} WHERE vendor IN ('none','error')"; my $sql = $cdr_db->prepare($tmp); $sql->execute; while ( my $cdr = $sql->fetchrow_hashref ) { @@ -3911,33 +3894,34 @@ sub processlist() { # Deal with a list of calls which have not been rated so far. - my ($astpp_db, $cdr_db, $config, @chargelist) = @_; - my ( $status); - foreach (@chargelist) { + my ($astpp_db, $cdr_db, $config, $chargelist, $vars) = @_; + my ( $status, $cdrinfo); + foreach (@$chargelist) { my $uniqueid = $_; - print STDERR gettext("Processing Uniqueid: ") . $_; - my $cdrinfo = &get_cdr( $cdr_db, $uniqueid ); + print STDERR gettext("Processing Uniqueid: ") . @$chargelist; + $cdrinfo = ($vars) ? $vars : &get_cdr( $config, $cdr_db, $uniqueid ); my $savedcdrinfo = $cdrinfo; - my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'rating' WHERE uniqueid = " - . $cdr_db->quote($uniqueid) - . " AND cost = 'none'" - . " AND dst = " - . $cdr_db->quote($cdrinfo->{dst}) - . " LIMIT 1"; - $cdr_db->do($tmp); + if(!$vars) { + my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'rating' WHERE uniqueid = " + . $cdr_db->quote($uniqueid) + . " AND cost = 'none'" + . " AND dst = " + . $cdr_db->quote($cdrinfo->{dst}) + . " LIMIT 1"; + $cdr_db->do($tmp); + } else { + $cdrinfo->{'cost'} = 'rating'; + } if ( $cdrinfo->{accountcode} ) { my $carddata = &get_account( $astpp_db, $cdrinfo->{accountcode} ); if ($carddata->{number}) { - if ( $cdrinfo->{lastapp} eq "MeetMe" ) { # - $cdrinfo->{billsec} = $cdrinfo - ->{duration}; # There is an issue with calls that come out of meetme - } # not having the right billable seconds. - if ( $cdrinfo->{billsec} <= 0 ) { - &save_ast_cdr( $cdr_db, $uniqueid, 0,$cdrinfo->{dst} ) - if $config->{astcdr} == 1; - &save_ast_cdr_vendor( $cdr_db, $uniqueid, 0,$cdrinfo->{dst} ) - if $config->{astcdr} == 1 - && $config->{trackvendorcharges} == 1; + if ( $cdrinfo->{lastapp} eq "MeetMe" ) { # There is an issue with calls that come out of meetmee + $cdrinfo->{billsec} = $cdrinfo->{duration}; + } + if ( $cdrinfo->{billsec} <= 0 ) { # not having the right billable seconds. + &save_ast_cdr( $config, $cdr_db, $uniqueid, 0,$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; + &save_ast_cdr_vendor( $config, $cdr_db, $uniqueid, 0,$cdrinfo->{dst} ) + if !$vars && $config->{astcdr} == 1 && $config->{trackvendorcharges} == 1; print STDERR "\n----------------------\n"; print STDERR "CDR Written - No Billable Seconds\n"; print STDERR @@ -3946,19 +3930,19 @@ print STDERR "----------------------\n"; } elsif ( $cdrinfo->{accountcode} ) { - $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata); - $cdrinfo = &get_cdr( $cdr_db, $uniqueid ); + $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, $vars); + $cdrinfo = &get_cdr( $config, $cdr_db, $uniqueid ) if !$vars; if ( $status == 1 ) { my $previous_account = $carddata->{number}; while ( $carddata->{reseller} ne "" ) { - $cdrinfo = &get_cdr( $cdr_db, $uniqueid ); + $cdrinfo = &get_cdr( $config, $cdr_db, $uniqueid ) if !$vars; print STDERR "Charge $uniqueid to $carddata->{reseller}" if $config->{debug} == 1; $carddata = &get_account( $astpp_db, $carddata->{reseller} ); - $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata); + $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, $vars); my $tmp = "SELECT id FROM cdrs WHERE uniqueid = '" . $uniqueid . "' AND cardnum = '" . $previous_account . "' LIMIT 1"; print STDERR "$tmp\n" if $config->{debug} == 1; - my $sql = $astpp_db->prepare($tmp); + my $sql = $astpp_db->prepare($tmp); $sql->execute; my $previous_data = $sql->fetchrow_hashref; $sql->finish; @@ -3966,15 +3950,14 @@ $tmp = "SELECT id,debit,credit FROM cdrs WHERE uniqueid = '" . $uniqueid . "' AND cardnum = '" . $carddata->{number} . "' LIMIT 1"; print STDERR "$tmp\n" if $config->{debug} == 1; - $sql = $astpp_db->prepare($tmp); + $sql = $astpp_db->prepare($tmp); $sql->execute; my $cdrdata = $sql->fetchrow_hashref; $sql->finish; $cdrdata->{cost} = $cdrdata->{debit} - $cdrdata->{credit}; $tmp = "UPDATE cdrs SET cost = " . $cdrdata->{cost} - . " WHERE id = " . $previous_data->{id} . " AND callednum = " - . $cdr_db->quote($cdrinfo->{dst}); + . " WHERE id = " . $previous_data->{id} . " AND callednum = " . $cdr_db->quote($cdrinfo->{dst}); print STDERR "$tmp\n" if $config->{debug} == 1; $astpp_db->do($tmp); $previous_account = $carddata->{number}; @@ -3987,12 +3970,16 @@ print STDERR "ERROR - ERROR - ERROR - ERROR - ERROR \n"; print STDERR "NO ACCOUNT EXISTS IN ASTPP\n"; print STDERR -"uniqueid: $uniqueid, Account: $cdrinfo->{accountcode}, phoneno: $cdrinfo->{dst}\n"; + "uniqueid: $uniqueid, Account: $cdrinfo->{accountcode}, phoneno: $cdrinfo->{dst}\n"; print STDERR "disposition: $cdrinfo->{disposition}\n"; print STDERR "----------------------\n"; - my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'none' WHERE uniqueid = " - . $uniqueid . " AND cost = 'rating' LIMIT 1"; - $cdr_db->do($tmp); + if(!$vars) { + my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'none' WHERE uniqueid = " + . $uniqueid . " AND cost = 'rating' LIMIT 1"; + $cdr_db->do($tmp); + } else { + $cdrinfo->{cost} = 'none'; + } } } else { @@ -4000,61 +3987,101 @@ print STDERR "ERROR - ERROR - ERROR - ERROR - ERROR \n"; print STDERR "NO ACCOUNTCODE IN DATABASE\n"; print STDERR -"uniqueid: $uniqueid, cardno: $cdrinfo->{accountcode}, phoneno: $cdrinfo->{dst}\n"; + "uniqueid: $uniqueid, cardno: $cdrinfo->{accountcode}, phoneno: $cdrinfo->{dst}\n"; print STDERR "disposition: $cdrinfo->{disposition}\n"; print STDERR "----------------------\n"; - my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'none' WHERE uniqueid = " - . $uniqueid . " AND cost = 'rating' LIMIT 1"; - $cdr_db->do($tmp); + if(!$vars) { + my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'none' WHERE uniqueid = " + . $uniqueid . " AND cost = 'rating' LIMIT 1"; + $cdr_db->do($tmp); + } else { + $cdrinfo->{cost} = 'none'; + } } my $phrase = "none"; - &vendor_process_rating( $astpp_db, $cdr_db, $config, $phrase, $uniqueid ) if $config->{trackvendorcharges} == 1; - + &vendor_process_rating( $astpp_db, $cdr_db, $config, $phrase, $uniqueid, $vars ) if $config->{trackvendorcharges} == 1; } } sub vendor_process_rating() { #Rate Vendor calls. - my ( $astpp_db, $cdr_db, $config, $phrase, $uniqueid ) = @_; + my ( $astpp_db, $cdr_db, $config, $phrase, $uniqueid, $vars ) = @_; my $tmp = "SELECT * FROM trunks ORDER BY LENGTH(path)"; my $sql = $astpp_db->prepare($tmp); print STDERR "$tmp\n" . "\n" if $config->{debug} == 1; $sql->execute; while ( my $trunk = $sql->fetchrow_hashref ) { my $tmp; - if ( $uniqueid ne "" ) { - $tmp = - "SELECT * FROM $config->{asterisk_cdr_table} where lastapp = 'Dial'" - . " AND vendor = " - . $cdr_db->quote($phrase) - . " AND (dstchannel LIKE '$trunk->{tech}/$trunk->{path}%'" - . " OR dstchannel LIKE '$trunk->{tech}\[$trunk->{path}\]%'" - . " OR lastdata LIKE '$trunk->{tech}/$trunk->{path}%'" - . " OR lastdata LIKE '$trunk->{tech}\[$trunk->{path}\]%')" - . " AND uniqueid = " - . $cdr_db->quote($uniqueid) - . " AND disposition = 'ANSWERED'"; - } - else { - $tmp = - "SELECT * FROM $config->{asterisk_cdr_table} where lastapp = 'Dial'" - . " AND vendor = " - . $cdr_db->quote($phrase) - . " AND (dstchannel LIKE '$trunk->{tech}/$trunk->{path}%'" - . " OR dstchannel LIKE '$trunk->{tech}\[$trunk->{path}\]%'" - . " OR lastdata LIKE '$trunk->{tech}/$trunk->{path}%'" - . " OR lastdata LIKE '$trunk->{tech}\[$trunk->{path}\]%')" - . " AND disposition = 'ANSWERED'"; - } - print STDERR "$tmp\n" . "\n" if $config->{debug} == 1; - my $sql1 = $cdr_db->prepare($tmp); - $sql1->execute; - while ( my $cdrinfo = $sql1->fetchrow_hashref ) { - my $tmp = - "SELECT * FROM outbound_routes WHERE " - . $astpp_db->quote( $cdrinfo->{dst} ) - . " RLIKE pattern AND status = 1 AND trunk = " - . $astpp_db->quote( $trunk->{name} ) - . " ORDER by LENGTH(pattern) DESC, cost"; + if(!$vars) { + if ( $uniqueid ne "" ) { + $tmp = + "SELECT * FROM $config->{asterisk_cdr_table} where lastapp = 'Dial'" + . " AND vendor = " + . $cdr_db->quote($phrase) + . " AND (dstchannel LIKE '$trunk->{tech}/$trunk->{path}%'" + . " OR dstchannel LIKE '$trunk->{tech}\[$trunk->{path}\]%'" + . " OR lastdata LIKE '$trunk->{tech}/$trunk->{path}%'" + . " OR lastdata LIKE '$trunk->{tech}\[$trunk->{path}\]%')" + . " AND uniqueid = " + . $cdr_db->quote($uniqueid) + . " AND disposition = 'ANSWERED'"; + } else { + $tmp = "SELECT * FROM $config->{asterisk_cdr_table} where lastapp = 'Dial'" + . " AND vendor = " + . $cdr_db->quote($phrase) + . " AND (dstchannel LIKE '$trunk->{tech}/$trunk->{path}%'" + . " OR dstchannel LIKE '$trunk->{tech}\[$trunk->{path}\]%'" + . " OR lastdata LIKE '$trunk->{tech}/$trunk->{path}%'" + . " OR lastdata LIKE '$trunk->{tech}\[$trunk->{path}\]%')" + . " AND disposition = 'ANSWERED'"; + } + print STDERR "$tmp\n" . "\n" if $config->{debug} == 1; + my $sql1 = $cdr_db->prepare($tmp); + $sql1->execute; + while ( my $cdrinfo = $sql1->fetchrow_hashref ) { + my $tmp = "SELECT * FROM outbound_routes WHERE " + . $astpp_db->quote( $cdrinfo->{dst} ) + . " RLIKE pattern AND status = 1 AND trunk = " + . $astpp_db->quote( $trunk->{name} ) + . " ORDER by LENGTH(pattern) DESC, cost"; + my $sql2 = $astpp_db->prepare($tmp); + $sql2->execute; + print STDERR "$tmp\n" . "\n" if $config->{debug} == 1; + my $pricerecord = $sql2->fetchrow_hashref; + $sql2->finish; + if ( $pricerecord->{id} ) { + my $cost = &calc_call_cost( + $pricerecord->{connectcost}, $pricerecord->{cost}, + $cdrinfo->{billsec}, $pricerecord->{inc}, + $pricerecord->{includedseconds} + ); + $cost = sprintf( "%." . $config->{decimalpoints} . "f", $cost ); + &post_cdr( + $astpp_db, $config, + $cdrinfo->{uniqueid}, $trunk->{provider}, + $cdrinfo->{src}, $cdrinfo->{dst}, + $cdrinfo->{disposition}, $cdrinfo->{billsec}, + $cost * -1, $cdrinfo->{calldate}, + "", $cdrinfo->{trunk}, + $pricerecord->{comment} . "|" . $pricerecord->{pattern} + ) if $config->{posttoastpp} == 1; + &save_ast_cdr_vendor( $config, $cdr_db, $cdrinfo->{uniqueid}, $cost,$cdrinfo->{dst} ); + my $tmp = "UPDATE cdrs SET cost = '" . $cost . "' WHERE uniqueid = '" . + $cdrinfo->{uniqueid} . "' AND cost = 0 " + . " AND cardnum != '" . $trunk->{provider} . "' AND dst = " + . $astpp_db->quote($cdrinfo->{dst}) . " LIMIT 1"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $astpp_db->do($tmp); + } else { + &save_ast_cdr_vendor( $config, $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ); + } + } + } else { + $cardinfo = $vars; + my $tmp = "SELECT * FROM outbound_routes WHERE " + . $astpp_db->quote( $cdrinfo->{dst} ) + . " RLIKE pattern AND status = 1 AND trunk = " + . $astpp_db->quote( $trunk->{name} ) + . " ORDER by LENGTH(pattern) DESC, cost"; my $sql2 = $astpp_db->prepare($tmp); $sql2->execute; print STDERR "$tmp\n" . "\n" if $config->{debug} == 1; @@ -4062,22 +4089,20 @@ $sql2->finish; if ( $pricerecord->{id} ) { my $cost = &calc_call_cost( - $pricerecord->{connectcost}, $pricerecord->{cost}, - $cdrinfo->{billsec}, $pricerecord->{inc}, - $pricerecord->{includedseconds} - ); + $pricerecord->{connectcost}, $pricerecord->{cost}, + $cdrinfo->{billsec}, $pricerecord->{inc}, + $pricerecord->{includedseconds} + ); $cost = sprintf( "%." . $config->{decimalpoints} . "f", $cost ); &post_cdr( - $astpp_db, $config, - $cdrinfo->{uniqueid}, $trunk->{provider}, - $cdrinfo->{src}, $cdrinfo->{dst}, - $cdrinfo->{disposition}, $cdrinfo->{billsec}, - $cost * -1, $cdrinfo->{calldate}, - "", $cdrinfo->{trunk}, - $pricerecord->{comment} . "|" . $pricerecord->{pattern} - ) - if $config->{posttoastpp} == 1; - &save_ast_cdr_vendor( $cdr_db, $cdrinfo->{uniqueid}, $cost,$cdrinfo->{dst} ); + $astpp_db, $config, + $cdrinfo->{uniqueid}, $trunk->{provider}, + $cdrinfo->{src}, $cdrinfo->{dst}, + $cdrinfo->{disposition}, $cdrinfo->{billsec}, + $cost * -1, $cdrinfo->{calldate}, + "", $cdrinfo->{trunk}, + $pricerecord->{comment} . "|" . $pricerecord->{pattern} + ) if $config->{posttoastpp} == 1; my $tmp = "UPDATE cdrs SET cost = '" . $cost . "' WHERE uniqueid = '" . $cdrinfo->{uniqueid} . "' AND cost = 0 " . " AND cardnum != '" . $trunk->{provider} . "' AND dst = " @@ -4085,10 +4110,6 @@ print STDERR "$tmp\n" if $config->{debug} == 1; $astpp_db->do($tmp); } - else { - &save_ast_cdr_vendor( $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ); - } - } } $sql->finish; Modified: trunk/astpp-rate-engine.pl =================================================================== --- trunk/astpp-rate-engine.pl 2007-12-29 04:26:16 UTC (rev 2170) +++ trunk/astpp-rate-engine.pl 2007-12-29 04:58:01 UTC (rev 2171) @@ -60,7 +60,7 @@ my @chargelist; push @chargelist, $uniqueid; #sleep $config->{sleep}; - &processlist($astpp_db, $cdr_db, $config, @chargelist); + &processlist($astpp_db, $cdr_db, $config, \@chargelist); #&cleanup_cdrs($cdr_db, $config); &shutdown(); exit(0); @@ -91,7 +91,7 @@ ); my @chargelist; push @chargelist, $ARGV[16]; - &processlist($astpp_db, $cdr_db, $config, @chargelist); + &processlist($astpp_db, $cdr_db, $config, \@chargelist, \%args); &cleanup_cdrs($cdr_db, $config); } elsif ( $run_type eq "price_only" ) { @@ -144,13 +144,13 @@ if ( !$cdr_db ) { $cdr_db = &connect_db( $config, @output ); } - my $cdrinfo = &get_cdr( $cdr_db, $input->{Uniqueid},1 ); + my $cdrinfo = &get_cdr( $config, $cdr_db, $input->{Uniqueid},1 ); # my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'rating' WHERE uniqueid = " . $input->{Uniqueid} . " AND cost = 'none' AND dst = " . $cdr_db->quote($cdrinfo->{dst}) . " LIMIT 1"; # print STDERR $tmp if $config->{debug} == 1; # print $tmp if $config->{debug} == 1; # $cdr_db->do($tmp); if ($cdrinfo->{lastapp} eq "MeetMe" || $cdrinfo->{billsec} > 0 || $cdrinfo->{cost} eq "none") { - &processlist($astpp_db, $cdr_db, $config, @chargelist); + &processlist($astpp_db, $cdr_db, $config, \@chargelist); &vendor_process_rating( $astpp_db, $cdr_db, $config, "none", $input->{Uniqueid} ) if $config->{trackvendorcharges} == 1; } # else { &cleanup_cdrs($cdr_db, $config); @@ -166,17 +166,17 @@ &cleanup_cdrs($cdr_db, $config); my @chargelist; my $phrase = "none"; - @chargelist = &list_cdrs_status( $cdr_db, $phrase ); # Grab a list of all calls with "none" assigned in the cost field - &processlist($astpp_db, $cdr_db, $config, @chargelist); # Bill as many calls as we can. + @chargelist = &list_cdrs_status( $config, $cdr_db, $phrase ); # Grab a list of all calls with "none" assigned in the cost field + &processlist($astpp_db, $cdr_db, $config, \@chargelist); # Bill as many calls as we can. $phrase = "error"; - @chargelist = &list_cdrs_status( $cdr_db, $phrase ); # Grab a list of all calls with "none" assigned in the cost field - &processlist($astpp_db, $cdr_db, $config, @chargelist); # See if we can now bill some of the calls that are marked in "error" + @chargelist = &list_cdrs_status( $config, $cdr_db, $phrase ); # Grab a list of all calls with "none" assigned in the cost field + &processlist($astpp_db, $cdr_db, $config, \@chargelist); # See if we can now bill some of the calls that are marked in "error" # print STDERR gettext("START ON VENDOR CALL RATING!") . "\n" if $config->{debug} == 1; # &vendor_process_rating( $astpp_db, $cdr_db, $config, "none", 0 ) if $config->{trackvendorcharges} == 1; # &vendor_process_rating( $astpp_db, $cdr_db, $config. $config, "error", 0 ) if $config->{trackvendorcharges} == 1; # print STDERR gettext("VENDOR CALLS WHICH HAVE NOT BEEN RATED.") . "\n" if $config->{debug} == 1; # Print a list of calls which have not been rated - &vendor_not_billed($cdr_db) if $config->{trackvendorcharges} == 1; + &vendor_not_billed($config, $cdr_db) if $config->{trackvendorcharges} == 1; &cleanup_cdrs($cdr_db, $config); } &shutdown(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-01-19 06:28:13
|
Revision: 2173 http://astpp.svn.sourceforge.net/astpp/?rev=2173&view=rev Author: darrenkw Date: 2008-01-18 22:28:08 -0800 (Fri, 18 Jan 2008) Log Message: ----------- Resolved: [ 1866419 ] missing account-remove.tpl Modified Paths: -------------- trunk/astpp-common.pl Added Paths: ----------- trunk/templates/account-remove.tpl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-12-29 04:59:59 UTC (rev 2172) +++ trunk/astpp-common.pl 2008-01-19 06:28:08 UTC (rev 2173) @@ -1308,6 +1308,7 @@ sub list_accounts_selective() { my ( $astpp_db, $reseller, $type ) = @_; my ( $sql, @accountlist, $row, $tmp ); + $reseller = "" if !$reseller; if ( $type == -1 ) { $tmp = "SELECT number FROM accounts WHERE status < 2 AND reseller = " Added: trunk/templates/account-remove.tpl =================================================================== --- trunk/templates/account-remove.tpl (rev 0) +++ trunk/templates/account-remove.tpl 2008-01-19 06:28:08 UTC (rev 2173) @@ -0,0 +1,23 @@ +<input name="mode" value="Remove Account" type="hidden"> +<table class="default"> +<tr class="header"> + <td colspan=3>Please select the account you wish to remove</td> +</tr> +<tr> + <td> + <TMPL_VAR NAME="accountlist_menu"> + </td> + <td> + <input name="number" size="20" type="text"> + </td> + <td> + <input name="action" value="Remove Account" type="submit"> + </td> +</tr> +<tr> + <td> + <TMPL_VAR NAME="status"> + </td> +</tr> +</table> +</form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-05-03 22:02:11
|
Revision: 2174 http://astpp.svn.sourceforge.net/astpp/?rev=2174&view=rev Author: darrenkw Date: 2008-05-03 15:02:09 -0700 (Sat, 03 May 2008) Log Message: ----------- Added a program to convert the Master.csv file into a series of SQL statements. Added Paths: ----------- trunk/contrib/ trunk/contrib/astpp-import-cdrs.pl Added: trunk/contrib/astpp-import-cdrs.pl =================================================================== --- trunk/contrib/astpp-import-cdrs.pl (rev 0) +++ trunk/contrib/astpp-import-cdrs.pl 2008-05-03 22:02:09 UTC (rev 2174) @@ -0,0 +1,117 @@ +#!/usr/bin/perl +# Author: Darren Wiebe <da...@al...> +# Date: May 2,2008 +# +# This program was written by Darren Wiebe <da...@al...>. +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2 or later +# at your option. +# + +use DBI; +use Text::CSV; + + +require "/usr/local/astpp/astpp-common.pl"; +$ENV{LANGUAGE} = "en"; # de, es, br - whatever +print STDERR "Interface language is set to: " . $ENV{LANGUAGE} . "\n"; +use vars qw(@output $astpp_db $config + $status $config $ASTPP); + +$infile = $ARGV[0]; +$outfile = $ARGV[1]; + +sub initialize() { + $config = &load_config(); + $astpp_db = &connect_db( $config, @output ); + $config = &load_config_db( $astpp_db, $config ) if $astpp_db; + $cdr_db = &cdr_connect_db( $config, @output ); +} + +sub finduniqueid() { + my ( $cc, $count, $startingdigit, $sql, $record ); + for ( ; ; ) { + $count = 1; + $cc = + int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ); + $sql = + $cdr_db->prepare( + "SELECT COUNT(*) FROM cdr WHERE uniqueid = " + . $cdr_db->quote($cc) ); + $sql->execute; + $record = $sql->fetchrow_hashref; + $count = $record->{"COUNT(*)"}; + $sql->finish; + return $cc if ( $count == 0 ); + } +} + + +sub read_file { + open(READFILE,"$infile") || + die "Error - could not open $infile for reading.\n"; + @data =<READFILE>; + close(READFILE); + my $csv = Text::CSV->new(); + foreach $temp (@data) { + print STDERR $temp; + if ( $csv->parse ($temp) ) { + my $tmp; + @column = $csv->fields(); + $uniqueid = &finduniqueid; + print STDERR "DURATION: $column[13] UNIQUEID: $uniqueid ACCOUNT: $column[0] DST: $column[2]\n"; + &printsql; + } else { + my $error = $csv->error_input; + $status .= "pars() failed on argument: " . $error . "<br>"; + } + + } +} + +sub printsql() { + open ( OUTFILE, ">>$outfile" ) || die "Could not open outfile"; + $tmp = "INSERT INTO cdr (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,cost,vendor) VALUES (" . + $cdr_db->quote($column[9]) . ", " . + $cdr_db->quote($column[4]) . ", " . + $cdr_db->quote($column[1]) . ", " . + $cdr_db->quote($column[2]) . ", " . + $cdr_db->quote($column[3]) . ", " . + $cdr_db->quote($column[5]) . ", " . + $cdr_db->quote($column[6]) . ", " . + $cdr_db->quote($column[7]) . ", " . + $cdr_db->quote($column[8]) . ", " . + $cdr_db->quote($column[12]) . ", " . + $cdr_db->quote($column[13]) . ", " . + $cdr_db->quote($column[14]) . ", " . + $cdr_db->quote($column[15]) . ", " . + $cdr_db->quote($column[0]) . ", " . + $cdr_db->quote($uniqueid) . ", " . + $cdr_db->quote("none") . ", " . + $cdr_db->quote("none") . ");"; + print STDERR $tmp . "\n"; + print OUTFILE $tmp . "\n"; + close (OUTFILE); +} + + +if ($infile eq "" || $outfile eq "") { + print "\n---- Command Line Error ---- \n\n"; + print "Please call this program with your csv file as the first argument.\n"; + print "The next argument should be the name of the file you want the sql dumped\n"; + print "into. For more info pleas peruse the source code.\n"; + print "ie ./astpp-import-cdrs.pl ./Master.csv ./Master.sql\n\n"; + exit(0); +} + +&initialize(); + +&read_file; Property changes on: trunk/contrib/astpp-import-cdrs.pl ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-05-06 01:11:31
|
Revision: 2177 http://astpp.svn.sourceforge.net/astpp/?rev=2177&view=rev Author: darrenkw Date: 2008-05-05 18:11:34 -0700 (Mon, 05 May 2008) Log Message: ----------- Corrected the permissions set in the makefile. Fixed bug: [ 1956258 ] Interface rating doesn't show call cost Modified Paths: -------------- trunk/Makefile trunk/astpp-admin.cgi Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2008-05-03 22:07:56 UTC (rev 2176) +++ trunk/Makefile 2008-05-06 01:11:34 UTC (rev 2177) @@ -14,7 +14,7 @@ EXTENSIONS=/etc/asterisk/extensions.conf LOCALE_DIR=/usr/local/share/locale OWNER=root -GROUP=root +GROUP=wheel WWWDIR=/var/www all: Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-05-03 22:07:56 UTC (rev 2176) +++ trunk/astpp-admin.cgi 2008-05-06 01:11:34 UTC (rev 2177) @@ -9174,9 +9174,9 @@ ) . "</td><td>" . submit( -name => 'action', -value => gettext("Price Call...") ) - . "</td></tr> -</table> -"; + . "</td></tr><tr><td colspan=4>" + . $status + . "</td></tr></table>"; return $body; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-05-21 22:52:56
|
Revision: 2180 http://astpp.svn.sourceforge.net/astpp/?rev=2180&view=rev Author: darrenkw Date: 2008-05-21 15:52:55 -0700 (Wed, 21 May 2008) Log Message: ----------- Moved "Calculate Call Charge" output to an HTML Template. Adjusted code posting cdrs to OSCommerce so that callerid information is posted also. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-common.pl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-05-21 22:50:10 UTC (rev 2179) +++ trunk/astpp-admin.cgi 2008-05-21 22:52:55 UTC (rev 2180) @@ -9103,8 +9103,17 @@ sub build_calc_charge() { my ( $status, $body, $cost, $length, $increment ); + $template = + HTML::Template->new( + filename => '/var/lib/astpp/templates/calc-charge.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; - @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); + $template->param( + pricelists => popup_menu( + -name => "pricelist", + -values => \@pricelists + ) + ); if ( $params->{action} eq gettext("Price Call...") ) { my $branddata = &get_pricelist( $astpp_db, $params->{pricelist} ); my $numdata = &get_route( $astpp_db, $config, $params->{phonenumber}, @@ -9143,41 +9152,10 @@ . gettext(" for a call lasting ") . $params->{length} . gettext(" minutes."); + $template->param( + status => $status); } - $body = start_form - . "<table class=\"default\">" - . "<tr class=\"header\"><td>" - . hidden( -name => 'mode', -default => gettext("Calc Charge") ) - . gettext("Phone Number") - . "</td><td>" - . gettext("Length (Minutes)") - . "</td><td>" - . gettext("Pricelist") - . "</td><td>" - . gettext("Action") - . "</td></tr> -<tr class=\"rowone\"><td>" - . textfield( - -name => 'phonenumber', - -size => 20 - ) - . "</td><td>" - . textfield( - -name => 'length', - -size => 4 - ) - . "</td><td>" - . popup_menu( - -name => 'pricelist', - -values => \@pricelists, - -default => $config->{default_brand} - ) - . "</td><td>" - . submit( -name => 'action', -value => gettext("Price Call...") ) - . "</td></tr><tr><td colspan=4>" - . $status - . "</td></tr></table>"; - return $body; + return $template->output; } sub build_configuration() { Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-05-21 22:50:10 UTC (rev 2179) +++ trunk/astpp-common.pl 2008-05-21 22:52:55 UTC (rev 2180) @@ -4454,7 +4454,7 @@ sub osc_post_charge() { my ($osc_db, $config, $invoice_id, $row ) = @_; my ( $sql, $desc, $tmp, $price ); - $desc = "$row->{callstart} $row->{callednum} SEC:$row->{billseconds}"; + $desc = "$row->{callstart} SRC: $row->{callerid} DST: $row->{callednum} SEC:$row->{billseconds} $row->{notes}"; $price = $row->{debit} / 10000; $tmp = "INSERT INTO `orders_products` (`orders_products_id`,`orders_id`,`products_id`,`products_name`,`products_price`," This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-05-25 23:15:29
|
Revision: 2181 http://astpp.svn.sourceforge.net/astpp/?rev=2181&view=rev Author: darrenkw Date: 2008-05-25 16:15:33 -0700 (Sun, 25 May 2008) Log Message: ----------- Added support to prepend digits in front of those autogenerated. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-common.pl Added Paths: ----------- trunk/sql/astpp-2008-05-25.sql Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-05-21 22:52:55 UTC (rev 2180) +++ trunk/astpp-admin.cgi 2008-05-25 23:15:33 UTC (rev 2181) @@ -9684,6 +9684,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $sipid = $config->{sip_ext_prepend} . $sipid; $sipid = substr( $sipid, 0, 5 ); $sipid = $name . $sipid; $ASTPP->debug( user=> $param->{username}, debug => "SIPID: $sipid" ); @@ -10110,6 +10111,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $iaxid = $config->{iax2_ext_prepend} . $iaxid; $iaxid = substr( $iaxid, 0, 5 ); $iaxid = $name . $iaxid; $ASTPP->debug( user=> $param->{username}, debug => "IAXID: $iaxid"); Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-05-21 22:52:55 UTC (rev 2180) +++ trunk/astpp-common.pl 2008-05-25 23:15:33 UTC (rev 2181) @@ -95,6 +95,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $pin = $config->{pin_cc_prepend} . $pin; $pin = substr( $pin, 0, $config->{pinlength} ); } $sql = @@ -1835,6 +1836,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $pin = $config->{pin_act_prepend} . $pin; if ( $config->{startingdigit} ne "" && $config->{startingdigit} ne "0" ) { @@ -1880,6 +1882,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $cc = $config->{cc_prepend} . $cc; if ( $config->{startingdigit} ne "" && $config->{startingdigit} ne "0" ) { @@ -1925,6 +1928,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $cc = $config->{cc_prepend} . $cc; if ( $config->{startingdigit} ne "" && $config->{startingdigit} ne "0" ) { @@ -2744,6 +2748,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $sipid = $config->{sip_ext_prepend} . $sipid; $sipid = substr( $sipid, 0, 5 ); $sipid = $name . $sipid; print STDERR "SIPID: $sipid\n" if $config->{debug} == 1; @@ -2775,6 +2780,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $iaxid = $config->{iax2_ext_prepend} . $iaxid; $iaxid = substr( $iaxid, 0, 5 ); $iaxid = $name . $iaxid; print STDERR "IAXID: $iaxid\n" if $config->{debug} == 1; Added: trunk/sql/astpp-2008-05-25.sql =================================================================== --- trunk/sql/astpp-2008-05-25.sql (rev 0) +++ trunk/sql/astpp-2008-05-25.sql 2008-05-25 23:15:33 UTC (rev 2181) @@ -0,0 +1,1292 @@ +DROP TABLE IF EXISTS `routes`; +CREATE TABLE routes ( +id INTEGER NOT NULL AUTO_INCREMENT, +pattern CHAR(40), +comment CHAR(80), +connectcost INTEGER NOT NULL, +includedseconds INTEGER NOT NULL, +cost INTEGER NOT NULL, +pricelist CHAR(80), +inc INTEGER, +reseller CHAR(50) default NULL, +precedence INT(4) NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), +KEY `pattern` (`pattern`), +KEY `pricelist` (`pricelist`), +KEY `reseller` (`reseller`), +KEY `status` (`status`) +); + +DROP TABLE IF EXISTS `pricelists`; +CREATE TABLE pricelists ( +name CHAR(40) NOT NULL, +markup INTEGER NOT NULL DEFAULT 0, +inc INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +reseller CHAR(50) default NULL, +PRIMARY KEY (`name`) +); + +DROP TABLE IF EXISTS `callingcardbrands`; +CREATE TABLE callingcardbrands ( +name CHAR(40) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +validfordays CHAR(4) NOT NULL DEFAULT '', +pin INTEGER NOT NULL DEFAULT 0, +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `pricelist` (`pricelist`) +); + +DROP TABLE IF EXISTS `callingcardcdrs`; +CREATE TABLE callingcardcdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(50) NOT NULL DEFAULT '', +clid CHAR(80) NOT NULL DEFAULT '', +destination CHAR(40) NOT NULL DEFAULT '', +disposition CHAR(20)NOT NULL DEFAULT '', +callstart CHAR(40) NOT NULL DEFAULT '', +seconds INTEGER NOT NULL DEFAULT 0, +debit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +credit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +status INTEGER DEFAULT 0 NOT NULL, +uniqueid VARCHAR(32) NOT NULL DEFAULT '', +notes CHAR(80) NOT NULL DEFAULT '', +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `cardnumber` (`cardnumber`) +); + +DROP TABLE IF EXISTS `trunks`; +CREATE TABLE trunks ( +name VARCHAR(30) NOT NULL, +tech CHAR(10) NOT NULL DEFAULT '', +path CHAR(40) NOT NULL DEFAULT '', +provider CHAR(100) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +dialed_modify TEXT NOT NULL DEFAULT '', +resellers TEXT NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +maxchannels INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (`name`), + KEY `provider` (`provider`), + KEY `provider_2` (`provider`) +); + +DROP TABLE IF EXISTS `outbound_routes`; +CREATE TABLE outbound_routes ( +pattern CHAR(40), +id INTEGER NOT NULL AUTO_INCREMENT, +comment CHAR(80) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +trunk CHAR(80) NOT NULL DEFAULT '', +inc CHAR(10) NOT NULL DEFAULT '', +strip CHAR(40) NOT NULL DEFAULT '', +prepend CHAR(40) NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +resellers TEXT NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `trunk` (`trunk`), + KEY `pattern` (`pattern`) +); + +DROP TABLE IF EXISTS `dids`; +CREATE TABLE dids ( +number CHAR(40) NOT NULL, +account CHAR(50) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +monthlycost INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +inc CHAR(10) NOT NULL DEFAULT '', +extensions CHAR(180) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +provider CHAR(40) NOT NULL DEFAULT '', +country CHAR (80)NOT NULL DEFAULT '', +province CHAR (80) NOT NULL DEFAULT '', +city CHAR (80) NOT NULL DEFAULT '', +prorate int(1) NOT NULL default 0, +setup int(11) NOT NULL default 0, +limittime int(1) NOT NULL default 1, +disconnectionfee INT(11) NOT NULL default 0, +variables TEXT NOT NULL DEFAULT '', +options varchar(40) default NULL, +maxchannels int(4) NOT NULL default 0, +chargeonallocation int(1) NOT NULL default 1, +allocation_bill_status int(1) NOT NULL default 0, +dial_as CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `account` (`account`) +); + +DROP TABLE IF EXISTS `accounts`; +CREATE TABLE accounts ( +cc CHAR(20) NOT NULL DEFAULT '', +number CHAR(50) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(24) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +credit INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +creation TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +pin INTEGER NOT NULL DEFAULT 0, +credit_limit INTEGER NOT NULL DEFAULT 0, +posttoexternal INTEGER NOT NULL DEFAULT 0, +balance DECIMAL(20,6) NOT NULL DEFAULT 0, +password CHAR(80) NOT NULL DEFAULT '', +first_name CHAR(40) NOT NULL DEFAULT '', +middle_name CHAR(40) NOT NULL DEFAULT '', +last_name CHAR(40) NOT NULL DEFAULT '', +company_name CHAR(40) NOT NULL DEFAULT '', +address_1 CHAR(80) NOT NULL DEFAULT '', +address_2 CHAR(80) NOT NULL DEFAULT '', +address_3 CHAR(80) NOT NULL DEFAULT '', +postal_code CHAR(12) NOT NULL DEFAULT '', +province CHAR(40) NOT NULL DEFAULT '', +city CHAR(80) NOT NULL DEFAULT '', +country CHAR(40) NOT NULL DEFAULT '', +telephone_1 CHAR(40) NOT NULL DEFAULT '', +telephone_2 CHAR(40) NOT NULL DEFAULT '', +fascimile CHAR(40) NOT NULL DEFAULT '', +email CHAR(80) NOT NULL DEFAULT '', +language CHAR(2) NOT NULL DEFAULT '', +currency CHAR(3) NOT NULL DEFAULT '', +maxchannels INTEGER DEFAULT 1 NOT NULL, +routing_technique INT(4) NOT NULL DEFAULT 0, +dialed_modify TEXT NOT NULL DEFAULT '', +type INTEGER DEFAULT 0, +tz CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +DROP TABLE IF EXISTS `counters`; +CREATE TABLE counters ( +id INTEGER NOT NULL AUTO_INCREMENT, +package CHAR(40) NOT NULL DEFAULT '', +account VARCHAR(50) NOT NULL, +seconds INTEGER NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +DROP TABLE IF EXISTS `callingcards`; +CREATE TABLE callingcards ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(20) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +value INTEGER NOT NULL DEFAULT 0, +used INTEGER NOT NULL DEFAULT 0, +brand VARCHAR(20) NOT NULL DEFAULT '', +created DATETIME, +firstused DATETIME, +expiry DATETIME, +validfordays CHAR(4) NOT NULL DEFAULT '', +inuse INTEGER NOT NULL DEFAULT 0, +pin CHAR(20), +account VARCHAR(50) NOT NULL DEFAULT '', +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +maint_day INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +timeused INTEGER NOT NULL DEFAULT 0, +invoice CHAR(20) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `brand` (`brand`) +); + +CREATE TABLE charge_to_account ( +id INTEGER NOT NULL AUTO_INCREMENT, +charge_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(50) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +CREATE TABLE queue_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +queue_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE pbx_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +pbx_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE extension_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +extension_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE cdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +uniqueid varchar(32) NOT NULL DEFAULT '', +cardnum CHAR(50), +callerid CHAR(80), +callednum varchar(80) NOT NULL DEFAULT '', +billseconds INT DEFAULT 0 NOT NULL, +trunk VARCHAR(30), +disposition varchar(45) NOT NULL DEFAULT '', +callstart varchar(80) NOT NULL DEFAULT '', +debit DECIMAL (20,6) NOT NULL DEFAULT 0, +credit DECIMAL (20,6) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 0 NOT NULL, +notes CHAR(80), +provider CHAR(50), +cost DECIMAL(20,6) NOT NULL DEFAULT 0, +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `cardnum` (`cardnum`), + KEY `provider` (`provider`), + KEY `trunk` (`trunk`), + KEY `uniqueid` (`uniqueid`), + KEY `status` (`status`) +); + +CREATE TABLE packages ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +pattern CHAR(40) NOT NULL DEFAULT '', +includedseconds INTEGER NOT NULL DEFAULT 0, +reseller VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE ani_map ( +number char(20) NOT NULL, +account char(50) NOT NULL default '', +status int(11) NOT NULL default '0', +context varchar(20) NOT NULL, + PRIMARY KEY (`number`), +KEY `account` (`account`) +); + +CREATE TABLE `ip_map` ( +ip char(15) NOT NULL default '', +account char(20) NOT NULL default '', +prefix varchar(20) NULL, +context varchar(20) NOT NULL, +PRIMARY KEY (`ip`,`prefix`), +KEY `account` (`account`) +); + +CREATE TABLE charges ( +id INTEGER NOT NULL AUTO_INCREMENT, +pricelist CHAR(40) NOT NULL DEFAULT '', +description VARCHAR(80) NOT NULL DEFAULT '', +charge INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +reseller CHAR(40) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`) +); + +CREATE TABLE manager_action_variables ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(60) NOT NULL DEFAULT '', +value CHAR(60) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE callingcard_stats ( +uniqueid VARCHAR(48) NOT NULL, +total_time VARCHAR(48) NOT NULL, +billable_time VARCHAR(48) NOT NULL, +timestamp DATETIME NULL, +PRIMARY KEY (`uniqueid`) +); + +CREATE TABLE system ( +name VARCHAR(48) NULL, +value VARCHAR(255) NULL, +comment VARCHAR(255) NULL, +timestamp DATETIME NULL, +reseller VARCHAR(48) NULL, +brand VARCHAR(48) NULL, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `brand` (`brand`) +); + + +INSERT INTO system (name, value, comment) VALUES ( +'callout_accountcode','admin','Call Files: What accountcode should we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'lcrcontext', +'astpp-outgoing', +'This is the Local context we use to route our outgoing calls through esp for callbacks'); + + +INSERT INTO system (name, value, comment) VALUES ( +'maxretries', +'3', +'Call Files: How many times do we retry?'); + +INSERT INTO system (name, value, comment) VALUES ( +'retrytime', +'30', +'Call Files: How long do we wait between retries?'); + +INSERT INTO system (name, value, comment) VALUES ( +'waittime', +'15', +'Call Files: How long do we wait before the initial call?'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidname', +'Private', +'Call Files: Outgoing CallerID Name'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidnumber', +'0000000000', +'Call Files: Outgoing CallerID Number'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_context', +'astpp-callingcards', +'Call Files: For callingcards what context do we end up in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_extension', 's', +'Call Files: For callingcards what extension do we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser_dbengine', '0', +'For now this must be MySQL'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser', '0', +'Use OPENSER? 1 for yes or 0 for no'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbname', '0', +'OPENSER Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbuser', '0', +'OPENSER Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbhost', '0', +'OPENSER Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbpass', '0', +'OPENSER Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_domain', NULL, +'OPENSER Domain', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_email', 'em...@as...', +'Email address that email should appear to be from', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_dir', '/etc/asterisk', +'Which directory are asterisk configuration files stored in?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_website', 'http://www.astpp.org', +'Link to your company website', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_name', 'ASTPP.ORG', +'The name of your company. Used in emails.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'email', '1', +'Send out email? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'user_email', '1', +'Email user on account changes? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'debug', '0', +'Enable debugging output? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'emailadd', 'em...@as...', +'Administrator email address', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'startingdigit', '0', +'The digit that all calling cards must start with. 0=disabled', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'enablelcr', '1', +'Use least cost routing 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'log_file', '/var/log/astpp/astpp.log', +'ASTPP Log file', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key_home', 'http://www.astpp.org/astpp.pub', +'Asterisk RSA Key location (optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rate_engine_csv_file', '/var/log/astpp/astpp.csv', +'CSV File for call rating data', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'csv_dir', '/var/log/astpp/', +'CSV File Directory', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_brand', 'default', +'Default pricelist. If a price is not found in the customers pricelist we check this one.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'new_user_brand', 'default', +'What is the default pricelist for new customers?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_context', 'custom-astpp', +'What is the default context for new devices?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cardlength', '10', +'Number of digits in calling cards and cc codes.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_server', 'voip.astpp.org', +'Your default voip server. Used in outgoing email.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'currency', 'CAD', +'Name of the currency you use', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'iax_port', '4569', +'Default IAX2 Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sip_port', '5060', +'Default SIP Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'ipaddr', 'dynamic', +'Default IP Address for new devices', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key', 'astpp.pub', +'Asterisk RSA Key Name (Optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pinlength', '6', +'For those calling cards that are using pins this is the number of digits it will have.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'credit_limit', '0', +'Default credit limit in dollars.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints', '4', +'How many decimal points do we bill to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'max_free_length', '100', +'What is the maximum length (in minutes) of calls that are at no charge?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'trackvendorcharges', '1', +'Do we track the amount of money we spend with specific providers? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_logo', 'http://www.astpp.org/logo.png', +'', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_slogan', 'Welcome to ASTPP', +'', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'version', '1.5Beta', 'ASTPP Version', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_language', 'en', 'Default ASTPP Language',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'card_retries','3', 'How many retries do we allow for calling card numbers?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pin_retries','3', 'How many retries do we allow for pins?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'number_retries','3','How many retries do we allow calling card users when dialing a number?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'booth_context','callshop_booth','Please enter the default context for a callshop booth.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards_max_length','9000','What is the maximum length (in ms) of a callingcard call?',''); + +INSERT INTO system (name,value,comment,timestamp) VALUES ( +'template_die_on_bad_params','0','Should HTML::Template die on bad parameters?',''); +-- +-- This is where the old "enh-config" settings start +-- + +INSERT INTO system (name, value, comment, timestamp) VALUES ('results_per_page','30','How many results per page do we should in the web interface?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astpp_dir','/var/lib/astpp','Where do the astpp configs live?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'auth','a23asudf9810-zalkj32423','This is the override authorization code and will allow access to the system.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_dbengine','MySQL','Database type for Asterisk(tm) -Realtime',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbengine','MySQL','Database type for the cdr database',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_dbengine','MySQL','Database type for OSCommerce',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbengine','MySQL','Database type for AgileBill(tm)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_dbengine','MySQL','Database type for FreePBX',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'externalbill','oscommerce','Please specify the external billing application to use. If you are not using any then leave it blank. Valid options are "agile" and "oscommerce".',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards','1','Do you wish to enable calling cards? 1 for yes and 2 for no.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astcdr','1','Change this one at your own peril. If you switch it off, calls will not be marked as billed in asterisk once they are billed.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'posttoastpp','1','Change this one at your own peril. If you switch it off, calls will not be written to astpp when they are calculated.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sleep','10','How long shall the rating engine sleep after it has been notified of a hangup? (in seconds)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_amp','0','If this is enabled, ASTPP will create users and DIDs in the FreePBX (www.freepbx.org) database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_rt','1','If this is enabled, ASTPP will create users and DIDs in the Asterisk Realtime database.',''); + +INSERT INTO system (name, value, comment) VALUES ( +'service_prepend','778',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_length,','7',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_filler','4110000',''); + +INSERT INTO system (name, value, comment) VALUES ( +'asterisk_cdr_table','cdr','Which table of the Asterisk(TM) database are the cdrs in?' +); + +-- AgileBill(Trademark of AgileCo) Settings: +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_db','agile','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_site_id','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_charge_status','0','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_taxable','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbprefix','_','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_service_prepend','778','',''); + +-- OSCommerce Settings (www.oscommerce.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_db','oscommerce','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_pass','password','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_product_id','99999999','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_payment_method','"Charge"','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_order_status','1','',''); + +-- FreePBX Settings (www.freepbx.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_db','asterisk','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_pass','passw0rd','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_dtmfmode','rfc2833','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_callgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_pickupgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_notransfer','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_qualify','yes','',''); + +-- Asterisk -realtime Settings +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_db','realtime','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_insecure','very','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_type','friend','',''); +INSERT INTO system (name, value, comment) VALUES ( +'rt_voicemail_table','voicemail_users',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_rate_announce','1','Do we want the calling cards script to announce the rate on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_timelimit_announce','1','Do we want the calling cards script to announce the timelimit on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_cancelled_prompt','1','Do we want the calling cards script to announce that the call was cancelled?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_menu','1','Do we want the calling cards script to present a menu before exiting?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_connection_prompt','1','Do we want the calling cards script to announce that it is connecting the call?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_pin_input_timeout','15000','How long do we wait when entering the calling card pin? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_number_input_timeout','15000','How long do we wait when entering the calling card number? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_dial_input_timeout','15000','How long do we wait when entering the destination number in calling cards? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_general_input_timeout','15000','How long do we wait for input in general menus? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_welcome_file','silence/1','What do we play for a welcome file?'); + +INSERT INTO system (name, value, comment) VALUES ( +'sip_ext_prepend','10','What should every autoadded SIP extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'iax2_ext_prepend','10','What should every autoadded IAX2 extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'cc_prepend','','What should every autoadded callingcard begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_cc_prepend','','What should every autoadded callingcard pin begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_act_prepend','','What should every autoadded account pin begin with?'); + + +-- +-- Enough Configuration settings +-- + +DROP TABLE IF EXISTS `countrycode`; +CREATE TABLE `countrycode` ( + `country` varchar(255) NOT NULL, + PRIMARY KEY (`country`), + KEY `country` (`country`) +); + +INSERT INTO `countrycode` (`country`) VALUES + ('Afghanistan'), + ('Alaska'), + ('Albania'), + ('Algeria'), + ('AmericanSamoa'), + ('Andorra'), + ('Angola'), + ('Antarctica'), + ('Argentina'), + ('Armenia'), + ('Aruba'), + ('Ascension'), + ('Australia'), + ('Austria'), + ('Azerbaijan'), + ('Bahrain'), + ('Bangladesh'), + ('Belarus'), + ('Belgium'), + ('Belize'), + ('Benin'), + ('Bhutan'), + ('Bolivia'), + ('Bosnia & Herzegovina'), + ('Botswana'), + ('Brazil'), + ('Brunei Darussalam'), + ('Bulgaria'), + ('Burkina Faso'), + ('Burundi'), + ('Cambodia'), + ('Cameroon'), + ('Canadda'), + ('Cape Verde Islands'), + ('Central African Republic'), + ('Chad'), + ('Chile'), + ('China'), + ('Colombia'), + ('Comoros'), + ('Congo'), + ('Cook Islands'), + ('Costa Rica'), + ('Croatia'), + ('Cuba'), + ('Cuba Guantanamo Bay'), + ('Cyprus'), + ('Czech Republic'), + ('Denmark'), + ('Diego Garcia'), + ('Djibouti'), + ('Dominican Republic'), + ('East Timor'), + ('Ecuador'), + ('Egypt'), + ('El Salvador'), + ('Equatorial Guinea'), + ('Eritrea'), + ('Estonia'), + ('Ethiopia'), + ('Faroe Islands'); +INSERT INTO `countrycode` (`country`) VALUES + ('Fiji Islands'), + ('Finland'), + ('France'), + ('French Guiana'), + ('French Polynesia'), + ('Gabonese Republic'), + ('Gambia'), + ('Georgia'), + ('Germany'), + ('Ghana'), + ('Gibraltar'), + ('Greece'), + ('Greenland'), + ('Guadeloupe'), + ('Guam'), + ('Guatemala'), + ('Guinea'), + ('Guyana'), + ('Haiti'), + ('Honduras'), + ('Hong Kong'), + ('Hungary'), + ('Iceland'), + ('India'), + ('Indonesia'), + ('Iran'), + ('Iraq'), + ('Ireland'), + ('Israel'), + ('Italy'), + ('Jamaica'), + ('Japan'), + ('Jordan'), + ('Kazakstan'), + ('Kenya'), + ('Kiribati'), + ('Kuwait'), + ('Kyrgyz Republic'), + ('Laos'), + ('Latvia'), + ('Lebanon'), + ('Lesotho'), + ('Liberia'), + ('Libya'), + ('Liechtenstein'), + ('Lithuania'), + ('Luxembourg'), + ('Macao'), + ('Madagascar'), + ('Malawi'), + ('Malaysia'), + ('Maldives'), + ('Mali Republic'), + ('Malta'), + ('Marshall Islands'), + ('Martinique'), + ('Mauritania'), + ('Mauritius'), + ('MayotteIsland'), + ('Mexico'), + ('Midway Islands'), + ('Moldova'), + ('Monaco'), + ('Mongolia'), + ('Morocco'); +INSERT INTO `countrycode` (`country`) VALUES + ('Mozambique'), + ('Myanmar'), + ('Namibia'), + ('Nauru'), + ('Nepal'), + ('Netherlands'), + ('Netherlands Antilles'), + ('New Caledonia'), + ('New Zealand'), + ('Nicaragua'), + ('Niger'), + ('Nigeria'), + ('Niue'), + ('Norfolk Island'), + ('North Korea'), + ('Norway'), + ('Oman'), + ('Pakistan'), + ('Palau'), + ('Palestinian Settlements'), + ('Panama'), + ('PapuaNew Guinea'), + ('Paraguay'), + ('Peru'), + ('Philippines'), + ('Poland'), + ('Portugal'), + ('Puerto Rico'), + ('Qatar'), + ('RéunionIsland'), + ('Romania'), + ('Russia'), + ('Rwandese Republic'), + ('San Marino'), + ('São Tomé and Principe'), + ('Saudi Arabia'), + ('Senegal '), + ('Serbia and Montenegro'), + ('Seychelles Republic'), + ('Sierra Leone'), + ('Singapore'), + ('Slovak Republic'), + ('Slovenia'), + ('Solomon Islands'), + ('Somali Democratic Republic'), + ('South Africa'), + ('South Korea'), + ('Spain'), + ('Sri Lanka'), + ('St Kitts - Nevis'), + ('St. Helena'), + ('St. Lucia'), + ('St. Pierre & Miquelon'), + ('St. Vincent & Grenadines'), + ('Sudan'); +INSERT INTO `countrycode` (`country`) VALUES + ('Suriname'), + ('Swaziland'), + ('Sweden'), + ('Switzerland'), + ('Syria'), + ('Taiwan'), + ('Tajikistan'), + ('Tanzania'), + ('Thailand'), + ('Togolese Republic'), + ('Tokelau'), + ('Tonga Islands'), + ('Trinidad & Tobago'), + ('Tunisia'), + ('Turkey'), + ('Turkmenistan'), + ('Tuvalu'), + ('Uganda'), + ('Ukraine'), + ('United Arab Emirates'), + ('United Kingdom'), + ('United States of America'), + ('Uruguay'), + ('Uzbekistan'), + ('Vanuatu'), + ('Venezuela'), + ('Vietnam'), + ('Wake Island'), + ('Wallisand Futuna Islands'), + ('Western Samoa'), + ('Yemen'), + ('Zambia'), + ('Zimbabwe'); + +DROP TABLE IF EXISTS `currency`; +CREATE TABLE `currency` ( + `Currency` varchar(3) NOT NULL default '', + `CurrencyName` varchar(40) NOT NULL default '', + PRIMARY KEY (`Currency`) +); + +INSERT INTO `currency` (`Currency`,`CurrencyName`) VALUES + ('USD','US Dollars'), + ('CAD','Canadian Dollars'), + ('AUD','Australian Dollars'); + +CREATE TABLE `language` ( + `language` varchar(5) NOT NULL, + `languagename` varchar(40) NOT NULL, + `active` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`language`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `language` (`language`,`languagename`,`active`) VALUES + ('en','English',1), + ('fr','French',1), + ('de','German',1); + +CREATE TABLE `resellers` ( + name varchar(40) NOT NULL default '', + status int(11) NOT NULL default '1', + posttoexternal int(11) NOT NULL default '0', + agile_site_id int(11) NOT NULL default '0', + config_file char(80) NOT NULL default 'reseller.conf', + companyname varchar(255) default NULL, + slogan varchar(255) default NULL, + footer varchar(255) default NULL, + pricelist varchar(255) default NULL, + currency varchar(255) default NULL, + logo varchar(255) default NULL, + website varchar(255) default NULL, + adminemail varchar(255) default NULL, + salesemail varchar(255) default NULL, + phone varchar(45) default NULL, + fax varchar(45) default NULL, + address1 varchar(255) default NULL, + address2 varchar(255) default NULL, + city varchar(255) default NULL, + state varchar(255) default NULL, + postcode varchar(255) default NULL, + country varchar(255) default NULL, + defaultbrand varchar(45) NOT NULL default 'default', + defaultcurrency varchar(45) NOT NULL default 'USD', + defaultcredit varchar(45) NOT NULL default '0.00', + externalbill varchar(45) NOT NULL default '', + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +CREATE TABLE templates ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +reseller VARCHAR(45) NOT NULL default '', +template TEXT NOT NULL default '', + PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +INSERT INTO templates (name,template) VALUES +('voip_account_refilled','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been refilled. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('voip_reactivate_account','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been reactivated. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_add_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been added. +Your Username is -- $vars->{extension} -- +Your Password is -- $vars->{secret} -- +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('add_sip_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In sip.conf: +[$config->{company_name}-in] +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=from-pstn +accountcode=$config->{company_name} +[$config->{company_name}] +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid= <555-555-5555> +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +In the [globals] section add: +register => $vars->{user}:password@$config->{asterisk_server}'); + +INSERT INTO templates (name,template) VALUES +('add_iax_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In iax.conf: +At the bottom of the file add: +[$config->{company_name}-in] +;trunk=yes ;optional .. only works if you have a zaptel or ztdummy driver running +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=incoming +accountcode=$config->{company_name} ;for call tracking in the cdr +[$config->{company_name}] +;to simplify and config outgoing calls +;trunk=yes ;optional .. only works if you have a zaptel driver running +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid=<555-555-5555> ;only the number will really be used +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_remove_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP Termination with $config->{company_name} has been removed +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_calling_card','You have added a $vars->{pricelist} callingcard in the amount of $vars->{pennies} cents. +Card Number $cc Pin: $pin +Thanks for your patronage. +The $config->{company_name} sales team'); + +INSERT INTO templates (name,template) VALUES +('email_add_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been added +The number is: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team +Here is a sample setup which would call a few sip phones with incoming calls: +[incoming] +exten => _1$did,1,Wait(2) +exten => _1$did,2,Dial(SIP/2201&SIP/2202,15,Ttm) ; dial a couple of phones for 15 secs +exten => _1$did,3,Voicemail(u1000) ; go to unavailable voicemail (vm box 1000) +exten => _1$did,103,Voicemail(b1000) ; go to busy voicemail (vm box 1000)'); + +INSERT INTO templates (name,template) VALUES +('email_remove_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been removed +The number was: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_new_invoice','Invoice # $invoice in the amount of \$$total has been added to your account. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_low_balance','Your VOIP account with $config->{company_name} has a balance of \$$balance. +Please visit our website to refill your account to ensure uninterrupted service. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +CREATE TABLE `sweeplist` ( + `Id` int(10) unsigned NOT NULL default '0', + `sweep` varchar(45) NOT NULL default '', + PRIMARY KEY (`Id`) +); + +INSERT INTO sweeplist (Id,sweep) VALUES +(0,'daily'), +(1,'weekly'), +(2,'monthly'), +(3,'quarterly'), +(4,'semi-annually'), +(5,'annually') +; + +CREATE TABLE userlevels ( +userlevelid int(11) NOT NULL, +userlevelname varchar(50) NOT NULL, +PRIMARY KEY (`userlevelid`) +); + +INSERT INTO `userlevels` (`userlevelid`,`userlevelname`) VALUES + (-1,'Administrator'), + (0,'Anonymous'), + (1,'Reseller'), + (2,'Admin'), + (3,'Vendor'), + (4,'Customer Service'), + (5,'Users'); + +CREATE TABLE reseller_pricing ( +id INTEGER NOT NULL AUTO_INCREMENT, +reseller VARCHAR(50) NOT NULL, +type INTEGER NOT NULL DEFAULT 1, +monthlycost INTEGER NOT NULL DEFAULT 0, +prorate INTEGER NOT NULL DEFAULT 0, +setup INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +note VARCHAR(50) NOT NULL DEFAULT '', +disconnectionfee INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +inc CHAR(10) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE callshops ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(50) NOT NULL, +osc_dbname VARCHAR(50) NOT NULL DEFAULT '', +osc_dbpass VARCHAR(50) NOT NULL DEFAULT '', +osc_dbuser VARCHAR(50) NOT NULL DEFAULT '', +osc_dbhost VARCHAR(50) NOT NULL DEFAULT '', +osc_site VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), +KEY `name` (`name`) +); + +CREATE TABLE extensions_status ( +id INTEGER NOT NULL AUTO_INCREMENT, +tech VARCHAR(6) NULL, +extension VARCHAR(20) NULL, +number VARCHAR(255) NULL, +status VARCHAR(255) NULL, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +Privilege VARCHAR(255) NULL, +Channel VARCHAR(255) NULL, +Cause VARCHAR(255) NULL, +Causetxt VARCHAR(255) NULL, +PeerStatus VARCHAR(255) NULL, +Peer VARCHAR(255) NULL, +Context VARCHAR(255) NULL, +Application VARCHAR(255) NULL, +AppData VARCHAR(255) NULL, +Priority VARCHAR(255) NULL, +Uniqueid VARCHAR(255) NULL, +Event VARCHAR(255) NULL, +State VARCHAR(255) NULL, +CallerIDName VARCHAR(255) NULL, +CallerID VARCHAR(255) NULL, +AstExtension VARCHAR(255) NULL, +PRIMARY KEY (`id`), +KEY `extension` (`extension`)); + +CREATE TABLE activity_logs ( +id INTEGER NOT NULL AUTO_INCREMENT, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +message TEXT NOT NULL DEFAULT '', +user VARCHAR(50), +PRIMARY KEY (`id`)); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-06-07 04:47:08
|
Revision: 2184 http://astpp.svn.sourceforge.net/astpp/?rev=2184&view=rev Author: darrenkw Date: 2008-06-06 21:47:11 -0700 (Fri, 06 Jun 2008) Log Message: ----------- Import Freeswitch support. This code works much, much faster using mod_perl. Modified Paths: -------------- trunk/astpp-common.pl trunk/astpp-ip-map.agi trunk/modules/ASTPP/lib/ASTPP.pm Added Paths: ----------- trunk/freeswitch/ trunk/freeswitch/README trunk/freeswitch/astpp-fs-xml.pl trunk/freeswitch/test-fs-xml.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-06-01 00:42:36 UTC (rev 2183) +++ trunk/astpp-common.pl 2008-06-07 04:47:11 UTC (rev 2184) @@ -1704,6 +1704,7 @@ my @pricelists = split ( m/,/m, $pricelist ); foreach my $pricelistname (@pricelists) { $pricelistname =~ s/"//g; #Strip off quotation marks + print STDERR "Pricelist: $pricelistname \n"; $record = &search_for_route($astpp_db,$config,$destination,$pricelist); print STDERR "pattern: $record->{pattern}\n" if $record->{pattern}; last if $record->{pattern}; #Returnes if we've found a match. @@ -1728,12 +1729,12 @@ } $record = &search_for_route($astpp_db,$config,$destination,$config->{default_brand}); print STDERR "pattern: $record->{pattern}\n" if $record->{pattern}; - } - if ( !$record->{pattern} ) { #If we have not found a route yet then we look in the "Default" pricelist. + } + if ( !$record->{pattern} ) { #If we have not found a route yet then we look in the "Default" pricelist. $record = &search_for_route($astpp_db,$config,$destination,$config->{default_brand}); print STDERR "pattern: $record->{pattern}\n" if $record->{pattern}; - } - print STDERR "Route: $record->{comment} Cost: $record->{cost} Pricelist: $record->{pricelist} Pattern: $record->{pattern}\n" if $record; + } + print STDERR "Route: $record->{comment} Cost: $record->{cost} Pricelist: $record->{pricelist} Pattern: $record->{pattern}\n" if $record; } elsif ($type =~ /ASTPP-DID/) { Modified: trunk/astpp-ip-map.agi =================================================================== --- trunk/astpp-ip-map.agi 2008-06-01 00:42:36 UTC (rev 2183) +++ trunk/astpp-ip-map.agi 2008-06-07 04:47:11 UTC (rev 2184) @@ -21,13 +21,17 @@ #exten => _X.,n,Goto(astpp-outgoing,${EXTEN},1) use DBI; +use ASTPP; use Asterisk::AGI; use POSIX qw(ceil floor); use POSIX qw(strftime); use strict; -use vars qw(@output $verbose $AGI $config $SIG $astpp_db); +use vars qw($ASTPP @output $verbose $AGI $config $SIG $astpp_db); @output = ( "STDERR", "LOGFILE" ); $verbose = 2; +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. +$ASTPP->set_asterisk_agi($AGI); require "/usr/local/astpp/astpp-common.pl"; $AGI = new Asterisk::AGI; @@ -36,6 +40,7 @@ $config = &load_config(); $astpp_db = &connect_db( $config, @output ); $config = &load_config_db($astpp_db,$config); + $ASTPP->set_astpp_db($astpp_db); } sub ignore_hup { @@ -45,31 +50,12 @@ } } -sub get_ip() { - my ($number,$extension) = @_; - my ($sql,$tmp); - $tmp = "SELECT * FROM ip_map WHERE ip = " . $astpp_db->quote($number); - -##### I know I wrote it with the OR statement for some reason but I can't figure out why. I'm leaving it here for now. -# $tmp = "SELECT * FROM ip_map WHERE ip = " . $astpp_db->quote($number) -# . " AND prefix IS NULL OR $extension RLIKE prefix ORDER BY LENGTH(prefix) DESC LIMIT 1"; -########### -$tmp = "SELECT * FROM ip_map WHERE ip = " . $astpp_db->quote($number) - . " AND prefix IN (NULL,'') OR ip = " . $astpp_db->quote($number) . " AND " . $astpp_db->quote($extension) . " RLIKE prefix ORDER BY LENGTH(prefix) DESC LIMIT 1"; - print STDERR $tmp if $config->{debug} == 1; - $AGI->verbose( "$tmp\n", $verbose ) if $config->{debug} == 1; - $sql = - $astpp_db->prepare($tmp); - $sql->execute; - my $anidata = $sql->fetchrow_hashref; - $sql->finish; - return $anidata; -} ################# Program Starts Here ################################# my ($ip, $extension) = @ARGV; my ($sql); &initialize; -my $anidata = &get_ip($ip,$extension); +my $anidata = $ASTPP->ip_address_authenticate( ip_address => $ip, destination => $extension); + if ($anidata) { my $carddata=&get_account($astpp_db, $anidata->{account}); $AGI->set_variable( 'ACCOUNTCODE', "\"$carddata->{cc}\"" ); Added: trunk/freeswitch/README =================================================================== --- trunk/freeswitch/README (rev 0) +++ trunk/freeswitch/README 2008-06-07 04:47:11 UTC (rev 2184) @@ -0,0 +1 @@ +This directory contains the support for Freeswitch. Please be aware that this is a work under development. Added: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl (rev 0) +++ trunk/freeswitch/astpp-fs-xml.pl 2008-06-07 04:47:11 UTC (rev 2184) @@ -0,0 +1,177 @@ +#!/usr/bin/perl +# +# ASTPP - Open Source Voip Billing +# +# Copyright (C) 2008, Aleph Communications +# +# Darren Wiebe (da...@al...) +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2. +############################################################ +# +# Usage-example: +# + +use DBI; +use CGI; +use CGI qw/:standard Vars/; +use ASTPP; +use strict; +use vars qw($params $ASTPP @output $config $astpp_db $verbosity ); +use Locale::gettext_pp qw(:locale_h); +require "/usr/local/astpp/astpp-common.pl"; +$ENV{LANGUAGE} = "en"; # de, es, br - whatever +print STDERR "Interface language is set to: " . $ENV{LANGUAGE} . "\n"; +bindtextdomain( "astpp", "/usr/local/share/locale" ); +textdomain("astpp"); +$verbosity = 2; +@output = ("STDERR"); +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. + + +sub initialize() { + $config = &load_config(); + $astpp_db = &connect_db( $config, @output ); + $ASTPP->set_astpp_db($astpp_db); + $config = &load_config_db( $astpp_db, $config ) if $astpp_db; +} + +################# Programs start here ####################################### +&initialize; +my ( $xml, $maxlength, $maxmins,$callstatus ); +foreach my $param ( param() ) { + $params->{$param} = param($param); + $ASTPP->debug( debug => "$param $params->{$param}" ); +} +$xml = header(-type => 'text/plain'); + +$ASTPP->debug( debug => "Destination = $params->{'Caller-Destination-Number'}"); + +if ($params->{section} eq "dialplan") { +$xml = $ASTPP->fs_dialplan_xml_header( xml => $xml, destination_number => $params->{'Caller-Destination-Number'}); + +if (!$params->{variable_accountcode}) { +# First we strip off X digits to see if this account is prepending numbers +# as authentications + $ASTPP->debug( debug => "Checking CC Number: " . $params->{'Caller-Destination-Number'}); + my $cc = substr( $params->{'Caller-Destination-Number'}, 0, $config->{cardlength} ); + my $sql = $astpp_db->prepare("SELECT number FROM accounts WHERE cc = $cc"); + $sql->execute; + my $record = $sql->fetchrow_hashref; + $sql->finish; + $params->{variable_accountcode} = $record->{cardnum} if ($record->{cardnum}); +} +if (!$params->{variable_accountcode}) { + $ASTPP->debug( debug => "Checking IP Address:" . $params->{network_addr}); + my $ip_data = $ASTPP->ip_address_authenticate( ip_address => $params->{network_addr}, destination => $params->{'Caller-Destination-Number'}); + if ($ip_data) { + $params->{variable_accountcode} = $ip_data->{account}; + $params->{'Caller-Destination-Number'} =~ s/$ip_data->{prefix}//g; + } +} + +$ASTPP->debug( debug => "$params->{variable_accountcode}, $params->{'Caller-Destination-Number'}"); + +my $carddata = &get_account( $astpp_db, $params->{variable_accountcode} ); # Fetch all the account info from the db. + +if ( !$carddata->{number} ) { # Check to see if the account exists. If not then exit. + $ASTPP->debug( debug => "CALLSTATUS 2"); + $ASTPP->debug( debug =>"CANNOT RETRIEVE CARD"); + $xml .= "<action application=\"reject\" data=\"CANNOT RETRIEVE ACCOUNT\"/>\n"; + $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml); + print $xml; + exit(0); +} + +if ($carddata->{dialed_modify}) { + my @regexs = split(m/,/m, $carddata->{dialed_modify}); + foreach my $regex (@regexs) { + $regex =~ s/"//g; #Strip off quotation marks + my ($grab,$replace) = split(m!/!i, $regex); # This will split the variable into a "grab" and "replace" as needed + $ASTPP->debug( debug => "Grab: $grab"); + $ASTPP->debug( debug => "Replacement: $replace"); + $ASTPP->debug( debug => "Phone Before: $params->{'Caller-Destination-Number'}"); + $$params->{'Caller-Destination-Number'} =~ s/$grab/$replace/is; + $ASTPP->debug( debug => "Phone After: $params->{'Caller-Destination-Number'}" ); + } + } + +$ASTPP->debug( debug => "FINDING LIMIT FOR: " . $carddata->{number}); +($callstatus, $maxlength) = &max_length($astpp_db, $config, $carddata, $params->{'Caller-Destination-Number'}); +my $routeinfo = &get_route( $astpp_db, $config, $params->{'Caller-Destination-Number'}, $carddata->{pricelist},$carddata ); + +$ASTPP->debug( debug => "Minimum Charge on call = " . $routeinfo->{cost}); +my $minimumcharge = $routeinfo->{cost}; +my @reseller_list; +$ASTPP->debug( debug => "CALLSTATUS: $callstatus MAX_LENGTH: $maxlength"); +while ( $carddata->{reseller} && $maxlength > 1 && $callstatus == 1) { + $ASTPP->debug( debug => "FINDING LIMIT FOR: $carddata->{reseller}"); + $carddata = &get_account( $astpp_db, $carddata->{reseller} ); + push @reseller_list, $carddata->{number}; + $ASTPP->debug( debug => "ADDING $carddata->{number} to the list of resellers for this account"); + my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $carddata, $params->{'Caller-Destination-Number'}); + my $routeinfo = &get_route( $astpp_db, $config, $params->{'Caller-Destination-Number'}, $carddata->{pricelist},$carddata ); + if ($resellercallstatus != 1) { + $carddata->{reseller} = ""; + $callstatus = $resellercallstatus; + } elsif ($resellermaxlength < $maxlength) { + $maxlength = $resellermaxlength; + } + $ASTPP->debug( debug => "Reseller cost = $routeinfo->{cost} and minimum charge is $minimumcharge"); + if ($resellermaxlength < 1 || $routeinfo->{cost} > $minimumcharge ) { + $ASTPP->debug( debug => "Reseller call is priced too cheap! Call being barred!"); + $xml .= "<action application=\"reject\" data=\"Reseller call is priced too cheap! Call being barred!\"/>\n"; + $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml); + print $xml; + exit(0); + } + $ASTPP->debug( debug => "RESELLER Max Length: $resellermaxlength"); + $ASTPP->debug( debug => "RESELLER Call Status: $resellercallstatus"); +} + +if ($config->{debug} == 1) { + $ASTPP->debug( debug => "PRINTING LIST OF RESELLERS FOR THIS ACCOUNT" ); + foreach my $reseller (@reseller_list) { + $ASTPP->debugb( debug => "RESELLER: $reseller" ); + } +} + +$ASTPP->debug( "Max Call Length: $maxlength minutes" ); +$ASTPP->debug( "Call Status: $callstatus" ); + +if ( $maxlength <= 1 ) { + $ASTPP->debug( debug => "NOT ENOUGH CREDIT" ); + $xml .= "<action application=\"reject\" data=\"NOT ENOUGH CREDIT\"/>\n"; + $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml); + print $xml; + exit(0); +} + +# Set the timelimit as well as other variables which are needed in the dialplan. +my $timelimit = "L(" . sprintf( "%.0f", $maxlength * 60 * 1000 ) . ":60000:30000)"; + +$ASTPP->debug( debug => "Looking for outbound Route" ); +my $routeinfo = &get_route($astpp_db,$config,$params->{'Caller-Destination-Number'},$carddata->{pricelist},$carddata); +# Get the list of routes for the phone number. +my @outboundroutes = &get_outbound_routes( $astpp_db, $params->{'Caller-Destination-Number'},$carddata,$routeinfo, @reseller_list ); +foreach my $route (@outboundroutes) { + $ASTPP->debug( debug => "$route->{trunk}: cost $route->{cost}\t $route->{pattern}" ); + if ($route->{cost} > $routeinfo->{cost}) { + $ASTPP->debug( debug => "$route->{trunk}: $route->{cost} > $routeinfo->{cost}, skipping" ); + } else { + $xml .= $ASTPP->fs_dialplan_xml_bridge( destination_number => $params->{'Caller-Destination-Number'}, + route_prepend => $route->{prepend}, + trunk_name => $route->{trunk}); + } +} +$xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml); +} elsif ($params->{section} eq "directory") { + $xml = $ASTPP->fs_directory_xml_header( xml => $xml); + $xml = $ASTPP->fs_directory_xml( xml => $xml); + $xml = $ASTPP->fs_directory_xml_footer( xml => $xml); +} +$ASTPP->debug( debug => $xml); +print $xml; +exit(0); Property changes on: trunk/freeswitch/astpp-fs-xml.pl ___________________________________________________________________ Name: svn:executable + * Added: trunk/freeswitch/test-fs-xml.pl =================================================================== --- trunk/freeswitch/test-fs-xml.pl (rev 0) +++ trunk/freeswitch/test-fs-xml.pl 2008-06-07 04:47:11 UTC (rev 2184) @@ -0,0 +1,45 @@ +#!/usr/bin/perl +# +# ASTPP - Open Source Voip Billing +# +# Copyright (C) 2008, Aleph Communications +# +# Darren Wiebe (da...@al...) +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2. +############################################################ + +use Time::HiRes qw( gettimeofday tv_interval ); +#use HTTP::Request; +#use LWP::UserAgent; +#use URI::URL; +#use WWW::Curl; +use LWP::Simple; + + +my $starttime = [gettimeofday]; + +my $url = 'http://localhost/cgi-bin/astpp-fs-xml.pl?section=dialplan&Caller-Destination-Number=123456789&variable_accountcode=1000'; +my $url = 'http://localhost/perl/astpp-fs-xml.pl?section=dialplan&Caller-Destination-Number=123456789&variable_accountcode=1000'; + +#my $req = HTTP::Request->new(POST, $url, $headers); +#my $ua = LWP::UserAgent->new(); +#my $resp = $ua->request($req); +#if ($resp->is_success) { +# +# print $resp->content; +#} else { +# print $resp->message; +#} + +my $count = 0; +while ($count < 500) { +print $count; +$count++; +my $content = get $url; +} +print $content; + +my $generation_time = tv_interval($starttime); +print "\n\n" . $generation_time . "\n\n"; Property changes on: trunk/freeswitch/test-fs-xml.pl ___________________________________________________________________ Name: svn:executable + * Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2008-06-01 00:42:36 UTC (rev 2183) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2008-06-07 04:47:11 UTC (rev 2184) @@ -76,6 +76,140 @@ # $self->{_config} = %config_hash if %config_hash; #} +sub ip_address_authenticate #Authenticates call by caller ip address. Works with both Asterisk(tm) and Freeswitch(tm) +# Requires +# ip_address = IP Address of calling device +# destination = Dialed number +{ + my ($self, %arg) = @_; + my ($sql,$tmp); + $tmp = "SELECT * FROM ip_map WHERE ip = " . $self->{_astpp_db}->quote($arg{ip_address}) + . " AND prefix IN (NULL,'') OR ip = " . $self->{_astpp_db}->quote($arg{ip_address}) + . " AND " . $self->{_astpp_db}->quote($arg{destination}) . " RLIKE prefix ORDER BY LENGTH(prefix) DESC LIMIT 1"; + $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + my $anidata = $sql->fetchrow_hashref; + $sql->finish; + return $anidata; +} + +sub fs_dialplan_xml_header +#Return the opening lines of the Freeswitch(TM) xml dialplan +{ + my ($self, %arg) = @_; + $arg{xml} .= "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; + $arg{xml} .= "<document type=\"freeswitch/xml\">\n"; + $arg{xml} .= "<section name=\"dialplan\" description=\"ASTPP Dynamic Routing\">\n"; + $arg{xml} .= "<context name=\"default\">\n"; + $arg{xml} .= "<extension name=\"$arg{destination_number}\">\n"; + $arg{xml} .= "<condition field=\"destination_number\" expression=\"$arg{destination_number}\">\n"; + return $arg{xml}; +} + +sub fs_dialplan_xml_bridge +#Return the bridge command along with details. This is only called if a call is approved. +# Requires the following variables: +# destination_number = The number we are trying to call +# trunk_name = The name of the trunk we're using. +# route_prepend = What do we tag on for numbers on this route? +{ + my ($self, %arg) = @_; + my ( $sql, $trunkdata, $dialstring ); + $sql = $self->{_astpp_db}->prepare( "SELECT * FROM trunks WHERE name = " + . $self->{_astpp_db}->quote( $arg{trunk_name} ) ); + $sql->execute; + $trunkdata = $sql->fetchrow_hashref; + $arg{route_prepend} = "" if !$arg{route_prepend}; + $sql->finish; + if ($trunkdata->{dialed_modify} && $trunkdata->{dialed_modify} ne "") { + my @regexs = split(m/","/m, $trunkdata->{dialed_modify}); + foreach my $regex (@regexs) { + $regex =~ s/"//g; #Strip off quotation marks + my ($grab,$replace) = split(m!/!i, $regex); # This will split the variable into a "grab" and "replace" as needed + print STDERR "Grab: $grab\n"; + print STDERR "Replacement: $replace\n"; + print STDERR "Phone Before: $arg{destination_number}\n"; + $arg{destination_number} =~ s/$grab/$replace/is; + print STDERR "Phone After: $arg{destination_number}\n"; + } + } + if ( $trunkdata->{tech} eq "Zap" ) { + $dialstring = "<action application=\"bridge\" data=\"openzap/" . $trunkdata->{path} . "/1/" . $arg{route_prepend} . $arg{destination_number}. "\"/>\n"; + return $dialstring; + } + elsif ( $trunkdata->{tech} eq "SIP" ) { + my ($profile,$dest) = split(m/","/m, $trunkdata->{path}); + $profile =~ s/"//g; #Strip off quotation marks + $dest =~ s/"//g; #Strip off quotation marks + if ($profile eq "gateway") { + $dialstring = "<action application=\"bridge\" data=\"sofia/gateway/" . $dest . "/" . $arg{route_prepend} . $arg{destination_number} . "\"/>\n"; + } else { + $dialstring = "<action application=\"bridge\" data=\"sofia/" . $profile . "/" . $arg{route_prepend} . $arg{destination_number} . "\@" . $dest . "\"/>\n"; + } + return $dialstring; + } + else { + print STDERR "CANNOT ROUTE THIS CALL!!!!!\n"; + return ""; + } +} + +sub fs_dialplan_xml_footer +#Return the closing lines of the Freeswitch(TM) xml dialplan +{ + my ($self, %arg) = @_; + $arg{xml} .= "</condition>\n"; + $arg{xml} .= "</extension>\n"; + $arg{xml} .= "</context>\n"; + $arg{xml} .= "</section>\n"; + $arg{xml} .= "</document>\n"; + return $arg{xml}; +} + +sub fs_directory_xml_header +#Return the opening lines of the Freeswitch(TM) xml directory +#xml = Current XML code, usually blank. +#domain = domain name +{ + my ($self, %arg) = @_; + $arg{xml} .= "<?xml version=\"1.0\"?>\n"; + $arg{xml} .= "<document type=\"freeswitch/xml\">\n"; + $arg{xml} .= "<section name=\"directory\" description=\"User Directory\">\n"; + $arg{xml} .= "<domain name=\"" . $arg{domain} . "\">\n"; + return $arg{xml}; +} + +sub fs_directory_xml +#Return the user detail lines for Freeswitch(TM) sip athentication. +#xml = Current XML code +{ + my ($self, %arg) = @_; + my ($sql); + $sql = $self->{_astpp_db}->prepare("SELECT * FROM fs_users"); + $sql->execute; + while (my $record = $sql->fetchrow_hashref) { + $arg{xml} .= "<user id=\"" . $record->{user} . "\">\n"; + $arg{xml} .= "<params>\n"; + $arg{xml} .= "<param name=\"password\" value=\"" . $record->{password} . "\"/>\n"; + $arg{xml} .= "</params>\n"; + $arg{xml} .= "</user>\n"; + }; + return $arg{xml}; +} + + + +sub fs_directory_xml_footer +#Return the closing lines of the Freeswitch(TM) xml dialplan +#xml = Current XML code +{ + my ($self, %arg) = @_; + $arg{xml} .= "</domain>\n"; + $arg{xml} .= "</section>\n"; + $arg{xml} .= "</document>\n"; + return $arg{xml}; +} + sub debug #Prints debugging if appropriate # { @@ -208,7 +342,6 @@ =head1 SYNOPSIS use ASTPP; - blah blah blah =head1 DESCRIPTION This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |