astpp-commit Mailing List for ASTPP - Open Source Voip Billing (Page 7)
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...> - 2008-08-23 16:02:32
|
Revision: 2188 http://astpp.svn.sourceforge.net/astpp/?rev=2188&view=rev Author: darrenkw Date: 2008-08-23 16:02:39 +0000 (Sat, 23 Aug 2008) Log Message: ----------- Commit patch for the following feature request. Will require more testing. [ 2033328 ] Generate invoices on selected time period Modified Paths: -------------- trunk/astpp-common.pl trunk/astpp-generate-invoices.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-07-03 00:06:16 UTC (rev 2187) +++ trunk/astpp-common.pl 2008-08-23 16:02:39 UTC (rev 2188) @@ -4475,12 +4475,34 @@ } sub osc_charges() { - my ($astpp_db, $osc_db, $config, $account) = @_; + my ($astpp_db, $osc_db, $config, $account, $params) = @_; my ( $invoice_id, $country_id, $zone_id, $tmp, $sql, $row, $cdr_count ); + if ($params->{startdate} && $params->{enddate}) { $tmp = "SELECT COUNT(*) FROM cdrs WHERE cardnum = " . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart >= DATE(" . $astpp_db->quote($params->{startdate}) . ")" + . " AND callstart <= DATE(" . $astpp_db->quote($params->{enddate}) . ")"; + } elsif ($params->{startdate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart >= DATE(" . $astpp_db->quote($params->{startdate}) . ")"; + } elsif ($params->{enddate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart <= DATE(" . $astpp_db->quote($params->{enddate}) . ")"; + } else { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) . " AND status = 0"; + } + print STDERR "$tmp \n"; $sql = $astpp_db->prepare($tmp); $sql->execute; @@ -4497,10 +4519,35 @@ ( $invoice_id, $country_id, $zone_id ) = &osc_create_invoice($astpp_db, $osc_db, $config, $account); if ($invoice_id) { - $tmp = - "SELECT * FROM cdrs WHERE cardnum = " - . $astpp_db->quote($account) - . " AND status = 0 ORDER BY callstart"; + if ($params->{startdate} && $params->{enddate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart >= DATE(" . $astpp_db->quote($params->{startdate}) . ")" + . " AND callstart <= DATE(" . $astpp_db->quote($params->{enddate}) . ")" + . " ORDER BY callstart"; + } elsif ($params->{startdate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart >= DATE(" . $astpp_db->quote($params->{startdate}) . ")" + . " ORDER BY callstart"; + } elsif ($params->{enddate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart <= DATE(" . $astpp_db->quote($params->{enddate}) . ")" + . " ORDER BY callstart"; + } else { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " ORDER BY callstart"; + } $sql = $astpp_db->prepare($tmp); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { @@ -4582,12 +4629,39 @@ } sub get_charges() { - my ($astpp_db, $config, $number) = @_; - my ( $sql, @chargelist, $record ); + my ($astpp_db, $config, $account,$params) = @_; + my ( $tmp,$sql, @chargelist, $record ); + if ($params->{startdate} && $params->{enddate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart >= DATE(" . $astpp_db->quote($params->{startdate}) . ")" + . " AND callstart <= DATE(" . $astpp_db->quote($params->{enddate}) . ")" + . " ORDER BY callstart"; + } elsif ($params->{startdate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart >= DATE(" . $astpp_db->quote($params->{startdate}) . ")" + . " ORDER BY callstart"; + } elsif ($params->{enddate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart <= DATE(" . $astpp_db->quote($params->{enddate}) . ")" + . " ORDER BY callstart"; + } else { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " ORDER BY callstart"; + } $sql = - $astpp_db->prepare( "SELECT * FROM cdrs WHERE cardnum = " - . $astpp_db->quote($number) - . " AND status = 0" ); + $astpp_db->prepare($tmp); $sql->execute; while ( $record = $sql->fetchrow_hashref ) { push @chargelist, $record->{id}; Modified: trunk/astpp-generate-invoices.pl =================================================================== --- trunk/astpp-generate-invoices.pl 2008-07-03 00:06:16 UTC (rev 2187) +++ trunk/astpp-generate-invoices.pl 2008-08-23 16:02:39 UTC (rev 2188) @@ -21,6 +21,9 @@ # 0 0 * 1,7 * /usr/local/astpp/astpp-generate-invoices.pl sweep=4 # 0 0 * 1 * /usr/local/astpp/astpp-generate-invoices.pl sweep=5 # +# To generate invoices only for a specific date range use the startdate & enddate. +# ie startdate=2008-06-01 endate=2008-06-30 +# use POSIX; use POSIX qw(strftime); use DBI; @@ -86,7 +89,7 @@ foreach my $cardno (@cardlist) { my $carddata = &get_account( $astpp_db, $cardno ); if ( $carddata->{posttoexternal} == 1 ) { - my @recordlist = &get_charges($astpp_db, $config, $cardno); + my @recordlist = &get_charges($astpp_db, $config, $cardno,$params); foreach my $record (@recordlist) { my $cdrinfo = &get_charge($record); my $cost; @@ -112,7 +115,7 @@ foreach my $cardno (@cardlist) { my $carddata = &get_account( $astpp_db, $cardno ); if ( $carddata->{posttoexternal} == 1 ) { - my @recordlist = &get_charges($astpp_db, $config, $cardno); + my @recordlist = &get_charges($astpp_db, $config, $cardno,$params); foreach my $record (@recordlist) { my $cdrinfo = &get_charge($record); my $cost; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-07-03 00:06:18
|
Revision: 2187 http://astpp.svn.sourceforge.net/astpp/?rev=2187&view=rev Author: darrenkw Date: 2008-07-02 17:06:16 -0700 (Wed, 02 Jul 2008) Log Message: ----------- Fixed a pagination error. Modified Paths: -------------- trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2008-06-07 15:00:20 UTC (rev 2186) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2008-07-03 00:06:16 UTC (rev 2187) @@ -281,7 +281,7 @@ # First we decide if we have multiple pages... - if ($arg{total_entries} > 1) { + if ($total_entries > 1) { my $html; $html = "<a href=\"" . $self->{_script} . "?mode=" @@ -295,7 +295,7 @@ . "<a href=\"" . $self->{_script} . "?mode=" . $arg{mode} . "&ve=" . $arg{ve} . "&te=" - . $arg{total_entries} . "&pg=" + . $total_entries . "&pg=" . $arg{last_page} . "\">" . "Last Page" . "</a>"; return ($sql,$html); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-06-07 14:41:14
|
Revision: 2185 http://astpp.svn.sourceforge.net/astpp/?rev=2185&view=rev Author: darrenkw Date: 2008-06-07 07:41:22 -0700 (Sat, 07 Jun 2008) Log Message: ----------- Commit installation instructions and sample configurations. Modified Paths: -------------- trunk/freeswitch/README Added Paths: ----------- trunk/freeswitch/conf/ trunk/freeswitch/conf/README trunk/freeswitch/conf/freeswitch.xml trunk/freeswitch/conf/modules.conf.xml trunk/freeswitch/conf/xml_curl.conf.xml Modified: trunk/freeswitch/README =================================================================== --- trunk/freeswitch/README 2008-06-07 04:47:11 UTC (rev 2184) +++ trunk/freeswitch/README 2008-06-07 14:41:22 UTC (rev 2185) @@ -1 +1,25 @@ This directory contains the support for Freeswitch. Please be aware that this is a work under development. + +We very strongly suggest running astpp-fs-xml.pl under mod_perl as in our tests it runs 10X as fast. Here are brief instructions on accomplishing that: + +1. Create a directory that will be run as mod_perl. This could be anywhere but for our test we'll use /usr/lib/mod_perl_bin/. + +2. Install mod_perl onto your server if it doesn't exist already. + +3. Add the following commands into your httpd.conf file: + + Alias /perl/ /usr/lib/mod_perl_bin/ + <Location /perl/> + SetHandler perl-script + PerlResponseHandler ModPerl::Registry + PerlOptions +ParseHeaders + Options +ExecCGI + Order allow,deny + Allow from all + </Location> + +4. You will need to manually copy the astpp-fs-xml.pl into this folder after doing the rest of the astpp installation. + +5. Point mod_xml_rpc.conf to http://localhost/perl/astpp-fs-xml.pl + +6. Currently you can only use the dialplan bindings but rest assured that other bindings are coming shortly. Added: trunk/freeswitch/conf/README =================================================================== --- trunk/freeswitch/conf/README (rev 0) +++ trunk/freeswitch/conf/README 2008-06-07 14:41:22 UTC (rev 2185) @@ -0,0 +1 @@ +These are the files that I've made changes in to enable mod_xml_curl. Added: trunk/freeswitch/conf/freeswitch.xml =================================================================== --- trunk/freeswitch/conf/freeswitch.xml (rev 0) +++ trunk/freeswitch/conf/freeswitch.xml 2008-06-07 14:41:22 UTC (rev 2185) @@ -0,0 +1,43 @@ +<?xml version="1.0"?> +<document type="freeswitch/xml"> + <!--#comment + All comments starting with #command will be preprocessed and never sent to the xml parser + Valid instructions: + #include ==> Include another file to this exact point + (partial xml should be encased in <include></include> tags) + #set ==> Set a global variable (can be expanded during preprocessing with $$ variables) + (note the double $$ which denotes preprocessor variables) + #comment ==> A general comment such as this + + The preprocessor will compile the full xml document to ${prefix}/log/freeswitch.xml.fsxml + Don't modify it while freeswitch is running cos it is mem mapped in most cases =D + + The same can be achieved with the <X-PRE-PROCESS> tag where the attrs 'cmd' and 'data' are + parsed in the same way. + --> + <!--#comment + vars.xml contains all the #set directives for the preprocessor. + --> + <X-PRE-PROCESS cmd="include" data="vars.xml"/> + + <section name="configuration" description="Various Configuration"> + <X-PRE-PROCESS cmd="include" data="autoload_configs/*.xml"/> + <X-PRE-PROCESS cmd="include" data="autoload_configs/xml_curl.conf.xml"/> + </section> + + <!-- mod_dingaling is reliant on the vcard data in the "directory" section. --> + <!-- mod_sofia is reliant on the user data for authorization --> + <section name="directory" description="User Directory"> + <X-PRE-PROCESS cmd="include" data="directory/*.xml"/> + </section> + + <!-- phrases section (under development still) --> + <section name="phrases" description="Speech Phrase Management"> + <macros> + <X-PRE-PROCESS cmd="include" data="lang/en/*.xml"/> + </macros> + </section> + +</document> + + Property changes on: trunk/freeswitch/conf/freeswitch.xml ___________________________________________________________________ Name: svn:executable + * Added: trunk/freeswitch/conf/modules.conf.xml =================================================================== --- trunk/freeswitch/conf/modules.conf.xml (rev 0) +++ trunk/freeswitch/conf/modules.conf.xml 2008-06-07 14:41:22 UTC (rev 2185) @@ -0,0 +1,89 @@ +<configuration name="modules.conf" description="Modules"> + <modules> + + <!-- Loggers (I'd load these first) --> + <load module="mod_console"/> + <load module="mod_logfile"/> + <!-- <load module="mod_syslog"/> --> + + <!-- Multi-Faceted --> + <!-- mod_enum is a dialplan interface, an application interface and an api command interface --> + <load module="mod_enum"/> + + <!-- XML Interfaces --> + <!-- <load module="mod_xml_rpc"/> --> + <load module="mod_xml_curl"/> + <load module="mod_xml_cdr"/> + + <!-- Event Handlers --> + <load module="mod_cdr_csv"/> + <!-- <load module="mod_event_multicast"/> --> + <load module="mod_event_socket"/> + <!-- <load module="mod_xmpp_event"/> --> + <!-- <load module="mod_zeroconf"/> --> + + <!-- Directory Interfaces --> + <!-- <load module="mod_ldap"/> --> + + <!-- Endpoints --> + <!-- <load module="mod_dingaling"/> --> + <!-- <load module="mod_iax"/> --> + <!-- <load module="mod_portaudio"/> --> + <!-- <load module="mod_alsa"/> --> + <load module="mod_sofia"/> + <!-- <load module="mod_wanpipe"/> --> + <!-- <load module="mod_woomera"/> --> + <!-- <load module="mod_openzap"/> --> + + <!-- Applications --> + <load module="mod_commands"/> + <load module="mod_conference"/> + <load module="mod_dptools"/> + <load module="mod_expr"/> + <load module="mod_fifo"/> + <load module="mod_voicemail"/> + <load module="mod_limit"/> + <load module="mod_esf"/> + <load module="mod_fsv"/> + + <!-- Dialplan Interfaces --> + <!-- <load module="mod_dialplan_directory"/> --> + <load module="mod_dialplan_xml"/> + <load module="mod_dialplan_asterisk"/> + + <!-- Codec Interfaces --> + <load module="mod_voipcodecs"/> + <load module="mod_g723_1"/> + <load module="mod_g729"/> + <load module="mod_amr"/> + <load module="mod_ilbc"/> + <load module="mod_speex"/> + <load module="mod_h26x"/> + + <!-- File Format Interfaces --> + <load module="mod_sndfile"/> + <load module="mod_native_file"/> + <!--For icecast/mp3 streams/files--> + <!--<load module="mod_shout"/>--> + <!--For local streams (play all the files in a directory)--> + <load module="mod_local_stream"/> + <load module="mod_tone_stream"/> + + <!-- Timers --> + + <!-- Languages --> + <load module="mod_spidermonkey"/> + <!-- <load module="mod_perl"/> --> + <!-- <load module="mod_python"/> --> + <!-- <load module="mod_java"/> --> + <!-- <load module="mod_lua"/> --> + + <!-- ASR /TTS --> + <!-- <load module="mod_cepstral"/> --> + <!-- <load module="mod_openmrcp"/> --> + <!-- <load module="mod_rss"/> --> + + <!-- Say --> + <load module="mod_say_en"/> + </modules> +</configuration> Added: trunk/freeswitch/conf/xml_curl.conf.xml =================================================================== --- trunk/freeswitch/conf/xml_curl.conf.xml (rev 0) +++ trunk/freeswitch/conf/xml_curl.conf.xml 2008-06-07 14:41:22 UTC (rev 2185) @@ -0,0 +1,22 @@ +<configuration name="xml_curl.conf" description="cURL XML Gateway"> + <bindings> + <binding name="example"> + <!-- The url to a gateway cgi that can generate xml similar to + what's in this file only on-the-fly (leave it commented if you dont + need it) --> + <!-- one or more |-delim of configuration|directory|dialplan --> + + <param name="gateway-url" value="http://localhost/cgi-bin/astpp-fs-xml.pl" bindings="dialplan"/> + <!-- set this to provide authentication credentials to the server --> + <!--<param name="gateway-credentials" value="muser:mypass"/>--> + <!-- set to true to disable Expect: 100-continue lighttpd requires this setting --> + <!--<param name="disable-100-continue" value="true"/>--> + + <!-- optional: if enabled this will disable CA root certificate checks by libcurl --> + <!-- note: default value is disabled. only enable if you want this! --> + <!-- <param name="ignore-cacert-check" value="true" /> --> + <!-- one or more of these imply you want to pick the exact variables that are transmitted --> + <!--<param name="enable-post-var" value="Unique-ID"/>--> + </binding> + </bindings> +</configuration> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-06-07 04:47:08
|
Revision: 2184 http://astpp.svn.sourceforge.net/astpp/?rev=2184&view=rev Author: darrenkw Date: 2008-06-06 21:47:11 -0700 (Fri, 06 Jun 2008) Log Message: ----------- Import Freeswitch support. This code works much, much faster using mod_perl. Modified Paths: -------------- trunk/astpp-common.pl trunk/astpp-ip-map.agi trunk/modules/ASTPP/lib/ASTPP.pm Added Paths: ----------- trunk/freeswitch/ trunk/freeswitch/README trunk/freeswitch/astpp-fs-xml.pl trunk/freeswitch/test-fs-xml.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-06-01 00:42:36 UTC (rev 2183) +++ trunk/astpp-common.pl 2008-06-07 04:47:11 UTC (rev 2184) @@ -1704,6 +1704,7 @@ my @pricelists = split ( m/,/m, $pricelist ); foreach my $pricelistname (@pricelists) { $pricelistname =~ s/"//g; #Strip off quotation marks + print STDERR "Pricelist: $pricelistname \n"; $record = &search_for_route($astpp_db,$config,$destination,$pricelist); print STDERR "pattern: $record->{pattern}\n" if $record->{pattern}; last if $record->{pattern}; #Returnes if we've found a match. @@ -1728,12 +1729,12 @@ } $record = &search_for_route($astpp_db,$config,$destination,$config->{default_brand}); print STDERR "pattern: $record->{pattern}\n" if $record->{pattern}; - } - if ( !$record->{pattern} ) { #If we have not found a route yet then we look in the "Default" pricelist. + } + if ( !$record->{pattern} ) { #If we have not found a route yet then we look in the "Default" pricelist. $record = &search_for_route($astpp_db,$config,$destination,$config->{default_brand}); print STDERR "pattern: $record->{pattern}\n" if $record->{pattern}; - } - print STDERR "Route: $record->{comment} Cost: $record->{cost} Pricelist: $record->{pricelist} Pattern: $record->{pattern}\n" if $record; + } + print STDERR "Route: $record->{comment} Cost: $record->{cost} Pricelist: $record->{pricelist} Pattern: $record->{pattern}\n" if $record; } elsif ($type =~ /ASTPP-DID/) { Modified: trunk/astpp-ip-map.agi =================================================================== --- trunk/astpp-ip-map.agi 2008-06-01 00:42:36 UTC (rev 2183) +++ trunk/astpp-ip-map.agi 2008-06-07 04:47:11 UTC (rev 2184) @@ -21,13 +21,17 @@ #exten => _X.,n,Goto(astpp-outgoing,${EXTEN},1) use DBI; +use ASTPP; use Asterisk::AGI; use POSIX qw(ceil floor); use POSIX qw(strftime); use strict; -use vars qw(@output $verbose $AGI $config $SIG $astpp_db); +use vars qw($ASTPP @output $verbose $AGI $config $SIG $astpp_db); @output = ( "STDERR", "LOGFILE" ); $verbose = 2; +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. +$ASTPP->set_asterisk_agi($AGI); require "/usr/local/astpp/astpp-common.pl"; $AGI = new Asterisk::AGI; @@ -36,6 +40,7 @@ $config = &load_config(); $astpp_db = &connect_db( $config, @output ); $config = &load_config_db($astpp_db,$config); + $ASTPP->set_astpp_db($astpp_db); } sub ignore_hup { @@ -45,31 +50,12 @@ } } -sub get_ip() { - my ($number,$extension) = @_; - my ($sql,$tmp); - $tmp = "SELECT * FROM ip_map WHERE ip = " . $astpp_db->quote($number); - -##### I know I wrote it with the OR statement for some reason but I can't figure out why. I'm leaving it here for now. -# $tmp = "SELECT * FROM ip_map WHERE ip = " . $astpp_db->quote($number) -# . " AND prefix IS NULL OR $extension RLIKE prefix ORDER BY LENGTH(prefix) DESC LIMIT 1"; -########### -$tmp = "SELECT * FROM ip_map WHERE ip = " . $astpp_db->quote($number) - . " AND prefix IN (NULL,'') OR ip = " . $astpp_db->quote($number) . " AND " . $astpp_db->quote($extension) . " RLIKE prefix ORDER BY LENGTH(prefix) DESC LIMIT 1"; - print STDERR $tmp if $config->{debug} == 1; - $AGI->verbose( "$tmp\n", $verbose ) if $config->{debug} == 1; - $sql = - $astpp_db->prepare($tmp); - $sql->execute; - my $anidata = $sql->fetchrow_hashref; - $sql->finish; - return $anidata; -} ################# Program Starts Here ################################# my ($ip, $extension) = @ARGV; my ($sql); &initialize; -my $anidata = &get_ip($ip,$extension); +my $anidata = $ASTPP->ip_address_authenticate( ip_address => $ip, destination => $extension); + if ($anidata) { my $carddata=&get_account($astpp_db, $anidata->{account}); $AGI->set_variable( 'ACCOUNTCODE', "\"$carddata->{cc}\"" ); Added: trunk/freeswitch/README =================================================================== --- trunk/freeswitch/README (rev 0) +++ trunk/freeswitch/README 2008-06-07 04:47:11 UTC (rev 2184) @@ -0,0 +1 @@ +This directory contains the support for Freeswitch. Please be aware that this is a work under development. Added: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl (rev 0) +++ trunk/freeswitch/astpp-fs-xml.pl 2008-06-07 04:47:11 UTC (rev 2184) @@ -0,0 +1,177 @@ +#!/usr/bin/perl +# +# ASTPP - Open Source Voip Billing +# +# Copyright (C) 2008, Aleph Communications +# +# Darren Wiebe (da...@al...) +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2. +############################################################ +# +# Usage-example: +# + +use DBI; +use CGI; +use CGI qw/:standard Vars/; +use ASTPP; +use strict; +use vars qw($params $ASTPP @output $config $astpp_db $verbosity ); +use Locale::gettext_pp qw(:locale_h); +require "/usr/local/astpp/astpp-common.pl"; +$ENV{LANGUAGE} = "en"; # de, es, br - whatever +print STDERR "Interface language is set to: " . $ENV{LANGUAGE} . "\n"; +bindtextdomain( "astpp", "/usr/local/share/locale" ); +textdomain("astpp"); +$verbosity = 2; +@output = ("STDERR"); +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. + + +sub initialize() { + $config = &load_config(); + $astpp_db = &connect_db( $config, @output ); + $ASTPP->set_astpp_db($astpp_db); + $config = &load_config_db( $astpp_db, $config ) if $astpp_db; +} + +################# Programs start here ####################################### +&initialize; +my ( $xml, $maxlength, $maxmins,$callstatus ); +foreach my $param ( param() ) { + $params->{$param} = param($param); + $ASTPP->debug( debug => "$param $params->{$param}" ); +} +$xml = header(-type => 'text/plain'); + +$ASTPP->debug( debug => "Destination = $params->{'Caller-Destination-Number'}"); + +if ($params->{section} eq "dialplan") { +$xml = $ASTPP->fs_dialplan_xml_header( xml => $xml, destination_number => $params->{'Caller-Destination-Number'}); + +if (!$params->{variable_accountcode}) { +# First we strip off X digits to see if this account is prepending numbers +# as authentications + $ASTPP->debug( debug => "Checking CC Number: " . $params->{'Caller-Destination-Number'}); + my $cc = substr( $params->{'Caller-Destination-Number'}, 0, $config->{cardlength} ); + my $sql = $astpp_db->prepare("SELECT number FROM accounts WHERE cc = $cc"); + $sql->execute; + my $record = $sql->fetchrow_hashref; + $sql->finish; + $params->{variable_accountcode} = $record->{cardnum} if ($record->{cardnum}); +} +if (!$params->{variable_accountcode}) { + $ASTPP->debug( debug => "Checking IP Address:" . $params->{network_addr}); + my $ip_data = $ASTPP->ip_address_authenticate( ip_address => $params->{network_addr}, destination => $params->{'Caller-Destination-Number'}); + if ($ip_data) { + $params->{variable_accountcode} = $ip_data->{account}; + $params->{'Caller-Destination-Number'} =~ s/$ip_data->{prefix}//g; + } +} + +$ASTPP->debug( debug => "$params->{variable_accountcode}, $params->{'Caller-Destination-Number'}"); + +my $carddata = &get_account( $astpp_db, $params->{variable_accountcode} ); # Fetch all the account info from the db. + +if ( !$carddata->{number} ) { # Check to see if the account exists. If not then exit. + $ASTPP->debug( debug => "CALLSTATUS 2"); + $ASTPP->debug( debug =>"CANNOT RETRIEVE CARD"); + $xml .= "<action application=\"reject\" data=\"CANNOT RETRIEVE ACCOUNT\"/>\n"; + $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml); + print $xml; + exit(0); +} + +if ($carddata->{dialed_modify}) { + my @regexs = split(m/,/m, $carddata->{dialed_modify}); + foreach my $regex (@regexs) { + $regex =~ s/"//g; #Strip off quotation marks + my ($grab,$replace) = split(m!/!i, $regex); # This will split the variable into a "grab" and "replace" as needed + $ASTPP->debug( debug => "Grab: $grab"); + $ASTPP->debug( debug => "Replacement: $replace"); + $ASTPP->debug( debug => "Phone Before: $params->{'Caller-Destination-Number'}"); + $$params->{'Caller-Destination-Number'} =~ s/$grab/$replace/is; + $ASTPP->debug( debug => "Phone After: $params->{'Caller-Destination-Number'}" ); + } + } + +$ASTPP->debug( debug => "FINDING LIMIT FOR: " . $carddata->{number}); +($callstatus, $maxlength) = &max_length($astpp_db, $config, $carddata, $params->{'Caller-Destination-Number'}); +my $routeinfo = &get_route( $astpp_db, $config, $params->{'Caller-Destination-Number'}, $carddata->{pricelist},$carddata ); + +$ASTPP->debug( debug => "Minimum Charge on call = " . $routeinfo->{cost}); +my $minimumcharge = $routeinfo->{cost}; +my @reseller_list; +$ASTPP->debug( debug => "CALLSTATUS: $callstatus MAX_LENGTH: $maxlength"); +while ( $carddata->{reseller} && $maxlength > 1 && $callstatus == 1) { + $ASTPP->debug( debug => "FINDING LIMIT FOR: $carddata->{reseller}"); + $carddata = &get_account( $astpp_db, $carddata->{reseller} ); + push @reseller_list, $carddata->{number}; + $ASTPP->debug( debug => "ADDING $carddata->{number} to the list of resellers for this account"); + my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $carddata, $params->{'Caller-Destination-Number'}); + my $routeinfo = &get_route( $astpp_db, $config, $params->{'Caller-Destination-Number'}, $carddata->{pricelist},$carddata ); + if ($resellercallstatus != 1) { + $carddata->{reseller} = ""; + $callstatus = $resellercallstatus; + } elsif ($resellermaxlength < $maxlength) { + $maxlength = $resellermaxlength; + } + $ASTPP->debug( debug => "Reseller cost = $routeinfo->{cost} and minimum charge is $minimumcharge"); + if ($resellermaxlength < 1 || $routeinfo->{cost} > $minimumcharge ) { + $ASTPP->debug( debug => "Reseller call is priced too cheap! Call being barred!"); + $xml .= "<action application=\"reject\" data=\"Reseller call is priced too cheap! Call being barred!\"/>\n"; + $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml); + print $xml; + exit(0); + } + $ASTPP->debug( debug => "RESELLER Max Length: $resellermaxlength"); + $ASTPP->debug( debug => "RESELLER Call Status: $resellercallstatus"); +} + +if ($config->{debug} == 1) { + $ASTPP->debug( debug => "PRINTING LIST OF RESELLERS FOR THIS ACCOUNT" ); + foreach my $reseller (@reseller_list) { + $ASTPP->debugb( debug => "RESELLER: $reseller" ); + } +} + +$ASTPP->debug( "Max Call Length: $maxlength minutes" ); +$ASTPP->debug( "Call Status: $callstatus" ); + +if ( $maxlength <= 1 ) { + $ASTPP->debug( debug => "NOT ENOUGH CREDIT" ); + $xml .= "<action application=\"reject\" data=\"NOT ENOUGH CREDIT\"/>\n"; + $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml); + print $xml; + exit(0); +} + +# Set the timelimit as well as other variables which are needed in the dialplan. +my $timelimit = "L(" . sprintf( "%.0f", $maxlength * 60 * 1000 ) . ":60000:30000)"; + +$ASTPP->debug( debug => "Looking for outbound Route" ); +my $routeinfo = &get_route($astpp_db,$config,$params->{'Caller-Destination-Number'},$carddata->{pricelist},$carddata); +# Get the list of routes for the phone number. +my @outboundroutes = &get_outbound_routes( $astpp_db, $params->{'Caller-Destination-Number'},$carddata,$routeinfo, @reseller_list ); +foreach my $route (@outboundroutes) { + $ASTPP->debug( debug => "$route->{trunk}: cost $route->{cost}\t $route->{pattern}" ); + if ($route->{cost} > $routeinfo->{cost}) { + $ASTPP->debug( debug => "$route->{trunk}: $route->{cost} > $routeinfo->{cost}, skipping" ); + } else { + $xml .= $ASTPP->fs_dialplan_xml_bridge( destination_number => $params->{'Caller-Destination-Number'}, + route_prepend => $route->{prepend}, + trunk_name => $route->{trunk}); + } +} +$xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml); +} elsif ($params->{section} eq "directory") { + $xml = $ASTPP->fs_directory_xml_header( xml => $xml); + $xml = $ASTPP->fs_directory_xml( xml => $xml); + $xml = $ASTPP->fs_directory_xml_footer( xml => $xml); +} +$ASTPP->debug( debug => $xml); +print $xml; +exit(0); Property changes on: trunk/freeswitch/astpp-fs-xml.pl ___________________________________________________________________ Name: svn:executable + * Added: trunk/freeswitch/test-fs-xml.pl =================================================================== --- trunk/freeswitch/test-fs-xml.pl (rev 0) +++ trunk/freeswitch/test-fs-xml.pl 2008-06-07 04:47:11 UTC (rev 2184) @@ -0,0 +1,45 @@ +#!/usr/bin/perl +# +# ASTPP - Open Source Voip Billing +# +# Copyright (C) 2008, Aleph Communications +# +# Darren Wiebe (da...@al...) +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2. +############################################################ + +use Time::HiRes qw( gettimeofday tv_interval ); +#use HTTP::Request; +#use LWP::UserAgent; +#use URI::URL; +#use WWW::Curl; +use LWP::Simple; + + +my $starttime = [gettimeofday]; + +my $url = 'http://localhost/cgi-bin/astpp-fs-xml.pl?section=dialplan&Caller-Destination-Number=123456789&variable_accountcode=1000'; +my $url = 'http://localhost/perl/astpp-fs-xml.pl?section=dialplan&Caller-Destination-Number=123456789&variable_accountcode=1000'; + +#my $req = HTTP::Request->new(POST, $url, $headers); +#my $ua = LWP::UserAgent->new(); +#my $resp = $ua->request($req); +#if ($resp->is_success) { +# +# print $resp->content; +#} else { +# print $resp->message; +#} + +my $count = 0; +while ($count < 500) { +print $count; +$count++; +my $content = get $url; +} +print $content; + +my $generation_time = tv_interval($starttime); +print "\n\n" . $generation_time . "\n\n"; Property changes on: trunk/freeswitch/test-fs-xml.pl ___________________________________________________________________ Name: svn:executable + * Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2008-06-01 00:42:36 UTC (rev 2183) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2008-06-07 04:47:11 UTC (rev 2184) @@ -76,6 +76,140 @@ # $self->{_config} = %config_hash if %config_hash; #} +sub ip_address_authenticate #Authenticates call by caller ip address. Works with both Asterisk(tm) and Freeswitch(tm) +# Requires +# ip_address = IP Address of calling device +# destination = Dialed number +{ + my ($self, %arg) = @_; + my ($sql,$tmp); + $tmp = "SELECT * FROM ip_map WHERE ip = " . $self->{_astpp_db}->quote($arg{ip_address}) + . " AND prefix IN (NULL,'') OR ip = " . $self->{_astpp_db}->quote($arg{ip_address}) + . " AND " . $self->{_astpp_db}->quote($arg{destination}) . " RLIKE prefix ORDER BY LENGTH(prefix) DESC LIMIT 1"; + $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + my $anidata = $sql->fetchrow_hashref; + $sql->finish; + return $anidata; +} + +sub fs_dialplan_xml_header +#Return the opening lines of the Freeswitch(TM) xml dialplan +{ + my ($self, %arg) = @_; + $arg{xml} .= "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; + $arg{xml} .= "<document type=\"freeswitch/xml\">\n"; + $arg{xml} .= "<section name=\"dialplan\" description=\"ASTPP Dynamic Routing\">\n"; + $arg{xml} .= "<context name=\"default\">\n"; + $arg{xml} .= "<extension name=\"$arg{destination_number}\">\n"; + $arg{xml} .= "<condition field=\"destination_number\" expression=\"$arg{destination_number}\">\n"; + return $arg{xml}; +} + +sub fs_dialplan_xml_bridge +#Return the bridge command along with details. This is only called if a call is approved. +# Requires the following variables: +# destination_number = The number we are trying to call +# trunk_name = The name of the trunk we're using. +# route_prepend = What do we tag on for numbers on this route? +{ + my ($self, %arg) = @_; + my ( $sql, $trunkdata, $dialstring ); + $sql = $self->{_astpp_db}->prepare( "SELECT * FROM trunks WHERE name = " + . $self->{_astpp_db}->quote( $arg{trunk_name} ) ); + $sql->execute; + $trunkdata = $sql->fetchrow_hashref; + $arg{route_prepend} = "" if !$arg{route_prepend}; + $sql->finish; + if ($trunkdata->{dialed_modify} && $trunkdata->{dialed_modify} ne "") { + my @regexs = split(m/","/m, $trunkdata->{dialed_modify}); + foreach my $regex (@regexs) { + $regex =~ s/"//g; #Strip off quotation marks + my ($grab,$replace) = split(m!/!i, $regex); # This will split the variable into a "grab" and "replace" as needed + print STDERR "Grab: $grab\n"; + print STDERR "Replacement: $replace\n"; + print STDERR "Phone Before: $arg{destination_number}\n"; + $arg{destination_number} =~ s/$grab/$replace/is; + print STDERR "Phone After: $arg{destination_number}\n"; + } + } + if ( $trunkdata->{tech} eq "Zap" ) { + $dialstring = "<action application=\"bridge\" data=\"openzap/" . $trunkdata->{path} . "/1/" . $arg{route_prepend} . $arg{destination_number}. "\"/>\n"; + return $dialstring; + } + elsif ( $trunkdata->{tech} eq "SIP" ) { + my ($profile,$dest) = split(m/","/m, $trunkdata->{path}); + $profile =~ s/"//g; #Strip off quotation marks + $dest =~ s/"//g; #Strip off quotation marks + if ($profile eq "gateway") { + $dialstring = "<action application=\"bridge\" data=\"sofia/gateway/" . $dest . "/" . $arg{route_prepend} . $arg{destination_number} . "\"/>\n"; + } else { + $dialstring = "<action application=\"bridge\" data=\"sofia/" . $profile . "/" . $arg{route_prepend} . $arg{destination_number} . "\@" . $dest . "\"/>\n"; + } + return $dialstring; + } + else { + print STDERR "CANNOT ROUTE THIS CALL!!!!!\n"; + return ""; + } +} + +sub fs_dialplan_xml_footer +#Return the closing lines of the Freeswitch(TM) xml dialplan +{ + my ($self, %arg) = @_; + $arg{xml} .= "</condition>\n"; + $arg{xml} .= "</extension>\n"; + $arg{xml} .= "</context>\n"; + $arg{xml} .= "</section>\n"; + $arg{xml} .= "</document>\n"; + return $arg{xml}; +} + +sub fs_directory_xml_header +#Return the opening lines of the Freeswitch(TM) xml directory +#xml = Current XML code, usually blank. +#domain = domain name +{ + my ($self, %arg) = @_; + $arg{xml} .= "<?xml version=\"1.0\"?>\n"; + $arg{xml} .= "<document type=\"freeswitch/xml\">\n"; + $arg{xml} .= "<section name=\"directory\" description=\"User Directory\">\n"; + $arg{xml} .= "<domain name=\"" . $arg{domain} . "\">\n"; + return $arg{xml}; +} + +sub fs_directory_xml +#Return the user detail lines for Freeswitch(TM) sip athentication. +#xml = Current XML code +{ + my ($self, %arg) = @_; + my ($sql); + $sql = $self->{_astpp_db}->prepare("SELECT * FROM fs_users"); + $sql->execute; + while (my $record = $sql->fetchrow_hashref) { + $arg{xml} .= "<user id=\"" . $record->{user} . "\">\n"; + $arg{xml} .= "<params>\n"; + $arg{xml} .= "<param name=\"password\" value=\"" . $record->{password} . "\"/>\n"; + $arg{xml} .= "</params>\n"; + $arg{xml} .= "</user>\n"; + }; + return $arg{xml}; +} + + + +sub fs_directory_xml_footer +#Return the closing lines of the Freeswitch(TM) xml dialplan +#xml = Current XML code +{ + my ($self, %arg) = @_; + $arg{xml} .= "</domain>\n"; + $arg{xml} .= "</section>\n"; + $arg{xml} .= "</document>\n"; + return $arg{xml}; +} + sub debug #Prints debugging if appropriate # { @@ -208,7 +342,6 @@ =head1 SYNOPSIS use ASTPP; - blah blah blah =head1 DESCRIPTION This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-06-01 00:42:30
|
Revision: 2183 http://astpp.svn.sourceforge.net/astpp/?rev=2183&view=rev Author: darrenkw Date: 2008-05-31 17:42:36 -0700 (Sat, 31 May 2008) Log Message: ----------- Added a copy of the logo in .png format. Added Paths: ----------- trunk/astpp.png Added: trunk/astpp.png =================================================================== (Binary files differ) Property changes on: trunk/astpp.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-05-31 20:44:14
|
Revision: 2182 http://astpp.svn.sourceforge.net/astpp/?rev=2182&view=rev Author: darrenkw Date: 2008-05-31 13:44:22 -0700 (Sat, 31 May 2008) Log Message: ----------- Finished the logging support as per [ 1825335 ] DID Change Logs. Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-05-25 23:15:33 UTC (rev 2181) +++ trunk/astpp-admin.cgi 2008-05-31 20:44:22 UTC (rev 2182) @@ -11136,10 +11136,15 @@ my $template = HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); +my $log_call = "astpp-admin.cgi,user=$param->{username}"; foreach my $param ( param() ) { $params->{$param} = param($param); $ASTPP->debug( user=> $param->{username}, debug => "$param $params->{$param}" ); + $log_call .= "$param=$params->{param},"; } + +$ASTPP->debug( debug => $log_call ); + if ( !$params->{mode} ) { $params->{mode} = gettext("Home"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-05-25 23:15:29
|
Revision: 2181 http://astpp.svn.sourceforge.net/astpp/?rev=2181&view=rev Author: darrenkw Date: 2008-05-25 16:15:33 -0700 (Sun, 25 May 2008) Log Message: ----------- Added support to prepend digits in front of those autogenerated. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-common.pl Added Paths: ----------- trunk/sql/astpp-2008-05-25.sql Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-05-21 22:52:55 UTC (rev 2180) +++ trunk/astpp-admin.cgi 2008-05-25 23:15:33 UTC (rev 2181) @@ -9684,6 +9684,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $sipid = $config->{sip_ext_prepend} . $sipid; $sipid = substr( $sipid, 0, 5 ); $sipid = $name . $sipid; $ASTPP->debug( user=> $param->{username}, debug => "SIPID: $sipid" ); @@ -10110,6 +10111,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $iaxid = $config->{iax2_ext_prepend} . $iaxid; $iaxid = substr( $iaxid, 0, 5 ); $iaxid = $name . $iaxid; $ASTPP->debug( user=> $param->{username}, debug => "IAXID: $iaxid"); Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-05-21 22:52:55 UTC (rev 2180) +++ trunk/astpp-common.pl 2008-05-25 23:15:33 UTC (rev 2181) @@ -95,6 +95,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $pin = $config->{pin_cc_prepend} . $pin; $pin = substr( $pin, 0, $config->{pinlength} ); } $sql = @@ -1835,6 +1836,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $pin = $config->{pin_act_prepend} . $pin; if ( $config->{startingdigit} ne "" && $config->{startingdigit} ne "0" ) { @@ -1880,6 +1882,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $cc = $config->{cc_prepend} . $cc; if ( $config->{startingdigit} ne "" && $config->{startingdigit} ne "0" ) { @@ -1925,6 +1928,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $cc = $config->{cc_prepend} . $cc; if ( $config->{startingdigit} ne "" && $config->{startingdigit} ne "0" ) { @@ -2744,6 +2748,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $sipid = $config->{sip_ext_prepend} . $sipid; $sipid = substr( $sipid, 0, 5 ); $sipid = $name . $sipid; print STDERR "SIPID: $sipid\n" if $config->{debug} == 1; @@ -2775,6 +2780,7 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); + $iaxid = $config->{iax2_ext_prepend} . $iaxid; $iaxid = substr( $iaxid, 0, 5 ); $iaxid = $name . $iaxid; print STDERR "IAXID: $iaxid\n" if $config->{debug} == 1; Added: trunk/sql/astpp-2008-05-25.sql =================================================================== --- trunk/sql/astpp-2008-05-25.sql (rev 0) +++ trunk/sql/astpp-2008-05-25.sql 2008-05-25 23:15:33 UTC (rev 2181) @@ -0,0 +1,1292 @@ +DROP TABLE IF EXISTS `routes`; +CREATE TABLE routes ( +id INTEGER NOT NULL AUTO_INCREMENT, +pattern CHAR(40), +comment CHAR(80), +connectcost INTEGER NOT NULL, +includedseconds INTEGER NOT NULL, +cost INTEGER NOT NULL, +pricelist CHAR(80), +inc INTEGER, +reseller CHAR(50) default NULL, +precedence INT(4) NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), +KEY `pattern` (`pattern`), +KEY `pricelist` (`pricelist`), +KEY `reseller` (`reseller`), +KEY `status` (`status`) +); + +DROP TABLE IF EXISTS `pricelists`; +CREATE TABLE pricelists ( +name CHAR(40) NOT NULL, +markup INTEGER NOT NULL DEFAULT 0, +inc INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +reseller CHAR(50) default NULL, +PRIMARY KEY (`name`) +); + +DROP TABLE IF EXISTS `callingcardbrands`; +CREATE TABLE callingcardbrands ( +name CHAR(40) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +validfordays CHAR(4) NOT NULL DEFAULT '', +pin INTEGER NOT NULL DEFAULT 0, +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `pricelist` (`pricelist`) +); + +DROP TABLE IF EXISTS `callingcardcdrs`; +CREATE TABLE callingcardcdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(50) NOT NULL DEFAULT '', +clid CHAR(80) NOT NULL DEFAULT '', +destination CHAR(40) NOT NULL DEFAULT '', +disposition CHAR(20)NOT NULL DEFAULT '', +callstart CHAR(40) NOT NULL DEFAULT '', +seconds INTEGER NOT NULL DEFAULT 0, +debit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +credit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +status INTEGER DEFAULT 0 NOT NULL, +uniqueid VARCHAR(32) NOT NULL DEFAULT '', +notes CHAR(80) NOT NULL DEFAULT '', +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `cardnumber` (`cardnumber`) +); + +DROP TABLE IF EXISTS `trunks`; +CREATE TABLE trunks ( +name VARCHAR(30) NOT NULL, +tech CHAR(10) NOT NULL DEFAULT '', +path CHAR(40) NOT NULL DEFAULT '', +provider CHAR(100) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +dialed_modify TEXT NOT NULL DEFAULT '', +resellers TEXT NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +maxchannels INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (`name`), + KEY `provider` (`provider`), + KEY `provider_2` (`provider`) +); + +DROP TABLE IF EXISTS `outbound_routes`; +CREATE TABLE outbound_routes ( +pattern CHAR(40), +id INTEGER NOT NULL AUTO_INCREMENT, +comment CHAR(80) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +trunk CHAR(80) NOT NULL DEFAULT '', +inc CHAR(10) NOT NULL DEFAULT '', +strip CHAR(40) NOT NULL DEFAULT '', +prepend CHAR(40) NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +resellers TEXT NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `trunk` (`trunk`), + KEY `pattern` (`pattern`) +); + +DROP TABLE IF EXISTS `dids`; +CREATE TABLE dids ( +number CHAR(40) NOT NULL, +account CHAR(50) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +monthlycost INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +inc CHAR(10) NOT NULL DEFAULT '', +extensions CHAR(180) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +provider CHAR(40) NOT NULL DEFAULT '', +country CHAR (80)NOT NULL DEFAULT '', +province CHAR (80) NOT NULL DEFAULT '', +city CHAR (80) NOT NULL DEFAULT '', +prorate int(1) NOT NULL default 0, +setup int(11) NOT NULL default 0, +limittime int(1) NOT NULL default 1, +disconnectionfee INT(11) NOT NULL default 0, +variables TEXT NOT NULL DEFAULT '', +options varchar(40) default NULL, +maxchannels int(4) NOT NULL default 0, +chargeonallocation int(1) NOT NULL default 1, +allocation_bill_status int(1) NOT NULL default 0, +dial_as CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `account` (`account`) +); + +DROP TABLE IF EXISTS `accounts`; +CREATE TABLE accounts ( +cc CHAR(20) NOT NULL DEFAULT '', +number CHAR(50) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(24) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +credit INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +creation TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +pin INTEGER NOT NULL DEFAULT 0, +credit_limit INTEGER NOT NULL DEFAULT 0, +posttoexternal INTEGER NOT NULL DEFAULT 0, +balance DECIMAL(20,6) NOT NULL DEFAULT 0, +password CHAR(80) NOT NULL DEFAULT '', +first_name CHAR(40) NOT NULL DEFAULT '', +middle_name CHAR(40) NOT NULL DEFAULT '', +last_name CHAR(40) NOT NULL DEFAULT '', +company_name CHAR(40) NOT NULL DEFAULT '', +address_1 CHAR(80) NOT NULL DEFAULT '', +address_2 CHAR(80) NOT NULL DEFAULT '', +address_3 CHAR(80) NOT NULL DEFAULT '', +postal_code CHAR(12) NOT NULL DEFAULT '', +province CHAR(40) NOT NULL DEFAULT '', +city CHAR(80) NOT NULL DEFAULT '', +country CHAR(40) NOT NULL DEFAULT '', +telephone_1 CHAR(40) NOT NULL DEFAULT '', +telephone_2 CHAR(40) NOT NULL DEFAULT '', +fascimile CHAR(40) NOT NULL DEFAULT '', +email CHAR(80) NOT NULL DEFAULT '', +language CHAR(2) NOT NULL DEFAULT '', +currency CHAR(3) NOT NULL DEFAULT '', +maxchannels INTEGER DEFAULT 1 NOT NULL, +routing_technique INT(4) NOT NULL DEFAULT 0, +dialed_modify TEXT NOT NULL DEFAULT '', +type INTEGER DEFAULT 0, +tz CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +DROP TABLE IF EXISTS `counters`; +CREATE TABLE counters ( +id INTEGER NOT NULL AUTO_INCREMENT, +package CHAR(40) NOT NULL DEFAULT '', +account VARCHAR(50) NOT NULL, +seconds INTEGER NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +DROP TABLE IF EXISTS `callingcards`; +CREATE TABLE callingcards ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(20) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +value INTEGER NOT NULL DEFAULT 0, +used INTEGER NOT NULL DEFAULT 0, +brand VARCHAR(20) NOT NULL DEFAULT '', +created DATETIME, +firstused DATETIME, +expiry DATETIME, +validfordays CHAR(4) NOT NULL DEFAULT '', +inuse INTEGER NOT NULL DEFAULT 0, +pin CHAR(20), +account VARCHAR(50) NOT NULL DEFAULT '', +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +maint_day INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +timeused INTEGER NOT NULL DEFAULT 0, +invoice CHAR(20) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `brand` (`brand`) +); + +CREATE TABLE charge_to_account ( +id INTEGER NOT NULL AUTO_INCREMENT, +charge_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(50) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +CREATE TABLE queue_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +queue_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE pbx_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +pbx_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE extension_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +extension_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE cdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +uniqueid varchar(32) NOT NULL DEFAULT '', +cardnum CHAR(50), +callerid CHAR(80), +callednum varchar(80) NOT NULL DEFAULT '', +billseconds INT DEFAULT 0 NOT NULL, +trunk VARCHAR(30), +disposition varchar(45) NOT NULL DEFAULT '', +callstart varchar(80) NOT NULL DEFAULT '', +debit DECIMAL (20,6) NOT NULL DEFAULT 0, +credit DECIMAL (20,6) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 0 NOT NULL, +notes CHAR(80), +provider CHAR(50), +cost DECIMAL(20,6) NOT NULL DEFAULT 0, +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `cardnum` (`cardnum`), + KEY `provider` (`provider`), + KEY `trunk` (`trunk`), + KEY `uniqueid` (`uniqueid`), + KEY `status` (`status`) +); + +CREATE TABLE packages ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +pattern CHAR(40) NOT NULL DEFAULT '', +includedseconds INTEGER NOT NULL DEFAULT 0, +reseller VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE ani_map ( +number char(20) NOT NULL, +account char(50) NOT NULL default '', +status int(11) NOT NULL default '0', +context varchar(20) NOT NULL, + PRIMARY KEY (`number`), +KEY `account` (`account`) +); + +CREATE TABLE `ip_map` ( +ip char(15) NOT NULL default '', +account char(20) NOT NULL default '', +prefix varchar(20) NULL, +context varchar(20) NOT NULL, +PRIMARY KEY (`ip`,`prefix`), +KEY `account` (`account`) +); + +CREATE TABLE charges ( +id INTEGER NOT NULL AUTO_INCREMENT, +pricelist CHAR(40) NOT NULL DEFAULT '', +description VARCHAR(80) NOT NULL DEFAULT '', +charge INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +reseller CHAR(40) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`) +); + +CREATE TABLE manager_action_variables ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(60) NOT NULL DEFAULT '', +value CHAR(60) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE callingcard_stats ( +uniqueid VARCHAR(48) NOT NULL, +total_time VARCHAR(48) NOT NULL, +billable_time VARCHAR(48) NOT NULL, +timestamp DATETIME NULL, +PRIMARY KEY (`uniqueid`) +); + +CREATE TABLE system ( +name VARCHAR(48) NULL, +value VARCHAR(255) NULL, +comment VARCHAR(255) NULL, +timestamp DATETIME NULL, +reseller VARCHAR(48) NULL, +brand VARCHAR(48) NULL, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `brand` (`brand`) +); + + +INSERT INTO system (name, value, comment) VALUES ( +'callout_accountcode','admin','Call Files: What accountcode should we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'lcrcontext', +'astpp-outgoing', +'This is the Local context we use to route our outgoing calls through esp for callbacks'); + + +INSERT INTO system (name, value, comment) VALUES ( +'maxretries', +'3', +'Call Files: How many times do we retry?'); + +INSERT INTO system (name, value, comment) VALUES ( +'retrytime', +'30', +'Call Files: How long do we wait between retries?'); + +INSERT INTO system (name, value, comment) VALUES ( +'waittime', +'15', +'Call Files: How long do we wait before the initial call?'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidname', +'Private', +'Call Files: Outgoing CallerID Name'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidnumber', +'0000000000', +'Call Files: Outgoing CallerID Number'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_context', +'astpp-callingcards', +'Call Files: For callingcards what context do we end up in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_extension', 's', +'Call Files: For callingcards what extension do we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser_dbengine', '0', +'For now this must be MySQL'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser', '0', +'Use OPENSER? 1 for yes or 0 for no'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbname', '0', +'OPENSER Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbuser', '0', +'OPENSER Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbhost', '0', +'OPENSER Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbpass', '0', +'OPENSER Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_domain', NULL, +'OPENSER Domain', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_email', 'em...@as...', +'Email address that email should appear to be from', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_dir', '/etc/asterisk', +'Which directory are asterisk configuration files stored in?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_website', 'http://www.astpp.org', +'Link to your company website', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_name', 'ASTPP.ORG', +'The name of your company. Used in emails.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'email', '1', +'Send out email? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'user_email', '1', +'Email user on account changes? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'debug', '0', +'Enable debugging output? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'emailadd', 'em...@as...', +'Administrator email address', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'startingdigit', '0', +'The digit that all calling cards must start with. 0=disabled', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'enablelcr', '1', +'Use least cost routing 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'log_file', '/var/log/astpp/astpp.log', +'ASTPP Log file', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key_home', 'http://www.astpp.org/astpp.pub', +'Asterisk RSA Key location (optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rate_engine_csv_file', '/var/log/astpp/astpp.csv', +'CSV File for call rating data', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'csv_dir', '/var/log/astpp/', +'CSV File Directory', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_brand', 'default', +'Default pricelist. If a price is not found in the customers pricelist we check this one.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'new_user_brand', 'default', +'What is the default pricelist for new customers?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_context', 'custom-astpp', +'What is the default context for new devices?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cardlength', '10', +'Number of digits in calling cards and cc codes.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_server', 'voip.astpp.org', +'Your default voip server. Used in outgoing email.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'currency', 'CAD', +'Name of the currency you use', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'iax_port', '4569', +'Default IAX2 Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sip_port', '5060', +'Default SIP Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'ipaddr', 'dynamic', +'Default IP Address for new devices', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key', 'astpp.pub', +'Asterisk RSA Key Name (Optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pinlength', '6', +'For those calling cards that are using pins this is the number of digits it will have.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'credit_limit', '0', +'Default credit limit in dollars.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints', '4', +'How many decimal points do we bill to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'max_free_length', '100', +'What is the maximum length (in minutes) of calls that are at no charge?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'trackvendorcharges', '1', +'Do we track the amount of money we spend with specific providers? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_logo', 'http://www.astpp.org/logo.png', +'', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_slogan', 'Welcome to ASTPP', +'', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'version', '1.5Beta', 'ASTPP Version', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_language', 'en', 'Default ASTPP Language',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'card_retries','3', 'How many retries do we allow for calling card numbers?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pin_retries','3', 'How many retries do we allow for pins?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'number_retries','3','How many retries do we allow calling card users when dialing a number?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'booth_context','callshop_booth','Please enter the default context for a callshop booth.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards_max_length','9000','What is the maximum length (in ms) of a callingcard call?',''); + +INSERT INTO system (name,value,comment,timestamp) VALUES ( +'template_die_on_bad_params','0','Should HTML::Template die on bad parameters?',''); +-- +-- This is where the old "enh-config" settings start +-- + +INSERT INTO system (name, value, comment, timestamp) VALUES ('results_per_page','30','How many results per page do we should in the web interface?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astpp_dir','/var/lib/astpp','Where do the astpp configs live?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'auth','a23asudf9810-zalkj32423','This is the override authorization code and will allow access to the system.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_dbengine','MySQL','Database type for Asterisk(tm) -Realtime',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbengine','MySQL','Database type for the cdr database',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_dbengine','MySQL','Database type for OSCommerce',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbengine','MySQL','Database type for AgileBill(tm)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_dbengine','MySQL','Database type for FreePBX',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'externalbill','oscommerce','Please specify the external billing application to use. If you are not using any then leave it blank. Valid options are "agile" and "oscommerce".',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards','1','Do you wish to enable calling cards? 1 for yes and 2 for no.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astcdr','1','Change this one at your own peril. If you switch it off, calls will not be marked as billed in asterisk once they are billed.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'posttoastpp','1','Change this one at your own peril. If you switch it off, calls will not be written to astpp when they are calculated.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sleep','10','How long shall the rating engine sleep after it has been notified of a hangup? (in seconds)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_amp','0','If this is enabled, ASTPP will create users and DIDs in the FreePBX (www.freepbx.org) database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_rt','1','If this is enabled, ASTPP will create users and DIDs in the Asterisk Realtime database.',''); + +INSERT INTO system (name, value, comment) VALUES ( +'service_prepend','778',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_length,','7',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_filler','4110000',''); + +INSERT INTO system (name, value, comment) VALUES ( +'asterisk_cdr_table','cdr','Which table of the Asterisk(TM) database are the cdrs in?' +); + +-- AgileBill(Trademark of AgileCo) Settings: +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_db','agile','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_site_id','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_charge_status','0','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_taxable','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbprefix','_','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_service_prepend','778','',''); + +-- OSCommerce Settings (www.oscommerce.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_db','oscommerce','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_pass','password','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_product_id','99999999','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_payment_method','"Charge"','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_order_status','1','',''); + +-- FreePBX Settings (www.freepbx.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_db','asterisk','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_pass','passw0rd','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_dtmfmode','rfc2833','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_callgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_pickupgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_notransfer','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_qualify','yes','',''); + +-- Asterisk -realtime Settings +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_db','realtime','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_insecure','very','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_type','friend','',''); +INSERT INTO system (name, value, comment) VALUES ( +'rt_voicemail_table','voicemail_users',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_rate_announce','1','Do we want the calling cards script to announce the rate on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_timelimit_announce','1','Do we want the calling cards script to announce the timelimit on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_cancelled_prompt','1','Do we want the calling cards script to announce that the call was cancelled?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_menu','1','Do we want the calling cards script to present a menu before exiting?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_connection_prompt','1','Do we want the calling cards script to announce that it is connecting the call?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_pin_input_timeout','15000','How long do we wait when entering the calling card pin? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_number_input_timeout','15000','How long do we wait when entering the calling card number? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_dial_input_timeout','15000','How long do we wait when entering the destination number in calling cards? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_general_input_timeout','15000','How long do we wait for input in general menus? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_welcome_file','silence/1','What do we play for a welcome file?'); + +INSERT INTO system (name, value, comment) VALUES ( +'sip_ext_prepend','10','What should every autoadded SIP extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'iax2_ext_prepend','10','What should every autoadded IAX2 extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'cc_prepend','','What should every autoadded callingcard begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_cc_prepend','','What should every autoadded callingcard pin begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_act_prepend','','What should every autoadded account pin begin with?'); + + +-- +-- Enough Configuration settings +-- + +DROP TABLE IF EXISTS `countrycode`; +CREATE TABLE `countrycode` ( + `country` varchar(255) NOT NULL, + PRIMARY KEY (`country`), + KEY `country` (`country`) +); + +INSERT INTO `countrycode` (`country`) VALUES + ('Afghanistan'), + ('Alaska'), + ('Albania'), + ('Algeria'), + ('AmericanSamoa'), + ('Andorra'), + ('Angola'), + ('Antarctica'), + ('Argentina'), + ('Armenia'), + ('Aruba'), + ('Ascension'), + ('Australia'), + ('Austria'), + ('Azerbaijan'), + ('Bahrain'), + ('Bangladesh'), + ('Belarus'), + ('Belgium'), + ('Belize'), + ('Benin'), + ('Bhutan'), + ('Bolivia'), + ('Bosnia & Herzegovina'), + ('Botswana'), + ('Brazil'), + ('Brunei Darussalam'), + ('Bulgaria'), + ('Burkina Faso'), + ('Burundi'), + ('Cambodia'), + ('Cameroon'), + ('Canadda'), + ('Cape Verde Islands'), + ('Central African Republic'), + ('Chad'), + ('Chile'), + ('China'), + ('Colombia'), + ('Comoros'), + ('Congo'), + ('Cook Islands'), + ('Costa Rica'), + ('Croatia'), + ('Cuba'), + ('Cuba Guantanamo Bay'), + ('Cyprus'), + ('Czech Republic'), + ('Denmark'), + ('Diego Garcia'), + ('Djibouti'), + ('Dominican Republic'), + ('East Timor'), + ('Ecuador'), + ('Egypt'), + ('El Salvador'), + ('Equatorial Guinea'), + ('Eritrea'), + ('Estonia'), + ('Ethiopia'), + ('Faroe Islands'); +INSERT INTO `countrycode` (`country`) VALUES + ('Fiji Islands'), + ('Finland'), + ('France'), + ('French Guiana'), + ('French Polynesia'), + ('Gabonese Republic'), + ('Gambia'), + ('Georgia'), + ('Germany'), + ('Ghana'), + ('Gibraltar'), + ('Greece'), + ('Greenland'), + ('Guadeloupe'), + ('Guam'), + ('Guatemala'), + ('Guinea'), + ('Guyana'), + ('Haiti'), + ('Honduras'), + ('Hong Kong'), + ('Hungary'), + ('Iceland'), + ('India'), + ('Indonesia'), + ('Iran'), + ('Iraq'), + ('Ireland'), + ('Israel'), + ('Italy'), + ('Jamaica'), + ('Japan'), + ('Jordan'), + ('Kazakstan'), + ('Kenya'), + ('Kiribati'), + ('Kuwait'), + ('Kyrgyz Republic'), + ('Laos'), + ('Latvia'), + ('Lebanon'), + ('Lesotho'), + ('Liberia'), + ('Libya'), + ('Liechtenstein'), + ('Lithuania'), + ('Luxembourg'), + ('Macao'), + ('Madagascar'), + ('Malawi'), + ('Malaysia'), + ('Maldives'), + ('Mali Republic'), + ('Malta'), + ('Marshall Islands'), + ('Martinique'), + ('Mauritania'), + ('Mauritius'), + ('MayotteIsland'), + ('Mexico'), + ('Midway Islands'), + ('Moldova'), + ('Monaco'), + ('Mongolia'), + ('Morocco'); +INSERT INTO `countrycode` (`country`) VALUES + ('Mozambique'), + ('Myanmar'), + ('Namibia'), + ('Nauru'), + ('Nepal'), + ('Netherlands'), + ('Netherlands Antilles'), + ('New Caledonia'), + ('New Zealand'), + ('Nicaragua'), + ('Niger'), + ('Nigeria'), + ('Niue'), + ('Norfolk Island'), + ('North Korea'), + ('Norway'), + ('Oman'), + ('Pakistan'), + ('Palau'), + ('Palestinian Settlements'), + ('Panama'), + ('PapuaNew Guinea'), + ('Paraguay'), + ('Peru'), + ('Philippines'), + ('Poland'), + ('Portugal'), + ('Puerto Rico'), + ('Qatar'), + ('RéunionIsland'), + ('Romania'), + ('Russia'), + ('Rwandese Republic'), + ('San Marino'), + ('São Tomé and Principe'), + ('Saudi Arabia'), + ('Senegal '), + ('Serbia and Montenegro'), + ('Seychelles Republic'), + ('Sierra Leone'), + ('Singapore'), + ('Slovak Republic'), + ('Slovenia'), + ('Solomon Islands'), + ('Somali Democratic Republic'), + ('South Africa'), + ('South Korea'), + ('Spain'), + ('Sri Lanka'), + ('St Kitts - Nevis'), + ('St. Helena'), + ('St. Lucia'), + ('St. Pierre & Miquelon'), + ('St. Vincent & Grenadines'), + ('Sudan'); +INSERT INTO `countrycode` (`country`) VALUES + ('Suriname'), + ('Swaziland'), + ('Sweden'), + ('Switzerland'), + ('Syria'), + ('Taiwan'), + ('Tajikistan'), + ('Tanzania'), + ('Thailand'), + ('Togolese Republic'), + ('Tokelau'), + ('Tonga Islands'), + ('Trinidad & Tobago'), + ('Tunisia'), + ('Turkey'), + ('Turkmenistan'), + ('Tuvalu'), + ('Uganda'), + ('Ukraine'), + ('United Arab Emirates'), + ('United Kingdom'), + ('United States of America'), + ('Uruguay'), + ('Uzbekistan'), + ('Vanuatu'), + ('Venezuela'), + ('Vietnam'), + ('Wake Island'), + ('Wallisand Futuna Islands'), + ('Western Samoa'), + ('Yemen'), + ('Zambia'), + ('Zimbabwe'); + +DROP TABLE IF EXISTS `currency`; +CREATE TABLE `currency` ( + `Currency` varchar(3) NOT NULL default '', + `CurrencyName` varchar(40) NOT NULL default '', + PRIMARY KEY (`Currency`) +); + +INSERT INTO `currency` (`Currency`,`CurrencyName`) VALUES + ('USD','US Dollars'), + ('CAD','Canadian Dollars'), + ('AUD','Australian Dollars'); + +CREATE TABLE `language` ( + `language` varchar(5) NOT NULL, + `languagename` varchar(40) NOT NULL, + `active` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`language`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `language` (`language`,`languagename`,`active`) VALUES + ('en','English',1), + ('fr','French',1), + ('de','German',1); + +CREATE TABLE `resellers` ( + name varchar(40) NOT NULL default '', + status int(11) NOT NULL default '1', + posttoexternal int(11) NOT NULL default '0', + agile_site_id int(11) NOT NULL default '0', + config_file char(80) NOT NULL default 'reseller.conf', + companyname varchar(255) default NULL, + slogan varchar(255) default NULL, + footer varchar(255) default NULL, + pricelist varchar(255) default NULL, + currency varchar(255) default NULL, + logo varchar(255) default NULL, + website varchar(255) default NULL, + adminemail varchar(255) default NULL, + salesemail varchar(255) default NULL, + phone varchar(45) default NULL, + fax varchar(45) default NULL, + address1 varchar(255) default NULL, + address2 varchar(255) default NULL, + city varchar(255) default NULL, + state varchar(255) default NULL, + postcode varchar(255) default NULL, + country varchar(255) default NULL, + defaultbrand varchar(45) NOT NULL default 'default', + defaultcurrency varchar(45) NOT NULL default 'USD', + defaultcredit varchar(45) NOT NULL default '0.00', + externalbill varchar(45) NOT NULL default '', + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +CREATE TABLE templates ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +reseller VARCHAR(45) NOT NULL default '', +template TEXT NOT NULL default '', + PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +INSERT INTO templates (name,template) VALUES +('voip_account_refilled','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been refilled. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('voip_reactivate_account','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been reactivated. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_add_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been added. +Your Username is -- $vars->{extension} -- +Your Password is -- $vars->{secret} -- +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('add_sip_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In sip.conf: +[$config->{company_name}-in] +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=from-pstn +accountcode=$config->{company_name} +[$config->{company_name}] +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid= <555-555-5555> +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +In the [globals] section add: +register => $vars->{user}:password@$config->{asterisk_server}'); + +INSERT INTO templates (name,template) VALUES +('add_iax_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In iax.conf: +At the bottom of the file add: +[$config->{company_name}-in] +;trunk=yes ;optional .. only works if you have a zaptel or ztdummy driver running +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=incoming +accountcode=$config->{company_name} ;for call tracking in the cdr +[$config->{company_name}] +;to simplify and config outgoing calls +;trunk=yes ;optional .. only works if you have a zaptel driver running +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid=<555-555-5555> ;only the number will really be used +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_remove_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP Termination with $config->{company_name} has been removed +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_calling_card','You have added a $vars->{pricelist} callingcard in the amount of $vars->{pennies} cents. +Card Number $cc Pin: $pin +Thanks for your patronage. +The $config->{company_name} sales team'); + +INSERT INTO templates (name,template) VALUES +('email_add_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been added +The number is: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team +Here is a sample setup which would call a few sip phones with incoming calls: +[incoming] +exten => _1$did,1,Wait(2) +exten => _1$did,2,Dial(SIP/2201&SIP/2202,15,Ttm) ; dial a couple of phones for 15 secs +exten => _1$did,3,Voicemail(u1000) ; go to unavailable voicemail (vm box 1000) +exten => _1$did,103,Voicemail(b1000) ; go to busy voicemail (vm box 1000)'); + +INSERT INTO templates (name,template) VALUES +('email_remove_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been removed +The number was: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_new_invoice','Invoice # $invoice in the amount of \$$total has been added to your account. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_low_balance','Your VOIP account with $config->{company_name} has a balance of \$$balance. +Please visit our website to refill your account to ensure uninterrupted service. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +CREATE TABLE `sweeplist` ( + `Id` int(10) unsigned NOT NULL default '0', + `sweep` varchar(45) NOT NULL default '', + PRIMARY KEY (`Id`) +); + +INSERT INTO sweeplist (Id,sweep) VALUES +(0,'daily'), +(1,'weekly'), +(2,'monthly'), +(3,'quarterly'), +(4,'semi-annually'), +(5,'annually') +; + +CREATE TABLE userlevels ( +userlevelid int(11) NOT NULL, +userlevelname varchar(50) NOT NULL, +PRIMARY KEY (`userlevelid`) +); + +INSERT INTO `userlevels` (`userlevelid`,`userlevelname`) VALUES + (-1,'Administrator'), + (0,'Anonymous'), + (1,'Reseller'), + (2,'Admin'), + (3,'Vendor'), + (4,'Customer Service'), + (5,'Users'); + +CREATE TABLE reseller_pricing ( +id INTEGER NOT NULL AUTO_INCREMENT, +reseller VARCHAR(50) NOT NULL, +type INTEGER NOT NULL DEFAULT 1, +monthlycost INTEGER NOT NULL DEFAULT 0, +prorate INTEGER NOT NULL DEFAULT 0, +setup INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +note VARCHAR(50) NOT NULL DEFAULT '', +disconnectionfee INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +inc CHAR(10) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE callshops ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(50) NOT NULL, +osc_dbname VARCHAR(50) NOT NULL DEFAULT '', +osc_dbpass VARCHAR(50) NOT NULL DEFAULT '', +osc_dbuser VARCHAR(50) NOT NULL DEFAULT '', +osc_dbhost VARCHAR(50) NOT NULL DEFAULT '', +osc_site VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), +KEY `name` (`name`) +); + +CREATE TABLE extensions_status ( +id INTEGER NOT NULL AUTO_INCREMENT, +tech VARCHAR(6) NULL, +extension VARCHAR(20) NULL, +number VARCHAR(255) NULL, +status VARCHAR(255) NULL, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +Privilege VARCHAR(255) NULL, +Channel VARCHAR(255) NULL, +Cause VARCHAR(255) NULL, +Causetxt VARCHAR(255) NULL, +PeerStatus VARCHAR(255) NULL, +Peer VARCHAR(255) NULL, +Context VARCHAR(255) NULL, +Application VARCHAR(255) NULL, +AppData VARCHAR(255) NULL, +Priority VARCHAR(255) NULL, +Uniqueid VARCHAR(255) NULL, +Event VARCHAR(255) NULL, +State VARCHAR(255) NULL, +CallerIDName VARCHAR(255) NULL, +CallerID VARCHAR(255) NULL, +AstExtension VARCHAR(255) NULL, +PRIMARY KEY (`id`), +KEY `extension` (`extension`)); + +CREATE TABLE activity_logs ( +id INTEGER NOT NULL AUTO_INCREMENT, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +message TEXT NOT NULL DEFAULT '', +user VARCHAR(50), +PRIMARY KEY (`id`)); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-05-21 22:52:56
|
Revision: 2180 http://astpp.svn.sourceforge.net/astpp/?rev=2180&view=rev Author: darrenkw Date: 2008-05-21 15:52:55 -0700 (Wed, 21 May 2008) Log Message: ----------- Moved "Calculate Call Charge" output to an HTML Template. Adjusted code posting cdrs to OSCommerce so that callerid information is posted also. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-common.pl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-05-21 22:50:10 UTC (rev 2179) +++ trunk/astpp-admin.cgi 2008-05-21 22:52:55 UTC (rev 2180) @@ -9103,8 +9103,17 @@ sub build_calc_charge() { my ( $status, $body, $cost, $length, $increment ); + $template = + HTML::Template->new( + filename => '/var/lib/astpp/templates/calc-charge.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; - @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); + $template->param( + pricelists => popup_menu( + -name => "pricelist", + -values => \@pricelists + ) + ); if ( $params->{action} eq gettext("Price Call...") ) { my $branddata = &get_pricelist( $astpp_db, $params->{pricelist} ); my $numdata = &get_route( $astpp_db, $config, $params->{phonenumber}, @@ -9143,41 +9152,10 @@ . gettext(" for a call lasting ") . $params->{length} . gettext(" minutes."); + $template->param( + status => $status); } - $body = start_form - . "<table class=\"default\">" - . "<tr class=\"header\"><td>" - . hidden( -name => 'mode', -default => gettext("Calc Charge") ) - . gettext("Phone Number") - . "</td><td>" - . gettext("Length (Minutes)") - . "</td><td>" - . gettext("Pricelist") - . "</td><td>" - . gettext("Action") - . "</td></tr> -<tr class=\"rowone\"><td>" - . textfield( - -name => 'phonenumber', - -size => 20 - ) - . "</td><td>" - . textfield( - -name => 'length', - -size => 4 - ) - . "</td><td>" - . popup_menu( - -name => 'pricelist', - -values => \@pricelists, - -default => $config->{default_brand} - ) - . "</td><td>" - . submit( -name => 'action', -value => gettext("Price Call...") ) - . "</td></tr><tr><td colspan=4>" - . $status - . "</td></tr></table>"; - return $body; + return $template->output; } sub build_configuration() { Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-05-21 22:50:10 UTC (rev 2179) +++ trunk/astpp-common.pl 2008-05-21 22:52:55 UTC (rev 2180) @@ -4454,7 +4454,7 @@ sub osc_post_charge() { my ($osc_db, $config, $invoice_id, $row ) = @_; my ( $sql, $desc, $tmp, $price ); - $desc = "$row->{callstart} $row->{callednum} SEC:$row->{billseconds}"; + $desc = "$row->{callstart} SRC: $row->{callerid} DST: $row->{callednum} SEC:$row->{billseconds} $row->{notes}"; $price = $row->{debit} / 10000; $tmp = "INSERT INTO `orders_products` (`orders_products_id`,`orders_id`,`products_id`,`products_name`,`products_price`," This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-05-21 22:50:07
|
Revision: 2179 http://astpp.svn.sourceforge.net/astpp/?rev=2179&view=rev Author: darrenkw Date: 2008-05-21 15:50:10 -0700 (Wed, 21 May 2008) Log Message: ----------- Added "Calculate Call Charge" template. Added Paths: ----------- trunk/templates/calc-charge.tpl Added: trunk/templates/calc-charge.tpl =================================================================== --- trunk/templates/calc-charge.tpl (rev 0) +++ trunk/templates/calc-charge.tpl 2008-05-21 22:50:10 UTC (rev 2179) @@ -0,0 +1,25 @@ +<table class="default"> +<input type="hidden" name="mode" value="Calc Charge" /> + <tr class="header"> + <td colspan=5>Add / Edit / List Packages</td> + </tr> + <tr class="header"> + <td>Phone Number</td> + <td>Length (Minutes)</td> + <td>Pricelist</td> + <td>Action</td> + </tr> + <tr class="rowone"> + <td><input type="text" name="phonenumber" size="20" /></td> + <td><input type="text" name="length" size="6" /></td> + <td><TMPL_VAR NAME="pricelists"></td> + <td><input type="submit" name="action" value="Price Call..." /></td> + </tr> +</table> + +<table> + <tr> + <td><TMPL_VAR NAME="status"></td> + </tr> + </table> +</form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-05-06 02:02:07
|
Revision: 2178 http://astpp.svn.sourceforge.net/astpp/?rev=2178&view=rev Author: darrenkw Date: 2008-05-05 19:02:09 -0700 (Mon, 05 May 2008) Log Message: ----------- Resolved Bug: [1956264 ] Email invoices Modified Paths: -------------- trunk/astpp-common.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-05-06 01:11:34 UTC (rev 2177) +++ trunk/astpp-common.pl 2008-05-06 02:02:09 UTC (rev 2178) @@ -437,6 +437,7 @@ # configured per reseller. sub email_refill_account() { my ( $astpp_db,$reseller,$config, $vars ) = @_; + $vars->{email} = $config->{company_email} if $config->{user_email} == 0; my %mail = ( To => $vars->{email}, From => $config->{company_email}, @@ -460,6 +461,7 @@ # configured per reseller. sub email_reactivate_account() { my ( $astpp_db,$reseller,$config, $vars ) = @_; + $vars->{email} = $config->{company_email} if $config->{user_email} == 0; my %mail = ( To => $vars->{email}, From => $config->{company_email}, @@ -483,6 +485,7 @@ # configured per reseller. sub email_add_user() { my ( $astpp_db,$reseller,$config, $vars ) = @_; + $vars->{email} = $config->{company_email} if $config->{user_email} == 0; my %mail = ( To => $vars->{email}, From => $config->{company_email}, @@ -508,6 +511,7 @@ # configured per reseller. sub email_add_device() { my ( $astpp_db,$reseller, $config, $vars ) = @_; + $vars->{email} = $config->{company_email} if $config->{user_email} == 0; my %mail = ( To => $vars->{email}, From => $config->{company_email}, @@ -581,6 +585,7 @@ # configured per reseller. sub email_del_user() { my ( $astpp_db,$reseller,$config, $vars) = @_; + $vars->{email} = $config->{company_email} if $config->{user_email} == 0; my %mail = ( To => $vars->{email}, From => $config->{company_email}, @@ -604,6 +609,7 @@ # configured per reseller. sub email_add_callingcard() { my ( $astpp_db,$reseller,$config, $vars, $cc, $pin ) = @_; + $vars->{email} = $config->{company_email} if $config->{user_email} == 0; my %mail = ( To => $vars->{email}, From => $config->{company_email}, @@ -627,7 +633,7 @@ # configured per reseller. sub email_add_did() { my ( $astpp_db, $reseller,$vars, $did, $config, $email ) = @_; - $email = $config->{company_email} if ( $email eq "" ); + $email = $config->{company_email} if $config->{user_email} == 0; my %mail = ( To => $email, From => $config->{company_email}, @@ -658,7 +664,7 @@ # configured per reseller. sub email_del_did() { my ( $astpp_db, $reseller,$vars, $did, $config, $email ) = @_; - $email = $config->{company_email} if ( $email eq "" ); + $email = $config->{company_email} if $config->{user_email} == 0; my %mail = ( To => $email, From => $config->{company_email}, @@ -684,6 +690,7 @@ # configured per reseller. sub email_new_invoice() { my ( $astpp_db,$reseller,$config, $email, $invoice, $total ) = @_; + $email = $config->{company_email} if $config->{user_email} == 0; my %mail = ( To => $email, From => $config->{company_email}, @@ -707,6 +714,7 @@ # configured per reseller. sub email_low_balance() { my ( $astpp_db, $reseller,$config, $email, $balance ) = @_; + $email = $config->{company_email} if $config->{user_email} == 0; my %mail = ( To => $email, From => $config->{company_email}, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-05-06 01:11:31
|
Revision: 2177 http://astpp.svn.sourceforge.net/astpp/?rev=2177&view=rev Author: darrenkw Date: 2008-05-05 18:11:34 -0700 (Mon, 05 May 2008) Log Message: ----------- Corrected the permissions set in the makefile. Fixed bug: [ 1956258 ] Interface rating doesn't show call cost Modified Paths: -------------- trunk/Makefile trunk/astpp-admin.cgi Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2008-05-03 22:07:56 UTC (rev 2176) +++ trunk/Makefile 2008-05-06 01:11:34 UTC (rev 2177) @@ -14,7 +14,7 @@ EXTENSIONS=/etc/asterisk/extensions.conf LOCALE_DIR=/usr/local/share/locale OWNER=root -GROUP=root +GROUP=wheel WWWDIR=/var/www all: Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-05-03 22:07:56 UTC (rev 2176) +++ trunk/astpp-admin.cgi 2008-05-06 01:11:34 UTC (rev 2177) @@ -9174,9 +9174,9 @@ ) . "</td><td>" . submit( -name => 'action', -value => gettext("Price Call...") ) - . "</td></tr> -</table> -"; + . "</td></tr><tr><td colspan=4>" + . $status + . "</td></tr></table>"; return $body; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-05-03 22:07:49
|
Revision: 2176 http://astpp.svn.sourceforge.net/astpp/?rev=2176&view=rev Author: darrenkw Date: 2008-05-03 15:07:56 -0700 (Sat, 03 May 2008) Log Message: ----------- Resolved Bug [ 1956259 ] Incorrect uniqueid shown in output Modified Paths: -------------- trunk/astpp-common.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-05-03 22:03:34 UTC (rev 2175) +++ trunk/astpp-common.pl 2008-05-03 22:07:56 UTC (rev 2176) @@ -3899,7 +3899,7 @@ my ( $status, $cdrinfo); foreach (@$chargelist) { my $uniqueid = $_; - print STDERR gettext("Processing Uniqueid: ") . @$chargelist; + print STDERR gettext("Processing Uniqueid: ") . $uniqueid . "\n"; $cdrinfo = ($vars) ? $vars : &get_cdr( $config, $cdr_db, $uniqueid ); my $savedcdrinfo = $cdrinfo; if(!$vars) { @@ -3926,7 +3926,7 @@ print STDERR "\n----------------------\n"; print STDERR "CDR Written - No Billable Seconds\n"; print STDERR - "uniqueid $uniqueid, cardno $cdrinfo->{accountcode}, phoneno $cdrinfo->{dst}\n"; + "uniqueid $cdrinfo->{uniqueid}, cardno $cdrinfo->{accountcode}, phoneno $cdrinfo->{dst}\n"; print STDERR "disposition $cdrinfo->{disposition}\n"; print STDERR "----------------------\n"; } @@ -3988,7 +3988,7 @@ print STDERR "ERROR - ERROR - ERROR - ERROR - ERROR \n"; print STDERR "NO ACCOUNTCODE IN DATABASE\n"; print STDERR - "uniqueid: $uniqueid, cardno: $cdrinfo->{accountcode}, phoneno: $cdrinfo->{dst}\n"; + "uniqueid: $cdrinfo->{uniqueid}, cardno: $cdrinfo->{accountcode}, phoneno: $cdrinfo->{dst}\n"; print STDERR "disposition: $cdrinfo->{disposition}\n"; print STDERR "----------------------\n"; if(!$vars) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-05-03 22:03:29
|
Revision: 2175 http://astpp.svn.sourceforge.net/astpp/?rev=2175&view=rev Author: darrenkw Date: 2008-05-03 15:03:34 -0700 (Sat, 03 May 2008) Log Message: ----------- The Accountlist template was missing data in a dropdown. Modified Paths: -------------- trunk/templates/account-info.tpl Modified: trunk/templates/account-info.tpl =================================================================== --- trunk/templates/account-info.tpl 2008-05-03 22:02:09 UTC (rev 2174) +++ trunk/templates/account-info.tpl 2008-05-03 22:03:34 UTC (rev 2175) @@ -5,7 +5,7 @@ <td>Action</td> </tr> <tr class="rowone"> - <td><TMPL_VAR NAME="accountlist"> <input name="accountnum" size="20" type="text"></td> + <td><TMPL_VAR NAME="accountlist"> <input name="accountnum" value=<TMPL_VAR NAME="accountnum"> size="20" type="text"></td> <td><input name="action" value="Information" type="submit"></td> </tr> </table> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-05-03 22:02:11
|
Revision: 2174 http://astpp.svn.sourceforge.net/astpp/?rev=2174&view=rev Author: darrenkw Date: 2008-05-03 15:02:09 -0700 (Sat, 03 May 2008) Log Message: ----------- Added a program to convert the Master.csv file into a series of SQL statements. Added Paths: ----------- trunk/contrib/ trunk/contrib/astpp-import-cdrs.pl Added: trunk/contrib/astpp-import-cdrs.pl =================================================================== --- trunk/contrib/astpp-import-cdrs.pl (rev 0) +++ trunk/contrib/astpp-import-cdrs.pl 2008-05-03 22:02:09 UTC (rev 2174) @@ -0,0 +1,117 @@ +#!/usr/bin/perl +# Author: Darren Wiebe <da...@al...> +# Date: May 2,2008 +# +# This program was written by Darren Wiebe <da...@al...>. +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2 or later +# at your option. +# + +use DBI; +use Text::CSV; + + +require "/usr/local/astpp/astpp-common.pl"; +$ENV{LANGUAGE} = "en"; # de, es, br - whatever +print STDERR "Interface language is set to: " . $ENV{LANGUAGE} . "\n"; +use vars qw(@output $astpp_db $config + $status $config $ASTPP); + +$infile = $ARGV[0]; +$outfile = $ARGV[1]; + +sub initialize() { + $config = &load_config(); + $astpp_db = &connect_db( $config, @output ); + $config = &load_config_db( $astpp_db, $config ) if $astpp_db; + $cdr_db = &cdr_connect_db( $config, @output ); +} + +sub finduniqueid() { + my ( $cc, $count, $startingdigit, $sql, $record ); + for ( ; ; ) { + $count = 1; + $cc = + int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ); + $sql = + $cdr_db->prepare( + "SELECT COUNT(*) FROM cdr WHERE uniqueid = " + . $cdr_db->quote($cc) ); + $sql->execute; + $record = $sql->fetchrow_hashref; + $count = $record->{"COUNT(*)"}; + $sql->finish; + return $cc if ( $count == 0 ); + } +} + + +sub read_file { + open(READFILE,"$infile") || + die "Error - could not open $infile for reading.\n"; + @data =<READFILE>; + close(READFILE); + my $csv = Text::CSV->new(); + foreach $temp (@data) { + print STDERR $temp; + if ( $csv->parse ($temp) ) { + my $tmp; + @column = $csv->fields(); + $uniqueid = &finduniqueid; + print STDERR "DURATION: $column[13] UNIQUEID: $uniqueid ACCOUNT: $column[0] DST: $column[2]\n"; + &printsql; + } else { + my $error = $csv->error_input; + $status .= "pars() failed on argument: " . $error . "<br>"; + } + + } +} + +sub printsql() { + open ( OUTFILE, ">>$outfile" ) || die "Could not open outfile"; + $tmp = "INSERT INTO cdr (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,cost,vendor) VALUES (" . + $cdr_db->quote($column[9]) . ", " . + $cdr_db->quote($column[4]) . ", " . + $cdr_db->quote($column[1]) . ", " . + $cdr_db->quote($column[2]) . ", " . + $cdr_db->quote($column[3]) . ", " . + $cdr_db->quote($column[5]) . ", " . + $cdr_db->quote($column[6]) . ", " . + $cdr_db->quote($column[7]) . ", " . + $cdr_db->quote($column[8]) . ", " . + $cdr_db->quote($column[12]) . ", " . + $cdr_db->quote($column[13]) . ", " . + $cdr_db->quote($column[14]) . ", " . + $cdr_db->quote($column[15]) . ", " . + $cdr_db->quote($column[0]) . ", " . + $cdr_db->quote($uniqueid) . ", " . + $cdr_db->quote("none") . ", " . + $cdr_db->quote("none") . ");"; + print STDERR $tmp . "\n"; + print OUTFILE $tmp . "\n"; + close (OUTFILE); +} + + +if ($infile eq "" || $outfile eq "") { + print "\n---- Command Line Error ---- \n\n"; + print "Please call this program with your csv file as the first argument.\n"; + print "The next argument should be the name of the file you want the sql dumped\n"; + print "into. For more info pleas peruse the source code.\n"; + print "ie ./astpp-import-cdrs.pl ./Master.csv ./Master.sql\n\n"; + exit(0); +} + +&initialize(); + +&read_file; Property changes on: trunk/contrib/astpp-import-cdrs.pl ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-01-19 06:28:13
|
Revision: 2173 http://astpp.svn.sourceforge.net/astpp/?rev=2173&view=rev Author: darrenkw Date: 2008-01-18 22:28:08 -0800 (Fri, 18 Jan 2008) Log Message: ----------- Resolved: [ 1866419 ] missing account-remove.tpl Modified Paths: -------------- trunk/astpp-common.pl Added Paths: ----------- trunk/templates/account-remove.tpl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-12-29 04:59:59 UTC (rev 2172) +++ trunk/astpp-common.pl 2008-01-19 06:28:08 UTC (rev 2173) @@ -1308,6 +1308,7 @@ sub list_accounts_selective() { my ( $astpp_db, $reseller, $type ) = @_; my ( $sql, @accountlist, $row, $tmp ); + $reseller = "" if !$reseller; if ( $type == -1 ) { $tmp = "SELECT number FROM accounts WHERE status < 2 AND reseller = " Added: trunk/templates/account-remove.tpl =================================================================== --- trunk/templates/account-remove.tpl (rev 0) +++ trunk/templates/account-remove.tpl 2008-01-19 06:28:08 UTC (rev 2173) @@ -0,0 +1,23 @@ +<input name="mode" value="Remove Account" type="hidden"> +<table class="default"> +<tr class="header"> + <td colspan=3>Please select the account you wish to remove</td> +</tr> +<tr> + <td> + <TMPL_VAR NAME="accountlist_menu"> + </td> + <td> + <input name="number" size="20" type="text"> + </td> + <td> + <input name="action" value="Remove Account" type="submit"> + </td> +</tr> +<tr> + <td> + <TMPL_VAR NAME="status"> + </td> +</tr> +</table> +</form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-12-29 04:59:54
|
Revision: 2172 http://astpp.svn.sourceforge.net/astpp/?rev=2172&view=rev Author: darrenkw Date: 2007-12-28 20:59:59 -0800 (Fri, 28 Dec 2007) Log Message: ----------- Fix a minor typo. Modified Paths: -------------- trunk/astpp-common.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-12-29 04:58:01 UTC (rev 2171) +++ trunk/astpp-common.pl 2007-12-29 04:59:59 UTC (rev 2172) @@ -4076,7 +4076,7 @@ } } } else { - $cardinfo = $vars; + my $cdrinfo = $vars; my $tmp = "SELECT * FROM outbound_routes WHERE " . $astpp_db->quote( $cdrinfo->{dst} ) . " RLIKE pattern AND status = 1 AND trunk = " This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-12-29 04:58:19
|
Revision: 2171 http://astpp.svn.sourceforge.net/astpp/?rev=2171&view=rev Author: darrenkw Date: 2007-12-28 20:58:01 -0800 (Fri, 28 Dec 2007) Log Message: ----------- Commit Realtime Rating Engine cleanups by Sonia Kahn Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-common.pl trunk/astpp-rate-engine.pl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-12-29 04:26:16 UTC (rev 2170) +++ trunk/astpp-admin.cgi 2007-12-29 04:58:01 UTC (rev 2171) @@ -1529,7 +1529,7 @@ ); $template->param( dids => &count_dids( $astpp_db, "" ) ); $template->param( - unbilled_cdrs => &count_unbilled_cdrs( $cdr_db, $accounts ) ); + unbilled_cdrs => &count_unbilled_cdrs( $config, $cdr_db, $accounts ) ); } elsif ( $params->{logintype} == 2 && $astpp_db && $cdr_db ) { $template->param( @@ -1550,7 +1550,7 @@ $template->param( total_owing => &accounts_total_balance($astpp_db,"")/10000 ); $template->param( dids => &count_dids( $astpp_db, "" ) ); $template->param( - unbilled_cdrs => &count_unbilled_cdrs( $cdr_db, "NULL,''" ) ); + unbilled_cdrs => &count_unbilled_cdrs( $config, $cdr_db, "NULL,''" ) ); } return $template->output; @@ -11083,9 +11083,9 @@ $iax2_login = $sql->fetchrow_hashref; $sql->finish; } - my @chargelist = &list_cdrs_account( $cdr_db, $accountinfo->{number}, + my @chargelist = &list_cdrs_account( $config, $cdr_db, $accountinfo->{number}, $accountinfo->{cc} ); - &processlist( $astpp_db, $cdr_db, $config, @chargelist ) + &processlist( $astpp_db, $cdr_db, $config, \@chargelist ) ; # Bill as many calls as we can. $status .= gettext("We rated as many CDRS as we could") . "<br>"; $tmp = @@ -11137,7 +11137,7 @@ filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); $template->param( booth_name => $params->{booth_name} ); my $balance = &accountbalance( $astpp_db, $params->{booth_name} ) / 10000; - my $unrated = &count_unrated_cdrs_account( $cdr_db, $accountinfo->{number}, + my $unrated = &count_unrated_cdrs_account( $config, $cdr_db, $accountinfo->{number}, $accountinfo->{cc} ); $ASTPP->debug( user=> $param->{username}, debug => $balance); $template->param( unrated_cdrs => $unrated ); Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-12-29 04:26:16 UTC (rev 2170) +++ trunk/astpp-common.pl 2007-12-29 04:58:01 UTC (rev 2171) @@ -1417,21 +1417,21 @@ # Select a specific cdr from the Asterisk(tm) cdr table. sub get_cdr() { - my ( $cdr_db, $uniqueid,$rating,$dst ) = @_; + my ( $config, $cdr_db, $uniqueid,$rating,$dst ) = @_; my ( $sql, $cdrdata ); if ($dst) { $sql = $cdr_db->prepare( - "SELECT * FROM cdr WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND dst = " . $cdr_db->quote($dst) . " ORDER BY cost DESC LIMIT 1" ); + "SELECT * FROM $config->{asterisk_cdr_table} WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND dst = " . $cdr_db->quote($dst) . " ORDER BY cost DESC LIMIT 1" ); } elsif ($rating) { $sql = $cdr_db->prepare( - "SELECT * FROM cdr WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND cost in ('error','none') ORDER BY cost DESC LIMIT 1" ); + "SELECT * FROM $config->{asterisk_cdr_table} WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND cost in ('error','none') ORDER BY cost DESC LIMIT 1" ); } else { $sql = $cdr_db->prepare( - "SELECT * FROM cdr WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " ORDER by cost DESC LIMIT 1" ); + "SELECT * FROM $config->{asterisk_cdr_table} WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " ORDER by cost DESC LIMIT 1" ); } $sql->execute; $cdrdata = $sql->fetchrow_hashref; @@ -1441,8 +1441,8 @@ # Update the cost of a cdr in the Asterisk(tm) cdr table. This is used to denote a cdr that has been rated. sub save_ast_cdr() { - my ( $cdr_db, $uniqueid, $cost,$dst ) = @_; - $cdr_db->do( "UPDATE cdr SET cost = " + my ( $config, $cdr_db, $uniqueid, $cost,$dst ) = @_; + $cdr_db->do( "UPDATE $config->{asterisk_cdr_table} SET cost = " . $cdr_db->quote($cost) . "WHERE uniqueid = " . $cdr_db->quote($uniqueid) @@ -1455,11 +1455,11 @@ # used to select cdrs that have not been billed which have value "none" or those that the rating engine ran # into a problem with which are marked "error". sub list_cdrs_status() { - my ( $cdr_db, $default ) = @_; + my ( $config, $cdr_db, $default ) = @_; my ( $sql, @cdrlist, $row ); $sql = $cdr_db->prepare( - "SELECT * FROM cdr WHERE cost = " . $cdr_db->quote($default) ); + "SELECT * FROM $config->{asterisk_cdr_table} WHERE cost = " . $cdr_db->quote($default) ); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { push @cdrlist, $row->{uniqueid}; @@ -1469,11 +1469,11 @@ # Select all the unbilled CDRS belonging to a specific account. This is mostly used by booths. sub list_cdrs_account() { - my ( $cdr_db, $account, $cc ) = @_; + my ( $config, $cdr_db, $account, $cc ) = @_; my ( $sql, @cdrlist, $row ); $sql = $cdr_db->prepare( - "SELECT * FROM cdr WHERE cost IN ('none', 'error') AND accountcode IN (" . $cdr_db->quote($account) . ", " . $cdr_db->quote($cc) . ") AND disposition REGEXP 'ANSWE.*'"); + "SELECT * FROM $config->{asterisk_cdr_table} WHERE cost IN ('none', 'error') AND accountcode IN (" . $cdr_db->quote($account) . ", " . $cdr_db->quote($cc) . ") AND disposition REGEXP 'ANSWE.*'"); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { push @cdrlist, $row->{uniqueid}; @@ -1484,8 +1484,8 @@ # Update the cost of a cdr in the Asterisk(tm) cdr table. This is used to denote a cdr that has been tagged # to a vendor. sub save_ast_cdr_vendor() { - my ( $cdr_db, $uniqueid, $cost,$dst ) = @_; - $cdr_db->do( "UPDATE cdr SET vendor = " + my ( $config, $cdr_db, $uniqueid, $cost,$dst ) = @_; + $cdr_db->do( "UPDATE $config->{asterisk_cdr_table} SET vendor = " . $cdr_db->quote($cost) . "WHERE uniqueid = " . $cdr_db->quote($uniqueid) @@ -1498,11 +1498,11 @@ # used to select cdrs that have not been tagged to a vendor which have value "none" or those that the rating engine ran # into a problem with which are marked "error". sub list_cdrs_status_vendor() { - my ( $cdr_db, $default ) = @_; + my ( $config, $cdr_db, $default ) = @_; my ( $sql, @cdrlist, $row ); $sql = $cdr_db->prepare( - "SELECT * FROM cdr WHERE vendor = " . $cdr_db->quote($default) ); + "SELECT * FROM $config->{asterisk_cdr_table} WHERE vendor = " . $cdr_db->quote($default) ); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { push @cdrlist, $row->{uniqueid}; @@ -2174,38 +2174,37 @@ # Write ASTPP cdr. I think this one is mostly deprecated but should probably be completely removed. sub post_cdr() { - my ( - $astpp_db, $config, $uniqueid, $account, $clid, - $dest, $disp, $seconds, $cost, $callstart, - $postexternal, $trunk, $notes,$pricelist,$pattern - ) - = @_; + my ( + $astpp_db, $config, $uniqueid, $account, $clid, + $dest, $disp, $seconds, $cost, $callstart, + $postexternal, $trunk, $notes,$pricelist,$pattern + ) = @_; - # The cost is passed in 100ths of a penny. - my ( $tmp, $status ); - $trunk = gettext("N/A") if ( !$trunk ); - $uniqueid = gettext("N/A") if ( !$uniqueid ); - $pricelist = gettext("N/A") if ( !$pricelist ); - $pattern = gettext("N/A") if ( !$pattern ); - $status = 0; - $tmp = -"INSERT INTO cdrs(uniqueid,cardnum,callerid,callednum,trunk,disposition,billseconds," - . "debit,callstart,status,notes,pricelist,pattern) VALUES (" - . $astpp_db->quote($uniqueid) . ", " - . $astpp_db->quote($account) . ", " - . $astpp_db->quote($clid) . ", " - . $astpp_db->quote($dest) . ", " - . $astpp_db->quote($trunk) . ", " - . $astpp_db->quote($disp) . ", " - . $astpp_db->quote($seconds) . ", " - . $astpp_db->quote($cost) . ", " - . $astpp_db->quote($callstart) . ", " - . $astpp_db->quote($status) . ", " - . $astpp_db->quote($notes) . "," - . $astpp_db->quote($pricelist) . "," - . $astpp_db->quote($pattern) . ")"; - print STDERR "$tmp\n"; - $astpp_db->do($tmp); +# The cost is passed in 100ths of a penny. + my ( $tmp, $status ); + $trunk = gettext("N/A") if ( !$trunk ); + $uniqueid = gettext("N/A") if ( !$uniqueid ); + $pricelist = gettext("N/A") if ( !$pricelist ); + $pattern = gettext("N/A") if ( !$pattern ); + $status = 0; + $tmp = + "INSERT INTO cdrs(uniqueid,cardnum,callerid,callednum,trunk,disposition,billseconds," + . "debit,callstart,status,notes,pricelist,pattern) VALUES (" + . $astpp_db->quote($uniqueid) . ", " + . $astpp_db->quote($account) . ", " + . $astpp_db->quote($clid) . ", " + . $astpp_db->quote($dest) . ", " + . $astpp_db->quote($trunk) . ", " + . $astpp_db->quote($disp) . ", " + . $astpp_db->quote($seconds) . ", " + . $astpp_db->quote($cost) . ", " + . $astpp_db->quote($callstart) . ", " + . $astpp_db->quote($status) . ", " + . $astpp_db->quote($notes) . "," + . $astpp_db->quote($pricelist) . "," + . $astpp_db->quote($pattern) . ")"; + print STDERR "$tmp\n"; + $astpp_db->do($tmp); } ############### Integration with AgileBill starts here ################## @@ -3267,10 +3266,10 @@ # Return a list of unbilled cdrs from the Asterisk(TM) cdr database. sub count_unbilled_cdrs() { - my ($cdr_db,$account) = @_; + my ($config, $cdr_db,$account) = @_; my ( $sql, $count, $record ); $sql = - $cdr_db->prepare( "SELECT COUNT(*) FROM cdr WHERE cost = 'error' OR " + $cdr_db->prepare( "SELECT COUNT(*) FROM $config->{asterisk_cdr_table} WHERE cost = 'error' OR " . "accountcode IN (" . $account . ") AND cost ='none'" ); $sql->execute; $record = $sql->fetchrow_hashref; @@ -3358,11 +3357,11 @@ # List unrated CDRS per account sub count_unrated_cdrs_account() { - my ( $cdr_db, $account, $cc ) = @_; + my ( $config, $cdr_db, $account, $cc ) = @_; my ( $sql, @cdrlist, $record, $count ); $sql = $cdr_db->prepare( - "SELECT COUNT(*) FROM cdr WHERE cost IN ('none', 'error') AND accountcode IN (" . $cdr_db->quote($account) . ", " . $cdr_db->quote($cc) . ")"); + "SELECT COUNT(*) FROM $config->{asterisk_cdr_table} WHERE cost IN ('none', 'error') AND accountcode IN (" . $cdr_db->quote($account) . ", " . $cdr_db->quote($cc) . ")"); $sql->execute; $record = $sql->fetchrow_hashref; $count = $record->{"COUNT(*)"}; @@ -3748,21 +3747,18 @@ } sub rating() { # This routine recieves a specific cdr and takes care of rating it and of marking it as rated. It bills resellers as appropriate. - my ( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, @output ) = @_; + my ( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, $vars, @output ) = @_; my ( $increment, $numdata, $package, $notes, $status ); print STDERR "----------------------------------------------------------------\n"; print STDERR -"uniqueid: $cdrinfo->{uniqueid}, cardno: $carddata->{number}, phoneno: $cdrinfo->{dst}, Userfield: $cdrinfo->{userfield}\n"; + "uniqueid: $cdrinfo->{uniqueid}, cardno: $carddata->{number}, phoneno: $cdrinfo->{dst}, Userfield: $cdrinfo->{userfield}\n"; print STDERR -"disposition: $cdrinfo->{disposition} Pricelist: $carddata->{pricelist} reseller: $carddata->{reseller}\n"; + "disposition: $cdrinfo->{disposition} Pricelist: $carddata->{pricelist} reseller: $carddata->{reseller}\n"; if ( $cdrinfo->{disposition} =~ /^ANSWERED$/ ) { - $numdata = - &get_route( $astpp_db, $config, $cdrinfo->{dst}, - $carddata->{pricelist}, $carddata, $cdrinfo->{userfield} ); + $numdata = &get_route( $astpp_db, $config, $cdrinfo->{dst}, $carddata->{pricelist}, $carddata, $cdrinfo->{userfield} ); print STDERR "PATTERN: $numdata->{pattern}"; if ( !$numdata->{pattern} ) { - &save_ast_cdr( $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ) - if $config->{astcdr} == 1; + &save_ast_cdr( $config, $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; print STDERR "ERROR - ERROR - ERROR - ERROR - ERROR \n"; print STDERR "NO MATCHING PATTERN\n"; print STDERR "----------------------------------------------------------------\n"; @@ -3771,28 +3767,23 @@ print STDERR "FOUND A MATCHING PATTERN.\n"; my $branddata = &get_pricelist( $astpp_db, $carddata->{pricelist} ); print STDERR -"pricelistData: $branddata->{name} $branddata->{markup} $branddata->{inc} $branddata->{status}\n"; + "pricelistData: $branddata->{name} $branddata->{markup} $branddata->{inc} $branddata->{status}\n"; $package = &get_package( $astpp_db, $carddata, $cdrinfo->{dst} ); - if ($package->{id}) { - my $counter = - &get_counter( $astpp_db, $package->{id}, - $carddata->{number} ); + if ($package->{id}) { + my $counter = &get_counter( $astpp_db, $package->{id}, $carddata->{number} ); my $difference; - if ( !$counter->{id}) { - my $tmp = - "INSERT INTO counters (package,account) VALUES (" - . $astpp_db->quote( $package->{id} ) . ", " - . $astpp_db->quote( $carddata->{number} ) . ")"; + if ( !$counter->{id}) { + my $tmp = "INSERT INTO counters (package,account) VALUES (" + . $astpp_db->quote( $package->{id} ) . ", " + . $astpp_db->quote( $carddata->{number} ) . ")"; print STDERR "/n" . $tmp . "/n" if $config->{debug} == 1; - $astpp_db->do($tmp); - $counter = - &get_counter( $astpp_db, $package->{id}, - $carddata->{number} ); + $astpp_db->do($tmp); + $counter = &get_counter( $astpp_db, $package->{id}, $carddata->{number} ); print STDERR "JUST CREATED COUNTER: $counter->{id}\n" if $config->{debug} == 1; - } - if ( $package->{includedseconds} > $counter->{seconds}) { - my $availableseconds = $package->{includedseconds} - $counter->{seconds}; + } + if ( $package->{includedseconds} > $counter->{seconds}) { + my $availableseconds = $package->{includedseconds} - $counter->{seconds}; my $freeseconds; if ($availableseconds >= $cdrinfo->{billsec}) { $freeseconds = $cdrinfo->{billsec}; @@ -3801,23 +3792,18 @@ $freeseconds = $availableseconds; $cdrinfo->{billsec} = $cdrinfo->{billsec} - $availableseconds; } - my $tmp = - "UPDATE counters SET seconds = " - . $astpp_db->quote( - $counter->{seconds} + $freeseconds ) - . " WHERE id = " - . $astpp_db->quote( $counter->{id} ); + my $tmp = "UPDATE counters SET seconds = " + . $astpp_db->quote( $counter->{seconds} + $freeseconds ) + . " WHERE id = " + . $astpp_db->quote( $counter->{id} ); print STDERR $tmp . "/n" if $config->{debug} == 1; - $astpp_db->do($tmp); - } - } + $astpp_db->do($tmp); + } + } if ( $branddata->{markup} ne "" && $branddata->{markup} != 0 ) { - $numdata->{connectcost} = - $numdata->{connectcost} * - ( ( $branddata->{markup} / 10000 ) + 1 ); - $numdata->{cost} = - $numdata->{cost} * ( ( $branddata->{markup} / 10000 ) + 1 ); + $numdata->{connectcost} = $numdata->{connectcost} * ( ( $branddata->{markup} / 10000 ) + 1 ); + $numdata->{cost} = $numdata->{cost} * ( ( $branddata->{markup} / 10000 ) + 1 ); } if ( $numdata->{inc} > 0 ) { $increment = $numdata->{inc}; @@ -3826,24 +3812,22 @@ $increment = $branddata->{inc}; } print STDERR -"$numdata->{connectcost}, $numdata->{cost}, $cdrinfo->{billsec}, $increment, $numdata->{includedseconds}"; + "$numdata->{connectcost}, $numdata->{cost}, $cdrinfo->{billsec}, $increment, $numdata->{includedseconds}"; my $cost = &calc_call_cost( - $numdata->{connectcost}, $numdata->{cost}, - $cdrinfo->{billsec}, $increment, - $numdata->{includedseconds} - ); + $numdata->{connectcost}, $numdata->{cost}, + $cdrinfo->{billsec}, $increment, + $numdata->{includedseconds} + ); $cost = sprintf( "%." . $config->{decimalpoints} . "f", $cost ); print STDERR "Matching pattern is $numdata->{pattern}\n"; - #Blocks all signals so that the program cannot be killed while writing costs. +#Blocks all signals so that the program cannot be killed while writing costs. my $sigset = POSIX::SigSet->new; my $blockset = POSIX::SigSet->new( SIGINT, SIGQUIT, SIGCHLD ); - sigprocmask( SIG_BLOCK, $blockset, $sigset ) - or die "Could not block INT,QUIT,CHLD signals: $!\n"; - &save_ast_cdr( $cdr_db, $cdrinfo->{uniqueid}, $cost,$cdrinfo->{dst} ) - if $config->{astcdr} == 1; + sigprocmask( SIG_BLOCK, $blockset, $sigset ) or die "Could not block INT,QUIT,CHLD signals: $!\n"; + &save_ast_cdr( $config, $cdr_db, $cdrinfo->{uniqueid}, $cost,$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; if ( $cdrinfo->{accountcode} ne $carddata->{number} && $cdrinfo->{accountcode} ne $carddata->{cc}) { $notes = $cdrinfo->{accountcode} . "|" . $numdata->{comment} . "|" . $numdata->{pattern}; } @@ -3851,29 +3835,28 @@ $notes = "|" . $numdata->{comment} . "|" . $numdata->{pattern}; } &post_cdr( - $astpp_db, $config, - $cdrinfo->{uniqueid}, $carddata->{number}, - $cdrinfo->{src}, $cdrinfo->{dst}, - $cdrinfo->{disposition}, $cdrinfo->{billsec}, - $cost, $cdrinfo->{calldate}, - "", $cdrinfo->{trunk}, - $notes,$numdata->{pricelist}, $numdata->{pattern} - ) - if $config->{posttoastpp} == 1; + $astpp_db, $config, + $cdrinfo->{uniqueid}, $carddata->{number}, + $cdrinfo->{src}, $cdrinfo->{dst}, + $cdrinfo->{disposition}, $cdrinfo->{billsec}, + $cost, $cdrinfo->{calldate}, + "", $cdrinfo->{trunk}, + $notes,$numdata->{pricelist}, $numdata->{pattern} + ) + if $config->{posttoastpp} == 1; &print_csv( - $config, $carddata->{number}, $cdrinfo->{disposition}, - $cdrinfo->{calldate}, $cdrinfo->{dst}, - $cdrinfo->{billsec}, $cost, - $carddata->{reseller}, $cdrinfo, @output - ); + $config, $carddata->{number}, $cdrinfo->{disposition}, + $cdrinfo->{calldate}, $cdrinfo->{dst}, + $cdrinfo->{billsec}, $cost, + $carddata->{reseller}, $cdrinfo, @output + ); sigprocmask( SIG_SETMASK, $sigset ) # Restore the passing of signals - or die "Could not restore INT,QUIT,CHLD signals: $!\n"; # - $status = 1; + or die "Could not restore INT,QUIT,CHLD signals: $!\n"; # + $status = 1; } } else { - &save_ast_cdr( $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ) - if $config->{astcdr} == 1; + &save_ast_cdr( $config, $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; print STDERR "ERROR - ERROR - ERROR - ERROR - ERROR \n"; print STDERR "DISPOSITION: $cdrinfo->{disposition} \n"; print STDERR "UNIQUEID: $cdrinfo->{uniqueid} \n"; @@ -3891,8 +3874,8 @@ } sub vendor_not_billed() { # Prints the information on calls where the "vendor" field is either none or error. - my ($cdr_db) = @_; - my $tmp = "SELECT * FROM cdr WHERE vendor IN ('none','error')"; + my ($config, $cdr_db) = @_; + my $tmp = "SELECT * FROM $config->{asterisk_cdr_table} WHERE vendor IN ('none','error')"; my $sql = $cdr_db->prepare($tmp); $sql->execute; while ( my $cdr = $sql->fetchrow_hashref ) { @@ -3911,33 +3894,34 @@ sub processlist() { # Deal with a list of calls which have not been rated so far. - my ($astpp_db, $cdr_db, $config, @chargelist) = @_; - my ( $status); - foreach (@chargelist) { + my ($astpp_db, $cdr_db, $config, $chargelist, $vars) = @_; + my ( $status, $cdrinfo); + foreach (@$chargelist) { my $uniqueid = $_; - print STDERR gettext("Processing Uniqueid: ") . $_; - my $cdrinfo = &get_cdr( $cdr_db, $uniqueid ); + print STDERR gettext("Processing Uniqueid: ") . @$chargelist; + $cdrinfo = ($vars) ? $vars : &get_cdr( $config, $cdr_db, $uniqueid ); my $savedcdrinfo = $cdrinfo; - my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'rating' WHERE uniqueid = " - . $cdr_db->quote($uniqueid) - . " AND cost = 'none'" - . " AND dst = " - . $cdr_db->quote($cdrinfo->{dst}) - . " LIMIT 1"; - $cdr_db->do($tmp); + if(!$vars) { + my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'rating' WHERE uniqueid = " + . $cdr_db->quote($uniqueid) + . " AND cost = 'none'" + . " AND dst = " + . $cdr_db->quote($cdrinfo->{dst}) + . " LIMIT 1"; + $cdr_db->do($tmp); + } else { + $cdrinfo->{'cost'} = 'rating'; + } if ( $cdrinfo->{accountcode} ) { my $carddata = &get_account( $astpp_db, $cdrinfo->{accountcode} ); if ($carddata->{number}) { - if ( $cdrinfo->{lastapp} eq "MeetMe" ) { # - $cdrinfo->{billsec} = $cdrinfo - ->{duration}; # There is an issue with calls that come out of meetme - } # not having the right billable seconds. - if ( $cdrinfo->{billsec} <= 0 ) { - &save_ast_cdr( $cdr_db, $uniqueid, 0,$cdrinfo->{dst} ) - if $config->{astcdr} == 1; - &save_ast_cdr_vendor( $cdr_db, $uniqueid, 0,$cdrinfo->{dst} ) - if $config->{astcdr} == 1 - && $config->{trackvendorcharges} == 1; + if ( $cdrinfo->{lastapp} eq "MeetMe" ) { # There is an issue with calls that come out of meetmee + $cdrinfo->{billsec} = $cdrinfo->{duration}; + } + if ( $cdrinfo->{billsec} <= 0 ) { # not having the right billable seconds. + &save_ast_cdr( $config, $cdr_db, $uniqueid, 0,$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; + &save_ast_cdr_vendor( $config, $cdr_db, $uniqueid, 0,$cdrinfo->{dst} ) + if !$vars && $config->{astcdr} == 1 && $config->{trackvendorcharges} == 1; print STDERR "\n----------------------\n"; print STDERR "CDR Written - No Billable Seconds\n"; print STDERR @@ -3946,19 +3930,19 @@ print STDERR "----------------------\n"; } elsif ( $cdrinfo->{accountcode} ) { - $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata); - $cdrinfo = &get_cdr( $cdr_db, $uniqueid ); + $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, $vars); + $cdrinfo = &get_cdr( $config, $cdr_db, $uniqueid ) if !$vars; if ( $status == 1 ) { my $previous_account = $carddata->{number}; while ( $carddata->{reseller} ne "" ) { - $cdrinfo = &get_cdr( $cdr_db, $uniqueid ); + $cdrinfo = &get_cdr( $config, $cdr_db, $uniqueid ) if !$vars; print STDERR "Charge $uniqueid to $carddata->{reseller}" if $config->{debug} == 1; $carddata = &get_account( $astpp_db, $carddata->{reseller} ); - $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata); + $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, $vars); my $tmp = "SELECT id FROM cdrs WHERE uniqueid = '" . $uniqueid . "' AND cardnum = '" . $previous_account . "' LIMIT 1"; print STDERR "$tmp\n" if $config->{debug} == 1; - my $sql = $astpp_db->prepare($tmp); + my $sql = $astpp_db->prepare($tmp); $sql->execute; my $previous_data = $sql->fetchrow_hashref; $sql->finish; @@ -3966,15 +3950,14 @@ $tmp = "SELECT id,debit,credit FROM cdrs WHERE uniqueid = '" . $uniqueid . "' AND cardnum = '" . $carddata->{number} . "' LIMIT 1"; print STDERR "$tmp\n" if $config->{debug} == 1; - $sql = $astpp_db->prepare($tmp); + $sql = $astpp_db->prepare($tmp); $sql->execute; my $cdrdata = $sql->fetchrow_hashref; $sql->finish; $cdrdata->{cost} = $cdrdata->{debit} - $cdrdata->{credit}; $tmp = "UPDATE cdrs SET cost = " . $cdrdata->{cost} - . " WHERE id = " . $previous_data->{id} . " AND callednum = " - . $cdr_db->quote($cdrinfo->{dst}); + . " WHERE id = " . $previous_data->{id} . " AND callednum = " . $cdr_db->quote($cdrinfo->{dst}); print STDERR "$tmp\n" if $config->{debug} == 1; $astpp_db->do($tmp); $previous_account = $carddata->{number}; @@ -3987,12 +3970,16 @@ print STDERR "ERROR - ERROR - ERROR - ERROR - ERROR \n"; print STDERR "NO ACCOUNT EXISTS IN ASTPP\n"; print STDERR -"uniqueid: $uniqueid, Account: $cdrinfo->{accountcode}, phoneno: $cdrinfo->{dst}\n"; + "uniqueid: $uniqueid, Account: $cdrinfo->{accountcode}, phoneno: $cdrinfo->{dst}\n"; print STDERR "disposition: $cdrinfo->{disposition}\n"; print STDERR "----------------------\n"; - my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'none' WHERE uniqueid = " - . $uniqueid . " AND cost = 'rating' LIMIT 1"; - $cdr_db->do($tmp); + if(!$vars) { + my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'none' WHERE uniqueid = " + . $uniqueid . " AND cost = 'rating' LIMIT 1"; + $cdr_db->do($tmp); + } else { + $cdrinfo->{cost} = 'none'; + } } } else { @@ -4000,61 +3987,101 @@ print STDERR "ERROR - ERROR - ERROR - ERROR - ERROR \n"; print STDERR "NO ACCOUNTCODE IN DATABASE\n"; print STDERR -"uniqueid: $uniqueid, cardno: $cdrinfo->{accountcode}, phoneno: $cdrinfo->{dst}\n"; + "uniqueid: $uniqueid, cardno: $cdrinfo->{accountcode}, phoneno: $cdrinfo->{dst}\n"; print STDERR "disposition: $cdrinfo->{disposition}\n"; print STDERR "----------------------\n"; - my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'none' WHERE uniqueid = " - . $uniqueid . " AND cost = 'rating' LIMIT 1"; - $cdr_db->do($tmp); + if(!$vars) { + my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'none' WHERE uniqueid = " + . $uniqueid . " AND cost = 'rating' LIMIT 1"; + $cdr_db->do($tmp); + } else { + $cdrinfo->{cost} = 'none'; + } } my $phrase = "none"; - &vendor_process_rating( $astpp_db, $cdr_db, $config, $phrase, $uniqueid ) if $config->{trackvendorcharges} == 1; - + &vendor_process_rating( $astpp_db, $cdr_db, $config, $phrase, $uniqueid, $vars ) if $config->{trackvendorcharges} == 1; } } sub vendor_process_rating() { #Rate Vendor calls. - my ( $astpp_db, $cdr_db, $config, $phrase, $uniqueid ) = @_; + my ( $astpp_db, $cdr_db, $config, $phrase, $uniqueid, $vars ) = @_; my $tmp = "SELECT * FROM trunks ORDER BY LENGTH(path)"; my $sql = $astpp_db->prepare($tmp); print STDERR "$tmp\n" . "\n" if $config->{debug} == 1; $sql->execute; while ( my $trunk = $sql->fetchrow_hashref ) { my $tmp; - if ( $uniqueid ne "" ) { - $tmp = - "SELECT * FROM $config->{asterisk_cdr_table} where lastapp = 'Dial'" - . " AND vendor = " - . $cdr_db->quote($phrase) - . " AND (dstchannel LIKE '$trunk->{tech}/$trunk->{path}%'" - . " OR dstchannel LIKE '$trunk->{tech}\[$trunk->{path}\]%'" - . " OR lastdata LIKE '$trunk->{tech}/$trunk->{path}%'" - . " OR lastdata LIKE '$trunk->{tech}\[$trunk->{path}\]%')" - . " AND uniqueid = " - . $cdr_db->quote($uniqueid) - . " AND disposition = 'ANSWERED'"; - } - else { - $tmp = - "SELECT * FROM $config->{asterisk_cdr_table} where lastapp = 'Dial'" - . " AND vendor = " - . $cdr_db->quote($phrase) - . " AND (dstchannel LIKE '$trunk->{tech}/$trunk->{path}%'" - . " OR dstchannel LIKE '$trunk->{tech}\[$trunk->{path}\]%'" - . " OR lastdata LIKE '$trunk->{tech}/$trunk->{path}%'" - . " OR lastdata LIKE '$trunk->{tech}\[$trunk->{path}\]%')" - . " AND disposition = 'ANSWERED'"; - } - print STDERR "$tmp\n" . "\n" if $config->{debug} == 1; - my $sql1 = $cdr_db->prepare($tmp); - $sql1->execute; - while ( my $cdrinfo = $sql1->fetchrow_hashref ) { - my $tmp = - "SELECT * FROM outbound_routes WHERE " - . $astpp_db->quote( $cdrinfo->{dst} ) - . " RLIKE pattern AND status = 1 AND trunk = " - . $astpp_db->quote( $trunk->{name} ) - . " ORDER by LENGTH(pattern) DESC, cost"; + if(!$vars) { + if ( $uniqueid ne "" ) { + $tmp = + "SELECT * FROM $config->{asterisk_cdr_table} where lastapp = 'Dial'" + . " AND vendor = " + . $cdr_db->quote($phrase) + . " AND (dstchannel LIKE '$trunk->{tech}/$trunk->{path}%'" + . " OR dstchannel LIKE '$trunk->{tech}\[$trunk->{path}\]%'" + . " OR lastdata LIKE '$trunk->{tech}/$trunk->{path}%'" + . " OR lastdata LIKE '$trunk->{tech}\[$trunk->{path}\]%')" + . " AND uniqueid = " + . $cdr_db->quote($uniqueid) + . " AND disposition = 'ANSWERED'"; + } else { + $tmp = "SELECT * FROM $config->{asterisk_cdr_table} where lastapp = 'Dial'" + . " AND vendor = " + . $cdr_db->quote($phrase) + . " AND (dstchannel LIKE '$trunk->{tech}/$trunk->{path}%'" + . " OR dstchannel LIKE '$trunk->{tech}\[$trunk->{path}\]%'" + . " OR lastdata LIKE '$trunk->{tech}/$trunk->{path}%'" + . " OR lastdata LIKE '$trunk->{tech}\[$trunk->{path}\]%')" + . " AND disposition = 'ANSWERED'"; + } + print STDERR "$tmp\n" . "\n" if $config->{debug} == 1; + my $sql1 = $cdr_db->prepare($tmp); + $sql1->execute; + while ( my $cdrinfo = $sql1->fetchrow_hashref ) { + my $tmp = "SELECT * FROM outbound_routes WHERE " + . $astpp_db->quote( $cdrinfo->{dst} ) + . " RLIKE pattern AND status = 1 AND trunk = " + . $astpp_db->quote( $trunk->{name} ) + . " ORDER by LENGTH(pattern) DESC, cost"; + my $sql2 = $astpp_db->prepare($tmp); + $sql2->execute; + print STDERR "$tmp\n" . "\n" if $config->{debug} == 1; + my $pricerecord = $sql2->fetchrow_hashref; + $sql2->finish; + if ( $pricerecord->{id} ) { + my $cost = &calc_call_cost( + $pricerecord->{connectcost}, $pricerecord->{cost}, + $cdrinfo->{billsec}, $pricerecord->{inc}, + $pricerecord->{includedseconds} + ); + $cost = sprintf( "%." . $config->{decimalpoints} . "f", $cost ); + &post_cdr( + $astpp_db, $config, + $cdrinfo->{uniqueid}, $trunk->{provider}, + $cdrinfo->{src}, $cdrinfo->{dst}, + $cdrinfo->{disposition}, $cdrinfo->{billsec}, + $cost * -1, $cdrinfo->{calldate}, + "", $cdrinfo->{trunk}, + $pricerecord->{comment} . "|" . $pricerecord->{pattern} + ) if $config->{posttoastpp} == 1; + &save_ast_cdr_vendor( $config, $cdr_db, $cdrinfo->{uniqueid}, $cost,$cdrinfo->{dst} ); + my $tmp = "UPDATE cdrs SET cost = '" . $cost . "' WHERE uniqueid = '" . + $cdrinfo->{uniqueid} . "' AND cost = 0 " + . " AND cardnum != '" . $trunk->{provider} . "' AND dst = " + . $astpp_db->quote($cdrinfo->{dst}) . " LIMIT 1"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $astpp_db->do($tmp); + } else { + &save_ast_cdr_vendor( $config, $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ); + } + } + } else { + $cardinfo = $vars; + my $tmp = "SELECT * FROM outbound_routes WHERE " + . $astpp_db->quote( $cdrinfo->{dst} ) + . " RLIKE pattern AND status = 1 AND trunk = " + . $astpp_db->quote( $trunk->{name} ) + . " ORDER by LENGTH(pattern) DESC, cost"; my $sql2 = $astpp_db->prepare($tmp); $sql2->execute; print STDERR "$tmp\n" . "\n" if $config->{debug} == 1; @@ -4062,22 +4089,20 @@ $sql2->finish; if ( $pricerecord->{id} ) { my $cost = &calc_call_cost( - $pricerecord->{connectcost}, $pricerecord->{cost}, - $cdrinfo->{billsec}, $pricerecord->{inc}, - $pricerecord->{includedseconds} - ); + $pricerecord->{connectcost}, $pricerecord->{cost}, + $cdrinfo->{billsec}, $pricerecord->{inc}, + $pricerecord->{includedseconds} + ); $cost = sprintf( "%." . $config->{decimalpoints} . "f", $cost ); &post_cdr( - $astpp_db, $config, - $cdrinfo->{uniqueid}, $trunk->{provider}, - $cdrinfo->{src}, $cdrinfo->{dst}, - $cdrinfo->{disposition}, $cdrinfo->{billsec}, - $cost * -1, $cdrinfo->{calldate}, - "", $cdrinfo->{trunk}, - $pricerecord->{comment} . "|" . $pricerecord->{pattern} - ) - if $config->{posttoastpp} == 1; - &save_ast_cdr_vendor( $cdr_db, $cdrinfo->{uniqueid}, $cost,$cdrinfo->{dst} ); + $astpp_db, $config, + $cdrinfo->{uniqueid}, $trunk->{provider}, + $cdrinfo->{src}, $cdrinfo->{dst}, + $cdrinfo->{disposition}, $cdrinfo->{billsec}, + $cost * -1, $cdrinfo->{calldate}, + "", $cdrinfo->{trunk}, + $pricerecord->{comment} . "|" . $pricerecord->{pattern} + ) if $config->{posttoastpp} == 1; my $tmp = "UPDATE cdrs SET cost = '" . $cost . "' WHERE uniqueid = '" . $cdrinfo->{uniqueid} . "' AND cost = 0 " . " AND cardnum != '" . $trunk->{provider} . "' AND dst = " @@ -4085,10 +4110,6 @@ print STDERR "$tmp\n" if $config->{debug} == 1; $astpp_db->do($tmp); } - else { - &save_ast_cdr_vendor( $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ); - } - } } $sql->finish; Modified: trunk/astpp-rate-engine.pl =================================================================== --- trunk/astpp-rate-engine.pl 2007-12-29 04:26:16 UTC (rev 2170) +++ trunk/astpp-rate-engine.pl 2007-12-29 04:58:01 UTC (rev 2171) @@ -60,7 +60,7 @@ my @chargelist; push @chargelist, $uniqueid; #sleep $config->{sleep}; - &processlist($astpp_db, $cdr_db, $config, @chargelist); + &processlist($astpp_db, $cdr_db, $config, \@chargelist); #&cleanup_cdrs($cdr_db, $config); &shutdown(); exit(0); @@ -91,7 +91,7 @@ ); my @chargelist; push @chargelist, $ARGV[16]; - &processlist($astpp_db, $cdr_db, $config, @chargelist); + &processlist($astpp_db, $cdr_db, $config, \@chargelist, \%args); &cleanup_cdrs($cdr_db, $config); } elsif ( $run_type eq "price_only" ) { @@ -144,13 +144,13 @@ if ( !$cdr_db ) { $cdr_db = &connect_db( $config, @output ); } - my $cdrinfo = &get_cdr( $cdr_db, $input->{Uniqueid},1 ); + my $cdrinfo = &get_cdr( $config, $cdr_db, $input->{Uniqueid},1 ); # my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'rating' WHERE uniqueid = " . $input->{Uniqueid} . " AND cost = 'none' AND dst = " . $cdr_db->quote($cdrinfo->{dst}) . " LIMIT 1"; # print STDERR $tmp if $config->{debug} == 1; # print $tmp if $config->{debug} == 1; # $cdr_db->do($tmp); if ($cdrinfo->{lastapp} eq "MeetMe" || $cdrinfo->{billsec} > 0 || $cdrinfo->{cost} eq "none") { - &processlist($astpp_db, $cdr_db, $config, @chargelist); + &processlist($astpp_db, $cdr_db, $config, \@chargelist); &vendor_process_rating( $astpp_db, $cdr_db, $config, "none", $input->{Uniqueid} ) if $config->{trackvendorcharges} == 1; } # else { &cleanup_cdrs($cdr_db, $config); @@ -166,17 +166,17 @@ &cleanup_cdrs($cdr_db, $config); my @chargelist; my $phrase = "none"; - @chargelist = &list_cdrs_status( $cdr_db, $phrase ); # Grab a list of all calls with "none" assigned in the cost field - &processlist($astpp_db, $cdr_db, $config, @chargelist); # Bill as many calls as we can. + @chargelist = &list_cdrs_status( $config, $cdr_db, $phrase ); # Grab a list of all calls with "none" assigned in the cost field + &processlist($astpp_db, $cdr_db, $config, \@chargelist); # Bill as many calls as we can. $phrase = "error"; - @chargelist = &list_cdrs_status( $cdr_db, $phrase ); # Grab a list of all calls with "none" assigned in the cost field - &processlist($astpp_db, $cdr_db, $config, @chargelist); # See if we can now bill some of the calls that are marked in "error" + @chargelist = &list_cdrs_status( $config, $cdr_db, $phrase ); # Grab a list of all calls with "none" assigned in the cost field + &processlist($astpp_db, $cdr_db, $config, \@chargelist); # See if we can now bill some of the calls that are marked in "error" # print STDERR gettext("START ON VENDOR CALL RATING!") . "\n" if $config->{debug} == 1; # &vendor_process_rating( $astpp_db, $cdr_db, $config, "none", 0 ) if $config->{trackvendorcharges} == 1; # &vendor_process_rating( $astpp_db, $cdr_db, $config. $config, "error", 0 ) if $config->{trackvendorcharges} == 1; # print STDERR gettext("VENDOR CALLS WHICH HAVE NOT BEEN RATED.") . "\n" if $config->{debug} == 1; # Print a list of calls which have not been rated - &vendor_not_billed($cdr_db) if $config->{trackvendorcharges} == 1; + &vendor_not_billed($config, $cdr_db) if $config->{trackvendorcharges} == 1; &cleanup_cdrs($cdr_db, $config); } &shutdown(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-12-29 04:26:13
|
Revision: 2170 http://astpp.svn.sourceforge.net/astpp/?rev=2170&view=rev Author: darrenkw Date: 2007-12-28 20:26:16 -0800 (Fri, 28 Dec 2007) Log Message: ----------- Resolved: [ 1847735 ] refill bugs Modified Paths: -------------- trunk/astpp-common.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-19 10:12:08 UTC (rev 2169) +++ trunk/astpp-common.pl 2007-12-29 04:26:16 UTC (rev 2170) @@ -3549,17 +3549,17 @@ # Status 2 means the card has expired. # Status 3 means the card is empty. my ($astpp_db,$cardinfo) = @_; - my $now = $astpp_db->selectall_arrayref("SELECT NOW() + 0")->[0][0]; + my $now = $astpp_db->selectall_arrayref("SELECT NOW()")->[0][0]; print STDERR "Present Time: $now\n"; print STDERR "Expiration Date: $cardinfo->{expiry}\n"; print STDERR "Valid for Days: $cardinfo->{validfordays}\n"; - print STDERR "First Use: $cardinfo->{firstuse}\n"; + print STDERR "First Use: $cardinfo->{firstused}\n"; if ( $cardinfo->{inuse} != 0 ) { return 1; #Status 1 means card is in use. } if ( $cardinfo->{validfordays} > 0 ) { - $now = $astpp_db->selectall_arrayref("SELECT NOW() + 0")->[0][0]; + $now = $astpp_db->selectall_arrayref("SELECT NOW()")->[0][0]; if ( $now gt $cardinfo->{expiry} && $cardinfo->{expiry} ne "0000-00-00 00:00:00" ) { my $sql = "UPDATE callingcards SET status = 2 WHERE cardnumber = " This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-19 10:12:05
|
Revision: 2169 http://astpp.svn.sourceforge.net/astpp/?rev=2169&view=rev Author: darrenkw Date: 2007-11-19 02:12:08 -0800 (Mon, 19 Nov 2007) Log Message: ----------- Mostly resolve the issues in astpp-refill.agi. There are a few little cosmetic issues left. Modified Paths: -------------- trunk/astpp-refill.agi Modified: trunk/astpp-refill.agi =================================================================== --- trunk/astpp-refill.agi 2007-11-19 10:00:21 UTC (rev 2168) +++ trunk/astpp-refill.agi 2007-11-19 10:12:08 UTC (rev 2169) @@ -140,7 +140,7 @@ my $destcardinfo = &get_callingcard( $astpp_db, $destcardnumber, $config ) if $destcardnumber; my $retries = 0; while ( $destcardinfo->{status} != 1 && $retries < $config->{card_retries} ) { - my $cardnum = $AGI->get_data( $sound->{card_to_refill}, $input_timeout ); + my $cardnum = $AGI->get_data( $sound->{card_to_refill}, $config->{calling_cards_number_input_timeout}, $config->{cardlength}); $destcardinfo = &get_callingcard( $astpp_db, $cardnum, $config ); $destcardinfo = &get_account( $astpp_db, $cardnum ) if !$destcardinfo; $cc = 1 if $destcardinfo->{cc}; @@ -163,7 +163,7 @@ $config = &load_config_db_brand($astpp_db,$config,$destcardinfo->{brand}); $retries = 0; while ( $destcardinfo->{pin} != $destpin && $retries < $config->{pin_retries} ) { - $destpin = $AGI->get_data( $sound->{pin}, $input_timeout ); + $destpin = $AGI->get_data( $sound->{pin}, $config->{calling_cards_pin_input_timeout}, $config->{pinlength} ); if ( $destcardinfo->{pin} != $destpin ) { $AGI->stream_file($sound->{pin_incorrect}); } @@ -196,7 +196,7 @@ my $sourcecardinfo = &get_callingcard( $astpp_db, $sourcecardnumber, $config ) if $sourcecardnumber; $retries = 0; while ( $sourcecardinfo->{status} != 1 && $retries < $config->{card_retries} ) { - my $cardnum = $AGI->get_data( $sound->{card_to_empty}, $input_timeout ); + my $cardnum = $AGI->get_data( $sound->{card_to_empty}, $config->{calling_cards_number_input_timeout}, $config->{cardlength} ); $sourcecardinfo = &get_callingcard( $astpp_db, $cardnum, $config ); $AGI->verbose( "ASTPP Number: $cardnum ", $verbosity ) if $config->{debug} == 1; @@ -209,7 +209,7 @@ } $retries = 0; while ( $sourcecardinfo->{pin} != $sourcepin && $retries < $config->{pin_retries} ) { - $sourcepin = $AGI->get_data( $sound->{astpp_please_pin_card_empty}, $input_timeout ); + $sourcepin = $AGI->get_data( $sound->{pin}, $config->{calling_cards_number_input_timeout}, $config->{cardlength} ); if ( $sourcecardinfo->{pin} != $sourcepin ) { $AGI->stream_file($sound->{pin_incorrect}); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-19 10:00:21
|
Revision: 2168 http://astpp.svn.sourceforge.net/astpp/?rev=2168&view=rev Author: darrenkw Date: 2007-11-19 02:00:21 -0800 (Mon, 19 Nov 2007) Log Message: ----------- Card_inuse was being declared twice and the second time was marked as empty. Modified Paths: -------------- trunk/astpp-common.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-19 09:47:43 UTC (rev 2167) +++ trunk/astpp-common.pl 2007-11-19 10:00:21 UTC (rev 2168) @@ -3640,7 +3640,6 @@ $sound->{pin} = "astpp-pleasepin"; #Please enter your pin followed by pound. $sound->{pin_incorrect} = "astpp-invalidpin"; #Incorrect pin. $sound->{point} = "astcc-point"; #point. -$sound->{card_inuse} = ""; $sound->{register_ani} = "astpp-register" ; # "Register ANI to this card? Press 1 for yes or any other key for no." This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-19 09:47:40
|
Revision: 2167 http://astpp.svn.sourceforge.net/astpp/?rev=2167&view=rev Author: darrenkw Date: 2007-11-19 01:47:43 -0800 (Mon, 19 Nov 2007) Log Message: ----------- Added a couple of sound files. Also corrected the error in astpp-callingcards.agi. Asterisk cannot handle the amount of debugging I was throwing at it through the agi interface so I turned that off. Modified Paths: -------------- trunk/astpp-callingcards.agi trunk/sounds/astpp-phonenum.gsm trunk/sounds/astpp-this-card-has-a-balance-of.gsm Modified: trunk/astpp-callingcards.agi =================================================================== --- trunk/astpp-callingcards.agi 2007-11-18 05:18:03 UTC (rev 2166) +++ trunk/astpp-callingcards.agi 2007-11-19 09:47:43 UTC (rev 2167) @@ -40,7 +40,7 @@ $AGI->set_variable( 'ASTPP', '1' ); $ASTPP = ASTPP->new; $ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to be. -$ASTPP->set_asterisk_agi($AGI); +#$ASTPP->set_asterisk_agi($AGI); sub initialize() { $SIG{HUP} = 'ignore_hup'; # We ignore the HUP command that Asterisk sends on a call hangup. Modified: trunk/sounds/astpp-phonenum.gsm =================================================================== (Binary files differ) Modified: trunk/sounds/astpp-this-card-has-a-balance-of.gsm =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-18 05:17:59
|
Revision: 2166 http://astpp.svn.sourceforge.net/astpp/?rev=2166&view=rev Author: darrenkw Date: 2007-11-17 21:18:03 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Updated sample dialplan to use new audio file. Modified Paths: -------------- trunk/samples/sample.astpp-dialplan.conf Modified: trunk/samples/sample.astpp-dialplan.conf =================================================================== --- trunk/samples/sample.astpp-dialplan.conf 2007-11-18 05:17:05 UTC (rev 2165) +++ trunk/samples/sample.astpp-dialplan.conf 2007-11-18 05:18:03 UTC (rev 2166) @@ -38,7 +38,7 @@ [astpp-callingcards] exten => s,1,Answer -exten => s,2,Background(welcome); Welcome to Company X Calling Cards +exten => s,2,Background(astpp-menu); Welcome to Company X Calling Cards ; Press 1 to enter our calling card system. ; Press 2 to register your callerid number to your card. ; Press 3 to request a callback. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-18 05:17:04
|
Revision: 2165 http://astpp.svn.sourceforge.net/astpp/?rev=2165&view=rev Author: darrenkw Date: 2007-11-17 21:17:05 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Added a few audio files. Added Paths: ----------- trunk/sounds/astcc-badphone.gsm trunk/sounds/astpp-card-to-empty.gsm trunk/sounds/astpp-card-to-refill.gsm trunk/sounds/astpp-menu.gsm Added: trunk/sounds/astcc-badphone.gsm =================================================================== (Binary files differ) Property changes on: trunk/sounds/astcc-badphone.gsm ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/sounds/astpp-card-to-empty.gsm =================================================================== (Binary files differ) Property changes on: trunk/sounds/astpp-card-to-empty.gsm ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/sounds/astpp-card-to-refill.gsm =================================================================== (Binary files differ) Property changes on: trunk/sounds/astpp-card-to-refill.gsm ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/sounds/astpp-menu.gsm =================================================================== (Binary files differ) Property changes on: trunk/sounds/astpp-menu.gsm ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-18 03:13:50
|
Revision: 2164 http://astpp.svn.sourceforge.net/astpp/?rev=2164&view=rev Author: darrenkw Date: 2007-11-17 19:13:48 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Greatly enhanced the device monitor to log more and allow call hangup abilities. Modified Paths: -------------- trunk/astpp-device-monitor.pl Modified: trunk/astpp-device-monitor.pl =================================================================== --- trunk/astpp-device-monitor.pl 2007-11-18 03:13:07 UTC (rev 2163) +++ trunk/astpp-device-monitor.pl 2007-11-18 03:13:48 UTC (rev 2164) @@ -18,6 +18,7 @@ use Locale::Country; use Locale::gettext_pp qw(:locale_h); use Data::Dumper; +use ASTPP; use strict; use lib './lib', '../lib'; @@ -27,16 +28,19 @@ print STDERR "Interface language is set to: $ENV{'LANGUAGE'}\n"; bindtextdomain( "ASTPP", "/var/locale" ); textdomain("ASTPP"); -use vars qw(@output $shucks $params $astpp_db $cdr_db $config +use vars qw($ASTPP @output $shucks $params $astpp_db $cdr_db $config $uniqueid $run_type); @output = ( "STDOUT", "LOGFILE" ); $shucks = 0; +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. sub initialize() { $SIG{INT} = \&catch_zap; $config = &load_config(); $astpp_db = &connect_db( $config, @output ); $config = &load_config_db($astpp_db,$config); + $ASTPP->set_astpp_db($astpp_db); } ################# Program Starts HERE ################################# @@ -44,7 +48,7 @@ use POE; use POE::Component::Client::Asterisk::Manager; -print STDERR gettext("Connecting to Asterisk"); +$ASTPP->debug( debug=> gettext("Connecting to Asterisk")); POE::Component::Client::Asterisk::Manager->new( Alias => 'monitor', RemoteHost => $config->{astman_host}, @@ -54,7 +58,7 @@ CallBacks => { input => ':all', dial => { 'Event' => 'Newexten', # This is triggered when an extension starts a call. - 'Application' => 'Dial' +# 'Application' => 'Dial' }, hangup => { 'Event' => 'Hangup', }, @@ -88,10 +92,17 @@ if ( !$astpp_db ) { $astpp_db = &connect_db( $config, @output ); } - print STDERR "Peer: $peer REGISTERED" if $config->{debug} == 1; - $astpp_db->do("INSERT INTO extensions_status (tech,extension,status) VALUES (" + + $ASTPP->debug( debug=> "Peer: $peer REGISTERED"); + my $tmp = "INSERT INTO extensions_status (tech,extension,status,Event,Privilege,PeerStatus,Peer) VALUES (" . $astpp_db->quote(@extension[0]) . "," - . $astpp_db->quote(@extension[1]) . ",'Registered')"); + . $astpp_db->quote(@extension[1]) . ",'Registered'," + . $astpp_db->quote($_[ARG0]->{Event}) . "," + . $astpp_db->quote($_[ARG0]->{Privilege}) . "," + . $astpp_db->quote($_[ARG0]->{PeerStatus}) . "," + . $astpp_db->quote($_[ARG0]->{Peer}) . ")"; + $ASTPP->debug( debug=> "SQL: $tmp"); + $astpp_db->do($tmp); } sub manager_record_unregister() { @@ -100,10 +111,12 @@ if ( !$astpp_db ) { $astpp_db = &connect_db( $config, @output ); } - print STDERR "Peer: $peer UNREGISTERED" if $config->{debug} == 1; - $astpp_db->do("INSERT INTO extensions_status (tech,extension,status) VALUES (" + $ASTPP->debug( debug=> "Peer: $peer UNREGISTERED"); + my $tmp = "INSERT INTO extensions_status (tech,extension,status) VALUES (" . $astpp_db->quote(@extension[0]) . "," - . $astpp_db->quote(@extension[1]) . ",'UnRegistered')"); + . $astpp_db->quote(@extension[1]) . ",'UnRegistered')"; + $ASTPP->debug( debug=> "SQL: $tmp"); + $astpp_db->do($tmp); } sub manager_record_answer() { @@ -113,11 +126,13 @@ if ( !$astpp_db ) { $astpp_db = &connect_db( $config, @output ); } - print STDERR "Peer: @extension1[0] Answer" if $config->{debug} == 1; - $astpp_db->do("INSERT INTO extensions_status (tech,extension,status,number) VALUES (" + $ASTPP->debug( debug=> "Peer: @extension1[0] Answer"); + my $tmp = "INSERT INTO extensions_status (tech,extension,status,number) VALUES (" . $astpp_db->quote(@extension[0]) . "," . $astpp_db->quote(@extension1[0]) . ",'Answer'," - . $astpp_db->quote($_[ARG0]->{Extension}) . ")"); + . $astpp_db->quote($_[ARG0]->{Extension}) . ")"; + $ASTPP->debug( debug=> "SQL: $tmp"); + $astpp_db->do($tmp); } sub manager_record_dial() { @@ -127,11 +142,21 @@ if ( !$astpp_db ) { $astpp_db = &connect_db( $config, @output ); } - print STDERR "Peer: @extension1[0] PLACING CALL" if $config->{debug} == 1; - $astpp_db->do("INSERT INTO extensions_status (tech,extension,status,number) VALUES (" + $ASTPP->debug( debug=> "Peer: @extension1[0] PLACING CALL"); + my $tmp = "INSERT INTO extensions_status (tech,extension,status,number,Channel,Privilege,Context,AstExtension,Application,Uniqueid,AppData,Priority) VALUES (" . $astpp_db->quote(@extension[0]) . "," . $astpp_db->quote(@extension1[0]) . ",'Dial'," - . $astpp_db->quote($_[ARG0]->{Extension}) . ")"); + . $astpp_db->quote($_[ARG0]->{Extension}) . "," + . $astpp_db->quote($_[ARG0]->{Channel}) . "," + . $astpp_db->quote($_[ARG0]->{Privilege}) . "," + . $astpp_db->quote($_[ARG0]->{Context}) . "," + . $astpp_db->quote($_[ARG0]->{Extension}) . "," + . $astpp_db->quote($_[ARG0]->{Application}) . "," + . $astpp_db->quote($_[ARG0]->{Uniqueid}) . "," + . $astpp_db->quote($_[ARG0]->{AppData}) . "," + . $astpp_db->quote($_[ARG0]->{Priority}) . ")"; + $ASTPP->debug( debug=> "SQL: $tmp"); + $astpp_db->do($tmp); } sub manager_record_hangup() { @@ -142,10 +167,12 @@ if ( !$astpp_db ) { $astpp_db = &connect_db( $config, @output ); } - print STDERR "Peer: @extension2[0] HUNGUP" if $config->{debug} == 1; - $astpp_db->do("INSERT INTO extensions_status (tech,extension,status) VALUES (" + $ASTPP->debug( debug=> "Peer: @extension2[0] HUNGUP"); + my $tmp = "INSERT INTO extensions_status (tech,extension,status) VALUES (" . $astpp_db->quote(@extension[0]) . "," - . $astpp_db->quote(@extension2[0]) . ",'Hungup')"); + . $astpp_db->quote(@extension2[0]) . ",'Hungup')"; + $ASTPP->debug( debug=> "SQL: $tmp"); + $astpp_db->do($tmp); } $poe_kernel->run(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-18 03:13:11
|
Revision: 2163 http://astpp.svn.sourceforge.net/astpp/?rev=2163&view=rev Author: darrenkw Date: 2007-11-17 19:13:07 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Added call hangup capabilities. Modified Paths: -------------- trunk/astpp-common.pl trunk/templates/booths-list.tpl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-18 03:12:44 UTC (rev 2162) +++ trunk/astpp-common.pl 2007-11-18 03:13:07 UTC (rev 2163) @@ -3488,6 +3488,18 @@ return (1, $maxlength); } +sub hangup_call() { + my ($astpp_db,$config,$channel) = @_; + use Asterisk::Manager; + my $astman = new Asterisk::Manager; + $astman->user($config->{astman_user}); + $astman->secret($config->{astman_secret}); + $astman->host($config->{astman_host}); + $astman->connect || die $astman->error . "\n"; + my %callout = ( Action => 'Hangup', Channel => $channel); + print STDERR $astman->sendcommand(%callout); +} + # Perfrom callout using the Asterisk Manager Interface. sub perform_callout() { my ($astpp_db,$config,$number,$lcrcontext,$accountcode,$maxretries,$waittime,$retrytime,$clidname,$clidnumber,$context,$extension,%variables) = @_; @@ -3522,36 +3534,11 @@ ActionID => $actionid, Variable => "ACTIONID=$actionid", Priority => '1' ); -# foreach my $variable (@variables) { -# print STDERR "SET: $variable->{name} - $variable->{value} \n"; -# %callout->{Variable} = "$variable->{name}=$variable->{value}"; -# } foreach my $key (keys %callout) { - print STDERR "Key: $key Value: " . $callout{$key} . "\n"; + print STDERR "Key: $key Value: " . $callout{$key} . "\n"; } -print STDERR $astman->sendcommand(%callout); - - -# use Asterisk::Outgoing; -# my $out = new Asterisk::Outgoing; -# my $channel = "Local\/" . $number . "\@$lcrcontext"; -# $out->setvariable( 'Channel', $channel ); -# $out->setvariable( 'MaxRetries', $maxretries ); -# $out->setvariable( 'RetryTime', $retrytime ); -# $out->setvariable( 'WaitTime', $waittime ); -# $out->setvariable( "context", $context ); -# $out->setvariable( "extension", $extension ); -# $out->setvariable( "CallerID", "<$clidname> $clidnumber" ); -# $out->setvariable( "SetVar", "ACCOUNTCODE = $accountcode "); -# foreach my $variable (@variables) { -# print STDERR "SET: $variable->{name} - $variable->{value} /n"; -# $out->setvariable( "Set", "$variable->{name} = $variable->{value}" ); -# $out->setvariable( "SetVar", "$variable->{name} = $variable->{value}" ); -# } -# $out->outtime( time() + 15 ); -# $out->create_outgoing; -# print STDERR "Created Call to: $number\n"; + print STDERR $astman->sendcommand(%callout); } # Check to see if a calling card is ok to use. Modified: trunk/templates/booths-list.tpl =================================================================== --- trunk/templates/booths-list.tpl 2007-11-18 03:12:44 UTC (rev 2162) +++ trunk/templates/booths-list.tpl 2007-11-18 03:13:07 UTC (rev 2163) @@ -25,7 +25,8 @@ <TD><TMPL_VAR NAME="callstart"></TD> <TD><TMPL_VAR NAME="number"></TD> <TD><TMPL_VAR NAME="status"></TD> - <TD> <a href="astpp-admin.cgi?mode=List Booths&action=Deactivate Booth&booth_name=<TMPL_VAR NAME="name">">Deactivate Booth</a> + <TD> <a href="astpp-admin.cgi?mode=List Booths&action=Hangup Call&channel=<TMPL_VAR NAME="channel">">Hangup Call</a> + <a href="astpp-admin.cgi?mode=List Booths&action=Deactivate Booth&booth_name=<TMPL_VAR NAME="name">">Deactivate Booth</a> <a href="astpp-admin.cgi?mode=List Booths&action=Restore Booth&booth_name=<TMPL_VAR NAME="name">">Restore Booth</a> </TD> </TR> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |