astpp-commit Mailing List for ASTPP - Open Source Voip Billing (Page 4)
Brought to you by:
darrenkw
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(8) |
Oct
(1) |
Nov
(34) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
(3) |
Jul
(1) |
Aug
(3) |
Sep
(8) |
Oct
(3) |
Nov
(11) |
Dec
(6) |
2009 |
Jan
(9) |
Feb
(11) |
Mar
(6) |
Apr
(3) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
(14) |
Oct
(32) |
Nov
(2) |
Dec
|
2010 |
Jan
(1) |
Feb
(11) |
Mar
(2) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(6) |
Oct
(1) |
Nov
|
Dec
(5) |
2011 |
Jan
(7) |
Feb
|
Mar
(1) |
Apr
(3) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dar...@us...> - 2009-09-28 15:36:39
|
Revision: 2263 http://astpp.svn.sourceforge.net/astpp/?rev=2263&view=rev Author: darrenkw Date: 2009-09-28 15:36:21 +0000 (Mon, 28 Sep 2009) Log Message: ----------- Correct the uniqueid fields. Modified Paths: -------------- trunk/sql/astpp-2009-09-23.sql Modified: trunk/sql/astpp-2009-09-23.sql =================================================================== --- trunk/sql/astpp-2009-09-23.sql 2009-09-28 15:24:27 UTC (rev 2262) +++ trunk/sql/astpp-2009-09-23.sql 2009-09-28 15:36:21 UTC (rev 2263) @@ -61,7 +61,7 @@ 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 '', +uniqueid VARCHAR(60) NOT NULL DEFAULT '', notes CHAR(80) NOT NULL DEFAULT '', pricelist CHAR(80) NOT NULL DEFAULT '', pattern CHAR(80) NOT NULL DEFAULT '', @@ -249,7 +249,7 @@ CREATE TABLE cdrs ( id INTEGER NOT NULL AUTO_INCREMENT, -uniqueid varchar(32) NOT NULL DEFAULT '', +uniqueid varchar(60) NOT NULL DEFAULT '', cardnum CHAR(50), callerid CHAR(80), callednum varchar(80) NOT NULL DEFAULT '', @@ -326,7 +326,7 @@ ); CREATE TABLE callingcard_stats ( -uniqueid VARCHAR(48) NOT NULL, +uniqueid VARCHAR(60) NOT NULL, total_time VARCHAR(48) NOT NULL, billable_time VARCHAR(48) NOT NULL, timestamp DATETIME NULL, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-09-28 15:24:38
|
Revision: 2262 http://astpp.svn.sourceforge.net/astpp/?rev=2262&view=rev Author: darrenkw Date: 2009-09-28 15:24:27 +0000 (Mon, 28 Sep 2009) Log Message: ----------- Add new fields in cdrdb. Added Paths: ----------- trunk/sql/cdrdb-2009-09-28.sql Added: trunk/sql/cdrdb-2009-09-28.sql =================================================================== --- trunk/sql/cdrdb-2009-09-28.sql (rev 0) +++ trunk/sql/cdrdb-2009-09-28.sql 2009-09-28 15:24:27 UTC (rev 2262) @@ -0,0 +1,69 @@ +-- +-- Table structure for table `cdr` +-- + +DROP TABLE IF EXISTS `cdr`; +CREATE TABLE `cdr` ( + `calldate` datetime NOT NULL default '0000-00-00 00:00:00', + `clid` varchar(80) NOT NULL default '', + `src` varchar(80) NOT NULL default '', + `dst` varchar(80) NOT NULL default '', + `dcontext` varchar(80) NOT NULL default '', + `channel` varchar(80) NOT NULL default '', + `dstchannel` varchar(80) NOT NULL default '', + `lastapp` varchar(80) NOT NULL default '', + `lastdata` varchar(80) NOT NULL default '', + `duration` int(11) NOT NULL default '0', + `billsec` int(11) NOT NULL default '0', + `disposition` varchar(45) NOT NULL default '', + `amaflags` int(11) NOT NULL default '0', + `accountcode` varchar(20) NOT NULL default '', + `uniqueid` varchar(32) NOT NULL default '', + `userfield` varchar(255) NOT NULL default '', + `cost` varchar(20) NOT NULL default 'none', + `vendor` varchar(20) NOT NULL default 'none', + KEY `calldate` (`calldate`), + KEY `dst` (`dst`), + KEY `accountcode` (`accountcode`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + + +-- +-- Table structure for table `fscdr` +-- + +DROP TABLE IF EXISTS `fscdr`; +CREATE TABLE IF NOT EXISTS `fscdr` ( + `accountcode` varchar(20) NOT NULL default '', + `src` varchar(80) NOT NULL default '', + `dst` varchar(80) NOT NULL default '', + `dcontext` varchar(80) NOT NULL default '', + `clid` varchar(80) NOT NULL default '', + `channel` varchar(80) NOT NULL default '', + `dstchannel` varchar(80) NOT NULL default '', + `lastapp` varchar(80) NOT NULL default '', + `lastdata` varchar(80) NOT NULL default '', + `calldate` datetime NOT NULL default '0000-00-00 00:00:00', + `answerdate` datetime NOT NULL default '0000-00-00 00:00:00', + `enddate` datetime NOT NULL default '0000-00-00 00:00:00', + `duration` int(11) NOT NULL default '0', + `billsec` int(11) NOT NULL default '0', + `disposition` varchar(45) NOT NULL default '', + `amaflags` int(11) NOT NULL default '0', + `uniqueid` varchar(60) NOT NULL, + `userfield` varchar(255) NOT NULL default '', + `read_codec` varchar(60) NOT NULL default '', + `write_codec` varchar(60) NOT NULL default '', + `cost` varchar(20) NOT NULL default 'none', + `vendor` varchar(20) NOT NULL default 'none', + `provider` varchar(60) NOT NULL, + `trunk` varchar(60) NOT NULL, + `outbound_route` varchar(60) NOT NULL, + `progressmsec` varchar(20) NOT NULL, + `answermsec` varchar(20) NOT NULL, + `progress_mediamsec` varchar(20) NOT NULL, + KEY `calldate` (`calldate`), + KEY `dst` (`dst`), + KEY `accountcode` (`accountcode`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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] |
From: <dar...@us...> - 2009-09-24 01:54:09
|
Revision: 2260 http://astpp.svn.sourceforge.net/astpp/?rev=2260&view=rev Author: darrenkw Date: 2009-09-24 01:53:56 +0000 (Thu, 24 Sep 2009) Log Message: ----------- More Freeswitch improvements especially relating to rating calls. Modified Paths: -------------- trunk/freeswitch/astpp-callingcards.pl trunk/freeswitch/astpp-fs-monitor.pl trunk/modules/ASTPP/lib/ASTPP.pm trunk/scripts/astpp-common.pl trunk/scripts/astpp-rate-engine.pl trunk/templates/account-create.tpl trunk/web_interface/astpp-admin.cgi Modified: trunk/freeswitch/astpp-callingcards.pl =================================================================== --- trunk/freeswitch/astpp-callingcards.pl 2009-09-23 04:31:30 UTC (rev 2259) +++ trunk/freeswitch/astpp-callingcards.pl 2009-09-24 01:53:56 UTC (rev 2260) @@ -472,11 +472,13 @@ $session->execute( "export", "NEWCALL=1" ); $session->execute( "export", "DESTINATION=$stats{destination}" ); &exit_program(); + return 1; } elsif ( $whatnow == 2 ) { $session->execute( "export", "NEWCALL=1" ); $session->execute( "export", "DESTINATION=" ); &exit_program(); + return 1; } elsif ( $whatnow == 3 ) { $session->streamFile( $sound->{goodbye} ); @@ -500,7 +502,8 @@ . $astpp_db->quote( $stats{answered_time} ) . ")" ); $stats{total_time} = tv_interval( $stats{start_time} ); - exit(1); +# exit(1); + return 1; } sub print_console() #Dump string to the console @@ -585,7 +588,8 @@ if ( $cardinfo->{status} != 1 ) { $session->streamFile( $sound->{goodbye} ); $session->hangup(); - exit(1); +# exit(1); + return 1; } } @@ -606,7 +610,8 @@ if ( $pin != $cardinfo->{pin} ) { $session->streamFile( $sound->{pin_incorrect} ); $session->streamFile( $sound->{goodbye} ); - exit(0); +# exit(1); + return 1; } } &check_card($cardinfo) if $cc == 0; Modified: trunk/freeswitch/astpp-fs-monitor.pl =================================================================== --- trunk/freeswitch/astpp-fs-monitor.pl 2009-09-23 04:31:30 UTC (rev 2259) +++ trunk/freeswitch/astpp-fs-monitor.pl 2009-09-24 01:53:56 UTC (rev 2260) @@ -138,6 +138,8 @@ if $myhash->{'variable_last_app'} eq ""; $myhash->{'variable_last_arg'} = "" if $myhash->{'variable_last_arg'} eq ""; + $myhash->{'variable_caller_id'} = "N/A" + if $myhash->{'variable_caller_id'} eq ""; my $tmp = "INSERT INTO `fscdr` (`accountcode`, `src`, `dst`, `dcontext`, `clid`," . "`channel`, `dstchannel`, `lastapp`, `lastdata`, `calldate`, `answerdate`," Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-09-23 04:31:30 UTC (rev 2259) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-09-24 01:53:56 UTC (rev 2260) @@ -582,7 +582,7 @@ sub debug #Prints debugging if appropriate # { -my ($self, %arg) = @_; + my ($self, %arg) = @_; $self->{_verbosity_item_level} = $arg{verbosity} if $arg{verbosity}; print STDERR $arg{debug} . "\n" if $arg{debug} && $self->{_verbosity_item_level} <= $self->{_verbosity_level}; $self->{_asterisk_agi}->verbose($arg{debug} . "\n" , $self->{_verbosity_level}) if $arg{debug} && $self->{_asterisk_agi} && $self->{_verbosity_item_level} <= $self->{_verbosity_level}; Modified: trunk/scripts/astpp-common.pl =================================================================== --- trunk/scripts/astpp-common.pl 2009-09-23 04:31:30 UTC (rev 2259) +++ trunk/scripts/astpp-common.pl 2009-09-24 01:53:56 UTC (rev 2260) @@ -3838,80 +3838,80 @@ my ($astpp_db) = @_; my $sound; $sound->{no_responding} = - "astpp-down"; #The calling card platform is down, please try again later. + "astpp-down.gsm"; #The calling card platform is down, please try again later. $sound->{cardnumber} = - "astpp-accountnum"; #Please enter your card number followed by pound. -$sound->{cardnumber_incorrect} = "astpp-badaccount"; #Incorrect card number. -$sound->{pin} = "astpp-pleasepin"; #Please enter your pin followed by pound. -$sound->{pin_incorrect} = "astpp-invalidpin"; #Incorrect pin. -$sound->{goodbye} = "goodbye"; #Goodbye. + "astpp-accountnum.gsm"; #Please enter your card number followed by pound. +$sound->{cardnumber_incorrect} = "astpp-badaccount.gsm"; #Incorrect card number. +$sound->{pin} = "astpp-pleasepin.gsm"; #Please enter your pin followed by pound. +$sound->{pin_incorrect} = "astpp-invalidpin.gsm"; #Incorrect pin. +$sound->{goodbye} = "goodbye.gsm"; #Goodbye. $sound->{destination} = - "astpp-phonenum"; #Please enter the number you wish to dial followed by pound. -$sound->{destination_incorrect} = "astcc-badphone"; #Phone number not found! -$sound->{card_inuse} = "astpp-in-use"; #This card is presently being used. -$sound->{call_will_cost} = "astpp-willcost"; #This call will cost: -$sound->{main_currency} = "astpp-dollar"; #Dollar -$sound->{sub_currency} = "astpp-cent"; #Cent -$sound->{main_currency_plural} = "astpp-dollars"; #Dollars -$sound->{sub_currency_plural} = "astpp-cents"; #cents -$sound->{per} = "astpp-per"; #per -$sound->{minute} = "astpp-minute"; #Minute -$sound->{minutes} = "astpp-minutes"; #Minutes -$sound->{second} = "astpp-second"; #Second -$sound->{seconds} = "astpp-seconds"; #Seconds -$sound->{a_connect_charge} = "astpp-connectcharge"; #A connect charge of -$sound->{will_apply} = "astpp-willapply"; #Will apply + "astpp-phonenum.gsm"; #Please enter the number you wish to dial followed by pound. +$sound->{destination_incorrect} = "astcc-badphone.gsm"; #Phone number not found! +$sound->{card_inuse} = "astpp-in-use.gsm"; #This card is presently being used. +$sound->{call_will_cost} = "astpp-willcost.gsm"; #This call will cost: +$sound->{main_currency} = "astpp-dollar.gsm"; #Dollar +$sound->{sub_currency} = "astpp-cent.gsm"; #Cent +$sound->{main_currency_plural} = "astpp-dollars.gsm"; #Dollars +$sound->{sub_currency_plural} = "astpp-cents.gsm"; #cents +$sound->{per} = "astpp-per.gsm"; #per +$sound->{minute} = "astpp-minute.gsm"; #Minute +$sound->{minutes} = "astpp-minutes.gsm"; #Minutes +$sound->{second} = "astpp-second.gsm"; #Second +$sound->{seconds} = "astpp-seconds.gsm"; #Seconds +$sound->{a_connect_charge} = "astpp-connectcharge.gsm"; #A connect charge of +$sound->{will_apply} = "astpp-willapply.gsm"; #Will apply $sound->{please_wait_will_connect} = - "astpp-please-wait-while-i-connect"; #Please wait while I connect your call -$sound->{card_is_empty} = "astpp-card-is-empty"; #This card is empty. + "astpp-please-wait-while-i-connect.gsm"; #Please wait while I connect your call +$sound->{card_is_empty} = "astpp-card-is-empty.gsm"; #This card is empty. $sound->{card_has_balance_of} = - "astpp-this-card-has-a-balance-of"; #Card has a balance of: -$sound->{card_has_expired} = "astpp-card-has-expired"; #This card has expired. -$sound->{call_will_last} = "astpp-this-call-will-last"; #This call will last: + "astpp-this-card-has-a-balance-of.gsm"; #Card has a balance of: +$sound->{card_has_expired} = "astpp-card-has-expired.gsm"; #This card has expired. +$sound->{call_will_last} = "astpp-this-call-will-last.gsm"; #This call will last: $sound->{not_enough_credit} = - "astpp-not-enough-credit"; #You do not have enough credit + "astpp-not-enough-credit.gsm"; #You do not have enough credit $sound->{call_completed} = - "astpp-call-completed"; #This call has been completed. + "astpp-call-completed.gsm"; #This call has been completed. $sound->{astpp_callingcard_menu} = - "astpp-callingcard-menu" + "astpp-callingcard-menu.gsm" ; #Press one if you wish to place another call, press 2 for your card balance, or press 3 to hangup -$sound->{busy} = "astpp-busy-tryagain"; #Number was busy, Press 1 to try again. -$sound->{cancelled} = "astpp-cancelled-tryagain"; #Call was cancelled. +$sound->{busy} = "astpp-busy-tryagain.gsm"; #Number was busy, Press 1 to try again. +$sound->{cancelled} = "astpp-cancelled-tryagain.gsm"; #Call was cancelled. $sound->{congested} = - "astpp-congested-tryagain"; #Number was congested, Press 1 to try again. + "astpp-congested-tryagain.gsm"; #Number was congested, Press 1 to try again. $sound->{noanswer} = - "astpp-noanswer-tryagain"; #There was no answer, Press 1 to try again. + "astpp-noanswer-tryagain.gsm"; #There was no answer, Press 1 to try again. $sound->{badnumber} = - "astpp-badnumber"; # "Calls from this location are blocked!" + "astpp-badnumber.gsm"; # "Calls from this location are blocked!" $sound->{used_elsewhere} = - "astpp-used-elsewhere"; # "This location has been used already." -$sound->{goodbye} = "goodbye"; # "Goodbye" + "astpp-used-elsewhere.gsm"; # "This location has been used already." +$sound->{goodbye} = "goodbye.gsm"; # "Goodbye" $sound->{callback_performed} = - "astpp-callback-performed"; # "This callback has been performed please disconnect now" + "astpp-callback-performed.gsm"; # "This callback has been performed please disconnect now" $sound->{cardnumber} = - "astpp-accountnum"; #Please enter your card number followed by pound. -$sound->{cardnumber_incorrect} = "astpp-badaccount"; #Incorrect card number. -$sound->{pin} = "astpp-pleasepin"; #Please enter your pin followed by pound. -$sound->{pin_incorrect} = "astpp-invalidpin"; #Incorrect pin. -$sound->{point} = "astcc-point"; #point. + "astpp-accountnum.gsm"; #Please enter your card number followed by pound. +$sound->{cardnumber_incorrect} = "astpp-badaccount.gsm"; #Incorrect card number. +$sound->{pin} = "astpp-pleasepin.gsm"; #Please enter your pin followed by pound. +$sound->{pin_incorrect} = "astpp-invalidpin.gsm"; #Incorrect pin. +$sound->{point} = "astcc-point.gsm"; #point. $sound->{register_ani} = - "astpp-register" + "astpp-register.gsm" ; # "Register ANI to this card? Press 1 for yes or any other key for no." -$sound->{card_has_expired} = "astpp_expired"; #"This card has expired" -$sound->{card_is_empty} = "astpp-empty"; #This card is empty +$sound->{card_has_expired} = "astpp_expired.gsm"; #"This card has expired" +$sound->{card_is_empty} = "astpp-empty.gsm"; #This card is empty $sound->{where_to_call} = - "astpp-where-to-call" + "astpp-where-to-call.gsm" ; #Press 1 to receive a call at the number you called from or registered #Otherwise enter the number you wish to be called at. $sound->{number_to_register} = - "astpp-number-to-register"; #Press 1 to register the number you called from. + "astpp-number-to-register.gsm"; #Press 1 to register the number you called from. #Otherwise enter the number you wish to register. -$sound->{card_has_been_refilled} = "astpp-card-has-been-refilled"; # Your card has been refilled. -$sound->{card_to_refill} = "astpp-card-to-refill"; #please enter the card number you wish to refill followed +$sound->{card_has_been_refilled} = "astpp-card-has-been-refilled.gsm"; # Your card has been refilled. +$sound->{card_to_refill} = "astpp-card-to-refill.gsm"; #please enter the card number you wish to refill followed # by the pound sign. -$sound->{card_to_empty} = "astpp-card-to-empty"; #please enter the card number you wish to empty into your card +$sound->{card_to_empty} = "astpp-card-to-empty.gsm"; #please enter the card number you wish to empty into your card # followed by the pound sign. -$sound->{astpp_please_pin_card_empty} = "astpp-please-pin-card-empty"; #please enter the pin number for the card +$sound->{astpp_please_pin_card_empty} = "astpp-please-pin-card-empty.gsm"; #please enter the pin number for the card # you wish to empty followed by the pound # sign. return $sound; @@ -3965,6 +3965,21 @@ ######## Call Rating ################################ +sub cleanup_cdrs_fs() { + my ($cdr_db, $config) = @_; + $cdr_db->do("UPDATE $config->{freeswitch_cdr_table} SET cost = '0' WHERE disposition REGEXP 'ORIGINATOR_CANCEL'"); + $cdr_db->do("UPDATE $config->{freeswitch_cdr_table} SET cost = '0' WHERE disposition REGEXP 'CALL_REJECTED'"); + $cdr_db->do("UPDATE $config->{freeswitch_cdr_table} SET cost = '0' WHERE disposition REGEXP 'USER_NOT_REGISTERED'"); + $cdr_db->do("UPDATE $config->{freeswitch_cdr_table} SET cost = '0' WHERE disposition REGEXP 'CHAN_NOT_IMPLEMENTED'"); + $cdr_db->do("UPDATE $config->{freeswitch_cdr_table} SET cost = '0' WHERE disposition REGEXP 'INVALID_NUMBER_FORMAT'"); + if ($config->{trackvendorcharges} == 1) { + $cdr_db->do("UPDATE $config->{freeswitch_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'ORIGINATOR_CANCEL'"); + $cdr_db->do("UPDATE $config->{freeswitch_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'CALL_REJECTED'"); + $cdr_db->do("UPDATE $config->{freeswitch_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'USER_NOT_REGISTERED'"); + $cdr_db->do("UPDATE $config->{freeswitch_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'CHAN_NOT_IMPLEMENTED'"); + $cdr_db->do("UPDATE $config->{freeswitch_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'INVALID_NUMBER_FORMAT'"); + } +} sub cleanup_cdrs() { my ($cdr_db, $config) = @_; # First we cleanup all calls that are not answered Modified: trunk/scripts/astpp-rate-engine.pl =================================================================== --- trunk/scripts/astpp-rate-engine.pl 2009-09-23 04:31:30 UTC (rev 2259) +++ trunk/scripts/astpp-rate-engine.pl 2009-09-24 01:53:56 UTC (rev 2260) @@ -61,6 +61,7 @@ if ($softswitch eq "freeswitch") { $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}; $ASTPP->debug("Rating calls for Asterisk", $verbosity); Modified: trunk/templates/account-create.tpl =================================================================== --- trunk/templates/account-create.tpl 2009-09-23 04:31:30 UTC (rev 2259) +++ trunk/templates/account-create.tpl 2009-09-24 01:53:56 UTC (rev 2260) @@ -9,7 +9,7 @@ <td>Password</td> <td>Pricelist</td> <td>Billing Schedule</td> - <td>Credit Limit in<TMPL_VAR NAME="default_currency"></td> + <td>Credit Limit in <TMPL_VAR NAME="default_currency"></td> <td>Timezone</td> </tr> <tr class="rowone"> Modified: trunk/web_interface/astpp-admin.cgi =================================================================== --- trunk/web_interface/astpp-admin.cgi 2009-09-23 04:31:30 UTC (rev 2259) +++ trunk/web_interface/astpp-admin.cgi 2009-09-24 01:53:56 UTC (rev 2260) @@ -157,7 +157,7 @@ my @output = ("STDERR"); # "LOGFILE" ); my @language = all_language_codes; @language = sort @language; -my @currency; +#my @currency; my @deviceprotocol = ("SIP"); my @countries = all_country_names(); @countries = sort @countries; @@ -1421,7 +1421,7 @@ \n"; if ( $params->{answered} == 1 ) { $tmp = - " SELECT * from cdr where disposition = 'ANSWERED'" + " SELECT * from fscdr where disposition IN ('ANSWERED','NORMAL_CLEARING')" . " and calldate >= " . $cdr_db->quote($sd) . " and calldate <= " @@ -1430,7 +1430,7 @@ } else { $tmp = - " SELECT * from cdr where calldate >= " + " SELECT * from fscdr where calldate >= " . $cdr_db->quote($sd) . " and calldate <= " . $cdr_db->quote($ed); @@ -2026,7 +2026,7 @@ push( @account_ip_list, \%row ); } $template->param( account_ip_list => \@account_ip_list ); - $template->param( currency => $currency[0] ); + $template->param( currency => $config->{currency} ); ## List the SIP/IAX2 devices belonging to this account. ## my @account_device_list; @@ -2462,7 +2462,7 @@ freeswitch_context => $config->{freeswitch_context}, vm_password => $params->{accountpassword}, password => $params->{accountpassword}, - sip-ext-prepend => $config->{sip_ext_prepend}, + sip_ext_prepend => $config->{sip_ext_prepend}, ); $status .= "<br>"; if ( $config->{email} == 1 && $params->{accounttype} == 0 ) { @@ -2541,7 +2541,7 @@ $template->param( currency_menu => popup_menu( -name => "currency", - -values => \@currency + -values => $config->{currency} ) ); $template->param( @@ -2567,6 +2567,7 @@ ) ); $template->param( status => $status ); + $template->param( default_currency => $config->{currency} ); return $template->output; } @@ -3417,7 +3418,7 @@ . gettext("Brand") . "</td><td>" . gettext("Value") - . " $currency[0]" + . " $config->{currency}" . "</td><td>" . gettext("Used") . "</td><td>" @@ -3599,7 +3600,7 @@ . gettext("Pricelist") . "</td><td>" . gettext("Value") - . " $currency[0]" + . " $config->{currency}" . "</td><td>" . gettext("Used") . "</td><td>" @@ -3694,7 +3695,7 @@ . gettext("Length in Seconds") . "</td><td>" . gettext("Cost") - . "($currency[0]) </td></tr>"; + . "($config->{currency}) </td></tr>"; $sql = $astpp_db->prepare( "SELECT * FROM callingcardcdrs WHERE cardnumber = " . $astpp_db->quote( param('number') ) ); @@ -4000,9 +4001,9 @@ ); my $sql_select = -"SELECT * FROM cdr WHERE cost IN( 'error','rating') OR (accountcode IS NULL OR accountcode = '') AND cost ='none' ORDER BY calldate"; +"SELECT * FROM fscdr WHERE cost IN( 'error','rating') OR (accountcode IS NULL OR accountcode = '') AND cost ='none' ORDER BY calldate"; my $sql_count = -"SELECT COUNT(*) FROM cdr WHERE cost IN ( 'error','rating') OR (accountcode IS NULL OR accountcode = '') AND cost ='none'"; +"SELECT COUNT(*) FROM fscdr WHERE cost IN ( 'error','rating') OR (accountcode IS NULL OR accountcode = '') AND cost ='none'"; my ( $sql, $pagination ) = $ASTPP->pagination( sql_select => $sql_select, @@ -4701,7 +4702,7 @@ . "</td><td>" . popup_menu( -name => "currency", - -values => \@currency, + -values => $config->{currency}, -default => $accountinfo->{currency} ) . "</td><td>" @@ -5690,7 +5691,7 @@ -values => \@accountlist, ); $template->param( accountlist => $accountmenu ); - $template->param( currency => $config->{currency_name} ); + $template->param( currency => $config->{currency} ); $template->param( status => $status ); return $template->output; } @@ -8971,10 +8972,16 @@ ) . "</td><td>" . textfield( + -name => 'cost', + -size => 20, + -default => $record->{cost} + ) + . "</td><td>" + . textfield( -name => 'precedence', -size => 2, -default => $record->{precedence} - ) . "</td><td>"; + ); my @resellers = &list_resellers($astpp_db); $ASTPP->debug( user => $param->{username}, @@ -11214,7 +11221,7 @@ } $template->param( status => $status ); $template->param( pricelists => $pricelists ); - $template->param( currency => $currency ); + $template->param( currency => $config->{currency} ); $template->param( language => $language ); $template->param( context => $config->{booth_context} ); $template->param( default_currency => $config->{currency} ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-09-23 04:31:40
|
Revision: 2259 http://astpp.svn.sourceforge.net/astpp/?rev=2259&view=rev Author: darrenkw Date: 2009-09-23 04:31:30 +0000 (Wed, 23 Sep 2009) Log Message: ----------- Corrected the usage of ASTPP->debug object. Modified Paths: -------------- trunk/freeswitch/contrib/wasim/cdrload.pl Modified: trunk/freeswitch/contrib/wasim/cdrload.pl =================================================================== --- trunk/freeswitch/contrib/wasim/cdrload.pl 2009-09-23 04:29:52 UTC (rev 2258) +++ trunk/freeswitch/contrib/wasim/cdrload.pl 2009-09-23 04:31:30 UTC (rev 2259) @@ -35,9 +35,9 @@ my @LS = `ls -1t /usr/local/freeswitch/log/cdr-csv/Master.csv.*`; foreach my $line (@LS) { chop($line); - $ASTPP->debug($line); + $ASTPP->debug( debug => $line); my $stm = "load data local infile '$line' into table $config->{freeswitch_cdr_table} fields enclosed by '\"' terminated by ','"; - print STDERR $stm if $config->{debug} == 1; + $ASTPP->debug( debug => $stm); my $ul = $cdr_db->prepare($stm) or die "$0: Couldn't prepare statement $stm: " . $cdr_db->errstr;; $ul->execute(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-09-23 04:30:05
|
Revision: 2258 http://astpp.svn.sourceforge.net/astpp/?rev=2258&view=rev Author: darrenkw Date: 2009-09-23 04:29:52 +0000 (Wed, 23 Sep 2009) Log Message: ----------- Convert program from DOS to UNIX. Modified Paths: -------------- trunk/freeswitch/contrib/wasim/cdrload.pl Modified: trunk/freeswitch/contrib/wasim/cdrload.pl =================================================================== --- trunk/freeswitch/contrib/wasim/cdrload.pl 2009-09-22 23:10:07 UTC (rev 2257) +++ trunk/freeswitch/contrib/wasim/cdrload.pl 2009-09-23 04:29:52 UTC (rev 2258) @@ -1,49 +1,49 @@ -#!/usr/bin/perl -w - -# Convergence FreeSwitch Tools Version 7.0 : AGI -# (c) MMII Convergence. All rights reserved. -# <in...@co...> http://www.convergence.pk -# <da...@al...> http://www.aleph-com.net - -# This program is free software, distributed under the terms of -# the GNU General Public License.http://www.gnu.org/licenses.html - -use strict; -use DBI(); -use ASTPP; -use lib './lib', '../lib'; -require "/usr/local/astpp/astpp-common.pl"; - -use vars qw($config $astpp_db $osc_db $agile_db $cdr_db - @output @cardlist $config $params $ASTPP); - -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 ); -} - -$ASTPP = ASTPP->new; -$ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. -&initialize; - -my @cc = ("killall", "-HUP", "freeswitch"); -system(@cc) == 0 - or die "$0: system @cc failed: $?"; - -my @LS = `ls -1t /usr/local/freeswitch/log/cdr-csv/Master.csv.*`; -foreach my $line (@LS) { - chop($line); - $ASTPP->debug($line); - my $stm = "load data local infile '$line' into table $config->{freeswitch_cdr_table} fields enclosed by '\"' terminated by ','"; +#!/usr/bin/perl -w + +# Convergence FreeSwitch Tools Version 7.0 : AGI +# (c) MMII Convergence. All rights reserved. +# <in...@co...> http://www.convergence.pk +# <da...@al...> http://www.aleph-com.net + +# This program is free software, distributed under the terms of +# the GNU General Public License.http://www.gnu.org/licenses.html + +use strict; +use DBI(); +use ASTPP; +use lib './lib', '../lib'; +require "/usr/local/astpp/astpp-common.pl"; + +use vars qw($config $astpp_db $osc_db $agile_db $cdr_db + @output @cardlist $config $params $ASTPP); + +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 ); +} + +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. +&initialize; + +my @cc = ("killall", "-HUP", "freeswitch"); +system(@cc) == 0 + or die "$0: system @cc failed: $?"; + +my @LS = `ls -1t /usr/local/freeswitch/log/cdr-csv/Master.csv.*`; +foreach my $line (@LS) { + chop($line); + $ASTPP->debug($line); + my $stm = "load data local infile '$line' into table $config->{freeswitch_cdr_table} fields enclosed by '\"' terminated by ','"; print STDERR $stm if $config->{debug} == 1; - my $ul = $cdr_db->prepare($stm) - or die "$0: Couldn't prepare statement $stm: " . $cdr_db->errstr;; - $ul->execute(); - $ul->finish; - system("cat $line >> /usr/local/freeswitch/log/cdr-csv/FULL_Master.csv"); - unlink $line; -} - -exit; + my $ul = $cdr_db->prepare($stm) + or die "$0: Couldn't prepare statement $stm: " . $cdr_db->errstr;; + $ul->execute(); + $ul->finish; + system("cat $line >> /usr/local/freeswitch/log/cdr-csv/FULL_Master.csv"); + unlink $line; +} + +exit; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-09-22 23:10:18
|
Revision: 2257 http://astpp.svn.sourceforge.net/astpp/?rev=2257&view=rev Author: darrenkw Date: 2009-09-22 23:10:07 +0000 (Tue, 22 Sep 2009) Log Message: ----------- Fixed a couple of minor sql mistakes. Modified Paths: -------------- trunk/sql/astpp-2009-09-19.sql Modified: trunk/sql/astpp-2009-09-19.sql =================================================================== --- trunk/sql/astpp-2009-09-19.sql 2009-09-22 04:11:06 UTC (rev 2256) +++ trunk/sql/astpp-2009-09-19.sql 2009-09-22 23:10:07 UTC (rev 2257) @@ -173,7 +173,7 @@ type INTEGER DEFAULT 0, tz CHAR(40) NOT NULL DEFAULT '', PRIMARY KEY (`accountid`), - KEY `pricelist` (`number`), + KEY `number` (`number`), KEY `pricelist` (`pricelist`), KEY `reseller` (`reseller`) ); @@ -794,7 +794,7 @@ INSERT INTO system (name, value, comment, timestamp) VALUES ( 'call_max_length','1440000','What is the maximum length (in ms) of a LCR call?',''); ------- 3rd Party PBX Mods +-- 3rd Party PBX Mods INSERT INTO system (name, value, comment, timestamp) VALUES ( 'thirdlane_mods','0','Provides a few different modifications across the rating code to work better with Thirdlane(tm) cdrs.',''); @@ -1319,13 +1319,13 @@ user VARCHAR(50), PRIMARY KEY (`id`)); -CREATE TABLE sql_commands ( -id INTEGER NOT NULL AUTO_INCREMENT, -name VARCHAR(45) NOT NULL default '', -sql TEXT NOT NULL default '', -comment TEXT NOT NULL default '', -timestamp TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - PRIMARY KEY (`id`)); +-- CREATE TABLE sql_commands ( +-- id INTEGER NOT NULL AUTO_INCREMENT, +-- name VARCHAR(45) NOT NULL default '', +-- sql TEXT NOT NULL default '', +-- comment TEXT NOT NULL default '', +-- timestamp TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +-- PRIMARY KEY (`id`)); CREATE TABLE `invoices` ( `invoiceid` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , @@ -1374,8 +1374,9 @@ ) ENGINE = MYISAM ; -;;;; Create Views Here -; +-- Create Views Here +-- + CREATE VIEW taxes_to_accounts_view AS SELECT taxes_to_accounts.id, taxes_to_accounts.accountid, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-09-22 04:11:20
|
Revision: 2256 http://astpp.svn.sourceforge.net/astpp/?rev=2256&view=rev Author: darrenkw Date: 2009-09-22 04:11:06 +0000 (Tue, 22 Sep 2009) Log Message: ----------- I finished the Freeswitch SIP device editing/deleting/adding interface allowing easy access to work with SIP devices in FreeSwitch from the GUI. Modified Paths: -------------- trunk/modules/ASTPP/lib/ASTPP.pm trunk/templates/freeswitch-sip-list.tpl trunk/web_interface/astpp-admin.cgi Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-09-20 03:31:28 UTC (rev 2255) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-09-22 04:11:06 UTC (rev 2256) @@ -233,6 +233,194 @@ return $arg{xml}; } +sub fs_add_sip_user +# Add a SIP user +# Arguments +# sip_ext_prepend = $config->{sip_ext_prepend} +# accountcode +# context = $config->{freeswitch_context} +# vm_password = Password +# password = Password +# +{ + my ($self, %arg) = @_; + # Find uniqueid to prepend to the login + my $sipid = 0; + if (!$arg{username} || $arg{username} eq "") { + $arg{username} = $arg{accountcode}; + for ( ; ; ) { + my $count = 1; + $sipid = + 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 ); + $sipid = $arg{sip_ext_prepend} . $sipid; + $sipid = substr( $sipid, 0, 5 ); + $sipid = $arg{username} . $sipid; + my $sql = + $self->{_freeswitch_db}->prepare( + "SELECT COUNT(*) FROM directory WHERE username = " + . $self->{_freeswitch_db}->quote($sipid) ); + $sql->execute; + my $record = $sql->fetchrow_hashref; + $sql->finish; + if ( $record->{"COUNT(*)"} == 0 ) { + last; + } + } + } else { + $arg{username} =~ s/\W//mg; + $sipid = $arg{username} + } + + my $tmp = + "INSERT INTO directory (username,domain) VALUES (" + . $self->{_freeswitch_db}->quote($sipid) . ", " + . $self->{_freeswitch_db}->quote($arg{freeswitch_domain}). ")"; + print STDERR $tmp . "\n"; + my $sql = $self->{_freeswitch_db}->prepare($tmp); + if ( !$sql->execute ) { + print "$tmp failed"; + return (1,"SIP Device Creation Failed!"); + } + else { + my $directory_id = $sql->{'mysql_insertid'}; + my $tmp = "INSERT INTO directory_vars (directory_id,var_name,var_value) VALUES (" + . $self->{_freeswitch_db}->quote($directory_id) . "," + . "'accountcode'," + . $self->{_freeswitch_db}->quote($arg{accountcode}) + . "),(" + . $self->{_freeswitch_db}->quote($directory_id) . "," + . "'user_context'," + . $self->{_freeswitch_db}->quote($arg{freeswitch_context}) . ")"; + print STDERR $tmp . "\n"; + $self->{_freeswitch_db}->do($tmp); + + $tmp = "INSERT INTO directory_params (directory_id,param_name,param_value) VALUES (" + . $self->{_freeswitch_db}->quote($directory_id) . "," + . "'vm-password'," + . $self->{_freeswitch_db}->quote($arg{vm_password}) + . "),(" + . $self->{_freeswitch_db}->quote($directory_id) . "," + . "'password'," + . $self->{_freeswitch_db}->quote($arg{password}) . ")"; + print STDERR $tmp . "\n"; + $self->{_freeswitch_db}->do($tmp); + + return (0, "SIP Device Added!" . "Username:" . " " . $sipid . " " . "Password:" . " " . $arg{password}, $sipid); + } +} + + +sub fs_save_sip_user +{ + my ($self, %arg) = @_; + my $tmp = "UPDATE directory SET username = " + . $self->{_freeswitch_db}->quote($arg{username}) + . " WHERE id = " + . $self->{_freeswitch_db}->quote($arg{directory_id}); + print STDERR $tmp . "\n"; + $self->{_freeswitch_db}->do($tmp); + + $tmp = "UPDATE directory_vars SET var_value = " + . $self->{_freeswitch_db}->quote($arg{accountcode}) + . " WHERE var_name = 'accountcode'" + . " AND directory_id = " + . $self->{_freeswitch_db}->quote($arg{directory_id}); + print STDERR $tmp . "\n"; + $self->{_freeswitch_db}->do($tmp); + + $tmp = "UPDATE directory_vars SET var_value = " + . $self->{_freeswitch_db}->quote($arg{freeswitch_context}) + . " WHERE var_name = 'user_context'" + . " AND directory_id = " + . $self->{_freeswitch_db}->quote($arg{directory_id}); + print STDERR $tmp . "\n"; + $self->{_freeswitch_db}->do($tmp); + + $tmp = "UPDATE directory_params SET param_value = " + . $self->{_freeswitch_db}->quote($arg{vm_password}) + . " WHERE param_name = 'vm-password'" + . " AND directory_id = " + . $self->{_freeswitch_db}->quote($arg{directory_id}); + print STDERR $tmp . "\n"; + $self->{_freeswitch_db}->do($tmp); + + $tmp = "UPDATE directory_params SET param_value = " + . $self->{_freeswitch_db}->quote($arg{password}) + . " WHERE param_name = 'password'" + . " AND directory_id = " + . $self->{_freeswitch_db}->quote($arg{directory_id}); + print STDERR $tmp . "\n"; + $self->{_freeswitch_db}->do($tmp); + + return (0, "SIP Device Saved!" . "Username:" . " " . $arg{username} . " " . "Password:" . " " . $arg{password}, $arg{username}); +} + +sub fs_retrieve_sip_user +# Retrieve a SIP user +# Parameters +# directory_id = directory_id of sip user you are looking for. +{ + my ($self, %arg) = @_; + my ($tmp,$record,$sql,$deviceinfo); + $tmp = "SELECT username FROM directory WHERE id = " + . $self->{_freeswitch_db}->quote($arg{directory_id}); + print STDERR $tmp . "\n"; + $sql = $self->{_freeswitch_db}->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{username} = $record->{username}; + + $tmp = "SELECT var_value FROM directory_vars WHERE directory_id = " + . $self->{_freeswitch_db}->quote($arg{directory_id}) + . " AND var_name = 'user_context'"; + print STDERR $tmp . "\n"; + $sql = $self->{_freeswitch_db}->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{context} = $record->{var_value}; + + $tmp = "SELECT param_value FROM directory_params WHERE directory_id = " + . $self->{_freeswitch_db}->quote($arg{directory_id}) + . " AND param_name = 'password' LIMIT 1"; + print STDERR $tmp . "\n"; + $sql = $self->{_freeswitch_db}->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{password} = $record->{param_value}; + + $tmp = "SELECT param_value FROM directory_params WHERE directory_id = " + . $self->{_freeswitch_db}->quote($arg{directory_id}) + . " AND param_name = 'vm-password' LIMIT 1"; + print STDERR $tmp . "\n"; + $sql = $self->{_freeswitch_db}->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{vm_password} = $record->{param_value}; + + $tmp = "SELECT var_value FROM directory_vars WHERE directory_id = " + . $self->{_freeswitch_db}->quote($arg{directory_id}) + . " AND var_name = 'accountcode' LIMIT 1"; + print STDERR $tmp . "\n"; + $sql = $self->{_freeswitch_db}->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{accountcode} = $record->{var_value}; + return $deviceinfo; +} + + sub fs_delete_sip_user #Delete the SIP user #id = directory.id to delete Modified: trunk/templates/freeswitch-sip-list.tpl =================================================================== --- trunk/templates/freeswitch-sip-list.tpl 2009-09-20 03:31:28 UTC (rev 2255) +++ trunk/templates/freeswitch-sip-list.tpl 2009-09-22 04:11:06 UTC (rev 2256) @@ -2,14 +2,32 @@ <table> <tr> <input type="hidden" name="mode" value="Freeswitch(TM) SIP Devices"/> - <td colspan=7 align=center><TMPL_VAR NAME="status"></td> + <td colspan=8 align=center><TMPL_VAR NAME="status"></td> </tr> - <tr class="header"> - <td colspan=7><TMPL_VAR NAME="account_types"></td> + <tr align="center" class="header"> + <td colspan=8>Add / Edit Device</td> </tr> <tr class="header"> - <td colspan=7><input type="submit" name="action" value="Add..." /> <input type="submit" name="Refresh" value="Refresh" /></td> + <td>Directory ID</td> + <td>Username</td> + <td>Password</td> + <td>Accountcode</td> + <td>VM Password</td> + <td>Context</td> + <td colspan=2>Action</td> </tr> + <tr> + <td><TMPL_VAR NAME="directory_id"><input type="hidden" name="directory_id" value="<TMPL_VAR NAME="directory_id">"></td> + <TD><input name="fs_username" size="20" type="text" value="<TMPL_VAR NAME="fs_username">"></a></TD> + <TD><input name="fs_password" size="20" type="text" value="<TMPL_VAR NAME="fs_password">"></a></TD> + <TD><input name="accountcode" size="20" type="text" value="<TMPL_VAR NAME="accountcode">"></a></TD> + <TD><input name="vm_password" size="20" type="text" value="<TMPL_VAR NAME="vm_password">"></a></TD> + <TD><input name="context" size="20" type="text" value="<TMPL_VAR NAME="context">"></a></TD> + <td colspan=2><input type="submit" name="action" value="Save..." /></td> + </tr> + <tr align="Center" class="header"> + <td colspan=8>Current Devices</td> + </tr> <tr class="header"> <td>Directory ID</td> <td>Username</td> @@ -17,15 +35,15 @@ <td>Accountcode</td> <td>VM Password</td> <td>Context</td> - <td>Action</td> + <td colspan=2>Action</td> </tr> <TMPL_LOOP NAME="device_list"> <TR> <TD><TMPL_VAR NAME="directory_id"></td> - <TD><TMPL_VAR NAME="username"></a></TD> - <TD><TMPL_VAR NAME="password"></TD> + <TD><TMPL_VAR NAME="fs_username"></a></TD> + <TD><TMPL_VAR NAME="fs_password"></TD> <TD><TMPL_VAR NAME="accountcode"></TD> - <TD><TMPL_VAR NAME="vmpassword"></TD> + <TD><TMPL_VAR NAME="vm_password"></TD> <TD><TMPL_VAR NAME="context"></TD> <TD><a href="astpp-admin.cgi?mode=Freeswitch(TM) SIP Devices&directory_id=<TMPL_VAR NAME="directory_id">&action=Delete...">Delete...</a></TD> <TD><a href="astpp-admin.cgi?mode=Freeswitch(TM) SIP Devices&directory_id=<TMPL_VAR NAME="directory_id">&action=Edit...">Edit...</a></TD> Modified: trunk/web_interface/astpp-admin.cgi =================================================================== --- trunk/web_interface/astpp-admin.cgi 2009-09-20 03:31:28 UTC (rev 2255) +++ trunk/web_interface/astpp-admin.cgi 2009-09-22 04:11:06 UTC (rev 2256) @@ -2066,8 +2066,9 @@ ); foreach my $record (@sip_devices) { print STDERR $record->{username}; - my $deviceinfo = - &get_sip_account_freeswitch( $fs_db, $config, $record->{id} ); + my $deviceinfo = $ASTPP->fs_retrieve_sip_user( + directory_id => $record->{id} + ); my %row; $row{tech} = "SIP"; $row{type} = "user@" . $record->{domain}; @@ -2441,7 +2442,7 @@ } } if ( $config->{openser} == 1 ) { - $status .= $status .= + $status .= &add_sip_user_openser( $openser_db, $config, $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params ); @@ -2454,13 +2455,15 @@ } } if ( $config->{users_dids_freeswitch} == 1 ) { - my $name = - &finduniquesip_freeswitch( $fs_db, $config, - $params->{number} ); - $status .= - &add_sip_user_freeswitch( $fs_db, $config, $name, - $params->{accountpassword}, - $params->{number}, $params, $accountinfo->{cc} ); + my $failure; + ($failure, $status, $name) .= $ASTPP->fs_add_sip_user( + accountcode => $params->{number}, + freeswitch_domain => $config->{freeswitch_domain}, + freeswitch_context => $config->{freeswitch_context}, + vm_password => $params->{accountpassword}, + password => $params->{accountpassword}, + sip-ext-prepend => $config->{sip_ext_prepend}, + ); $status .= "<br>"; if ( $config->{email} == 1 && $params->{accounttype} == 0 ) { $params->{extension} = $name; @@ -9614,7 +9617,8 @@ $ASTPP->set_cdr_db($cdr_db); } -############### Freeswitch SIP Device handling ############################## +############### Freeswitch SIP Device handling ######################### + sub build_freeswitch_sip_devices() { return gettext("Database is NOT configured!") . "\n" unless $astpp_db; my ( @device_list, @sip_devices ); @@ -9629,18 +9633,59 @@ . $params->{directory_id} . " " . gettext("Removed Successfully!"); } + elsif ( $params->{action} eq "Save..." ) { + my $failure; + $ASTPP->debug( user => $param->{username}, debug => "Directory ID: " . $params->{directory_id}); + if (!$params->{directory_id} || $params->{directory_id} == 0 || $params->{directory_id} eq "") { + $ASTPP->debug( user => $param->{username}, debug => "Adding User"); + $params->{domain} = $config->{freeswitch_domain} if !$params->{domain}; + $params->{context} = $config->{freeswitch_context} if !$params->{context}; + ($failure, $status, $name) .= $ASTPP->fs_add_sip_user( + username => $params->{fs_username}, + accountcode => $params->{accountcode}, + freeswitch_domain => $params->{domain}, + freeswitch_context => $params->{context}, + vm_password => $params->{vm_password}, + password => $params->{fs_password}, + sip_ext_prepend => $config->{sip_ext_prepend}, + ); + } else { + $ASTPP->debug( user => $param->{username}, debug => "Saving User"); + $ASTPP->fs_save_sip_user( directory_id => $params->{directory_id}, + username => $params->{fs_username}, + accountcode => $params->{accountcode}, + freeswitch_domain => $params->{domain}, + freeswitch_context => $params->{context}, + vm_password => $params->{vm_password}, + password => $params->{fs_password}, + ); + } + $status .= "<br>"; + } + elsif ( $params->{action} eq "Edit..." ) { + my $deviceinfo = $ASTPP->fs_retrieve_sip_user( + directory_id => $params->{directory_id} + ); + $template->param( directory_id => $params->{directory_id} ); + $template->param( accountcode => $deviceinfo->{accountcode} ); + $template->param( context => $deviceinfo->{context} ); + $template->param( fs_password => $deviceinfo->{password} ); + $template->param( vm_password => $deviceinfo->{vm_password} ); + $template->param( fs_username => $deviceinfo->{username} ); + } @sip_devices = $ASTPP->fs_list_sip_usernames(); foreach my $record (@sip_devices) { - my $deviceinfo = - &get_sip_account_freeswitch( $fs_db, $config, $record->{id} ); + my $deviceinfo = $ASTPP->fs_retrieve_sip_user( + directory_id => $record->{id} + ); my %row; $row{directory_id} = $record->{id}; $row{tech} = "SIP"; $row{type} = "user@" . $record->{domain}; - $row{username} = $record->{username}; - $row{password} = $deviceinfo->{password}; - $row{vmpassword} = $deviceinfo->{vmpassword}; + $row{fs_username} = $record->{username}; + $row{fs_password} = $deviceinfo->{password}; + $row{vm_password} = $deviceinfo->{vm_password}; $row{context} = $deviceinfo->{context}; $row{accountcode} = $deviceinfo->{accountcode}; push( @device_list, \%row ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-09-20 03:31:37
|
Revision: 2255 http://astpp.svn.sourceforge.net/astpp/?rev=2255&view=rev Author: darrenkw Date: 2009-09-20 03:31:28 +0000 (Sun, 20 Sep 2009) Log Message: ----------- More work towards invoice presentation Modified Paths: -------------- trunk/modules/ASTPP/lib/ASTPP.pm trunk/templates/account-info.tpl trunk/web_interface/astpp-admin.cgi Added Paths: ----------- trunk/templates/invoice.tpl Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-09-20 00:18:28 UTC (rev 2254) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-09-20 03:31:28 UTC (rev 2255) @@ -429,6 +429,7 @@ # set total_entries *once* then pass it around # in the object's links from then on for efficiency: my ($record,$sql); + $arg{te} = 0 if !$arg{te}; my $verify = $arg{ve} || ''; my $total_entries = int( $arg{te} ); my $te_match = $total_entries @@ -580,6 +581,24 @@ } } +sub invoice_list_internal +{ + my ($self, %arg) = @_; # List Internal Invoices. + my ($tmp,$sql,@invoices); + $tmp = "SELECT * FROM invoice_list_view"; + if ($arg{accountid}) { + $tmp .= " WHERE accountid = " + . $self->{_astpp_db}->quote($arg{accountid}); + } + $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + while ( my $record = $sql->fetchrow_hashref ) { + push @invoices, $record; + } + $sql->finish; + return @invoices; +} + sub invoice_create_internal { my ($self, %arg) = @_; # Create invoice in ASTPP Internally and return the invoice number. @@ -728,6 +747,39 @@ return $arg{sort_order}; } + +sub account_cdr_post +{ + my ($self, %arg) = @_; # Create invoice in ASTPP Internally and return the invoice number. + $arg{description} = "" if !$arg{timestamp}; + $arg{pricelist} = "" if !$arg{pricelist}; + $arg{pattern} = "" if !$arg{pattern}; + $arg{answeredtime} = "0" if !$arg{answeredtime}; + $arg{uniqueid} = "N/A" if $arg{uniqueid} eq "" || !$arg{uniqueid}; + $arg{clid} = "N/A" if $arg{clid} eq "" || !$arg{clid}; + + my $tmp = "INSERT INTO cdrs (uniqueid, cardnum, callednum, debit," + . " billseconds, callstart,callerid,pricelist,pattern) VALUES (" + . $self->{_astpp_db}->quote($arg{uniqueid}) . ", " + . $self->{_astpp_db}->quote($arg{account}) . "," + . $self->{_astpp_db}->quote($arg{description}) . ", " + . $self->{_astpp_db}->quote($arg{amount}) . ", " + . $self->{_astpp_db}->quote($arg{answeredtime}) . ", " + . $self->{_astpp_db}->quote($arg{timestamp}) . ", " + . $self->{_astpp_db}->quote($arg{clid}) . "," + . $self->{_astpp_db}->quote($arg{pricelist}) . "," + . $self->{_astpp_db}->quote($arg{pattern}) . ")"; + + if ( $self->{_astpp_db}->do($tmp) ) { + return (1, "POSTED CDR: $arg{account} in the amount of: " . $arg{amount} / 10000 . "\n"); + } + else { + return (2, $tmp . " FAILED! \n"); + } +} + + + # Preloaded methods go here. 1; Modified: trunk/templates/account-info.tpl =================================================================== --- trunk/templates/account-info.tpl 2009-09-20 00:18:28 UTC (rev 2254) +++ trunk/templates/account-info.tpl 2009-09-20 03:31:28 UTC (rev 2255) @@ -76,7 +76,7 @@ <TMPL_LOOP NAME="chargelist"> <tr> <td><a href="astpp-admin.cgi?mode=View Details&chargeid=<TMPL_VAR NAME="id">&accountnum=<TMPL_VAR NAME="accountnum">&action=Remove Charge...">Remove Charge...</a></td> - <td><TMPL_VAR NAME="id"><td> + <td><TMPL_VAR NAME="id"></td> <td><TMPL_VAR NAME="description"></td> <td><TMPL_VAR NAME="sweep"></td> <td>$<TMPL_VAR NAME="cost"></td> @@ -200,6 +200,9 @@ </table> <table class="default"> <tr class="header"> + <td colspan=5>Invoices</td> + </tr> + <tr class="header"> <td>Invoice Number</td> <td>Invoice Date</td> <td>Invoice Total</td> @@ -210,7 +213,7 @@ <tr> <td><TMPL_VAR NAME="invoiceid"></td> <td><TMPL_VAR NAME="date"></td> - <td><TMPL_VAR NAME="total"></td> + <td><TMPL_VAR NAME="value"></td> <td><a href="astpp-admin.cgi?mode=View Invoice&format=html&invoiceid=<TMPL_VAR NAME="invoiceid">">View</a></td> <td><a href="astpp-admin.cgi?mode=View Invoice&format=pdf&invoiceid=<TMPL_VAR NAME="invoiceid">">View</a></td> </tr> Added: trunk/templates/invoice.tpl =================================================================== --- trunk/templates/invoice.tpl (rev 0) +++ trunk/templates/invoice.tpl 2009-09-20 03:31:28 UTC (rev 2255) @@ -0,0 +1,25 @@ + + +<table class="default"> + <tr class="header"> + <td>Date & Time</td> + <td>Caller*ID</td> + <td>Called Number</td> + <td>Disposition</td> + <td>Billable Seconds</td> + <td>Charge</td> + <td>Notes</td> + </tr> + <TMPL_LOOP NAME="invoice_cdr_list"> + <TR> + <TD><TMPL_VAR NAME="callstart"></TD> + <TD><TMPL_VAR NAME="callerid"></TD> + <TD><TMPL_VAR NAME="callednum"></TD> + <TD><TMPL_VAR NAME="disposition"></TD> + <TD><TMPL_VAR NAME="billseconds"></TD> + <TD><TMPL_VAR NAME="charge"></TD> + <TD><TMPL_VAR NAME="notes"></TD> + </TR> + </TMPL_LOOP> +</table> + Modified: trunk/web_interface/astpp-admin.cgi =================================================================== --- trunk/web_interface/astpp-admin.cgi 2009-09-20 00:18:28 UTC (rev 2254) +++ trunk/web_interface/astpp-admin.cgi 2009-09-20 03:31:28 UTC (rev 2255) @@ -2110,6 +2110,11 @@ } } $template->param( account_device_list => \@account_device_list ); + my @account_invoice_list = $ASTPP->invoice_list_internal( + accountid => $accountinfo->{accountid} + ); + $template->param( account_invoice_list => \@account_invoice_list ); + ### End Section ### ( $sql, $pagination ) = $ASTPP->pagination( sql_select => "SELECT * FROM cdrs WHERE cardnum =" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-09-20 01:22:35
|
Revision: 2254 http://astpp.svn.sourceforge.net/astpp/?rev=2254&view=rev Author: darrenkw Date: 2009-09-20 00:18:28 +0000 (Sun, 20 Sep 2009) Log Message: ----------- Add another view to show invoice totals. Modified Paths: -------------- trunk/scripts/astpp-generate-invoices.pl trunk/sql/astpp-2009-09-19.sql trunk/templates/account-info.tpl Modified: trunk/scripts/astpp-generate-invoices.pl =================================================================== --- trunk/scripts/astpp-generate-invoices.pl 2009-09-19 23:53:41 UTC (rev 2253) +++ trunk/scripts/astpp-generate-invoices.pl 2009-09-20 00:18:28 UTC (rev 2254) @@ -150,7 +150,7 @@ value => $subtotal, title => "Total", text => "Total", - class => "1" + class => "9" #class 9 = total ); } } Modified: trunk/sql/astpp-2009-09-19.sql =================================================================== --- trunk/sql/astpp-2009-09-19.sql 2009-09-19 23:53:41 UTC (rev 2253) +++ trunk/sql/astpp-2009-09-19.sql 2009-09-20 00:18:28 UTC (rev 2254) @@ -1386,3 +1386,15 @@ taxes.taxes_description FROM taxes_to_accounts, taxes WHERE taxes.taxes_id = taxes_to_accounts.taxes_id; + + +CREATE VIEW invoice_list_view AS SELECT +invoices.invoiceid, +invoices.accountid, +invoices.date, +invoices.status, +invoices_total.value, +invoices_total.class +FROM invoices, invoices_total +WHERE invoices_total.class = 9 +AND invoices.invoiceid = invoices_total.invoices_id; Modified: trunk/templates/account-info.tpl =================================================================== --- trunk/templates/account-info.tpl 2009-09-19 23:53:41 UTC (rev 2253) +++ trunk/templates/account-info.tpl 2009-09-20 00:18:28 UTC (rev 2254) @@ -197,6 +197,24 @@ <td><TMPL_VAR NAME="context"></td> </tr> </TMPL_LOOP> +</table> +<table class="default"> + <tr class="header"> + <td>Invoice Number</td> + <td>Invoice Date</td> + <td>Invoice Total</td> + <td>HTML View</td> + <td>PDF View</td> + </tr> + <TMPL_LOOP NAME="account_invoice_list"> + <tr> + <td><TMPL_VAR NAME="invoiceid"></td> + <td><TMPL_VAR NAME="date"></td> + <td><TMPL_VAR NAME="total"></td> + <td><a href="astpp-admin.cgi?mode=View Invoice&format=html&invoiceid=<TMPL_VAR NAME="invoiceid">">View</a></td> + <td><a href="astpp-admin.cgi?mode=View Invoice&format=pdf&invoiceid=<TMPL_VAR NAME="invoiceid">">View</a></td> + </tr> + </TMPL_LOOP> </table> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-09-19 23:53:53
|
Revision: 2253 http://astpp.svn.sourceforge.net/astpp/?rev=2253&view=rev Author: darrenkw Date: 2009-09-19 23:53:41 +0000 (Sat, 19 Sep 2009) Log Message: ----------- This adds support for internal invoice generation. This upgrade will require a few manual database upgrades. I am not committing invoice presentation yet. Modified Paths: -------------- trunk/modules/ASTPP/lib/ASTPP.pm trunk/scripts/astpp-common.pl trunk/scripts/astpp-generate-invoices.pl trunk/sql/astpp-2009-09-19.sql Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-09-19 18:53:05 UTC (rev 2252) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-09-19 23:53:41 UTC (rev 2253) @@ -517,7 +517,217 @@ return @pricelistlist; } +sub invoice_cdrs +# Function 1 = count cdrs +# Function 2 = return crds +# Function 3 = Internal Invoices, Post CDRs. +{ + my ($self, %arg) = @_; #Count the cdrs billable on a specific account + my $tmp; + if ($arg{function} == 1) { + $tmp = "SELECT COUNT(*) FROM cdrs WHERE cardnum = "; + } + elsif ($arg{function} == 2) { + $tmp = "SELECT * FROM cdrs WHERE cardnum = "; + } + elsif ($arg{function} == 3) { + $tmp = "UPDATE cdrs SET invoiceid = " + . $self->{_astpp_db}->quote($arg{invoiceid}) + . ",status = 1 " + . " WHERE cardnum = "; + } + if ($arg{startdate} && $arg{enddate}) { + $tmp .= $self->{_astpp_db}->quote($arg{cardnum}) + . " AND status = 0" + . " AND callstart >= DATE(" . $self->{_astpp_db}->quote($arg{startdate}) . ")" + . " AND callstart <= DATE(" . $self->{_astpp_db}->quote($arg{enddate}) . ")"; + } elsif ($arg{startdate}) { + $tmp .= $self->{_astpp_db}->quote($arg{cardnum}) + . " AND status = 0" + . " AND callstart >= DATE(" . $self->{_astpp_db}->quote($arg{startdate}) . ")"; + } elsif ($arg{enddate}) { + $tmp .= $self->{_astpp_db}->quote($arg{cardnum}) + . " AND status = 0" + . " AND callstart <= DATE(" . $self->{_astpp_db}->quote($arg{enddate}) . ")"; + } else { + $tmp .= $self->{_astpp_db}->quote($arg{cardnum}) + . " AND status = 0"; + } + if ($arg{function} == 2) { + $tmp .= " GROUP BY type ORDER BY callstart"; + } + print STDERR "$tmp \n"; + my $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + + if ($arg{function} == 1) { + my $row = $sql->fetchrow_hashref; + $sql->finish; + return( + $row->{"COUNT(*)"} + ); + } + elsif ($arg{function} == 2) { + my @cdrs; + while ( my $record = $sql->fetchrow_hashref ) { + push @cdrs, $record; + } + $sql->finish; + return( + @cdrs + ); + } +} + +sub invoice_create_internal +{ + my ($self, %arg) = @_; # Create invoice in ASTPP Internally and return the invoice number. + my $tmp = "INSERT into invoices (accountid,date) VALUES(" + . $self->{_astpp_db}->quote($arg{accountid}) + . ",curdate())"; + my $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + my $invoice = $sql->{'mysql_insertid'}; + $sql->finish; + return ( + $invoice + ); +} + +sub invoice_cdrs_subtotal_internal +{ + my ($self, %arg) = @_; # Create invoice in ASTPP Internally and return the invoice number. + my ($tmp,$row,$sql,$credit,$debit,$total); + $tmp = "SELECT SUM(debit) FROM cdrs WHERE invoiceid = " + . $self->{_astpp_db}->quote($arg{invoiceid}); + $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + $row = $sql->fetchrow_hashref; + $debit = $row->{"SUM(debit)"}; + $sql->finish; + $tmp = "SELECT SUM(credit) FROM cdrs WHERE invoiceid = " + . $self->{_astpp_db}->quote($arg{invoiceid}); + $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + $row = $sql->fetchrow_hashref; + $credit = $row->{"SUM(credit)"}; + $sql->finish; + if ( !$credit ) { $credit = 0; } + if ( !$debit ) { $debit = 0; } + $total = ( $debit - $credit ); + return ($total/10000); + +# $tmp = "INSERT into invoices_total (invoiceid,title,text,value,class,sort_order) VALUES(" +# . $self->{_astpp_db}->quote($arg{invoiceid}) +# . ",'Subtotal',''," +# . $self->{_astpp_db}->quote($total/10000) +# . ",1," +# . $self->{_astpp_db}->quote($arg{sort_order}) +# . ")"; +# $sql = $ $self->{_astpp_db}->prepare($tmp); +# $sql->execute; +# return $arg{sort_order}++; +} + +sub invoice_subtotal_post_internal +{ + my ($self, %arg) = @_; + $arg{value} = sprintf( "%." . $arg{decimalpoints_total} . "f", $arg{value} ); + my $tmp = "INSERT into invoices_total (invoices_id,title,text,value,class,sort_order) VALUES(" + . $self->{_astpp_db}->quote($arg{invoiceid}) + . "," + . $self->{_astpp_db}->quote($arg{title}) + . "," + . $self->{_astpp_db}->quote($arg{text}) + . "," + . $self->{_astpp_db}->quote($arg{value}) + . "," + . $self->{_astpp_db}->quote($arg{class}) + . "," + . $self->{_astpp_db}->quote($arg{sort_order}) + . ")"; + my $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + return $arg{sort_order}++; +} + +sub invoice_subtotal_internal +{ + my ($self, %arg) = @_; + my $tmp = "SELECT SUM(value) FROM invoices_total WHERE invoices_id = " + . $self->{_astpp_db}->quote($arg{invoiceid}); + my $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + my $row = $sql->fetchrow_hashref; + my $value = $row->{"SUM(value)"}; + $sql->finish; + return $value; +} + +sub invoice_taxes_internal +# function 1 = list +# function 2 = post +{ + my ($self, %arg) = @_; # Create invoice in ASTPP Internally and return the invoice number. + my (@taxes,$row,$tmp,$sql); + $tmp = "SELECT * FROM taxes_to_accounts_view WHERE accountid = " + . $self->{_astpp_db}->quote($arg{accountid}) + . " ORDER BY taxes_priority ASC"; + $sql = $self->{_astpp_db}->prepare($tmp); + print STDERR $tmp . "/n"; + $sql->execute; + while ( $row = $sql->fetchrow_hashref ) { + push @taxes, $row; + } + $sql->finish; + if ($arg{function} == 1) { + return @taxes; + } + my $tax_count = 1; + my $sort = 1; + my $tax_priority = ""; + my $subtotal = $arg{invoice_subtotal}; + foreach my $tax (@taxes) { + my ($tax_amount); + if ($tax_priority eq "") { + $tax_priority = $tax->{taxes_priority}; + } elsif($tax->{taxes_priority} > $tax_priority) { + $tax_priority = $tax->{taxes_priority}; + my $tmp = "SELECT SUM(value) FROM invoices_total WHERE invoices_id = " + . $self->{_astpp_db}->quote($arg{invoiceid}); + print STDERR $tmp . "\n"; + my $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + my $row = $sql->fetchrow_hashref; + $subtotal = $row->{"SUM(value)"}; + $sql->finish; + } + print STDERR "Subtotal: $subtotal \n"; + print STDERR "Tax_rate: $tax->{taxes_rate} \n"; + my $tax_total = (($subtotal * ( $tax->{taxes_rate} / 100 )) + $tax->{taxes_amount} ); + print STDERR "Tax Total: $tax_total \n"; + print STDERR "Round to: $arg{decimalpoints_tax} \n"; + $tax_total = sprintf( "%." . $arg{decimalpoints_tax} . "f", $tax_total ); + print STDERR "Tax Total: $tax_total \n"; + my $tmp = "INSERT INTO invoices_total (invoices_id,title,text,value,class,sort_order) VALUES(" + . $self->{_astpp_db}->quote($arg{invoiceid}) + . ",'TAX'," + . $self->{_astpp_db}->quote($tax->{taxes_description}) + . "," + . $self->{_astpp_db}->quote($tax_total) + . ",2," + . $self->{_astpp_db}->quote($arg{sort_order}) + . ")"; + print STDERR $tmp . "\n"; + my $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + + $arg{sort_order}++; + } + return $arg{sort_order}; +} + # Preloaded methods go here. 1; Modified: trunk/scripts/astpp-common.pl =================================================================== --- trunk/scripts/astpp-common.pl 2009-09-19 18:53:05 UTC (rev 2252) +++ trunk/scripts/astpp-common.pl 2009-09-19 23:53:41 UTC (rev 2253) @@ -999,7 +999,7 @@ $dsn = "DBI:Pg:database=$config->{cdr_dbname};host=$config->{cdr_dbhost}"; } - print STDERR $dsn if $config->{debug} == 1; + print STDERR $dsn . "\n" if $config->{debug} == 1; $dbh = DBI->connect( $dsn, $config->{cdr_dbuser}, $config->{cdr_dbpass} ); if ( !$dbh ) { print STDERR "CDR DATABASE IS DOWN\n"; @@ -3999,6 +3999,7 @@ else { $outfile = $config->{csv_dir} . $reseller . ".csv"; } + $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"; Modified: trunk/scripts/astpp-generate-invoices.pl =================================================================== --- trunk/scripts/astpp-generate-invoices.pl 2009-09-19 18:53:05 UTC (rev 2252) +++ trunk/scripts/astpp-generate-invoices.pl 2009-09-19 23:53:41 UTC (rev 2253) @@ -33,6 +33,7 @@ use Locale::Country; use Locale::gettext_pp qw(:locale_h); use Data::Dumper; +use ASTPP; #use strict; use lib './lib', '../lib'; @@ -44,7 +45,10 @@ use vars qw($config $astpp_db $osc_db $agile_db $cdr_db @output @cardlist $config $params); @output = ( "STDOUT", "LOGFILE" ); +$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 ); @@ -54,6 +58,7 @@ if $config->{externalbill} eq "oscommerce"; open( LOGFILE, ">>$config->{log_file}" ) || die "Error - could not open $config->{log_file} for writing\n"; + $ASTPP->set_astpp_db($astpp_db); } sub shutdown() { @@ -84,6 +89,73 @@ } } } +elsif ( $config->{externalbill} eq "internal" ) { + my @cardlist; + if ( $params->{sweep} ) { + @cardlist = &update_list_cards($astpp_db, $config, $params->{sweep} ); + } + foreach (@cardlist) { + my $cardno = $_; + my $carddata = &get_account( $astpp_db, $cardno ); + if ( $carddata->{posttoexternal} == 1 ) { + foreach my $handle (@output) { + print $handle "Card: $cardno \n"; + } + my $cdr_count = $ASTPP->invoice_cdrs( + accountid => $carddata->{accountid}, + cardnum => $carddata->{number}, + function => 1 + ); + if ($cdr_count > 0) { + my $invoice = $ASTPP->invoice_create_internal( + accountid => $carddata->{accountid} + ); + $ASTPP->invoice_cdrs( + accountid => $carddata->{accountid}, + cardnum => $carddata->{number}, + invoiceid => $invoice, + function => 3 + ); + + my $sort_order = 1; + + my $subtotal = $ASTPP->invoice_cdrs_subtotal_internal( + invoiceid => $invoice + ); + $sort_order = $ASTPP->invoice_subtotal_post_internal( + decimalpoints_total => $config->{decimalpoints_total}, + invoiceid => $invoice, + sort_order => $sort_order, + value => $subtotal, + title => "Sub Total", + text => "Sub Total", + class => "1" + ); + $sort_order = $ASTPP->invoice_taxes_internal( + accountid => $carddata->{accountid}, + invoiceid => $invoice, + sort_order => $sort_order, + function => 2, + decimalpoints_tax => $config->{decimalpoints_tax}, + decimalpoints_total => $config->{decimalpoints_total}, + invoice_subtotal => $subtotal + ); + $subtotal = $ASTPP->invoice_subtotal_internal( + invoiceid => $invoice + ); + $sort_order = $ASTPP->invoice_subtotal_post_internal( + decimalpoints_total => $config->{decimalpoints_total}, + invoiceid => $invoice, + sort_order => $sort_order, + value => $subtotal, + title => "Total", + text => "Total", + class => "1" + ); + } + } + } +} elsif ( $config->{externalbill} eq "agile" ) { my @cardlist = &list_cards($astpp_db); foreach my $cardno (@cardlist) { Modified: trunk/sql/astpp-2009-09-19.sql =================================================================== --- trunk/sql/astpp-2009-09-19.sql 2009-09-19 18:53:05 UTC (rev 2252) +++ trunk/sql/astpp-2009-09-19.sql 2009-09-19 23:53:41 UTC (rev 2253) @@ -172,7 +172,8 @@ dialed_modify TEXT NOT NULL DEFAULT '', type INTEGER DEFAULT 0, tz CHAR(40) NOT NULL DEFAULT '', -PRIMARY KEY (`number`), +PRIMARY KEY (`accountid`), + KEY `pricelist` (`number`), KEY `pricelist` (`pricelist`), KEY `reseller` (`reseller`) ); @@ -348,6 +349,9 @@ 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 ( @@ -1369,3 +1373,16 @@ `taxes_id` VARCHAR( 11 ) NOT NULL ) ENGINE = MYISAM ; + +;;;; Create Views Here +; +CREATE VIEW taxes_to_accounts_view AS SELECT +taxes_to_accounts.id, +taxes_to_accounts.accountid, +taxes.taxes_id, +taxes.taxes_priority, +taxes.taxes_amount, +taxes.taxes_rate, +taxes.taxes_description +FROM taxes_to_accounts, taxes +WHERE taxes.taxes_id = taxes_to_accounts.taxes_id; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-09-19 19:15:12
|
Revision: 2252 http://astpp.svn.sourceforge.net/astpp/?rev=2252&view=rev Author: darrenkw Date: 2009-09-19 18:53:05 +0000 (Sat, 19 Sep 2009) Log Message: ----------- SQL corrections. Change customerid to accountid to be more inline with the rest of the codebase. Modified Paths: -------------- trunk/sql/astpp-2009-09-19.sql Modified: trunk/sql/astpp-2009-09-19.sql =================================================================== --- trunk/sql/astpp-2009-09-19.sql 2009-09-19 18:22:36 UTC (rev 2251) +++ trunk/sql/astpp-2009-09-19.sql 2009-09-19 18:53:05 UTC (rev 2252) @@ -136,6 +136,7 @@ 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 '', @@ -1324,7 +1325,7 @@ CREATE TABLE `invoices` ( `invoiceid` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , -`customerid` INT( 11 ) NOT NULL , +`accountid` INT( 11 ) NOT NULL , `date` DATE NOT NULL , `status` TINYINT NOT NULL DEFAULT '0', `external_id` INT( 11 ) NOT NULL DEFAULT '0' @@ -1343,7 +1344,7 @@ CREATE TABLE `payments` ( `id` INT( 11 ) NOT NULL , -`customerid` INT( 11 ) NOT NULL , +`accountid` INT( 11 ) NOT NULL , `credit` DECIMAL NOT NULL DEFAULT '0', `status` TINYINT NOT NULL DEFAULT '0', `type` INT NOT NULL , @@ -1364,7 +1365,7 @@ CREATE TABLE `taxes_to_accounts` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , -`customerid` VARCHAR( 11 ) NOT NULL , +`accountid` VARCHAR( 11 ) NOT NULL , `taxes_id` VARCHAR( 11 ) NOT NULL ) ENGINE = MYISAM ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-09-19 18:22:49
|
Revision: 2251 http://astpp.svn.sourceforge.net/astpp/?rev=2251&view=rev Author: darrenkw Date: 2009-09-19 18:22:36 +0000 (Sat, 19 Sep 2009) Log Message: ----------- More work on the invoice presentation. Added Paths: ----------- trunk/sql/astpp-2009-09-19.sql Added: trunk/sql/astpp-2009-09-19.sql =================================================================== --- trunk/sql/astpp-2009-09-19.sql (rev 0) +++ trunk/sql/astpp-2009-09-19.sql 2009-09-19 18:22:36 UTC (rev 2251) @@ -0,0 +1,1370 @@ +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 '', +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 ( +'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) 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 ( +'astman_secret', 'amp111','Asterisk(tm) Manager Interface Secret', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'call_max_length','1440000','What is the maximum length (in ms) of a LCR call?',''); + +------ 3rd Party PBX Mods +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'thirdlane_mods','0','Provides a few different modifications across the rating code to work better with Thirdlane(tm) cdrs.',''); + +-- +-- 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`)); + +CREATE TABLE sql_commands ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +sql TEXT NOT NULL default '', +comment TEXT NOT NULL default '', +timestamp TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + PRIMARY KEY (`id`)); + +CREATE TABLE `invoices` ( +`invoiceid` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , +`customerid` INT( 11 ) NOT NULL , +`date` DATE NOT NULL , +`status` TINYINT NOT NULL DEFAULT '0', +`external_id` INT( 11 ) NOT NULL DEFAULT '0' +) ENGINE = MYISAM; + +CREATE TABLE `invoices_total` ( +`invoices_total_id` int(10) unsigned NOT NULL auto_increment, +`invoices_id` int(11) NOT NULL, +`title` varchar(255) NOT NULL, +`text` varchar(255) NOT NULL, +`value` decimal(15,4) NOT NULL, +`class` varchar(32) NOT NULL, +`sort_order` int(11) NOT NULL, +PRIMARY KEY (`invoices_total_id`) +); + + CREATE TABLE `payments` ( +`id` INT( 11 ) NOT NULL , +`customerid` INT( 11 ) NOT NULL , +`credit` DECIMAL NOT NULL DEFAULT '0', +`status` TINYINT NOT NULL DEFAULT '0', +`type` INT NOT NULL , +`notes` TEXT NOT NULL , +PRIMARY KEY ( `id` ) +) ENGINE = MYISAM; + + CREATE TABLE `taxes` ( +`taxes_id` int(11) NOT NULL auto_increment, +`taxes_priority` int(5) default '1', +`taxes_amount` decimal(7,4) NOT NULL, +`taxes_rate` decimal(7,4) NOT NULL, +`taxes_description` varchar(255) NOT NULL, +`last_modified` datetime default NULL, +`date_added` datetime NOT NULL, +PRIMARY KEY (`taxes_id`) +); + + CREATE TABLE `taxes_to_accounts` ( +`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , +`customerid` VARCHAR( 11 ) NOT NULL , +`taxes_id` VARCHAR( 11 ) NOT NULL +) ENGINE = MYISAM ; + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-05-16 00:39:10
|
Revision: 2250 http://astpp.svn.sourceforge.net/astpp/?rev=2250&view=rev Author: darrenkw Date: 2009-05-16 00:38:57 +0000 (Sat, 16 May 2009) Log Message: ----------- Fixed the code that emails out account details on account/device creation. Modified Paths: -------------- trunk/scripts/astpp-common.pl trunk/web_interface/astpp-admin.cgi Modified: trunk/scripts/astpp-common.pl =================================================================== --- trunk/scripts/astpp-common.pl 2009-05-15 23:57:25 UTC (rev 2249) +++ trunk/scripts/astpp-common.pl 2009-05-16 00:38:57 UTC (rev 2250) @@ -541,13 +541,15 @@ To => $vars->{email}, From => $config->{company_email}, Bcc => $config->{company_email}, - Subject => 'VOIP Account Created', + Subject => 'VOIP Device Account Created', 'X-Mailer' => "Mail::Sendmail version $Mail::Sendmail::VERSION", ); $mail{'Message : '} = "Attention: $vars->{title} $vars->{first} $vars->{last}\n" . "A new device has been enabled on your account. Here\n" . "is the necessary configuration information.\n\n" + . "Username: $vars->{extension}\n" + . "Password: $vars->{secret}\n\n" . "------- $config->{company_name} Configuration Info --------\n"; if ( $vars->{type} eq "SIP" ) { @@ -628,6 +630,7 @@ if ( sendmail %mail ) { print STDERR "Mail sent OK.\n" } else { print STDERR "Error sending mail: $Mail::Sendmail::error \n" } print STDERR "\n\$Mail::Sendmail::log says:\n", $Mail::Sendmail::log; + print STDERR $mail{'Message : '}; } # Send an email when on calling card creation. This needs to be updated and moved to templates which reside in the database and can be Modified: trunk/web_interface/astpp-admin.cgi =================================================================== --- trunk/web_interface/astpp-admin.cgi 2009-05-15 23:57:25 UTC (rev 2249) +++ trunk/web_interface/astpp-admin.cgi 2009-05-16 00:38:57 UTC (rev 2250) @@ -2310,6 +2310,8 @@ $params->{posttoexternal} ); } if ( $config->{email} == 1 && $params->{accounttype} == 0 ) { + $params->{extension} = $params->{number}; + $params->{secret} = $params->{accountpassword}; &email_add_user( $astpp_db, '', $config, $params ); } my $timestamp = &prettytimestamp; @@ -2408,6 +2410,12 @@ $params, $accountinfo->{cc} ); $status .= "<br>"; + if ( $config->{email} == 1 && $params->{accounttype} == 0 ) { + $params->{extension} = $name; + $params->{secret} = $params->{accountpassword}; + &email_add_device( $astpp_db, '', $config, $params ); + print STDERR "Sent Device Generation Email\n"; + } } if ( $config->{users_dids_amp} == 1 ) { my $name = @@ -2420,6 +2428,12 @@ $params, $accountinfo->{cc} ); $status .= "<br>"; + if ( $config->{email} == 1 && $params->{accounttype} == 0 ) { + $params->{extension} = $name; + $params->{secret} = $params->{accountpassword}; + &email_add_device( $astpp_db, '', $config, $params ); + print STDERR "Sent Device Generation Email\n"; + } } if ( $config->{openser} == 1 ) { $status .= $status .= @@ -2427,6 +2441,12 @@ $params->{accountpassword}, $params->{context}, $params->{number}, $params ); $status .= "<br>"; + if ( $config->{email} == 1 && $params->{accounttype} == 0 ) { + $params->{extension} = $name; + $params->{secret} = $params->{accountpassword}; + &email_add_device( $astpp_db, '', $config, $params ); + print STDERR "Sent Device Generation Email\n"; + } } if ( $config->{users_dids_freeswitch} == 1 ) { my $name = @@ -2437,6 +2457,12 @@ $params->{accountpassword}, $params->{number}, $params, $accountinfo->{cc} ); $status .= "<br>"; + if ( $config->{email} == 1 && $params->{accounttype} == 0 ) { + $params->{extension} = $name; + $params->{secret} = $params->{accountpassword}; + &email_add_device( $astpp_db, '', $config, $params ); + print STDERR "Sent Device Generation Email\n"; + } } } if ( $params->{IAX2} ) { @@ -2453,6 +2479,12 @@ $params, $accountinfo->{cc} ); $status .= "<br>"; + if ( $config->{email} == 1 && $params->{accounttype} == 0 ) { + $params->{extension} = $name; + $params->{secret} = $params->{accountpassword}; + &email_add_device( $astpp_db, '', $config, $params ); + print STDERR "Sent Device Generation Email\n"; + } } if ( $config->{users_dids_rt} == 1 ) { my $name = &finduniqueiax_rt( $params->{number} ); @@ -2463,6 +2495,12 @@ $params, $accountinfo->{cc} ); $status .= "<br>"; + if ( $config->{email} == 1 && $params->{accounttype} == 0 ) { + $params->{extension} = $name; + $params->{secret} = $params->{accountpassword}; + &email_add_device( $astpp_db, '', $config, $params ); + print STDERR "Sent Device Generation Email\n"; + } } } ### End of Device creation support This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-05-15 23:57:33
|
Revision: 2249 http://astpp.svn.sourceforge.net/astpp/?rev=2249&view=rev Author: darrenkw Date: 2009-05-15 23:57:25 +0000 (Fri, 15 May 2009) Log Message: ----------- Added the database tables for invoicing. Also modified the system table to make it easier to edit from within the gui. Added Paths: ----------- trunk/sql/astpp-2009-05-15.sql Added: trunk/sql/astpp-2009-05-15.sql =================================================================== --- trunk/sql/astpp-2009-05-15.sql (rev 0) +++ trunk/sql/astpp-2009-05-15.sql 2009-05-15 23:57:25 UTC (rev 2249) @@ -0,0 +1,1368 @@ +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 ( +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 ( +'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) 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 ( +'astman_secret', 'amp111','Asterisk(tm) Manager Interface Secret', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'call_max_length','1440000','What is the maximum length (in ms) of a LCR call?',''); + +------ 3rd Party PBX Mods +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'thirdlane_mods','0','Provides a few different modifications across the rating code to work better with Thirdlane(tm) cdrs.',''); + +-- +-- 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`)); + +CREATE TABLE sql_commands ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +sql TEXT NOT NULL default '', +comment TEXT NOT NULL default '', +timestamp TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + PRIMARY KEY (`id`)); + +CREATE TABLE `invoices` ( +`invoiceid` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , +`customerid` INT( 11 ) NOT NULL , +`date` DATE NOT NULL , +`status` TINYINT NOT NULL DEFAULT '0' +) ENGINE = MYISAM; + +CREATE TABLE `invoices_total` ( +`invoices_total_id` int(10) unsigned NOT NULL auto_increment, +`invoices_id` int(11) NOT NULL, +`title` varchar(255) NOT NULL, +`text` varchar(255) NOT NULL, +`value` decimal(15,4) NOT NULL, +`class` varchar(32) NOT NULL, +`sort_order` int(11) NOT NULL, +PRIMARY KEY (`invoices_total_id`) +); + + + CREATE TABLE `payments` ( +`id` INT( 11 ) NOT NULL , +`customerid` INT( 11 ) NOT NULL , +`credit` DECIMAL NOT NULL DEFAULT '0', +`status` TINYINT NOT NULL DEFAULT '0', +`type` INT NOT NULL , +`notes` TEXT NOT NULL , +PRIMARY KEY ( `id` ) +) ENGINE = MYISAM; + + CREATE TABLE `taxes` ( +`taxes_id` int(11) NOT NULL auto_increment, +`taxes_priority` int(5) default '1', +`taxes_amount` decimal(7,4) NOT NULL, +`taxes_rate` decimal(7,4) NOT NULL, +`taxes_description` varchar(255) NOT NULL, +`last_modified` datetime default NULL, +`date_added` datetime NOT NULL, +PRIMARY KEY (`taxes_id`) +); + + CREATE TABLE `taxes_to_accounts` ( +`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , +`customerid` VARCHAR( 11 ) NOT NULL , +`taxes_id` VARCHAR( 11 ) NOT NULL +) ENGINE = MYISAM ; + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-05-12 20:56:27
|
Revision: 2248 http://astpp.svn.sourceforge.net/astpp/?rev=2248&view=rev Author: darrenkw Date: 2009-05-12 20:56:17 +0000 (Tue, 12 May 2009) Log Message: ----------- Made the code that prints out the directory more inclusive. Modified Paths: -------------- trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-04-29 15:29:46 UTC (rev 2247) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-05-12 20:56:17 UTC (rev 2248) @@ -271,8 +271,9 @@ if ($arg{user}) { $tmp .= " WHERE username = " . $self->{_freeswitch_db}->quote($arg{user}); if ($arg{domain}) { - $tmp .= " AND domain = " - . $self->{_freeswitch_db}->quote($arg{domain}); + $tmp .= " AND domain IN( " + . $self->{_freeswitch_db}->quote($arg{domain}) + . ",'\$\${local_ip_v4}')"; } # } else { # if ($arg{domain}) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-04-29 15:29:51
|
Revision: 2247 http://astpp.svn.sourceforge.net/astpp/?rev=2247&view=rev Author: darrenkw Date: 2009-04-29 15:29:46 +0000 (Wed, 29 Apr 2009) Log Message: ----------- Updated FreeSwitch DID handling support. Modified Paths: -------------- trunk/freeswitch/astpp-fs-xml.pl trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2009-04-18 17:25:14 UTC (rev 2246) +++ trunk/freeswitch/astpp-fs-xml.pl 2009-04-29 15:29:46 UTC (rev 2247) @@ -68,9 +68,6 @@ DID => $didinfo->{number} ); - - - if ( !$params->{variable_accountcode} ) { # First we strip off X digits to see if this account is prepending numbers Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-04-18 17:25:14 UTC (rev 2246) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-04-29 15:29:46 UTC (rev 2247) @@ -133,7 +133,7 @@ # Return the dialplan code for an incoming call to a DID. { my ($self, %arg) = @_; - my ( $sql, $trunkdata, $dialstring,$data ); + my ( $xml,$sql, $trunkdata, $dialstring,$data ); my $tmp = "SELECT * FROM dids WHERE number = " . $self->{_astpp_db}->quote( $arg{did} ) . " LIMIT 1"; @@ -142,7 +142,21 @@ $sql->execute; my $diddata = $sql->fetchrow_hashref; $sql->finish; - return $diddata->{variables}; + my @variables = split /,(?!(?:[^",]|[^"],[^"])+")/, $diddata->{variables}; + foreach my $variable (@variables) { + $xml .= "<action application=\"set\" data=\"" . $variable . "\"/>\n"; + } + if ($diddata->{extensions} =~ m/^("|)(L|l)ocal.*/m) { + my ($junk,$ext,$context) = split /,(?!(?:[^",]|[^"],[^"])+")/, $diddata->{extensions}; + #jump to local dialplan +$ext =~ s/"//mg; +$context =~ s/"//mg; + $xml .= "<action application=\"execute_extension\" data=\"" . $ext ." XML " .$context . "\"/>\n"; + } else { + $xml .= "<action application=\"bridge\" data=\"" . $diddata->{extensions} . "\"/>\n"; + } + + return $xml; } sub fs_dialplan_xml_bridge This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-04-18 17:25:18
|
Revision: 2246 http://astpp.svn.sourceforge.net/astpp/?rev=2246&view=rev Author: darrenkw Date: 2009-04-18 17:25:14 +0000 (Sat, 18 Apr 2009) Log Message: ----------- This is the correct version of the callingcards file. Modified Paths: -------------- trunk/freeswitch/astpp-callingcards.pl Modified: trunk/freeswitch/astpp-callingcards.pl =================================================================== --- trunk/freeswitch/astpp-callingcards.pl 2009-04-18 17:11:43 UTC (rev 2245) +++ trunk/freeswitch/astpp-callingcards.pl 2009-04-18 17:25:14 UTC (rev 2246) @@ -20,679 +20,658 @@ use vars qw(@output $verbosity $config $astpp_db $cdr_db $ASTPP %stats %input $cc $pricelistinfo $brandinfo $sound @resellerlist $brand); $stats{start_time} = [gettimeofday]; -$cc = 0; -$verbosity = 1; +$cc = 0; +$verbosity = 1; require "/usr/local/astpp/astpp-common.pl"; $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. sub initialize() { - $SIG{HUP} = 'ignore_hup'; # We ignore the HUP command that Asterisk sends on a call hangup. - $config = &load_config(); # Load /var/lib/astpp/astpp-config.conf - $astpp_db = &connect_db( $config, @output ); - $ASTPP->set_astpp_db($astpp_db); - $config = &load_config_db($astpp_db,$config); - $brand = "brand"; #$AGI->get_variable("BRAND"); - if ($brand && $brand ne "") { - my $brandinfo = &get_cc_brand($astpp_db, $brand); - if ($brandinfo->{reseller}) { - $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); - } - $config = &load_config_db_brand($astpp_db,$config,$brand); + $SIG{HUP} = 'ignore_hup' + ; # We ignore the HUP command that Asterisk sends on a call hangup. + $config = &load_config(); # Load /var/lib/astpp/astpp-config.conf + $astpp_db = &connect_db( $config, @output ); + $ASTPP->set_astpp_db($astpp_db); + $config = &load_config_db( $astpp_db, $config ); + $brand = "brand"; #$AGI->get_variable("BRAND"); + if ( $brand && $brand ne "" ) { + my $brandinfo = &get_cc_brand( $astpp_db, $brand ); + if ( $brandinfo->{reseller} ) { + $config = + &load_config_db_reseller( $astpp_db, $config, + $brandinfo->{reseller} ); } - $cdr_db = &cdr_connect_db( $config, @output ); - $ASTPP->set_cdr_db($cdr_db); - $sound = &define_sounds($astpp_db); + $config = &load_config_db_brand( $astpp_db, $config, $brand ); + } + $cdr_db = &cdr_connect_db( $config, @output ); + $ASTPP->set_cdr_db($cdr_db); + $sound = &define_sounds($astpp_db); } -sub set_in_use() { # Set the "inuse" flag on the calling cards. This prevents multiple people from -# using the same card. - my ( $cardinfo, $status ) = @_; - my $sql; - $sql = - "UPDATE callingcards SET inuse = " - . $astpp_db->quote($status) - . " WHERE cardnumber = " - . $astpp_db->quote( $cardinfo->{cardnumber} ); - $astpp_db->do($sql); +sub set_in_use() +{ # Set the "inuse" flag on the calling cards. This prevents multiple people from + + # using the same card. + my ( $cardinfo, $status ) = @_; + my $sql; + $sql = + "UPDATE callingcards SET inuse = " + . $astpp_db->quote($status) + . " WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $astpp_db->do($sql); } -sub check_card() { # Check a few things before saying the card is ok. - my ($cardinfo) = @_; - my $now = $astpp_db->selectall_arrayref("SELECT NOW() + 0")->[0][0]; - $ASTPP->debug( debug => "Present Time: $now", - verbosity => $verbosity ); - $ASTPP->debug( debug => "Expiration Date: $cardinfo->{expiry}", - verbosity => $verbosity ); - $ASTPP->debug( debug => "Valid for Days: $cardinfo->{validfordays}", - verbosity => $verbosity ); - $ASTPP->debug( debug => "First Use: $cardinfo->{firstused}", - verbosity => $verbosity ); - if ( $cardinfo->{inuse} != 0 ) { # If the card is in use then say so and leave. - $session->streamFile($sound->{card_inuse}); - $session->streamFile($sound->{goodbye}); - &leave($cardinfo); +sub check_card() { # Check a few things before saying the card is ok. + my ($cardinfo) = @_; + my $now = $astpp_db->selectall_arrayref("SELECT NOW() + 0")->[0][0]; + $ASTPP->debug( + debug => "Present Time: $now", + verbosity => $verbosity + ); + $ASTPP->debug( + debug => "Expiration Date: $cardinfo->{expiry}", + verbosity => $verbosity + ); + $ASTPP->debug( + debug => "Valid for Days: $cardinfo->{validfordays}", + verbosity => $verbosity + ); + $ASTPP->debug( + debug => "First Use: $cardinfo->{firstused}", + verbosity => $verbosity + ); + if ( $cardinfo->{inuse} != 0 ) + { # If the card is in use then say so and leave. + $session->streamFile( $sound->{card_inuse} ); + $session->streamFile( $sound->{goodbye} ); + &leave($cardinfo); + } + &set_in_use( $cardinfo, 1 ) + ; # Now the card is in use and nobody else can use it. + if ( $cardinfo->{firstused} eq "00000000000000" + || $cardinfo->{firstused} eq "0000-00-00 00:00:00" ) + { # If "firstused" has not been set, we will set it now. + # At the same time we will update the "maint_day" field. + my $sql = + "UPDATE callingcards SET firstused = NOW() WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( + debug => $sql, + verbosity => $verbosity + ); + $astpp_db->do($sql); + $sql = + "UPDATE callingcards SET maint_day = DATE_ADD(NOW(), INTERVAL " + . "$cardinfo->{maint_fee_days} day) WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( + debug => $sql, + verbosity => $verbosity + ); + if ( $cardinfo->{maint_fee_days} > 0 ) { + $astpp_db->do($sql); } - &set_in_use( $cardinfo, 1 ); # Now the card is in use and nobody else can use it. - if ( $cardinfo->{firstused} eq "00000000000000" || $cardinfo->{firstused} eq "0000-00-00 00:00:00" ) { # If "firstused" has not been set, we will set it now. - # At the same time we will update the "maint_day" field. - my $sql = - "UPDATE callingcards SET firstused = NOW() WHERE cardnumber = " - . $astpp_db->quote( $cardinfo->{cardnumber} ); - $ASTPP->debug( debug => $sql, - verbosity => $verbosity ); - $astpp_db->do($sql); - $sql = - "UPDATE callingcards SET maint_day = DATE_ADD(NOW(), INTERVAL " - . "$cardinfo->{maint_fee_days} day) WHERE cardnumber = " - . $astpp_db->quote( $cardinfo->{cardnumber} ); - $ASTPP->debug( debug => $sql, - verbosity => $verbosity ); - if ( $cardinfo->{maint_fee_days} > 0 ) { - $astpp_db->do($sql); - } + # $cardinfo = &get_callingcard( $astpp_db, $cardinfo->{cardnumber} ); - if ( $cardinfo->{validfordays} > 0 ) { #Check if the card is set to expire and deal with that as appropriate. - my $sql = -"UPDATE callingcards SET expiry = DATE_ADD(NOW(), INTERVAL " - . " $cardinfo->{validfordays} day) WHERE cardnumber = " - . $astpp_db->quote( $cardinfo->{cardnumber} ); - $ASTPP->debug( debug => $sql, - verbosity => $verbosity ); - $astpp_db->do($sql); - $cardinfo = &get_callingcard( $astpp_db, $cardinfo->{cardnumber}, $config ); - } + if ( $cardinfo->{validfordays} > 0 ) + { #Check if the card is set to expire and deal with that as appropriate. + my $sql = + "UPDATE callingcards SET expiry = DATE_ADD(NOW(), INTERVAL " + . " $cardinfo->{validfordays} day) WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( + debug => $sql, + verbosity => $verbosity + ); + $astpp_db->do($sql); + $cardinfo = + &get_callingcard( $astpp_db, $cardinfo->{cardnumber}, $config ); } - elsif ( $cardinfo->{validfordays} > 0 ) { - my $now = $astpp_db->selectall_arrayref("SELECT NOW() + 0")->[0][0]; - $cardinfo->{expiry} = $astpp_db->selectall_arrayref("SELECT DATE_FORMAT('$cardinfo->{expiry}' , '\%Y\%m\%d\%H\%i\%s')")->[0][0]; - if ( $now >= $cardinfo->{expiry} ) { - my $sql = - "UPDATE callingcards SET status = 2 WHERE cardnumber = " - . $astpp_db->quote( $cardinfo->{cardnumber} ); - $ASTPP->debug( debug => $sql, - verbosity => $verbosity ); - $astpp_db->do($sql); - $sql = - "DELETE FROM ani_map WHERE account = " - . $astpp_db->quote( $cardinfo->{cardnumber} ); - $ASTPP->debug( debug => $sql, - verbosity => $verbosity ); - $astpp_db->do($sql); - $session->streamFile($sound->{card_has_expired}); - $session->streamFile($sound->{goodbye}); - &leave($cardinfo); - } + } + elsif ( $cardinfo->{validfordays} > 0 ) { + my $now = $astpp_db->selectall_arrayref("SELECT NOW() + 0")->[0][0]; + $cardinfo->{expiry} = $astpp_db->selectall_arrayref( + "SELECT DATE_FORMAT('$cardinfo->{expiry}' , '\%Y\%m\%d\%H\%i\%s')") + ->[0][0]; + if ( $now >= $cardinfo->{expiry} ) { + my $sql = "UPDATE callingcards SET status = 2 WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( + debug => $sql, + verbosity => $verbosity + ); + $astpp_db->do($sql); + $sql = "DELETE FROM ani_map WHERE account = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( + debug => $sql, + verbosity => $verbosity + ); + $astpp_db->do($sql); + $session->streamFile( $sound->{card_has_expired} ); + $session->streamFile( $sound->{goodbye} ); + &leave($cardinfo); } - $ASTPP->debug( debug => "Present Time: $now", - verbosity => $verbosity ); - $ASTPP->debug( debug => "Expiration Date: $cardinfo->{expiry}", - verbosity => $verbosity ); - $ASTPP->debug( debug => "Valid for Days: $cardinfo->{validfordays}", - verbosity => $verbosity ); - $ASTPP->debug( debug => "First Use: $cardinfo->{firstused}", - verbosity => $verbosity ); + } + $ASTPP->debug( + debug => "Present Time: $now", + verbosity => $verbosity + ); + $ASTPP->debug( + debug => "Expiration Date: $cardinfo->{expiry}", + verbosity => $verbosity + ); + $ASTPP->debug( + debug => "Valid for Days: $cardinfo->{validfordays}", + verbosity => $verbosity + ); + $ASTPP->debug( + debug => "First Use: $cardinfo->{firstused}", + verbosity => $verbosity + ); } -sub tell_cost() { #Say how much the call will cost. - my ( $numberinfo, $pricelistinfo, $cardinfo ) = @_; - if ( $pricelistinfo->{markup} ne "" && $pricelistinfo->{markup} != 0 ) { - $ASTPP->debug( debug => "Adding Markup of $pricelistinfo->{markup}", - verbosity => $verbosity); - $numberinfo->{connectcost} = - $numberinfo->{connectcost} * - ( ( $pricelistinfo->{markup} / 10000 ) + 1 ); - $numberinfo->{cost} = - $numberinfo->{cost} * ( ( $pricelistinfo->{markup} / 10000 ) + 1 ); - } - if ($config->{calling_cards_rate_announce} == 1) { +sub tell_cost() { #Say how much the call will cost. + my ( $numberinfo, $pricelistinfo, $cardinfo ) = @_; + if ( $pricelistinfo->{markup} ne "" && $pricelistinfo->{markup} != 0 ) { + $ASTPP->debug( + debug => "Adding Markup of $pricelistinfo->{markup}", + verbosity => $verbosity + ); + $numberinfo->{connectcost} = + $numberinfo->{connectcost} * + ( ( $pricelistinfo->{markup} / 10000 ) + 1 ); + $numberinfo->{cost} = + $numberinfo->{cost} * ( ( $pricelistinfo->{markup} / 10000 ) + 1 ); + } + if ( $config->{calling_cards_rate_announce} == 1 ) { if ( $numberinfo->{cost} > 0 ) { - $session->streamFile($sound->{call_will_cost}); - $session->execute("phrase","spell," . ceil($numberinfo->{cost}/100)); - $session->streamFile($sound->{currency}); - my @call_cost = split(/\./, ($numberinfo->{cost} / 100)); - $session->execute("phrase","spell," . @call_cost[0]); - if (@call_cost[1]) { - $session->streamFile($sound->{point}); - $session->execute("phrase","spell," . @call_cost[1]); - $session->streamFile($sound->{sub_currency}); - } - $session->streamFile($sound->{per}); - $session->streamFile($sound->{minute}); + $session->streamFile( $sound->{call_will_cost} ); + $session->execute( "phrase", + "spell," . ceil( $numberinfo->{cost} / 100 ) ); + $session->streamFile( $sound->{currency} ); + my @call_cost = split( /\./, ( $numberinfo->{cost} / 100 ) ); + $session->execute( "phrase", "spell," . @call_cost[0] ); + if ( @call_cost[1] ) { + $session->streamFile( $sound->{point} ); + $session->execute( "phrase", "spell," . @call_cost[1] ); + $session->streamFile( $sound->{sub_currency} ); + } + $session->streamFile( $sound->{per} ); + $session->streamFile( $sound->{minute} ); } if ( $numberinfo->{connectcost} > 0 ) { - $session->streamFile($sound->{a_connect_charge}); - $session->execute("phrase","spell," . ceil($numberinfo->{connectcost}/100)); - $session->streamFile($sound->{sub_currency}); - $session->streamFile($sound->{will_apply}); + $session->streamFile( $sound->{a_connect_charge} ); + $session->execute( "phrase", + "spell," . ceil( $numberinfo->{connectcost} / 100 ) ); + $session->streamFile( $sound->{sub_currency} ); + $session->streamFile( $sound->{will_apply} ); } - } + } } -sub timelimit() { #Calculate and say the time limit. - my ( $numberinfo, $pricelistinfo, $cardinfo, $phoneno ) = @_; - my ( $connectfee, $cost, $timelimit, $available, $maxtime, $balance ); - # Timelimit is in seconds - if ($cc == 0) { +sub timelimit() { #Calculate and say the time limit. + my ( $numberinfo, $pricelistinfo, $cardinfo, $phoneno ) = @_; + my ( $connectfee, $cost, $timelimit, $available, $maxtime, $balance ); + + # Timelimit is in seconds + if ( $cc == 0 ) { $available = - ( $cardinfo->{value} - $cardinfo->{used} ) - $numberinfo->{connectfee}; - $ASTPP->debug( debug => "FUNDS AVAILABLE: $available", - verbosity => $verbosity); - } elsif ( $cc == 1 ) { - $balance = &accountbalance( $astpp_db, $cardinfo->{number} ); - $balance = ($balance * -1) + ( $cardinfo->{credit_limit}); - $available = ($balance - $numberinfo->{connectfee}) / 100; - } - if ( $available > 0 && $numberinfo->{cost} > 0 ) { - $timelimit = ( ( $available / $numberinfo->{cost} ) * 60 ); - } - elsif ( $available >= 0 && $numberinfo->{cost} <= 0 ) { - $timelimit = $config->{callingcards_max_length}; - } - if ( $timelimit > $config->{callingcards_max_length} ) { - $timelimit = $config->{callingcards_max_length}; - } - $ASTPP->debug( debug => "TIMELIMIT: $timelimit", - verbosity => $verbosity); - if ($brandinfo->{reseller} ne "") { - ASTPP->debug( debug => "THIS BRAND BELONGS TO $brandinfo->{reseller}!", - verbosity => $verbosity); - my $carddata = &get_account( $astpp_db, $brandinfo->{reseller} ); + ( $cardinfo->{value} - $cardinfo->{used} ) - + $numberinfo->{connectfee}; + $ASTPP->debug( + debug => "FUNDS AVAILABLE: $available", + verbosity => $verbosity + ); + } + elsif ( $cc == 1 ) { + $balance = &accountbalance( $astpp_db, $cardinfo->{number} ); + $balance = ( $balance * -1 ) + ( $cardinfo->{credit_limit} ); + $available = ( $balance - $numberinfo->{connectfee} ) / 100; + } + if ( $available > 0 && $numberinfo->{cost} > 0 ) { + $timelimit = ( ( $available / $numberinfo->{cost} ) * 60 ); + } + elsif ( $available >= 0 && $numberinfo->{cost} <= 0 ) { + $timelimit = $config->{callingcards_max_length}; + } + if ( $timelimit > $config->{callingcards_max_length} ) { + $timelimit = $config->{callingcards_max_length}; + } + $ASTPP->debug( + debug => "TIMELIMIT: $timelimit", + verbosity => $verbosity + ); + if ( $brandinfo->{reseller} ne "" ) { + ASTPP->debug( + debug => "THIS BRAND BELONGS TO $brandinfo->{reseller}!", + verbosity => $verbosity + ); + my $carddata = &get_account( $astpp_db, $brandinfo->{reseller} ); + # ($callstatus, $maxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); # my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist},$carddata ); - my $minimumcharge = $numberinfo->{cost}; - my $belongs_to_reseller = 1; - while ( $belongs_to_reseller == 1 ) { - $ASTPP->debug( debug => "FINDING LIMIT FOR: $carddata->{reseller}", - verbosity => $verbosity); - push @resellerlist, $carddata->{number}; - $ASTPP->debug( debug => "PUSHING $carddata->{number} ONTO THE LIST OF RESELLERS", - verbosity => $verbosity); - my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); - my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist}, $carddata, "CC" ); - if ($resellercallstatus != 1) { - $carddata->{reseller} = ""; - $timelimit = 0; - } elsif ($resellermaxlength < $timelimit / 60) { - $timelimit = $resellermaxlength * 60; - } - if ($resellermaxlength < 1 || $routeinfo->{cost} > $minimumcharge ) { - $carddata->{reseller} = ""; - $timelimit = 0; - } - $ASTPP->debug( debug => "RESELLER Max Length: $resellermaxlength", - verbosity => $verbosity); - $ASTPP->debug( debug => "RESELLER Call Status: $resellercallstatus", - verbosity => $verbosity); - if ($carddata->{reseller} && $carddata->{reseller} ne "") { - $carddata = &get_account( $astpp_db, $carddata->{reseller} ); - } else { - $belongs_to_reseller = 0; - } - } - } else { - $ASTPP->debug( debug => "THIS BRAND DOES NOT BELONG TO A RESELLER!", - verbosity => $verbosity); + my $minimumcharge = $numberinfo->{cost}; + my $belongs_to_reseller = 1; + while ( $belongs_to_reseller == 1 ) { + $ASTPP->debug( + debug => "FINDING LIMIT FOR: $carddata->{reseller}", + verbosity => $verbosity + ); + push @resellerlist, $carddata->{number}; + $ASTPP->debug( + debug => + "PUSHING $carddata->{number} ONTO THE LIST OF RESELLERS", + verbosity => $verbosity + ); + my ( $resellercallstatus, $resellermaxlength ) = + &max_length( $astpp_db, $config, $carddata, $phoneno ); + my $routeinfo = + &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist}, + $carddata, "CC" ); + if ( $resellercallstatus != 1 ) { + $carddata->{reseller} = ""; + $timelimit = 0; + } + elsif ( $resellermaxlength < $timelimit / 60 ) { + $timelimit = $resellermaxlength * 60; + } + if ( $resellermaxlength < 1 || $routeinfo->{cost} > $minimumcharge ) + { + $carddata->{reseller} = ""; + $timelimit = 0; + } + $ASTPP->debug( + debug => "RESELLER Max Length: $resellermaxlength", + verbosity => $verbosity + ); + $ASTPP->debug( + debug => "RESELLER Call Status: $resellercallstatus", + verbosity => $verbosity + ); + if ( $carddata->{reseller} && $carddata->{reseller} ne "" ) { + $carddata = &get_account( $astpp_db, $carddata->{reseller} ); + } + else { + $belongs_to_reseller = 0; + } } - $ASTPP->debug( debug =>"TIMELIMIT: $timelimit", verbosity => $verbosity); + } + else { + $ASTPP->debug( + debug => "THIS BRAND DOES NOT BELONG TO A RESELLER!", + verbosity => $verbosity + ); + } + $ASTPP->debug( debug => "TIMELIMIT: $timelimit", verbosity => $verbosity ); + my $minutes = $timelimit / 60; + $ASTPP->debug( debug => "MINUTES: $minutes", verbosity => $verbosity ); + if ( $minutes > 0 && $config->{calling_cards_timelimit_announce} == 1 ) { my $minutes = $timelimit / 60; - $ASTPP->debug( debug => "MINUTES: $minutes", verbosity => $verbosity); - if ($minutes > 0 && $config->{calling_cards_timelimit_announce} == 1) { - my $minutes = $timelimit / 60; - $minutes = sprintf( "%.0f", $minutes ); - $session->streamFile($sound->{call_will_last}); - if ( $minutes == 1 ) { - $session->execute("phrase","spell," . $minutes); - $session->streamFile($sound->{minute}); - } - elsif ( $minutes > 1 ) { - $session->execute("phrase","spell," . $minutes); - $session->streamFile($sound->{minutes}); - } + $minutes = sprintf( "%.0f", $minutes ); + $session->streamFile( $sound->{call_will_last} ); + if ( $minutes == 1 ) { + $session->execute( "phrase", "spell," . $minutes ); + $session->streamFile( $sound->{minute} ); } - elsif ($minutes < 1) { - $session->streamFile($sound->{not_enough_credit}); - $session->streamFile($sound->{goodbye}); - &leave($cardinfo); + elsif ( $minutes > 1 ) { + $session->execute( "phrase", "spell," . $minutes ); + $session->streamFile( $sound->{minutes} ); } - $ASTPP->debug( debug => "Available: $available", - verbosity => $verbosity ); - $ASTPP->debug( debug => "Balance: $balance", verbosity => $verbosity ); - $ASTPP->debug( debug => "Max Time: $maxtime", verbosity => $verbosity ); - return $timelimit; + } + elsif ( $minutes < 1 ) { + $session->streamFile( $sound->{not_enough_credit} ); + $session->streamFile( $sound->{goodbye} ); + &leave($cardinfo); + } + $ASTPP->debug( + debug => "Available: $available", + verbosity => $verbosity + ); + $ASTPP->debug( debug => "Balance: $balance", verbosity => $verbosity ); + $ASTPP->debug( debug => "Max Time: $maxtime", verbosity => $verbosity ); + return $timelimit; } -sub say_balance() { #Calculate and say the card balance. - my ($cardinfo) = @_; - my ( $connectfee, $cost, $included, $sub_balance, $balance, $main_balance ); - if ($cc == 0 ) { +sub say_balance() { #Calculate and say the card balance. + my ($cardinfo) = @_; + my ( $connectfee, $cost, $included, $sub_balance, $balance, $main_balance ); + if ( $cc == 0 ) { $balance = $cardinfo->{value} - $cardinfo->{used}; - } elsif ($cc ==1) { + } + elsif ( $cc == 1 ) { $balance = &accountbalance( $astpp_db, $cardinfo->{number} ); - $balance = ($balance * -1) + ( $cardinfo->{credit_limit} ); + $balance = ( $balance * -1 ) + ( $cardinfo->{credit_limit} ); + } + if ( $balance > 0 ) { + $balance = $balance / 10000; + $balance = sprintf( "%.2f", $balance ); + $sub_balance = substr( $balance, -2, 2 ); + $main_balance = substr( $balance, 0, -2 ); + $session->streamFile( $sound->{card_has_balance_of} ); + if ( $main_balance == 1 ) { + $session->execute( "phrase", "spell," . $main_balance ); + $session->streamFile( $sound->{main_currency} ); } - if ( $balance > 0 ) { - $balance = $balance / 10000; - $balance = sprintf( "%.2f", $balance ); - $sub_balance = substr( $balance, -2, 2 ); - $main_balance = substr( $balance, 0, -2 ); - my $interrupt = $session->playAndGetDigits(1,1,1,0,"#*","$sound->{card_has_balance_of}","$sound->{card_has_balance_of}",'^[0-9]+$'); - if (!$interrupt || $interrupt eq "" || $interrupt == 0) { - if ( $main_balance == 1 ) { -$session->execute("phrase","spell," . $main_balance); - $session->streamFile($sound->{main_currency}); - } - elsif ( $main_balance > 1 ) { -$session->execute("phrase","spell," . $main_balance); - $session->streamFile($sound->{main_currency_plural}); - } - if ( $sub_balance == 1 ) { -$session->execute("phrase","spell," . $sub_balance); - $session->streamFile($sound->{sub_currency}); - } - elsif ( $sub_balance > 1 ) { -$session->execute("phrase","spell," . $sub_balance); - $session->streamFile($sound->{sub_currency_plural}); - } - } + elsif ( $main_balance > 1 ) { + $session->execute( "phrase", "spell," . $main_balance ); + $session->streamFile( $sound->{main_currency_plural} ); } - else { - $session->streamFile($sound->{card_is_empty}); - $session->streamFile($sound->{goodbye}); - &leave($cardinfo); + if ( $sub_balance == 1 ) { + $session->execute( "phrase", "spell," . $sub_balance ); + $session->streamFile( $sound->{sub_currency} ); } - return $balance; + elsif ( $sub_balance > 1 ) { + $session->execute( "phrase", "spell," . $sub_balance ); + $session->streamFile( $sound->{sub_currency_plural} ); + } + } + else { + $session->streamFile( $sound->{card_is_empty} ); + $session->streamFile( $sound->{goodbye} ); + &leave($cardinfo); + } + return $balance; } -sub update_balance() { #Update the available credit on the calling card. - my ( $cardinfo, $charge ) = @_; - my $sql = - "UPDATE callingcards SET used = " - . $astpp_db->quote( ($charge) + $cardinfo->{used} ) - . " WHERE cardnumber = " - . $astpp_db->quote( $cardinfo->{cardnumber} ); - $astpp_db->do($sql); +sub update_balance() { #Update the available credit on the calling card. + my ( $cardinfo, $charge ) = @_; + my $sql = + "UPDATE callingcards SET used = " + . $astpp_db->quote( ($charge) + $cardinfo->{used} ) + . " WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $astpp_db->do($sql); } -sub write_asterisk_cdr() { #Write the cdr record to the asterisk cdr db. This is done so we get a record of the call the callingcard user placed. - # This is especially important for resellers and calling cards. - my ( - $reseller, $clid, $destination, $status, - $callstart, $answeredtime, $dstchannel, $lastapp, $dialedtime, $uniqueid, $asterisk_time, $cdr_db - ) - = @_; - my ($sql); - if (!$status) {$status = gettext("N/A"); } - $sql = "INSERT INTO cdr (calldate,dst,clid,dstchannel,lastapp,duration,billsec,disposition,accountcode,uniqueid) VALUES(" - . $astpp_db->quote($asterisk_time) . ", " - . $astpp_db->quote($destination) . ", " - . $astpp_db->quote($clid) . ", " - . $astpp_db->quote($dstchannel) . ", " - . $astpp_db->quote($lastapp) . ", " - . $astpp_db->quote($dialedtime) . ", " - . $astpp_db->quote($answeredtime) . ", " - . $astpp_db->quote($status) . ", " - . $astpp_db->quote( $reseller ) . ", " - . $astpp_db->quote( $uniqueid ) . ")"; - $cdr_db->do($sql); - $session->execute("set", "ANSWEREDTIME=0" ); - $session->execute("set", "DIALEDTIME=0" ); - $session->execute("set", "DIALSTATUS=NO ANSWER" ); -} -sub write_cdr() { # Write the callingcardcdr record if this is a calling card. - my ( - $cardinfo, $clid, $destination, $status, - $callstart, $charge, $answeredtime - ) - = @_; - my ($sql); - if (!$status) {$status = gettext("N/A"); } - $sql = -"INSERT INTO callingcardcdrs (cardnumber,clid,destination,disposition,callstart,seconds," - . "debit) VALUES (" - . $astpp_db->quote( $cardinfo->{cardnumber} ) . ", " - . $astpp_db->quote($clid) . ", " - . $astpp_db->quote($destination) . ", " - . $astpp_db->quote($status) . ", " - . $astpp_db->quote($callstart) . ", " - . $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 ); - $session->execute("set", "ANSWEREDTIME=0" ); - $session->execute("set", "DIALEDTIME=0" ); - $session->execute("set", "DIALSTATUS=NO ANSWER" ); +sub dialout() { # Rig up the LCR stuff and do the outbound dialing. + # If a call does not go through we give the user the option + # of trying again. + my ( + $destination, $timelimit, $numberinfo, + $pricelistinfo, $cardinfo, $brandinfo + ) = @_; + my ( $status, $count, $increment ); + $ASTPP->debug( + debug => "Looking for outbound Route", + verbosity => $verbosity + ); + my @outboundroutes = + &get_outbound_routes( $astpp_db, $destination, $cardinfo, $numberinfo, + @resellerlist ); + $count = @outboundroutes; + if ( $count == 0 ) { + $ASTPP->debug( + debug => "NO OUTBOUND ROUTES FOUND!", + verbosity => $verbosity + ); + my $order = + $session->playAndGetDigits( 1, 1, 1, + $config->{calling_cards_general_input_timeout}, + "#*", "$sound->{noanswer}", "", '^[0-9]+$' ); + if ( $order != 1 ) { + &leave($cardinfo); + } + } + $count = 0; + foreach my $route (@outboundroutes) { + my $callstart = localtime(); + my ($accountcode); + $callstart = &prettytimestamp if $cc == 1; + $session->execute( "sched_hangup", "+" . $timelimit * 60 ); + my ( $xml_string, $data_string ) = $ASTPP->fs_dialplan_xml_bridge( + destination_number => $destination, + route_prepend => $route->{prepend}, + trunk_name => $route->{trunk} + ); + my ( $dialedtime, $uniqueid, $answeredtime, $clid ); + $session->execute( "export", "CALLINGCARDS=1" ); + if ( $cc == 1 ) { + $session->execute( "export", "ACCOUNTCODE=CC:$cardinfo->{number}" ); + } + else { + $session->execute( "export", + "ACCOUNTCODE=CC:$cardinfo->{cardnumber}" ); + } + $session->execute( "bridge", "$data_string" ); + return 1; + } } -sub dialout() { # Rig up the LCR stuff and do the outbound dialing. - # If a call does not go through we give the user the option - # of trying again. - my ( $destination, $timelimit, $numberinfo, $pricelistinfo, $cardinfo, $brandinfo ) = - @_; - my ( $status, $count, $increment ); - $ASTPP->debug( debug => "Looking for outbound Route", verbosity => $verbosity ); - my @outboundroutes = &get_outbound_routes( $astpp_db, $destination,$cardinfo,$numberinfo, @resellerlist ); - $count = @outboundroutes; - if ( $count == 0 ) { - $ASTPP->debug(debug => "NO OUTBOUND ROUTES FOUND!", verbosity => $verbosity ); - my $order = $session->playAndGetDigits(1,1,1,$config->{calling_cards_general_input_timeout},"#*","$sound->{noanswer}","$sound->{noanswer}",'^[0-9]+$'); - if ( $order != 1 ) { - &write_cdr( $cardinfo, "", $destination, gettext("NO Route Found"), "", 0, 0 ); - &leave($cardinfo); - } - } - $count = 0; - foreach my $route (@outboundroutes) { - my $callstart = localtime(); - my ($accountcode); - $callstart = &prettytimestamp if $cc == 1; - $session->execute("sched_hangup","+" . $timelimit/1000*60); - my ($xml_string,$data_string) = $ASTPP->fs_dialplan_xml_bridge( - destination_number => $destination, - route_prepend => $route->{prepend}, - trunk_name => $route->{trunk} - ); - my ($dialedtime,$uniqueid,$answeredtime,$clid); - my $vars = $session->execute("bridge","$data_string"); - - $ASTPP->debug( debug => "Vars: " . $vars); -# return 1 if (! $session->ready()); -# $VARS{destination_number} = $num_dial; -# UPDATEV(); -# return 1; - my $asterisk_time = &prettytimestamp; - $ASTPP->debug( debug => "CALL STATUS $status", verbosity => 1); - $ASTPP->debug( debug => "ANSWERED TIME $answeredtime", verbosity => $verbosity); - $ASTPP->debug( debug => "Account CC?: $cc", verbosity => $verbosity); - - if ( ( $status != ~/CHANUNAVAIL/ ) && ( $status != ~/CONGESTION/ ) ) { - if ( $status =~ /BUSY/ ) { - $ASTPP->debug( debug => "CALL BUSY", verbosity => $verbosity ); - my $order = $session->playAndGetDigits(1,1,1,$config->{calling_cards_general_input_timeout},"#*","$sound->{busy}","$sound->{busy}",'^[0-9]+$'); - if ( $order != 1 ) { - &write_cdr( $cardinfo, $clid, $destination, $status, - $callstart, 0, 0, $uniqueid ) - if $cc == 0; - &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, - $destination, $callstart, 0, $uniqueid, $clid ) - if $cc == 1; - &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); - &leave($cardinfo); - } else { - push @outboundroutes, $route; - } - } - elsif ( $status =~ /NOANSWER/ ) { - $ASTPP->debug(debug=> "NO ANSWER", verbosity => $verbosity ); - my $order = $session->playAndGetDigits(1,1,1,$config->{calling_cards_general_input_timeout},"#*","$sound->{noanswer}","$sound->{noanswer}",'^[0-9]+$'); - if ( $order != 1 ) { - &write_cdr( $cardinfo, $clid, $destination, $status, - $callstart, 0, 0, $uniqueid ) - if $cc == 0; - &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, - $destination, $callstart, 0, $uniqueid, $clid ) - if $cc == 1; - &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); - &leave($cardinfo); - } else { - push @outboundroutes, $route; - } - } - elsif ( $status =~ /ANSWER/ || $answeredtime > 0) { - $ASTPP->debug( debug => "CALL ANSWERED", verbosity => $verbosity ); - my $increment; - if ( $numberinfo->{inc} > 0 ) { - $increment = $numberinfo->{inc}; - } - else { - $increment = $pricelistinfo->{inc}; - } - $ASTPP->debug( debug => "$numberinfo->{connectcost}, $numberinfo->{cost}, $answeredtime, $increment, $numberinfo->{includedseconds}", - verbosity => $verbosity); - my $charge = &calc_call_cost( - $numberinfo->{connectcost}, $numberinfo->{cost}, - $answeredtime, $increment, - $numberinfo->{includedseconds} - ); - $ASTPP->debug( debug => "Cost $charge ", verbosity => $verbosity ); - if ($cardinfo->{minute_fee_pennies} > 0) { - $charge = (($cardinfo->{minute_fee_pennies} * 100) + $charge) if $cardinfo->{timeused} + $answeredtime => $cardinfo->{minute_fee_minutes}; - } - if ($cardinfo->{min_length_pennies} > 0 && ($cardinfo->{min_length_minutes}*60) > $answeredtime) { - $charge = (($cardinfo->{min_length_pennies} * 100) + $charge); - } - if ( $cc == 0 ) { - &write_cdr( - $cardinfo, $clid, $destination, $status, - $callstart, $charge, $answeredtime, $uniqueid - ); - &write_asterisk_cdr( $accountcode, $clid, $destination, "ANSWERED", - $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); - &update_balance( $cardinfo, $charge ); - $astpp_db->do("UPDATE callingcards SET timeused = " - . $astpp_db->quote($cardinfo->{timeused} + $answeredtime) - . " WHERE cardnumber = " - . $astpp_db->quote($cardinfo->{cardnumber})); - } - elsif ( $cc == 1 ) { - my $status = - &write_account_cdr( $astpp_db, $cardinfo->{number}, - $charge, $destination, $callstart, $answeredtime, $uniqueid, $clid ); - &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); - $ASTPP->debug( debug => $status, verbosity => $verbosity ); - } - $session->streamFile($sound->{call_completed}); - &leave($cardinfo); - } - elsif ( $status =~ /CANCEL/ ) { - $ASTPP->debug( debug => "CALL CANCELLED", verbosity => $verbosity ); - $session->streamFile($sound->{cancelled}) if $config->{calling_cards_cancelled_prompt} == 1; - &write_cdr( $cardinfo, $clid, $destination, $status, $callstart, 0, - 0, $uniqueid ) - if $cc == 0; - &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, - $destination, $callstart, 0, $uniqueid, $clid ) - if $cc == 1; - &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); - &leave($cardinfo); - } - else { - $ASTPP->debug( debug => "ERROR - ERROR - ERROR", verbosity => $verbosity ); - my $order = $session->playAndGetDigits(1,1,1,$config->{calling_cards_general_input_timeout},"#*","$sound->{noanswer}","$sound->{noanswer}",'^[0-9]+$'); - if ( $order != 1 ) { - &write_cdr( $cardinfo, $clid, $destination, $status, - $callstart, 0, 0, $uniqueid ) - if $cc == 0; - &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, - $destination, $callstart, 0, $uniqueid, $clid ) - if $cc == 1; - &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); - &leave($cardinfo); - } - } - } - } -} - - -sub leave() { # Prepare everything and then leave the calling card app. - my ($cardinfo) = @_; - my ($whatnow); - my $retries = 0; - &set_in_use( $cardinfo, 0 ) if $cc == 0; - while ($retries < 3) { - $whatnow = $session->playAndGetDigits(1,1,1,$config->{calling_cards_general_input_timeout},"#*","$sound->{astpp_callingcard_menu}","$sound->{astpp_callingcard_menu}",'^[0-9]+$'); - $ASTPP->debug( debug => "WHAT NEXT = $whatnow ", verbosity => $verbosity ); - if ($cc == 1) { - $session->execute("set", "CARDNUMBER=$cardinfo->{number}" ); - } else { - $session->execute("set", "CARDNUMBER=$cardinfo->{cardnumber}" ); - } - $session->execute("set", "PIN=$cardinfo->{pin}" ); - if ( $whatnow == 1 ) { - $session->execute("set", "NEWCALL=1" ); - $session->execute("set", "DESTINATION=$stats{destination}" ); - &exit_program(); - } - elsif ( $whatnow == 2 ) { - $session->execute("set", "NEWCALL=1" ); - $session->execute("set", "DESTINATION=" ); - &exit_program(); - } - elsif ( $whatnow == 3 ) { - $session->streamFile($sound->{goodbye}); - $session->hangup; - } else { - $retries++; - } +sub leave() { # Prepare everything and then leave the calling card app. + my ($cardinfo) = @_; + my ($whatnow); + my $retries = 0; + &set_in_use( $cardinfo, 0 ) if $cc == 0; + while ( $retries < 3 ) { + $whatnow = $session->playAndGetDigits( + 1, + 1, + 1, + $config->{calling_cards_general_input_timeout}, + "#*", + "$sound->{astpp_callingcard_menu}", + "", + '^[0-9]+$' + ); + $ASTPP->debug( + debug => "WHAT NEXT = $whatnow ", + verbosity => $verbosity + ); + if ( $cc == 1 ) { + $session->execute( "export", "CARDNUMBER=$cardinfo->{number}" ); } - if ($retries == 3) { - $session->streamFile($sound->{goodbye}); - $session->hangup; + else { + $session->execute( "export", "CARDNUMBER=$cardinfo->{cardnumber}" ); } + $session->execute( "export", "PIN=$cardinfo->{pin}" ); + if ( $whatnow == 1 ) { + $session->execute( "export", "NEWCALL=1" ); + $session->execute( "export", "DESTINATION=$stats{destination}" ); + &exit_program(); + } + elsif ( $whatnow == 2 ) { + $session->execute( "export", "NEWCALL=1" ); + $session->execute( "export", "DESTINATION=" ); + &exit_program(); + } + elsif ( $whatnow == 3 ) { + $session->streamFile( $sound->{goodbye} ); + } + else { + $retries++; + } + } + if ( $retries == 3 ) { + $session->streamFile( $sound->{goodbye} ); + } } sub exit_program() { - $stats{total_time} = tv_interval ($stats{start_time}); - $astpp_db->do("INSERT INTO callingcard_stats(uniqueid,total_time,billable_time) VALUES (" - . $astpp_db->quote($stats{uniqueid}) . "," - . $astpp_db->quote($stats{total_time}) . "," - . $astpp_db->quote($stats{answered_time}) . ")"); - $stats{total_time} = tv_interval ($stats{start_time}); - exit(0); + $stats{total_time} = tv_interval( $stats{start_time} ); + $astpp_db->do( +"INSERT INTO callingcard_stats(uniqueid,total_time,billable_time) VALUES (" + . $astpp_db->quote( $stats{uniqueid} ) . "," + . $astpp_db->quote( $stats{total_time} ) . "," + . $astpp_db->quote( $stats{answered_time} ) + . ")" ); + $stats{total_time} = tv_interval( $stats{start_time} ); + exit(1); } -sub print_console() #Dump string to the console +sub print_console() #Dump string to the console { - my ($output) = @_; - freeswitch::consoleLog("ASTPP",$output . "\n"); + my ($output) = @_; + freeswitch::consoleLog( "ASTPP", $output . "\n" ); } -sub say() -{ - my($phrase,$say) = @_; - $session->execute("phrase", $phrase ."," . $say ); +sub say() { + my ( $phrase, $say ) = @_; + $session->execute( "phrase", $phrase . "," . $say ); } - - ################# Program Starts Here ################################# -my ( $cardnum, $pin, $destination, $connectsurcharge, $perminsurcharge, $brand ) = - @ARGV; +my ( $cardnum, $pin, $destination, $connectsurcharge, $perminsurcharge, $brand ) + = @ARGV; my ( $retries, $cardinfo, $numberinfo, $pricelistinfo, @outboundroutes, - $callstart ); + $callstart ); $session->answer(); &initialize; -return 1 if (! $session->ready()); +my $vars = $session->getVariable("answered_time"); +$vars .= " : "; +$vars .= $session->getVariable("hangup_time"); +$ASTPP->debug( debug => "Vars: " . $vars ); +return 1 if ( !$session->ready() ); -if ($cardnum && $cardnum ne "") { - $ASTPP->debug( debug => "We recieved a cardnumber from the dialplan",verbosity => $verbosity); - $cardinfo = &get_callingcard( $astpp_db, $cardnum, $config ); - if ( !$cardinfo ) { - $cardinfo = &get_account_cc( $astpp_db, $cardnum ); - $cc = 1 if $cardinfo; - } -} else { #We won't play the welcome file when we already have card numbers. - $session->streamFile($config->{calling_cards_welcome_file}); +if ( $cardnum && $cardnum ne "" ) { + $ASTPP->debug( + debug => "We recieved a cardnumber from the dialplan", + verbosity => $verbosity + ); + $cardinfo = &get_callingcard( $astpp_db, $cardnum, $config ); + if ( !$cardinfo ) { + $cardinfo = &get_account_cc( $astpp_db, $cardnum ); + $cc = 1 if $cardinfo; + } } +else { #We won't play the welcome file when we already have card numbers. + $session->streamFile( $config->{calling_cards_welcome_file} ); +} + # If $cc == 1 means that we are using an ASTPP account instead of an actual # calling card. -if ( $cardinfo->{status} != 1 || !$cardinfo->{status}) { - $retries = 0; - while ( $cardinfo->{status} != 1 && $retries < $config->{card_retries} ) { - $cardnum = $session->playAndGetDigits($config->{cardlength},$config->{cardlength},1,$config->{calling_cards_number_input_timeout},"#","$sound->{cardnumber}","$sound->{cardnumber}",'^[0-9]+$'); - $cardinfo = &get_callingcard( $astpp_db, $cardnum, $config ); - if ( !$cardinfo ) { - $cardinfo = &get_account_cc( $astpp_db, $cardnum ); - $cc = 1 if $cardinfo; - } - $ASTPP->debug(debug => "CARD BRAND: $cardinfo->{brand} SPECIFIED BRAND: $brand", verbosity => $verbosity); - if ($brand && $brand ne "") { - $cardinfo = "" if $cardinfo->{brand} ne $brand; - } - $ASTPP->debug( debug => "ASTPP Number: $cardnum ", verbosity => $verbosity ); - $ASTPP->debug( debug => "ASTPP Number Status: $cardinfo->{status}", verbosity => $verbosity ); - if ( $cardinfo->{status} != 1 ) { - $session->streamFile($sound->{cardnumber_incorrect}); - } - $retries++; +if ( $cardinfo->{status} != 1 || !$cardinfo->{status} ) { + $retries = 0; + while ( $cardinfo->{status} != 1 && $retries < $config->{card_retries} ) { + $cardnum = $session->playAndGetDigits( + $config->{cardlength}, + $config->{cardlength}, + 1, + $config->{calling_cards_number_input_timeout}, + "#", + "$sound->{cardnumber}", + "", + '^[0-9]+$' + ); + $cardinfo = &get_callingcard( $astpp_db, $cardnum, $config ); + if ( !$cardinfo ) { + $cardinfo = &get_account_cc( $astpp_db, $cardnum ); + $cc = 1 if $cardinfo; } + $ASTPP->debug( + debug => "CARD BRAND: $cardinfo->{brand} SPECIFIED BRAND: $brand", + verbosity => $verbosity + ); + if ( $brand && $brand ne "" ) { + $cardinfo = "" if $cardinfo->{brand} ne $brand; + } + $ASTPP->debug( + debug => "ASTPP Number: $cardnum ", + verbosity => $verbosity + ); + $ASTPP->debug( + debug => "ASTPP Number Status: $cardinfo->{status}", + verbosity => $verbosity + ); if ( $cardinfo->{status} != 1 ) { - $session->streamFile($sound->{goodbye}); - exit(1); + $session->streamFile( $sound->{cardnumber_incorrect} ); } + $retries++; + } + if ( $cardinfo->{status} != 1 ) { + $session->streamFile( $sound->{goodbye} ); + $session->hangup(); + exit(1); + } } if ( $pin != $cardinfo->{pin} ) { - $retries = 0; - while ( $cardinfo->{pin} != $pin && $retries < $config->{pin_retries} ) { - $pin = $session->playAndGetDigits($config->{pinlength},$config->{pinlength},1,$config->{calling_cards_pin_input_timeout},"#","$sound->{pin}","$sound->{pin}",'^[0-9]+$'); - if ( $cardinfo->{pin} != $pin ) { - $session->streamFile($sound->{pin_incorrect}); - } - $retries++; + $retries = 0; + while ( $cardinfo->{pin} != $pin && $retries < $config->{pin_retries} ) { + $pin = $session->playAndGetDigits( + $config->{pinlength}, $config->{pinlength}, + 1, $config->{calling_cards_pin_input_timeout}, + "#", "$sound->{pin}", + "", '^[0-9]+$' + ); + if ( $cardinfo->{pin} != $pin ) { + $session->streamFile( $sound->{pin_incorrect} ); } - if ( $pin != $cardinfo->{pin} ) { - $session->streamFile($sound->{pin_incorrect}); - $session->streamFile($sound->{goodbye}); - exit(0); - } + $retries++; + } + if ( $pin != $cardinfo->{pin} ) { + $session->streamFile( $sound->{pin_incorrect} ); + $session->streamFile( $sound->{goodbye} ); + exit(0); + } } &check_card($cardinfo) if $cc == 0; my $balance = &say_balance($cardinfo); # Getting this far means we have a valid card and pin. $brandinfo = &get_cc_brand( $astpp_db, $cardinfo->{brand} ) if $cc == 0; -if ($brandinfo->{reseller}) { - $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); +if ( $brandinfo->{reseller} ) { + $config = + &load_config_db_reseller( $astpp_db, $config, $brandinfo->{reseller} ); } -$config = &load_config_db_brand($astpp_db,$config,$cardinfo->{brand}); +$config = &load_config_db_brand( $astpp_db, $config, $cardinfo->{brand} ); $pricelistinfo = &get_pricelist( $astpp_db, $brandinfo->{pricelist} ) if $cc == 0; $pricelistinfo = &get_pricelist( $astpp_db, $cardinfo->{pricelist} ) if $cc == 1; -if ($destination && $destination ne "" ) { - $numberinfo = - &get_route( $astpp_db, $config, $destination, $brandinfo->{pricelist}, $cardinfo ) - if $cc == 0; - $numberinfo = - &get_route( $astpp_db, $config, $destination, $cardinfo->{pricelist}, $cardinfo ) - if $cc == 1; +if ( $destination && $destination ne "" ) { + $numberinfo = + &get_route( $astpp_db, $config, $destination, $brandinfo->{pricelist}, + $cardinfo ) + if $cc == 0; + $numberinfo = + &get_route( $astpp_db, $config, $destination, $cardinfo->{pricelist}, + $cardinfo ) + if $cc == 1; } $retries = 0; while ( !$numberinfo->{pattern} && $retries < $config->{number_retries} ) { - $destination = $session->playAndGetDigits(4,35,1,$config->{calling_cards_dial_input_timeout},"#","$sound->{destination}","$sound->{destination}",'^[0-9]+$'); - $numberinfo = - &get_route( $astpp_db, $config, $destination, $brandinfo->{pricelist}, $cardinfo ); - if ( !$numberinfo->{pattern} ) { - $session->streamFile($sound->{destination_incorrect}); - } else { - $numberinfo->{cost} = $numberinfo->{cost} + $perminsurcharge if $perminsurcharge ne ""; - $numberinfo->{connectcost} = $numberinfo->{connectcost} + $connectsurcharge if $connectsurcharge ne ""; - } - $retries++; + $destination = + $session->playAndGetDigits( 4, 35, 1, + $config->{calling_cards_dial_input_timeout}, + "#", "$sound->{destination}", "", '^[0-9]+$' ); + $numberinfo = + &get_route( $astpp_db, $config, $destination, $brandinfo->{pricelist}, + $cardinfo ); + if ( !$numberinfo->{pattern} ) { + $session->streamFile( $sound->{destination_incorrect} ); + } + else { + $numberinfo->{cost} = $numberinfo->{cost} + $perminsurcharge + if $perminsurcharge ne ""; + $numberinfo->{connectcost} = + $numberinfo->{connectcost} + $connectsurcharge + if $connectsurcharge ne ""; + } + $retries++; } if ( !$numberinfo->{pattern} ) { - $session->streamFile($sound->{destination_incorrect}); - $session->streamFile($sound->{goodbye}); - $session->hangup(); - &leave($cardinfo); + $session->streamFile( $sound->{destination_incorrect} ); + $session->streamFile( $sound->{goodbye} ); + $session->hangup(); + &leave($cardinfo); } # Congratulations, we now have a working card,pin, and phone number. $stats{destination} = $destination; -&tell_cost( $numberinfo, $pricelistinfo, $cardinfo ); -my $timelimit = &timelimit( $numberinfo, $pricelistinfo, $cardinfo, $destination ); -$session->streamFile($sound->{please_wait_will_connect}) if $config->{calling_cards_connection_prompt} == 1; -&dialout( $destination, $timelimit, $numberinfo, $pricelistinfo, $cardinfo, $brandinfo ); +&tell_cost( $numberinfo, $pricelistinfo, $cardinfo ); +my $timelimit = + &timelimit( $numberinfo, $pricelistinfo, $cardinfo, $destination ); +$session->streamFile( $sound->{please_wait_will_connect} ) + if $config->{calling_cards_connection_prompt} == 1; +&dialout( + $destination, $timelimit, $numberinfo, + $pricelistinfo, $cardinfo, $brandinfo +); 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-04-18 17:11:52
|
Revision: 2245 http://astpp.svn.sourceforge.net/astpp/?rev=2245&view=rev Author: darrenkw Date: 2009-04-18 17:11:43 +0000 (Sat, 18 Apr 2009) Log Message: ----------- Callingcards and freeswitch are now working. Modified Paths: -------------- trunk/scripts/astpp-common.pl Added Paths: ----------- trunk/freeswitch/astpp-fs-monitor.pl Added: trunk/freeswitch/astpp-fs-monitor.pl =================================================================== --- trunk/freeswitch/astpp-fs-monitor.pl (rev 0) +++ trunk/freeswitch/astpp-fs-monitor.pl 2009-04-18 17:11:43 UTC (rev 2245) @@ -0,0 +1,277 @@ +#!/usr/bin/perl +# +# ASTPP - Open Source Voip Billing +# +# Copyright (C) 2004, Aleph Communications +# Copyright (C) Freeswitch (Some of this code was borrowed from the freeswitch contrib directory +# The attribution of that needs to be cleaned up.) +# +# Darren Wiebe (da...@al...) +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2. +############################################################ +use POSIX; +use POSIX qw(strftime); +use POSIX ':signal_h'; # used for alarm to ensure we get heartbeats +use DBI; +use CGI; +use CGI qw/:standard Vars/; +use Getopt::Long; +use Locale::Country; +use Locale::gettext_pp qw(:locale_h); +use Data::Dumper; +use FreeSWITCH::Client; +use strict; +use ASTPP; +use lib './lib', '../lib'; + +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", "/var/locale" ); +textdomain("ASTPP"); +use vars qw($ASTPP $fs $config $astpp_db $osc_db $agile_db $cdr_db $cdr_table + @output @cardlist $config $params $lastheartbeat); +@output = ( "STDOUT", "LOGFILE" ); +my $verbosity = 1; +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity($verbosity) + ; #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; + $cdr_db = &cdr_connect_db( $config, @output ); + $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); + +} + +sub fs_client_connect() { + my ($config) = @_; + my ($fs); + print STDERR "Connecting to FreeSwitch\n"; + $fs = init FreeSWITCH::Client { + -password => $config->{freeswitch_password}, + -host => $config->{freeswitch_host}, + -port => $config->{ffreeswitch_port} + }; + if ($fs) { + +# channel_create doesnt have the destination number so we wait for the codec event + $fs->sendmsg( + { 'command' => 'event plain heartbeat channel_hangup codec' } ); + $lastheartbeat = time; + return $fs; + } + else { + print STDERR "Unable to connect to FreeSwitch\n"; + } +} + +############################################### +&initialize; +my $timeout = 1; + +sigaction SIGALRM, new POSIX::SigAction sub { + if ( $lastheartbeat < ( time - $config->{freeswitch_timeout} ) ) { + print "Did not receive a heartbeat in the specified timeout\n"; + $fs->disconnect(); + undef $fs; + $fs = &fs_client_connect($config); + } + + # reset the alarm + alarm $timeout; +} or die "Error setting SIGALRM handler: $!\n"; + +alarm $timeout; + +while ( 1 > 0 ) { + my ( $myhash, %uuids ); + if ( defined $fs ) { + my $reply = $fs->readhash(undef); + if ( $reply->{socketerror} ) { + $fs = &fs_client_connect($config); + } + + if ( $reply->{body} ) { + $myhash = $reply->{event}; + + if ( $myhash->{'event-name'} eq "HEARTBEAT" ) + { ## Deal with heartbeats + $lastheartbeat = time; + print "Got a heartbeat\n"; + + } + elsif ( $myhash->{'event-name'} eq "CODEC" ) { ## New call setup + if ( !$uuids{ $myhash->{'unique-id'} } ) { + print $myhash->{'unique-id'} . " has called\n"; + $uuids{ $myhash->{'unique-id'} } = time; + while ( my ( $key, $value ) = each(%$myhash) ) { + print "CODEC: " . $key . ": " . $value . "\n"; + } + } + + } + elsif ( $myhash->{'event-name'} eq "CHANNEL_HANGUP" ) + { ## hangup event + print "\n\n############################\n\n"; + print $myhash->{'unique-id'} . " has hung up\n"; + delete $uuids{ $myhash->{ + 'unique-id'} }; # we get a codec event after hangup + + while ( my ( $key, $value ) = each(%$myhash) ) { + print "HANGUP: " . $key . ": " . $value . "\n"; + } + + # if ( $myhash->{'variable_last_app'} ) { + $myhash->{'variable_last_app'} = "" + if $myhash->{'variable_last_app'} eq ""; + $myhash->{'variable_last_arg'} = "" + if $myhash->{'variable_last_arg'} eq ""; + my $tmp = +"INSERT INTO `fscdr` (`accountcode`, `src`, `dst`, `dcontext`, `clid`," + . "`channel`, `dstchannel`, `lastapp`, `lastdata`, `calldate`, `answerdate`," + . "`enddate`, `duration`, `billsec`, `disposition`, `amaflags`, `uniqueid`," + . "`userfield`, `read_codec`, `write_codec`, `cost`, `vendor`) VALUES (" + . $cdr_db->quote( $myhash->{'variable_accountcode'} ) . "," + . $cdr_db->quote( $myhash->{'caller-caller-id-number'} ) . "," + . $cdr_db->quote( $myhash->{'caller-destination-number'} ) . "," + . $cdr_db->quote( $myhash->{'caller-context'} ) . "," + . $cdr_db->quote( $myhash->{'variable_caller_id'} ) . "," + . $cdr_db->quote( $myhash->{'other-leg-channel-name'} ) . "," + . $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->{'variable_answer_stamp'} ) . "," + . $cdr_db->quote( $myhash->{'variable_end_stamp'} ) . "," + . $cdr_db->quote( $myhash->{'variable_duration'} ) . "," + . $cdr_db->quote( $myhash->{'variable_billsec'} ) . "," + . $cdr_db->quote( $myhash->{'hangup-cause'} ) . ",''," + # . $cdr_db->quote($myhash->{''}) . "," #amaflags + . $cdr_db->quote( $myhash->{'unique-id'} ) . ",''," + # . $cdr_db->quote($myhash->{''}) . "," #userfield + . $cdr_db->quote( $myhash->{'variable_read_codec'} ) . "," + . $cdr_db->quote( $myhash->{'variable_write_codec'} ) + . ",'none','none')"; + print $tmp; + $cdr_db->do($tmp); + my (@chargelist); + push @chargelist, $myhash->{'unique-id'}; + &processlist( $astpp_db, $cdr_db, $cdr_table, $config, + \@chargelist ); + # } + if ( $myhash->{'variable_callingcards'} + && $myhash->{'variable_last_app'} eq "" ) + { + my ( $cardinfo, $brandinfo, $numberinfo, $pricelistinfo,$cc ); + my $cardnumber = substr( $myhash->{'variable_accountcode'}, 3 ); + $cardinfo = &get_callingcard( $astpp_db, $cardnumber, $config ); + if ( !$cardinfo ) { + $cardinfo = &get_account_cc( $astpp_db, $cardnumber ); + $cc = 1 if $cardinfo; + } + +# Getting this far means we have a valid card and pin. +$brandinfo = &get_cc_brand( $astpp_db, $cardinfo->{brand} ) if $cc == 0; +if ($brandinfo->{reseller}) { + $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); +} +$config = &load_config_db_brand($astpp_db,$config,$cardinfo->{brand}); +$pricelistinfo = &get_pricelist( $astpp_db, $brandinfo->{pricelist} ) + if $cc == 0; +$pricelistinfo = &get_pricelist( $astpp_db, $cardinfo->{pricelist} ) + if $cc == 1; + + print STDERR "THIS IS A CALLINGCARD CALL! \n"; + print STDERR "CARD: $cardinfo->{cardnumber} \n"; + print STDERR "CARD: $cardnumber \n"; + $numberinfo = &get_route( + $astpp_db, $config, + $myhash->{'caller-destination-number'}, + $brandinfo->{pricelist}, $cardinfo + ); + if ( $myhash->{'hangup-cause'} =~ /ANSWER/ + || $myhash->{'variable_billsec'} > 0 ) + { + $ASTPP->debug( + debug => "CALL ANSWERED", + verbosity => $verbosity + ); + my $increment; + if ( $numberinfo->{inc} > 0 ) { + $increment = $numberinfo->{inc}; + } + else { + $increment = $pricelistinfo->{inc}; + } + $ASTPP->debug( + debug => +"$numberinfo->{connectcost}, $numberinfo->{cost}, $myhash->{'variable_billsec'}, $increment, $numberinfo->{includedseconds}", + verbosity => $verbosity + ); + my $charge = &calc_call_cost( + $numberinfo->{connectcost}, + $numberinfo->{cost}, + $myhash->{'variable_billsec'}, + $increment, + $numberinfo->{includedseconds} + ); + $ASTPP->debug( + debug => "Cost $charge ", + verbosity => $verbosity + ); + if ( $cardinfo->{minute_fee_pennies} > 0 ) { + $charge = + ( ( $cardinfo->{minute_fee_pennies} * 100 ) + + $charge ) + if $cardinfo->{timeused} + + $myhash->{'variable_billsec'} => + $cardinfo->{minute_fee_minutes}; + } + if ( $cardinfo->{min_length_pennies} > 0 + && ( $cardinfo->{min_length_minutes} * 60 ) > + $myhash->{'variable_billsec'} ) + { + $charge = + ( ( $cardinfo->{min_length_pennies} * 100 ) + + $charge ); + } + + &write_callingcard_cdr( + $astpp_db, + $config, + $cardinfo, + $myhash->{'caller-caller-id-number'}, + $myhash->{'caller-destination-number'}, + $myhash->{'hangup-cause'}, + $myhash->{'variable_start_stamp'}, + $charge, + $myhash->{'variable_billsec'} + ); + &callingcard_set_in_use($astpp_db,$cardinfo,0); + &callingcard_update_balance($astpp_db,$cardinfo,$charge); + } + } + } + else { ## Unknown event + print "EVENT NAME: " . $myhash->{'event-name'} . "\n"; + print Dumper $myhash; + +# print "$reply->{body}\n"; # print out what was sent, myhash is translated by Client.pm + } + + } + } +} + Property changes on: trunk/freeswitch/astpp-fs-monitor.pl ___________________________________________________________________ Added: svn:executable + * Modified: trunk/scripts/astpp-common.pl =================================================================== --- trunk/scripts/astpp-common.pl 2009-03-23 14:18:45 UTC (rev 2244) +++ trunk/scripts/astpp-common.pl 2009-04-18 17:11:43 UTC (rev 2245) @@ -78,6 +78,30 @@ close(CONFIG); } +sub callingcard_update_balance() { #Update the available credit on the calling card. + my ( $astpp_db, $cardinfo, $charge ) = @_; + my $sql = + "UPDATE callingcards SET used = " + . $astpp_db->quote( ($charge) + $cardinfo->{used} ) + . " WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $astpp_db->do($sql); +} + + +sub callingcard_set_in_use() { # Set the "inuse" flag on the calling cards. This prevents multiple people from +# using the same card. + my ( $astpp_db, $cardinfo, $status ) = @_; + my $sql; + $sql = + "UPDATE callingcards SET inuse = " + . $astpp_db->quote($status) + . " WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $astpp_db->do($sql); +} + + # Add a calling card. sub add_callingcard() { my ( $astpp_db, $config, $branddata, $status, $pennies, @@ -2031,6 +2055,24 @@ } } +sub write_callingcard_cdr() { # Write the callingcardcdr record if this is a calling card. + my ($astpp_db, $config, $cardinfo, $clid, $destination, $status, $callstart, $charge, $answeredtime ) = @_; + my ($sql); + if (!$status) {$status = gettext("N/A"); } + $sql = +"INSERT INTO callingcardcdrs (cardnumber,clid,destination,disposition,callstart,seconds," + . "debit) VALUES (" + . $astpp_db->quote( $cardinfo->{cardnumber} ) . ", " + . $astpp_db->quote($clid) . ", " + . $astpp_db->quote($destination) . ", " + . $astpp_db->quote($status) . ", " + . $astpp_db->quote($callstart) . ", " + . $astpp_db->quote($answeredtime) . ", " + . $astpp_db->quote($charge) . ")"; + $astpp_db->do($sql); + print STDERR $sql . "\n"; +} + # 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, $pricelist, $pattern ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-03-23 14:18:58
|
Revision: 2244 http://astpp.svn.sourceforge.net/astpp/?rev=2244&view=rev Author: darrenkw Date: 2009-03-23 14:18:45 +0000 (Mon, 23 Mar 2009) Log Message: ----------- More updates to the FreeSwitch support. Modified Paths: -------------- trunk/scripts/astpp-common.pl Added Paths: ----------- trunk/sql/astpp-2009-03-18.sql Modified: trunk/scripts/astpp-common.pl =================================================================== --- trunk/scripts/astpp-common.pl 2009-03-18 23:25:11 UTC (rev 2243) +++ trunk/scripts/astpp-common.pl 2009-03-23 14:18:45 UTC (rev 2244) @@ -4208,7 +4208,8 @@ print STDERR "----------------------\n"; if(!$vars) { my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'error' WHERE uniqueid = " - . $uniqueid . " AND cost = 'rating' LIMIT 1"; + . $cdr_db->quote($uniqueid) + . " AND cost = 'rating' LIMIT 1"; $cdr_db->do($tmp); } else { $cdrinfo->{cost} = 'error'; @@ -4225,7 +4226,8 @@ print STDERR "----------------------\n"; if(!$vars) { my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'none' WHERE uniqueid = " - . $uniqueid . " AND cost = 'rating' LIMIT 1"; + . $cdr_db->quote($uniqueid) + . " AND cost = 'rating' LIMIT 1"; $cdr_db->do($tmp); } else { $cdrinfo->{cost} = 'none'; Added: trunk/sql/astpp-2009-03-18.sql =================================================================== --- trunk/sql/astpp-2009-03-18.sql (rev 0) +++ trunk/sql/astpp-2009-03-18.sql 2009-03-23 14:18:45 UTC (rev 2244) @@ -0,0 +1,1319 @@ +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', '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', '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 ( +'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', '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','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) 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 ( +'astman_secret', 'amp111','Asterisk(tm) Manager Interface Secret', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'call_max_length','1440000','What is the maximum length (in ms) of a LCR call?',''); + +------ 3rd Party PBX Mods +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'thirdlane_mods','0','Provides a few different modifications across the rating code to work better with Thirdlane(tm) cdrs.',''); + +-- +-- 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`)); + +CREATE TABLE sql_commands ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +sql TEXT NOT NULL default '', +comment TEXT NOT NULL default '', +timestamp TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + PRIMARY KEY (`id`)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-03-18 23:25:19
|
Revision: 2243 http://astpp.svn.sourceforge.net/astpp/?rev=2243&view=rev Author: darrenkw Date: 2009-03-18 23:25:11 +0000 (Wed, 18 Mar 2009) Log Message: ----------- Update code to allow authentication by ip address. Modified Paths: -------------- trunk/Makefile trunk/freeswitch/astpp-fs-xml.pl trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2009-03-11 02:46:52 UTC (rev 2242) +++ trunk/Makefile 2009-03-18 23:25:11 UTC (rev 2243) @@ -18,7 +18,7 @@ FS_SCRIPTS=/usr/local/freeswitch/scripts OWNER=root -GROUP=wheel +GROUP=root WWWDIR=/var/www all: install Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2009-03-11 02:46:52 UTC (rev 2242) +++ trunk/freeswitch/astpp-fs-xml.pl 2009-03-18 23:25:11 UTC (rev 2243) @@ -89,9 +89,9 @@ } if ( !$params->{variable_accountcode} ) { $ASTPP->debug( - debug => "Checking IP Address:" . $params->{network_addr} ); + debug => "Checking IP Address:" . $params->{'Hunt-Network-Addr'} ); my $ip_data = $ASTPP->ip_address_authenticate( - ip_address => $params->{network_addr}, + ip_address => $params->{'Hunt-Network-Addr'}, destination => $params->{'Caller-Destination-Number'} ); if ($ip_data) { @@ -218,7 +218,8 @@ $xml = $ASTPP->fs_dialplan_xml_timelimit( xml => $xml, - max_length => $maxlength + max_length => $maxlength, + accountcode => $carddata->{number} ); # Set the timelimit as well as other variables which are needed in the dialplan. Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-03-11 02:46:52 UTC (rev 2242) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-03-18 23:25:11 UTC (rev 2243) @@ -95,6 +95,7 @@ . " AND prefix IN (NULL,'') OR ip = " . $self->{_astpp_db}->quote($arg{ip_address}); $tmp .= " AND " . $self->{_astpp_db}->quote($arg{destination}) . " RLIKE prefix" if $arg{destination}; $tmp .= " ORDER BY LENGTH(prefix) DESC LIMIT 1"; + print STDERR $tmp; $sql = $self->{_astpp_db}->prepare($tmp); $sql->execute; my $anidata = $sql->fetchrow_hashref; @@ -124,6 +125,7 @@ { my ($self, %arg) = @_; $arg{xml} .= "<action application=\"sched_hangup\" data=\"+" . $arg{max_length} * 60 . "\"/>\n"; + $arg{xml} .= "<action application=\"set\" data=\"accountcode=" . $arg{accountcode} . "\"/>\n"; return $arg{xml}; } @@ -258,11 +260,11 @@ $tmp .= " AND domain = " . $self->{_freeswitch_db}->quote($arg{domain}); } - } else { - if ($arg{domain}) { - $tmp .= " WHERE domain = " - . $self->{_freeswitch_db}->quote($arg{domain}); - } +# } else { +# if ($arg{domain}) { +# $tmp .= " WHERE domain = " +# . $self->{_freeswitch_db}->quote($arg{domain}); +# } } } print STDERR $tmp; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-03-11 02:47:25
|
Revision: 2242 http://astpp.svn.sourceforge.net/astpp/?rev=2242&view=rev Author: darrenkw Date: 2009-03-11 02:46:52 +0000 (Wed, 11 Mar 2009) Log Message: ----------- Added Freeswitch DID support. Modified Paths: -------------- trunk/freeswitch/astpp-fs-xml.pl trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2009-03-10 00:52:26 UTC (rev 2241) +++ trunk/freeswitch/astpp-fs-xml.pl 2009-03-11 02:46:52 UTC (rev 2242) @@ -53,19 +53,21 @@ 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'} - ); - -# Check to see if this is a DID. If it is we handle it differently. -# + # Check to see if this is a DID. If it is we handle it differently. + # $didinfo = &get_did($astpp_db, $params->{'Caller-Destination-Number'}); if ($didinfo->{number}) { $astppdid = "ASTPP-DID"; $ASTPP->debug( debug => "This is a call for a DID: "); $params->{variable_accountcode} = $didinfo->{account}; } + + $xml = $ASTPP->fs_dialplan_xml_header( + xml => $xml, + destination_number => $params->{'Caller-Destination-Number'}, + DID => $didinfo->{number} + ); + @@ -113,7 +115,9 @@ $xml .= "<action application=\"reject\" data=\"CANNOT RETRIEVE ACCOUNT\"/>\n"; $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml ); - print $xml; +# print $xml; + $ASTPP->debug( debug => "Returning nothing so dialplan can continue." ); + print ""; exit(0); } @@ -228,8 +232,12 @@ $carddata->{pricelist}, $carddata, $astppdid ); - if ($astppdid > 0 ) { + if ($didinfo->{number} ) { $ASTPP->debug( debug => "THIS IS A DID CALL: $xml"); + my ($returned_data) = $ASTPP->fs_dialplan_xml_did( + did => $params->{'Caller-Destination-Number'} + ); + $xml .= $returned_data; } else { # Get the list of routes for the phone number. my @outboundroutes = Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-03-10 00:52:26 UTC (rev 2241) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-03-11 02:46:52 UTC (rev 2242) @@ -109,7 +109,11 @@ $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"; + if ($arg{DID} > 0) { + $arg{xml} .= "<context name=\"public\">\n"; + } else { $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}; @@ -123,6 +127,22 @@ return $arg{xml}; } +sub fs_dialplan_xml_did +# Return the dialplan code for an incoming call to a DID. +{ + my ($self, %arg) = @_; + my ( $sql, $trunkdata, $dialstring,$data ); + my $tmp = "SELECT * FROM dids WHERE number = " + . $self->{_astpp_db}->quote( $arg{did} ) . + " LIMIT 1"; + print STDERR $tmp; + $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + my $diddata = $sql->fetchrow_hashref; + $sql->finish; + return $diddata->{variables}; +} + 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: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-03-10 00:52:39
|
Revision: 2241 http://astpp.svn.sourceforge.net/astpp/?rev=2241&view=rev Author: darrenkw Date: 2009-03-10 00:52:26 +0000 (Tue, 10 Mar 2009) Log Message: ----------- Worked on removing Asterisk dependencies if installing for Freeswitch. Modified Paths: -------------- trunk/Makefile Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2009-03-07 22:38:22 UTC (rev 2240) +++ trunk/Makefile 2009-03-10 00:52:26 UTC (rev 2241) @@ -21,7 +21,7 @@ GROUP=wheel WWWDIR=/var/www -all: +all: install install_misc: mkdir -p $(DESTDIR)$(ASTPPDIR) @@ -48,12 +48,22 @@ install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-users.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp/astpp-users.cgi install -m 644 -o $(OWNER) -g $(GROUP) web_interface/style.css $(DESTDIR)$(WWWDIR)/html/_astpp/ install -m 644 -o $(OWNER) -g $(GROUP) web_interface/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.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_asterisk_config: install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-dialplan.conf $(DESTDIR)$(ASTERISKDIR)/sample.astpp-dialplan.conf +install_freeswitch_config: + @echo "--------------------"; + @echo "Sample Freeswitch configuration files live in"; + @echo "./freeswitch/conf. You will need to modify your"; + @echo "files to be similar to those."; + @echo "--------------------"; + install_samples: 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)/astpp-config.conf @@ -78,13 +88,13 @@ install -m 755 -o $(OWNER) -g $(GROUP) $$x $(PREFIX)$(ASTPPEXECDIR); \ done -install_sounds: +install_sounds_asterisk: for x in sounds/*.gsm; do \ echo $$x;\ install -m 644 $$x $(DESTDIR)$(SOUNDSDIR); \ done -install_sounds_fs: +install_sounds_freeswitch: for x in sounds/*.gsm; do \ echo $$x;\ install -m 644 $$x $(DESTDIR)$(FS_SOUNDSDIR); \ @@ -161,11 +171,23 @@ @echo "to change the 'auth' code as well as set more advanced features." @echo ""; @echo "'make install' updates all the sample files which have been installed but to overwrite any settings you have in place"; - @echo "perform a 'make samples'. Be aware that this will overwrite any astpp settings you may have as well as replace"; + @echo "If this is the first time you are installing ASTPP you need to perform a 'make samples'. "; + @echo "Be aware that this will overwrite any astpp settings you may have as well as replace"; @echo "your astpp-dialplan.conf file."; @echo ""; @echo "Thank you for using ASTPP! Please visit www.astpp.org for support information."; -install: all install_misc install_astpp_exec install_agi install_instructions_print +install_all_pre: install_misc install_astpp_exec +install_all_post: install_instructions_print -samples: install_images install_sounds install_templates install_samples +install_asterisk: install_all_pre install_asterisk_config install_sounds_asterisk install_agi install_all_post +install_freeswitch: install_all_pre install_freeswitch_config install_sounds_freeswitch install_all_post + +samples: install_images install_templates install_samples + +install: + @echo "------------------------------"; + @echo "Please use 'make install_asterisk if you are using Asterisk"; + @echo "Please use 'make install_freeswitch you are using Freeswitch"; + @echo "------------------------------"; + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-03-07 22:38:31
|
Revision: 2240 http://astpp.svn.sourceforge.net/astpp/?rev=2240&view=rev Author: darrenkw Date: 2009-03-07 22:38:22 +0000 (Sat, 07 Mar 2009) Log Message: ----------- Corrected freeswitch bridging code after adding support for returning the routing information in several formats. Modified Paths: -------------- trunk/freeswitch/astpp-fs-xml.pl trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2009-03-07 22:29:40 UTC (rev 2239) +++ trunk/freeswitch/astpp-fs-xml.pl 2009-03-07 22:38:22 UTC (rev 2240) @@ -244,11 +244,12 @@ ); } else { - $xml .= $ASTPP->fs_dialplan_xml_bridge( + my ($returned_data,$junk) = $ASTPP->fs_dialplan_xml_bridge( destination_number => $params->{'Caller-Destination-Number'}, route_prepend => $route->{prepend}, trunk_name => $route->{trunk} ); + $xml .= $returned_data; } } } Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-03-07 22:29:40 UTC (rev 2239) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-03-07 22:38:22 UTC (rev 2240) @@ -152,7 +152,7 @@ } if ( $trunkdata->{tech} eq "Zap" ) { $dialstring = "<action application=\"bridge\" data=\"openzap/" . $trunkdata->{path} . "/1/" . $arg{route_prepend} . $arg{destination_number} . "\"/>\n"; - return $dialstring,$data; + return ($dialstring,$data); } elsif ( $trunkdata->{tech} eq "SIP" ) { my ($profile,$dest) = split(m/","/m, $trunkdata->{path}); @@ -165,7 +165,7 @@ $data = "sofia/" . $profile . "/" . $arg{route_prepend} . $arg{destination_number} . "\@" . $dest; $dialstring = "<action application=\"bridge\" data=\"" . $data . "\"/>\n"; } - return $dialstring,$data; + return ($dialstring,$data); } else { print STDERR "CANNOT ROUTE THIS CALL!!!!!\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-03-07 22:29:45
|
Revision: 2239 http://astpp.svn.sourceforge.net/astpp/?rev=2239&view=rev Author: darrenkw Date: 2009-03-07 22:29:40 +0000 (Sat, 07 Mar 2009) Log Message: ----------- More freeswitch corrections and a few minor fixes to the interface. Modified Paths: -------------- trunk/Makefile trunk/freeswitch/astpp-callingcards.pl trunk/web_interface/astpp-admin.cgi Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2009-02-22 03:09:51 UTC (rev 2238) +++ trunk/Makefile 2009-03-07 22:29:40 UTC (rev 2239) @@ -13,6 +13,10 @@ ASTPPLOGDIR=/var/log/astpp/ EXTENSIONS=/etc/asterisk/extensions.conf LOCALE_DIR=/usr/local/share/locale + +FS_SOUNDSDIR=/usr/local/freeswitch/sounds/en/us/callie +FS_SCRIPTS=/usr/local/freeswitch/scripts + OWNER=root GROUP=wheel WWWDIR=/var/www @@ -80,6 +84,13 @@ install -m 644 $$x $(DESTDIR)$(SOUNDSDIR); \ done +install_sounds_fs: + for x in sounds/*.gsm; do \ + echo $$x;\ + install -m 644 $$x $(DESTDIR)$(FS_SOUNDSDIR); \ + done + + install_templates: for x in templates/*; do \ echo $$x;\ Modified: trunk/freeswitch/astpp-callingcards.pl =================================================================== --- trunk/freeswitch/astpp-callingcards.pl 2009-02-22 03:09:51 UTC (rev 2238) +++ trunk/freeswitch/astpp-callingcards.pl 2009-03-07 22:29:40 UTC (rev 2239) @@ -149,13 +149,13 @@ if ($config->{calling_cards_rate_announce} == 1) { if ( $numberinfo->{cost} > 0 ) { $session->streamFile($sound->{call_will_cost}); - $session->execute("phrase","pronounce," . ceil($numberinfo->{cost}/100)); + $session->execute("phrase","spell," . ceil($numberinfo->{cost}/100)); $session->streamFile($sound->{currency}); my @call_cost = split(/\./, ($numberinfo->{cost} / 100)); - $session->execute("phrase","pronounce," . @call_cost[0]); + $session->execute("phrase","spell," . @call_cost[0]); if (@call_cost[1]) { $session->streamFile($sound->{point}); - $session->execute("phrase","pronounce," . @call_cost[1]); + $session->execute("phrase","spell," . @call_cost[1]); $session->streamFile($sound->{sub_currency}); } $session->streamFile($sound->{per}); @@ -163,7 +163,7 @@ } if ( $numberinfo->{connectcost} > 0 ) { $session->streamFile($sound->{a_connect_charge}); - $session->execute("phrase","pronounce," . ceil($numberinfo->{connectcost}/100)); + $session->execute("phrase","spell," . ceil($numberinfo->{connectcost}/100)); $session->streamFile($sound->{sub_currency}); $session->streamFile($sound->{will_apply}); } @@ -243,11 +243,11 @@ $minutes = sprintf( "%.0f", $minutes ); $session->streamFile($sound->{call_will_last}); if ( $minutes == 1 ) { - $session->execute("phrase","pronounce," . $minutes); + $session->execute("phrase","spell," . $minutes); $session->streamFile($sound->{minute}); } elsif ( $minutes > 1 ) { - $session->execute("phrase","pronounce," . $minutes); + $session->execute("phrase","spell," . $minutes); $session->streamFile($sound->{minutes}); } } @@ -256,10 +256,6 @@ $session->streamFile($sound->{goodbye}); &leave($cardinfo); } - $maxtime = $timelimit * 1000; - - - $timelimit = "\|30\|HL($maxtime:60000:30000)\|Hgj"; $ASTPP->debug( debug => "Available: $available", verbosity => $verbosity ); $ASTPP->debug( debug => "Balance: $balance", verbosity => $verbosity ); @@ -284,19 +280,19 @@ my $interrupt = $session->playAndGetDigits(1,1,1,0,"#*","$sound->{card_has_balance_of}","$sound->{card_has_balance_of}",'^[0-9]+$'); if (!$interrupt || $interrupt eq "" || $interrupt == 0) { if ( $main_balance == 1 ) { -$session->execute("phrase","pronounce," . $main_balance); +$session->execute("phrase","spell," . $main_balance); $session->streamFile($sound->{main_currency}); } elsif ( $main_balance > 1 ) { -$session->execute("phrase","pronounce," . $main_balance); +$session->execute("phrase","spell," . $main_balance); $session->streamFile($sound->{main_currency_plural}); } if ( $sub_balance == 1 ) { -$session->execute("phrase","pronounce," . $sub_balance); +$session->execute("phrase","spell," . $sub_balance); $session->streamFile($sound->{sub_currency}); } elsif ( $sub_balance > 1 ) { -$session->execute("phrase","pronounce," . $sub_balance); +$session->execute("phrase","spell," . $sub_balance); $session->streamFile($sound->{sub_currency_plural}); } } @@ -389,17 +385,19 @@ } $count = 0; foreach my $route (@outboundroutes) { - my $dialstring = $ASTPP->fs_dialplan_xml_bridge(); my $callstart = localtime(); my ($accountcode); $callstart = &prettytimestamp if $cc == 1; - $session->execute->("sched_hangup","+" . $timelimit * 60); + $session->execute("sched_hangup","+" . $timelimit/1000*60); my ($xml_string,$data_string) = $ASTPP->fs_dialplan_xml_bridge( destination_number => $destination, route_prepend => $route->{prepend}, trunk_name => $route->{trunk} ); - my $vars = $session->execute->("bridge",$data_string); + my ($dialedtime,$uniqueid,$answeredtime,$clid); + my $vars = $session->execute("bridge","$data_string"); + + $ASTPP->debug( debug => "Vars: " . $vars); # return 1 if (! $session->ready()); # $VARS{destination_number} = $num_dial; # UPDATEV(); @@ -421,7 +419,7 @@ $destination, $callstart, 0, $uniqueid, $clid ) if $cc == 1; &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); &leave($cardinfo); } else { push @outboundroutes, $route; @@ -438,7 +436,7 @@ $destination, $callstart, 0, $uniqueid, $clid ) if $cc == 1; &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); &leave($cardinfo); } else { push @outboundroutes, $route; @@ -473,7 +471,7 @@ $callstart, $charge, $answeredtime, $uniqueid ); &write_asterisk_cdr( $accountcode, $clid, $destination, "ANSWERED", - $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); &update_balance( $cardinfo, $charge ); $astpp_db->do("UPDATE callingcards SET timeused = " . $astpp_db->quote($cardinfo->{timeused} + $answeredtime) @@ -485,7 +483,7 @@ &write_account_cdr( $astpp_db, $cardinfo->{number}, $charge, $destination, $callstart, $answeredtime, $uniqueid, $clid ); &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); $ASTPP->debug( debug => $status, verbosity => $verbosity ); } $session->streamFile($sound->{call_completed}); @@ -501,7 +499,7 @@ $destination, $callstart, 0, $uniqueid, $clid ) if $cc == 1; &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); &leave($cardinfo); } else { @@ -515,7 +513,7 @@ $destination, $callstart, 0, $uniqueid, $clid ) if $cc == 1; &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); &leave($cardinfo); } } @@ -671,7 +669,7 @@ } $retries = 0; while ( !$numberinfo->{pattern} && $retries < $config->{number_retries} ) { - $destination = $session->playAndGetDigits(4,999,1,$config->{calling_cards_dial_input_timeout},"#","$sound->{destination}","$sound->{destination}",'^[0-9]+$'); + $destination = $session->playAndGetDigits(4,35,1,$config->{calling_cards_dial_input_timeout},"#","$sound->{destination}","$sound->{destination}",'^[0-9]+$'); $numberinfo = &get_route( $astpp_db, $config, $destination, $brandinfo->{pricelist}, $cardinfo ); if ( !$numberinfo->{pattern} ) { Modified: trunk/web_interface/astpp-admin.cgi =================================================================== --- trunk/web_interface/astpp-admin.cgi 2009-02-22 03:09:51 UTC (rev 2238) +++ trunk/web_interface/astpp-admin.cgi 2009-03-07 22:29:40 UTC (rev 2239) @@ -2114,11 +2114,11 @@ ( $sql, $pagination ) = $ASTPP->pagination( sql_select => "SELECT * FROM cdrs WHERE cardnum =" . $astpp_db->quote( $accountinfo->{number} ) - . "and status IN (NULL, '', 0, 1)" + . "and ( status IS NULL OR status IN (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)", + . "and ( status IS NULL OR status IN (0,1,''))", results_per_page => $config->{results_per_page}, ve => $params->{ve}, te => $params->{ee}, @@ -2906,7 +2906,7 @@ } else { $tmp = -"SELECT name FROM callingcardbrands WHERE status < 2 AND reseller IN (NULL,'')"; +"SELECT name FROM callingcardbrands WHERE status < 2 AND (reseller IS NULL OR reseller = '')"; } $ASTPP->debug( user => $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); @@ -2928,7 +2928,7 @@ } else { $tmp = -"SELECT * FROM callingcardbrands WHERE status < 2 AND reseller IN (NULL,'') ORDER BY name limit $params->{limit} , $results_per_page"; +"SELECT * FROM callingcardbrands WHERE status < 2 AND (reseller IS NULL OR reseller = '') ORDER BY name limit $params->{limit} , $results_per_page"; } $ASTPP->debug( user => $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); @@ -3954,9 +3954,9 @@ ); my $sql_select = -"SELECT * FROM cdr WHERE cost IN( 'error','rating') OR accountcode IN (NULL,'') AND cost ='none' ORDER BY calldate"; +"SELECT * FROM cdr WHERE cost IN( 'error','rating') OR (accountcode IS NULL OR accountcode = '') AND cost ='none' ORDER BY calldate"; my $sql_count = -"SELECT COUNT(*) FROM cdr WHERE cost IN ( 'error','rating') OR accountcode IN (NULL,'') AND cost ='none'"; +"SELECT COUNT(*) FROM cdr WHERE cost IN ( 'error','rating') OR (accountcode IS NULL OR accountcode = '') AND cost ='none'"; my ( $sql, $pagination ) = $ASTPP->pagination( sql_select => $sql_select, @@ -6347,16 +6347,18 @@ $ASTPP->debug( user => $param->{username}, debug => $tmp ); } $tmp = -"INSERT INTO routes (pattern,comment,pricelist,connectcost,includedseconds,cost) VALUES (" +"INSERT INTO routes (pattern,comment,pricelist,connectcost,includedseconds,cost,inc,reseller) VALUES (" . $astpp_db->quote( "^" . $params->{number} . "\$" ) . "," - . $astpp_db->quote( $params->{country} . "," + . $astpp_db->quote("DID: " . $params->{country} . "," . $params->{province} . "," . $params->{city} ) . "," . $astpp_db->quote( $config->{default_brand} ) . "," . $astpp_db->quote( $params->{connectcost} ) . "," . $astpp_db->quote( $params->{included} ) . "," - . $astpp_db->quote( $params->{cost} ) . ")"; + . $astpp_db->quote( $params->{cost} ) . "," + . $astpp_db->quote( $params->{inc} ) . ",'')"; + $ASTPP->debug( user => $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Pattern") . " '" @@ -6430,10 +6432,9 @@ $tmp = "UPDATE routes SET" . " comment = " - . $astpp_db->quote( $params->{country} . "," - . $params->{province} . "," - . $params->{city} ) - . "," + . $astpp_db->quote("DID: " . $params->{country} . "," + . $params->{province} . "," + . $params->{city} ) . "," . " pricelist=" . $astpp_db->quote( $config->{default_brand} ) . "," . " connectcost=" @@ -6441,9 +6442,13 @@ . " includedseconds=" . $astpp_db->quote( $params->{included} ) . "," . " cost=" - . $astpp_db->quote( $params->{cost} ) + . $astpp_db->quote( $params->{cost} ) . "," + . " inc=" + . $astpp_db->quote( $params->{inc} ) . "," + . " status=1" . " WHERE pattern = " . $astpp_db->quote( "^" . $params->{number} . "\$" ); + $ASTPP->debug( user => $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Pattern") . " '" @@ -6490,8 +6495,7 @@ "<table class=\"default\">" . "<tr class=\"header\"><td colspan=12>" . gettext("All costs are in 1/100 of a penny") - . "</td></tr> -" + . "</td></tr>" . "<tr class=\"header\"><td>" . hidden( -name => 'mode', -value => gettext("Manage DIDs") ) . gettext("Number") @@ -7906,7 +7910,7 @@ "; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $tmp = - "SELECT * FROM routes WHERE status < 2 AND reseller IN (NULL,'')" + "SELECT * FROM routes WHERE status < 2 AND (reseller IS NULL OR reseller = '')" . " AND pricelist = " . $astpp_db->quote( $params->{username} ) . " UNION SELECT * FROM routes WHERE status < 2 " @@ -7915,7 +7919,7 @@ } else { $tmp = - "SELECT * FROM routes WHERE status < 2 AND reseller IN (NULL,'')"; + "SELECT * FROM routes WHERE status < 2 AND ( reseller IS NULL OR reseller = '' )"; } $ASTPP->debug( user => $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); @@ -7930,7 +7934,7 @@ if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $sql = $astpp_db->prepare( -"SELECT * FROM routes WHERE reseller IN (NULL,'') AND pricelist = " +"SELECT * FROM routes WHERE ( reseller IS NULL OR reseller = '') AND pricelist = " . $astpp_db->quote( $params->{username} ) . " UNION SELECT * FROM routes WHERE status < 2 " . " AND reseller = " @@ -7940,7 +7944,7 @@ } else { $sql = $astpp_db->prepare( -"SELECT * FROM routes WHERE reseller IN (NULL,'') AND status < 2 ORDER BY comment limit $params->{limit} , $results_per_page" +"SELECT * FROM routes WHERE ( reseller IS NULL OR reseller = '') AND status < 2 ORDER BY comment limit $params->{limit} , $results_per_page" ); } $sql->execute This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |