[Astpp-commit] SF.net SVN: astpp:[2261] trunk
Brought to you by:
darrenkw
From: <dar...@us...> - 2009-09-28 15:21:56
|
Revision: 2261 http://astpp.svn.sourceforge.net/astpp/?rev=2261&view=rev Author: darrenkw Date: 2009-09-28 15:21:45 +0000 (Mon, 28 Sep 2009) Log Message: ----------- Add realtime billing support for Freeswitch. Vendor rating for freeswitch is also working. Modified Paths: -------------- trunk/Makefile trunk/freeswitch/astpp-fs-monitor.pl trunk/freeswitch/astpp-fs-xml.pl trunk/modules/ASTPP/lib/ASTPP.pm trunk/scripts/astpp-common.pl trunk/scripts/astpp-rate-engine.pl trunk/web_interface/astpp-admin.cgi Added Paths: ----------- trunk/sql/astpp-2009-09-23.sql Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2009-09-24 01:53:56 UTC (rev 2260) +++ trunk/Makefile 2009-09-28 15:21:45 UTC (rev 2261) @@ -39,6 +39,7 @@ chgrp $(GROUP) $(DESTDIR)$(ASTPPEXECDIR) # Install Freeswitch .pl files as .cgi files install -m 755 -o $(OWNER) -g $(GROUP) freeswitch/astpp-fs-xml.pl $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-fs-xml.cgi + install -m 755 -o $(OWNER) -g $(GROUP) freeswitch/astpp-fs-cdr-xml.pl $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-fs-cdr-xml.cgi # install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-callback.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-callback.cgi install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-pricelist.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-pricelist.cgi Modified: trunk/freeswitch/astpp-fs-monitor.pl =================================================================== --- trunk/freeswitch/astpp-fs-monitor.pl 2009-09-24 01:53:56 UTC (rev 2260) +++ trunk/freeswitch/astpp-fs-monitor.pl 2009-09-28 15:21:45 UTC (rev 2261) @@ -32,7 +32,7 @@ print STDERR "Interface language is set to: $ENV{'LANGUAGE'}\n"; bindtextdomain( "ASTPP", "/var/locale" ); textdomain("ASTPP"); -use vars qw($ASTPP $fs $config $astpp_db $osc_db $agile_db $cdr_db $cdr_table +use vars qw($ASTPP $fs $config $astpp_db $osc_db $agile_db $cdr_db @output @cardlist $config $params $lastheartbeat); @output = ( "STDOUT", "LOGFILE" ); my $verbosity = 1; @@ -49,7 +49,6 @@ $fs = &fs_client_connect($config); open( LOGFILE, ">>$config->{log_file}" ) || die "Error - could not open $config->{log_file} for writing\n"; - $cdr_table = $config->{freeswitch_cdr_table}; # $ASTPP->debug("Rating calls for FreeSwitch", $verbosity); @@ -79,6 +78,7 @@ ############################################### &initialize; +$config->{cdr_table} = $config->{freeswitch_cdr_table}; my $timeout = 1; sigaction SIGALRM, new POSIX::SigAction sub { @@ -122,7 +122,8 @@ } } - elsif ( $myhash->{'event-name'} eq "CHANNEL_HANGUP" ) +# elsif ( $myhash->{'event-name'} eq "CHANNEL_HANGUP" ) + elsif ( $myhash->{'event-name'} eq "CHANNEL_DESTROY" ) { ## hangup event print "\n\n############################\n\n"; print $myhash->{'unique-id'} . " has hung up\n"; @@ -154,7 +155,8 @@ . $cdr_db->quote( $myhash->{'variable_channel_name'} ) . "," . $cdr_db->quote( $myhash->{'variable_last_app'} ) . "," . $cdr_db->quote( $myhash->{'variable_last_arg'} ) . "," - . $cdr_db->quote( $myhash->{'variable_start_stamp'} ) . "," + . $cdr_db->quote( $myhash->{'event-date-local'} ) . "," +# . $cdr_db->quote( $myhash->{'variable_start_stamp'} ) . "," . $cdr_db->quote( $myhash->{'variable_answer_stamp'} ) . "," . $cdr_db->quote( $myhash->{'variable_end_stamp'} ) . "," . $cdr_db->quote( $myhash->{'variable_duration'} ) . "," @@ -170,7 +172,7 @@ $cdr_db->do($tmp); my (@chargelist); push @chargelist, $myhash->{'unique-id'}; - &processlist( $astpp_db, $cdr_db, $cdr_table, $config, + &processlist( $astpp_db, $cdr_db, $config, \@chargelist ); # } if ( $myhash->{'variable_callingcards'} Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2009-09-24 01:53:56 UTC (rev 2260) +++ trunk/freeswitch/astpp-fs-xml.pl 2009-09-28 15:21:45 UTC (rev 2261) @@ -253,7 +253,8 @@ my ($returned_data,$junk) = $ASTPP->fs_dialplan_xml_bridge( destination_number => $params->{'Caller-Destination-Number'}, route_prepend => $route->{prepend}, - trunk_name => $route->{trunk} + trunk_name => $route->{trunk}, + route_id => $route->{id} ); $xml .= $returned_data; } Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-09-24 01:53:56 UTC (rev 2260) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-09-28 15:21:45 UTC (rev 2261) @@ -144,6 +144,7 @@ $sql->finish; my @variables = split /,(?!(?:[^",]|[^"],[^"])+")/, $diddata->{variables}; foreach my $variable (@variables) { + $arg{xml} .= "<action application=\"set\" data=\"accountcode=" . $arg{accountcode} . "\"/>\n"; $xml .= "<action application=\"set\" data=\"" . $variable . "\"/>\n"; } if ($diddata->{extensions} =~ m/^("|)(L|l)ocal.*/m) { @@ -174,6 +175,9 @@ $trunkdata = $sql->fetchrow_hashref; $arg{route_prepend} = "" if !$arg{route_prepend}; $sql->finish; + $dialstring = "<action application=\"set\" data=\"outbound_route=" . $arg{route_id} . "\"/>\n"; + $dialstring .= "<action application=\"set\" data=\"provider=" . $trunkdata->{provider} . "\"/>\n"; + $dialstring .= "<action application=\"set\" data=\"trunk=" . $trunkdata->{name} . "\"/>\n"; if ($trunkdata->{dialed_modify} && $trunkdata->{dialed_modify} ne "") { my @regexs = split(m/","/m, $trunkdata->{dialed_modify}); foreach my $regex (@regexs) { @@ -187,7 +191,7 @@ } } if ( $trunkdata->{tech} eq "Zap" ) { - $dialstring = "<action application=\"bridge\" data=\"openzap/" . $trunkdata->{path} . "/1/" . $arg{route_prepend} . $arg{destination_number} . "\"/>\n"; + $dialstring .= "<action application=\"bridge\" data=\"openzap/" . $trunkdata->{path} . "/1/" . $arg{route_prepend} . $arg{destination_number} . "\"/>\n"; return ($dialstring,$data); } elsif ( $trunkdata->{tech} eq "SIP" ) { @@ -196,10 +200,10 @@ $dest =~ s/"//g; #Strip off quotation marks if ($profile eq "gateway") { $data = "sofia/gateway/" . $dest . "/" . $arg{route_prepend} . $arg{destination_number}; - $dialstring = "<action application=\"bridge\" data=\"" . $data . "\"/>\n"; + $dialstring .= "<action application=\"bridge\" data=\"" . $data . "\"/>\n"; } else { $data = "sofia/" . $profile . "/" . $arg{route_prepend} . $arg{destination_number} . "\@" . $dest; - $dialstring = "<action application=\"bridge\" data=\"" . $data . "\"/>\n"; + $dialstring .= "<action application=\"bridge\" data=\"" . $data . "\"/>\n"; } return ($dialstring,$data); } @@ -674,7 +678,7 @@ . $arg{mode} . "&ve=" . $arg{ve} . "&te=" . $total_entries . "&pg=" - . $arg{last_page} . "\">" + . $pgr->get_last_page() . "\">" . "Last Page" . "</a>"; return ($sql,$html); } Modified: trunk/scripts/astpp-common.pl =================================================================== --- trunk/scripts/astpp-common.pl 2009-09-24 01:53:56 UTC (rev 2260) +++ trunk/scripts/astpp-common.pl 2009-09-28 15:21:45 UTC (rev 2261) @@ -1477,21 +1477,21 @@ # Select a specific cdr from the Asterisk(tm) cdr table. sub get_cdr() { - my ( $config, $cdr_db, $cdr_table, $uniqueid,$rating,$dst ) = @_; + my ( $config, $cdr_db, $uniqueid,$rating,$dst ) = @_; my ( $sql, $cdrdata ); if ($dst) { $sql = $cdr_db->prepare( - "SELECT * FROM $cdr_table WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND dst = " . $cdr_db->quote($dst) . " ORDER BY cost DESC LIMIT 1" ); + "SELECT * FROM $config->{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_table WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND cost in ('error','none') ORDER BY cost DESC LIMIT 1" ); + "SELECT * FROM $config->{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_table WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " ORDER by cost DESC LIMIT 1" ); + "SELECT * FROM $config->{cdr_table} WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " ORDER by cost DESC LIMIT 1" ); } $sql->execute; $cdrdata = $sql->fetchrow_hashref; @@ -1501,8 +1501,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_cdr() { - my ( $config, $cdr_db, $cdr_table, $uniqueid, $cost,$dst ) = @_; - $cdr_db->do( "UPDATE $cdr_table SET cost = " + my ( $config, $cdr_db, $uniqueid, $cost,$dst ) = @_; + $cdr_db->do( "UPDATE $config->{cdr_table} SET cost = " . $cdr_db->quote($cost) . "WHERE uniqueid = " . $cdr_db->quote($uniqueid) @@ -1515,11 +1515,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 ( $config, $cdr_db, $cdr_table, $default ) = @_; + my ( $config, $cdr_db, $default ) = @_; my ( $sql, @cdrlist, $row ); $sql = $cdr_db->prepare( - "SELECT * FROM $cdr_table WHERE cost = " . $cdr_db->quote($default) ); + "SELECT * FROM $config->{cdr_table} WHERE cost = " . $cdr_db->quote($default) ); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { push @cdrlist, $row->{uniqueid}; @@ -1544,25 +1544,27 @@ # 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_cdr_vendor() { - my ( $config, $cdr_db, $cdr_table, $uniqueid, $cost,$dst ) = @_; - $cdr_db->do( "UPDATE $cdr_table SET vendor = " + my ( $config, $cdr_db, $uniqueid, $cost,$dst ) = @_; + my $tmp = "UPDATE $config->{cdr_table} SET vendor = " . $cdr_db->quote($cost) - . "WHERE uniqueid = " + . " WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND dst = " . $cdr_db->quote($dst) - . " LIMIT 1"); + . " LIMIT 1"; + print STDERR $tmp . "\n" if $config->{debug} ==1; + $cdr_db->do($tmp); } # Select all cdrs in the Asterisk(tm) cdr database which have a specified value in the vendor field. This is # 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 ( $config, $cdr_db, $cdr_table, $default ) = @_; + my ( $config, $cdr_db, $default ) = @_; my ( $sql, @cdrlist, $row ); $sql = $cdr_db->prepare( - "SELECT * FROM $cdr_table WHERE vendor = " . $cdr_db->quote($default) ); + "SELECT * FROM $config->{cdr_table} WHERE vendor = " . $cdr_db->quote($default) ); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { push @cdrlist, $row->{uniqueid}; @@ -3518,7 +3520,7 @@ my ($config, $cdr_db,$account) = @_; my ( $sql, $count, $record ); $sql = - $cdr_db->prepare( "SELECT COUNT(*) FROM $config->{asterisk_cdr_table} WHERE cost = 'error' OR " + $cdr_db->prepare( "SELECT COUNT(*) FROM $config->{cdr_table} WHERE cost = 'error' OR " . "accountcode IN (" . $account . ") AND cost ='none'" ); $sql->execute; $record = $sql->fetchrow_hashref; @@ -3997,7 +3999,7 @@ $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'CANCEL'"); } if ($config->{thirdlane_mods} == 1) { - $cdr_db->do("UPDATE cdr SET accountcode = userfield WHERE (accountcode IS NULL or accountcode = '')"); + $cdr_db->do("UPDATE $config->{cdr_table} SET accountcode = userfield WHERE (accountcode IS NULL or accountcode = '')"); } } } @@ -4017,7 +4019,7 @@ $outfile = "/var/log/astpp/astpp.csv" if !$outfile; my $notes = "Notes: " . $cdrinfo->{accountcode}; open( OUTFILE, ">>$outfile" ) - || die "CSV Error - could not open $outfile for writing\n"; + || print STDERR "CSV Error - could not open $outfile for writing\n"; print OUTFILE << "ending_print_tag"; $cardno,$cost,$cdrinfo->{disposition},$cdrinfo->{calldate},$cdrinfo->{dst},$billsec,$notes ending_print_tag @@ -4025,7 +4027,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, $cdr_table, $config, $cdrinfo, $carddata, $vars, @output ) = @_; + my ( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, $vars, @output ) = @_; my ( $increment, $numdata, $package, $notes, $status ); print STDERR "----------------------------------------------------------------\n"; print STDERR @@ -4041,7 +4043,7 @@ $numdata = &get_route( $astpp_db, $config, $cdrinfo->{dst}, $carddata->{pricelist}, $carddata, $cdrinfo->{userfield} ); print STDERR "PATTERN: $numdata->{pattern}"; if ( !$numdata->{pattern} ) { - &save_cdr( $config, $cdr_db,$cdr_table, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; + &save_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"; @@ -4110,7 +4112,7 @@ 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_cdr( $config, $cdr_db,$cdr_table, $cdrinfo->{uniqueid}, $cost,$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; + &save_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}; } @@ -4139,7 +4141,7 @@ } } else { - &save_cdr( $config, $cdr_db,$cdr_table, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; + &save_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"; @@ -4158,7 +4160,7 @@ sub vendor_not_billed() { # Prints the information on calls where the "vendor" field is either none or error. my ($config, $cdr_db) = @_; - my $tmp = "SELECT * FROM $config->{asterisk_cdr_table} WHERE vendor IN ('none','error')"; + my $tmp = "SELECT * FROM $config->{cdr_table} WHERE vendor IN ('none','error')"; my $sql = $cdr_db->prepare($tmp); $sql->execute; while ( my $cdr = $sql->fetchrow_hashref ) { @@ -4177,15 +4179,14 @@ sub processlist() { # Deal with a list of calls which have not been rated so far. - my ($astpp_db, $cdr_db, $cdr_table, $config, $chargelist, $vars) = @_; + my ($astpp_db, $cdr_db, $config, $chargelist, $vars) = @_; my ( $status, $cdrinfo); - foreach (@$chargelist) { - my $uniqueid = $_; + foreach my $uniqueid (@$chargelist) { print STDERR gettext("Processing Uniqueid: ") . $uniqueid . "\n"; - $cdrinfo = ($vars) ? $vars : &get_cdr( $config, $cdr_db,$cdr_table, $uniqueid ); + $cdrinfo = &get_cdr( $config, $cdr_db, $uniqueid ); my $savedcdrinfo = $cdrinfo; # if(!$vars) { -# my $tmp = "UPDATE $cdr_table SET cost = 'rating' WHERE uniqueid = " +# my $tmp = "UPDATE $config->{cdr_table} SET cost = 'rating' WHERE uniqueid = " # . $cdr_db->quote($uniqueid) # . " AND cost = 'none'" # . " AND dst = " @@ -4213,9 +4214,9 @@ $cdrinfo->{billsec} = $cdrinfo->{duration}; } if ( $cdrinfo->{billsec} <= 0 ) { # not having the right billable seconds. - &save_cdr( $config, $cdr_db,$cdr_table, $uniqueid, 0,$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; - &save_cdr_vendor( $config, $cdr_db, $cdr_table, $uniqueid, 0,$cdrinfo->{dst} ) - if !$vars && $config->{astcdr} == 1 && $config->{trackvendorcharges} == 1; + &save_cdr( $config, $cdr_db, $uniqueid, 0,$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; + &save_cdr_vendor( $config, $cdr_db, $uniqueid, 0,$cdrinfo->{dst} ) + if $config->{astcdr} == 1; print STDERR "\n----------------------\n"; print STDERR "CDR Written - No Billable Seconds\n"; print STDERR @@ -4224,15 +4225,15 @@ print STDERR "----------------------\n"; } elsif ( $cdrinfo->{accountcode} ) { - $status = &rating( $astpp_db, $cdr_db,$cdr_table, $config, $cdrinfo, $carddata, $vars); - $cdrinfo = &get_cdr( $config, $cdr_db,$cdr_table, $uniqueid ) if !$vars; + $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( $config, $cdr_db,$cdr_table, $uniqueid ) if !$vars; + $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, $cdr_table,$config, $cdrinfo, $carddata, $vars); + $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; @@ -4295,12 +4296,66 @@ } } my $phrase = "none"; - &vendor_process_rating( $astpp_db, $cdr_db, $config, $phrase, $uniqueid, $vars ) if $config->{trackvendorcharges} == 1; + if ($config->{trackvendorcharges} == 1) { + print STDERR gettext("Vendor Rating Starting") . "/n"; + &vendor_process_rating( $astpp_db, $cdr_db, $config, $phrase, $uniqueid, $vars ) if $config->{softswitch} == 0; + &vendor_process_rating_fs( $astpp_db, $cdr_db, $config, $phrase, $uniqueid, $vars ) if $config->{softswitch} == 1; + } } } + +sub vendor_process_rating_fs() { #Rate Vendor calls. + my ( $astpp_db, $cdr_db, $config, $phrase, $uniqueid, $vars ) = @_; + my ($sql,$tmp); + print STDERR "Vendor Rating Uniqueid: " . $uniqueid . "\n"; + if(!$uniqueid) { + $tmp = "SELECT * FROM $config->{freeswitch_cdr_table} WHERE vendor IN ('error','none')"; + } else { + $tmp = "SELECT * FROM $config->{freeswitch_cdr_table} WHERE uniqueid = '$uniqueid'"; + } + print STDERR $tmp . "\n" if $config->{debug} == 1; + $sql = $cdr_db->prepare($tmp); + $sql->execute; + while ( my $cdrinfo = $sql->fetchrow_hashref ) { + my $tmp = "SELECT * FROM outbound_routes WHERE id = " + . $astpp_db->quote( $cdrinfo->{outbound_route} ); + my $sql2 = $astpp_db->prepare($tmp); + $sql2->execute; + print STDERR $tmp . "\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}, $cdrinfo->{provider}, + $cdrinfo->{src}, $cdrinfo->{dst}, + $cdrinfo->{disposition}, $cdrinfo->{billsec}, + $cost * -1, $cdrinfo->{calldate}, + "", $cdrinfo->{trunk}, + $pricerecord->{comment} . "|" . $pricerecord->{pattern} + ) if $config->{posttoastpp} == 1; + &save_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 != '" . $cdrinfo->{provider} . "' AND callednum = " + . $astpp_db->quote($cdrinfo->{dst}) . " LIMIT 1"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $astpp_db->do($tmp); + } else { + &save_cdr_vendor( $config, $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ); + } + } +} + sub vendor_process_rating() { #Rate Vendor calls. - my ( $astpp_db, $cdr_db, $cdr_table, $config, $phrase, $uniqueid, $vars ) = @_; + 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; @@ -4360,7 +4415,7 @@ "", $cdrinfo->{trunk}, $pricerecord->{comment} . "|" . $pricerecord->{pattern} ) if $config->{posttoastpp} == 1; - &save_cdr_vendor( $config, $cdr_db,$cdr_table, $cdrinfo->{uniqueid}, $cost,$cdrinfo->{dst} ); + &save_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 = " @@ -4368,7 +4423,7 @@ print STDERR "$tmp\n" if $config->{debug} == 1; $astpp_db->do($tmp); } else { - &save_cdr_vendor( $config, $cdr_db,$cdr_table, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ); + &save_cdr_vendor( $config, $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ); } } } else { Modified: trunk/scripts/astpp-rate-engine.pl =================================================================== --- trunk/scripts/astpp-rate-engine.pl 2009-09-24 01:53:56 UTC (rev 2260) +++ trunk/scripts/astpp-rate-engine.pl 2009-09-28 15:21:45 UTC (rev 2261) @@ -34,7 +34,7 @@ bindtextdomain( "ASTPP", "/var/locale" ); textdomain("ASTPP"); use vars qw(@output $shucks $params $astpp_db $cdr_db $config - $uniqueid $run_type $cdr_table); + $uniqueid $run_type); @output = ( "STDOUT", "LOGFILE" ); $shucks = 0; @@ -54,16 +54,15 @@ ################# Program Starts HERE ################################# $uniqueid = param('uniqueid'); #$ARGV[0]; $run_type = param('runtype'); # realtime,batch,price_only -$softswitch = param('softswitch'); # asterisk or freeswitch &initialize(); -if ($softswitch eq "freeswitch") { - $cdr_table = $config->{freeswitch_cdr_table}; +if ($config->{softswitch} == 1) { + $config->{cdr_table} = $config->{freeswitch_cdr_table}; $ASTPP->debug("Rating calls for FreeSwitch", $verbosity); &cleanup_cdrs_fs($cdr_db, $config); } else { - $cdr_table = $config->{asterisk_cdr_table}; + $config->{cdr_table} = $config->{asterisk_cdr_table}; $ASTPP->debug("Rating calls for Asterisk", $verbosity); } @@ -71,7 +70,7 @@ my @chargelist; push @chargelist, $uniqueid; #sleep $config->{sleep}; - &processlist($astpp_db, $cdr_db,$cdr_table, $config, \@chargelist); + &processlist($astpp_db, $cdr_db,$config, \@chargelist); #&cleanup_cdrs($cdr_db, $config); &shutdown(); exit(0); @@ -102,7 +101,7 @@ ); my @chargelist; push @chargelist, $ARGV[16]; - &processlist($astpp_db, $cdr_db,$cdr_table, $config, \@chargelist, \%args); + &processlist($astpp_db, $cdr_db, $config, \@chargelist, \%args); &cleanup_cdrs($cdr_db, $config); } elsif ( $run_type eq "price_only" ) { @@ -155,13 +154,13 @@ if ( !$cdr_db ) { $cdr_db = &connect_db( $config, @output ); } - my $cdrinfo = &get_cdr( $config, $cdr_db, $input->{Uniqueid},$cdr_table,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, $cdr_table, $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); @@ -177,17 +176,24 @@ &cleanup_cdrs($cdr_db, $config); my @chargelist; my $phrase = "none"; - @chargelist = &list_cdrs_status( $config, $cdr_db, $cdr_table, $phrase ); # Grab a list of all calls with "none" assigned in the cost field - &processlist($astpp_db, $cdr_db,$cdr_table, $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( $config, $cdr_db, $cdr_table, $phrase ); # Grab a list of all calls with "none" assigned in the cost field - &processlist($astpp_db, $cdr_db,$cdr_table, $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,$cdr_table, $config, "none", 0 ) if $config->{trackvendorcharges} == 1; -# &vendor_process_rating( $astpp_db, $cdr_db,$cdr_table, $config. $config, "error", 0 ) if $config->{trackvendorcharges} == 1; -# print STDERR gettext("VENDOR CALLS WHICH HAVE NOT BEEN RATED.") . "\n" if $config->{debug} == 1; + @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" + if ($config->{trackvendorcharges} == 1) { + print STDERR gettext("START ON VENDOR CALL RATING!") . "\n" if $config->{debug} == 1; + if ($config->{softswitch} == 0) { + &vendor_process_rating( $astpp_db, $cdr_db, $config, "none", 0 ); + &vendor_process_rating( $astpp_db, $cdr_db, $config. $config, "error", 0 ); + } elsif ($config->{softswitch} == 1) { + &vendor_process_rating_fs( $astpp_db, $cdr_db, $config, "none", 0 ); + &vendor_process_rating_fs( $astpp_db, $cdr_db, $config. $config, "error", 0 ); + } + 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($config, $cdr_db) if $config->{trackvendorcharges} == 1; + &vendor_not_billed($config, $cdr_db); + } &cleanup_cdrs($cdr_db, $config); } &shutdown(); Added: trunk/sql/astpp-2009-09-23.sql =================================================================== --- trunk/sql/astpp-2009-09-23.sql (rev 0) +++ trunk/sql/astpp-2009-09-23.sql 2009-09-28 15:21:45 UTC (rev 2261) @@ -0,0 +1,1403 @@ +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 ( +accountid INTEGER NOT NULL AUTO_INCREMENT, +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 (`accountid`), + KEY `number` (`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 '', +type tinyint(1) NOT NULL default '1', +invoiceid INT(11) DEFAULT 0 NOT NULL, +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 ( +id INTEGER NOT NULL AUTO_INCREMENT, +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 (`id`), + KEY (`name`), + KEY `reseller` (`reseller`), + KEY `brand` (`brand`) +); + + +INSERT INTO system (name, value, comment) VALUES ( +'log_file','/var/log/astpp/astpp.log','Where do I log to?'); + +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', 'MySQL','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', 'openser','OPENSER Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbuser', 'root','OPENSER Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbhost', 'localhost','OPENSER Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbpass', 'Passw0rd','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', '1','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 ( +'decimalpoints_tax', '2','How many decimal points do we calculate taxes to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints_total', '2','How many decimal points do we calculate totals 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', '0','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','The location of our company logo.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_slogan', 'Welcome to ASTPP','Company slogan', ''); + +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?',''); + +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','Passw0rd!','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, timestamp) VALUES ( +'users_dids_freeswitch','0','If this is enabled, ASTPP will create SIP users in the freeswitch database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'softswitch','0','What softswitch are we using? 0=asterisk, 1=freeswitch',''); + +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','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_post_nc','0','Do we post "free" items to the oscommerce invoice? 0=No 1=Yes',''); + +-- 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?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_directory','/usr/local/freeswitch','What is the Freeswitch root directory?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_password','ClueCon','Freeswitch event socket password'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_host','localhost','Freeswitch event socket host'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_port','8021','Freeswitch event socket port'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_timeout','30','Freeswitch seconds to expect a heartbeat event or reconnect'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_dbengine', 'MySQL','For now this must be MySQL'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbname', 'freeswitch','Freeswitch Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbuser', 'root','Freeswitch Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbhost', 'localhost','Freeswitch Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbpass', 'Passw0rd','Freeswitch Database Password', ''); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_cdr_table','fscdr','Which table of the cdr database are the Freeswitch cdrs in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_domain','$${local_ip_v4}','This is entered as the Freeswitch domain.'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_context','default','This is entered as the Freeswitch user context.'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbname', 'asteriskcdrdb', +'CDR Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbuser', 'root', +'CDR Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbhost', 'localhost', +'CDR Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbpass', 'Passw0rd', +'CDR Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_user', 'admin','Asterisk(tm) Manager Interface User', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_host', 'localhost','Asterisk(tm) Manager Interface Host', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ... [truncated message content] |