astpp-commit Mailing List for ASTPP - Open Source Voip Billing (Page 8)
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...> - 2007-11-18 03:12:46
|
Revision: 2162 http://astpp.svn.sourceforge.net/astpp/?rev=2162&view=rev Author: darrenkw Date: 2007-11-17 19:12:44 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Cleaned up the debugging in astpp-admin.cgi and added call hangup abilities. Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-18 00:26:27 UTC (rev 2161) +++ trunk/astpp-admin.cgi 2007-11-18 03:12:44 UTC (rev 2162) @@ -1200,7 +1200,7 @@ or dstchannel like '$row->{tech}\[$row->{path}\]%' ) "; my $sth4 = $cdr_db->prepare($sql4); - print STDERR " SQL: $sql4 \n " if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => " SQL: $sql4"); $sth4->execute(); my $ref4 = $sth4->fetchrow_hashref(); $sth4->finish; @@ -1337,7 +1337,7 @@ . $cdr_db->quote($sd) . " and calldate <= " . $cdr_db->quote($ed); - print STDERR " SQL: $tmp \n " if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => " SQL: $tmp"); } else { $tmp = @@ -1345,7 +1345,7 @@ . $cdr_db->quote($sd) . " and calldate <= " . $cdr_db->quote($ed); - print STDERR " SQL: $tmp \n " if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => " SQL: $tmp"); } if ( $params->{accountcode} && $params->{logintype} == 2 ) { $tmp .= @@ -1356,7 +1356,7 @@ "SELECT * FROM trunks WHERE name = " . $astpp_db->quote( $params->{trunk} ) . " LIMIT 1"; - print STDERR $tmpsql if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmpsql); $sql = $astpp_db->prepare($tmpsql); $sql->execute || return gettext("Something is wrong with the trunks database") @@ -1367,7 +1367,7 @@ " and (dstchannel like '$row->{tech}/$row->{path}\%'" . " or dstchannel like '$row->{tech}\[$row->{path}\]\%')"; } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); $sql = $cdr_db->prepare($tmp); $sql->execute; $results = $sql->rows; @@ -1492,7 +1492,7 @@ $accounts .= ","; } } - print STDERR $accounts if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $accounts); $template->param( customer_count => &count_accounts( $astpp_db, "WHERE type = 0 AND reseller = '$params->{username}'" @@ -1759,7 +1759,7 @@ . $astpp_db->quote($number) . ", " . $astpp_db->quote( $params->{prefix} ) . ", " . $astpp_db->quote( $params->{ipcontext} ) . ")"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); if ( $astpp_db->do($tmp) ) { $status .= gettext("IP") . " '" @@ -2110,7 +2110,7 @@ "You have added $params->{count} calling cards in the amount of $params->{value} cents. \n\n"; } my $brandinfo = &get_cc_brand( $astpp_db, $params->{brand} ); - print STDERR "BRAND: $params->{brand}\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "BRAND: $params->{brand}"); while ( $count < $params->{count} ) { my ( $number, $pin ) = &add_callingcard( $astpp_db, $config, $brandinfo, @@ -2384,7 +2384,7 @@ "DELETE FROM callingcardbrands WHERE name = " . $astpp_db->quote( $params->{name} ); } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); if ( $astpp_db->do($tmp) ) { $status .= gettext("Brand Deleted!"); } @@ -2431,7 +2431,7 @@ . $astpp_db->quote( $params->{min_length_minutes} ) . ", " . $astpp_db->quote( $params->{min_length_pennies} ) . ")"; } - print STDERR "sql" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "sql"); if ( $astpp_db->do($sql) ) { $status .= gettext("Brand Added!"); } @@ -2571,7 +2571,7 @@ . " WHERE name =" . $astpp_db->quote( $params->{name} ); } - print STDERR "$sql" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); if ( $astpp_db->do($sql) ) { $status .= gettext("Brand Updated!"); } @@ -2726,7 +2726,7 @@ $tmp = "SELECT name FROM callingcardbrands WHERE status < 2 AND reseller IN (NULL,'')"; } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); $sql = $astpp_db->prepare($tmp); $sql->execute || return gettext( @@ -2748,7 +2748,7 @@ $tmp = "SELECT * FROM callingcardbrands WHERE status < 2 AND reseller IN (NULL,'') ORDER BY name limit $params->{limit} , $results_per_page"; } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); $sql->execute || return gettext( @@ -3038,7 +3038,7 @@ . $astpp_db->quote( $cardinfo->{cardnumber} ) . " AND brand " . $brandsql; - print STDERR $sql if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); $astpp_db->do($sql) || print "$sql " . gettext("FAILED"); } @@ -3048,8 +3048,7 @@ if ( $params->{action} eq gettext("Refill") ) { $cardinfo = &get_callingcard( $astpp_db, $params->{cardnumber}, $config ); - print STDERR "CARDNUMBER: " . $cardinfo->{cardnumber} - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "CARDNUMBER: " . $cardinfo->{cardnumber}); &update_balance( $cardinfo, $params->{pennies} * 100 ); $status .= "$params->{cardnumber} " . gettext("Refilled") . "<br>\n"; } @@ -3240,7 +3239,7 @@ "SELECT * FROM callingcards WHERE status < 2 AND brand $brandsql ORDER BY id LIMIT " . ( $pgr->get_first() - 1 ) . ", " . $pgr->get_entries_on_this_page(); - print STDERR $sql if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); $sql = $astpp_db->prepare($sql); $sql->execute; @@ -3872,9 +3871,8 @@ sub default_callback { my (%stuff) = @_; foreach ( keys %stuff ) { - print STDERR "$_: " . $stuff{$_} . "\n"; + $ASTPP->debug( user=> $param->{username}, debug => "$_: " . $stuff{$_}); } - print STDERR "\n"; } sub build_statistics() { @@ -4584,7 +4582,7 @@ . $astpp_db->quote( $params->{desc} ) . ", " . $astpp_db->quote( $params->{charge} ) . ", " . $astpp_db->quote( $params->{sweep} ) . ", 1)"; - print STDERR "sql" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); if ( $astpp_db->do($sql) ) { $status .= gettext("Periodic Charge Added!"); } @@ -4715,7 +4713,7 @@ . $astpp_db->quote( $params->{sweep} ) . ", status = '1' WHERE id = " . $astpp_db->quote( $params->{chargeid} ); - print STDERR "sql" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); if ( $astpp_db->do($sql) ) { $status .= gettext("Periodic Charge Updated!"); } @@ -4729,7 +4727,7 @@ my $sql = "DELETE FROM charges WHERE id = " . $astpp_db->quote( $params->{chargeid} ); - print STDERR "sql" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); if ( $astpp_db->do($sql) ) { $status .= gettext("Periodic Charge Deleted!"); } @@ -4740,7 +4738,7 @@ $sql = "DELETE FROM charge_to_account WHERE charge_id = " . $astpp_db->quote( $params->{chargeid} ); - print STDERR $sql if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); if ( $astpp_db->do($sql) ) { $status .= gettext("Periodic Charge Deleted!"); } @@ -4914,7 +4912,7 @@ $uploaded = upload('rateimport'); my ( @data, $record ); while ( my $record = <$uploaded> ) { - print STDERR $record if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $record ); chomp; push @data, $record; } @@ -4955,7 +4953,7 @@ . $astpp_db->quote( $columns[9] ) . "," . $astpp_db->quote( $columns[1] ) . ", 1," . $astpp_db->quote( $columns[10] ) . ")"; - print STDERR $tmp; # if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Pattern: ") . " '" . $pattern . "' " @@ -5044,7 +5042,7 @@ $uploaded = upload('rateimport'); my ( @data, $record ); while ( my $record = <$uploaded> ) { - print STDERR $record if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $record ); chomp; push @data, $record; } @@ -5076,7 +5074,7 @@ . " AND pricelist = " . $astpp_db->quote( $resellerdata->{pricelist} ) . " LIMIT 1"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); $sql = $astpp_db->prepare($tmp); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { @@ -5266,7 +5264,7 @@ . $astpp_db->quote( $columns[13] ) . "," . $astpp_db->quote( $columns[14] ) . "," . $astpp_db->quote( $columns[15] ) . ")"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); if ( $astpp_db->do($tmp) ) { $status .= gettext("DID: ") . " '" @@ -5296,7 +5294,7 @@ gettext("The old pattern for") . " '" . $params->{number} . "' " . gettext("FAILED to remove!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $tmp = "INSERT INTO routes (pattern,comment,pricelist,connectcost,includedseconds,cost) VALUES (" @@ -5586,7 +5584,7 @@ gettext("Pricelist: ") . $params->{name} . gettext(" Failed to Reactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } } else { @@ -5624,7 +5622,7 @@ gettext("Pricelist: ") . $params->{name} . gettext(" Failed to Add!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } } $params->{action} = gettext("Information..."); @@ -5666,7 +5664,7 @@ gettext("Pricelist: ") . $params->{name} . gettext(" Failed to Update!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } } else { @@ -5705,7 +5703,7 @@ gettext("Pricelist: ") . $params->{name} . gettext(" Failed to Deactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } } $params->{action} = gettext("Information..."); @@ -5773,7 +5771,7 @@ $tmp = "SELECT * FROM pricelists WHERE status < 2 AND reseller IS NULL"; } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the ASTPP database!") @@ -5795,7 +5793,7 @@ $tmp = "SELECT * FROM pricelists WHERE status < 2 AND reseller IS NULL ORDER BY name limit $params->{limit} , $results_per_page"; } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the ASTPP database!") @@ -6158,7 +6156,7 @@ gettext("DID") . " '" . $params->{number} . "' " . gettext("FAILED to create!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $tmp = "DELETE FROM routes WHERE pattern = " @@ -6176,7 +6174,7 @@ gettext("The old pattern for") . " '" . $params->{number} . "' " . gettext("FAILED to remove!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $tmp = "INSERT INTO routes (pattern,comment,pricelist,connectcost,includedseconds,cost) VALUES (" @@ -6200,7 +6198,7 @@ gettext("Pattern") . " '" . $params->{number} . "' " . gettext("FAILED to create!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -6258,7 +6256,7 @@ gettext("DID") . " '" . $params->{number} . "' " . gettext("FAILED to update!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $tmp = "UPDATE routes SET" @@ -6288,7 +6286,7 @@ gettext("Pattern") . " '" . $params->{number} . "' " . gettext("FAILED to create!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -6307,7 +6305,7 @@ gettext("DID: ") . $params->{number} . gettext(" Failed to Deactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -6900,7 +6898,7 @@ . $astpp_db->quote($params->{username}) . " AND type = '1' AND note = " . $astpp_db->quote($params->{number}); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $astpp_db->do($tmp); $tmp = "INSERT INTO reseller_pricing (reseller,type,note,monthlycost,prorate,setup,cost,inc,disconnectionfee,connectcost,includedseconds,status) VALUES (" @@ -6916,7 +6914,7 @@ . $astpp_db->quote( $params->{connectcost} ) . "," . $astpp_db->quote( $params->{included} ) . ", '1')"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("DID.") . " '" @@ -6928,7 +6926,7 @@ gettext("DID") . " '" . $params->{number} . "' " . gettext("FAILED to create!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $astpp_db->do("UPDATE dids SET dial_as = " . $astpp_db->quote($params->{dial_as})); $tmp = @@ -6936,7 +6934,7 @@ . $astpp_db->quote( "^" . $params->{number} . "\$" ) . " AND pricelist = " . $astpp_db->quote( $params->{username} ); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("The old pattern for") . " '" @@ -6948,7 +6946,7 @@ gettext("The old pattern for") . " '" . $params->{number} . "' " . gettext("FAILED to remove!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $tmp = "INSERT INTO routes (pattern,comment,pricelist,connectcost,includedseconds,cost) VALUES (" @@ -6961,7 +6959,7 @@ . $astpp_db->quote( $params->{connectcost} ) . "," . $astpp_db->quote( $params->{included} ) . "," . $astpp_db->quote( $params->{cost} ) . ")"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Pattern") . " '" @@ -6973,7 +6971,7 @@ gettext("Pattern") . " '" . $params->{number} . "' " . gettext("FAILED to create!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -6983,7 +6981,7 @@ . $astpp_db->quote( $params->{number} ) . " AND type = '1' AND reseller = " . $astpp_db->quote( $params->{username} ); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("DID: ") @@ -6995,7 +6993,7 @@ gettext("DID: ") . $params->{number} . gettext(" Failed to Deactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -7365,7 +7363,7 @@ "SELECT * FROM routes WHERE id = " . $astpp_db->quote( $params->{id} ); } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); $sql->execute; $record = $sql->fetchrow_hashref; @@ -7467,7 +7465,7 @@ . " AND pricelist = " . $astpp_db->quote( $resellerdata->{pricelist} ) . " LIMIT 1"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { @@ -7503,7 +7501,7 @@ . $astpp_db->quote( $params->{cost} ) . "," . $astpp_db->quote( $params->{inc} ) . "," . $astpp_db->quote($reseller) . ")"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Pattern") . " '" @@ -7515,7 +7513,7 @@ gettext("Pattern") . " '" . $params->{pattern} . "' " . gettext("FAILED to create!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); } $params->{action} = gettext("Information..."); } @@ -7533,15 +7531,14 @@ . " AND pricelist = " . $astpp_db->quote( $resellerdata->{pricelist} ) . " LIMIT 1"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); $sql = $astpp_db->prepare($tmp); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { $routeinfo = $row; } $sql->finish; - print STDERR "Reseller Cost = $routeinfo->{cost}" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "Reseller Cost = $routeinfo->{cost}" ); if ( $routeinfo->{cost} > $params->{cost} ) { $status .= "<br><b>" . gettext("Pattern: ") @@ -7586,7 +7583,7 @@ gettext("Pattern") . " '" . $params->{id} . "' " . gettext("FAILED to saved!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -7614,7 +7611,7 @@ gettext("Route: ") . $params->{id} . gettext(" Failed to Deactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -7737,7 +7734,7 @@ $tmp = "SELECT * FROM routes WHERE status < 2 AND reseller IN (NULL,'')"; } - print STDERR $tmp if ( $config->{debug} == 1 ); + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the ASTPP database!") @@ -7865,7 +7862,7 @@ my $results = $astpp_db->prepare($sql); $results->execute; while ( my $counterinfo = $results->fetchrow_hashref ) { - print STDERR "COUNTER: " . $counterinfo->{id} if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "COUNTER: " . $counterinfo->{id} ); my (%row); $row{id} = $counterinfo->{id}; $row{package} = $counterinfo->{name}; @@ -7927,7 +7924,7 @@ gettext("Package: ") . $params->{name} . gettext(" Failed to Add!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -7940,7 +7937,7 @@ . $astpp_db->quote( $params->{edit_includedseconds} ) . " WHERE id = " . $astpp_db->quote( $params->{id} ); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Package: ") @@ -7970,7 +7967,7 @@ gettext("Package: ") . $params->{id} . gettext(" Failed to Deactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -7999,7 +7996,7 @@ my $results = $astpp_db->prepare($sql); $results->execute; while ( my $packageinfo = $results->fetchrow_hashref ) { - print STDERR "PACKAGE: " . $packgeinfo->{id} if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "PACKAGE: " . $packgeinfo->{id} ); my (%row); $row{id} = $packageinfo->{id}; $row{name} = $packageinfo->{name}; @@ -8096,22 +8093,18 @@ -default => $record->{precedence} ) . "</td><td>"; my @resellers = &list_resellers($astpp_db); - print STDERR "RESELLER LIST: $record->{resellers}" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER LIST: $record->{resellers}"); foreach my $reseller (@resellers) { my $reseller_enabled; -# my $regex_pattern = "m\/'" . $reseller . "'\/"; # This cryptic bit of code searches for $reseller surrounded by quotation marks. -# print STDERR "REGEX PATTERN: $regex_pattern" if $config->{debug} == 1; if ( $record->{resellers} =~ m/'$reseller'/ ) { $reseller_enabled = 1; } else { $reseller_enabled = 0; } - print STDERR "RESELLER_ENABLED: $reseller_enabled" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER_ENABLED: $reseller_enabled"); $body .= checkbox( -name => "reseller-$reseller", -checked => $reseller_enabled, @@ -8144,7 +8137,7 @@ . $astpp_db->quote( $params->{precedence} ) . ", " . $astpp_db->quote($resellerlist) . ", " . $astpp_db->quote( $params->{provider} ) . ")"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Trunk: ") @@ -8186,7 +8179,7 @@ . $astpp_db->quote( $params->{maxchannels} ) . " WHERE name = " . $astpp_db->quote( $params->{name} ); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Trunk: ") @@ -8198,7 +8191,7 @@ gettext("Trunk: ") . $params->{name} . gettext(" Failed to Update!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -8217,7 +8210,7 @@ gettext("Trunk: ") . $params->{name} . gettext(" Failed to Deactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $tmp = "DELETE FROM routes WHERE trunk = " @@ -8227,7 +8220,7 @@ } else { $status .= gettext("Related Routes Failed to Remove!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -8292,21 +8285,16 @@ -size => 2 ) . "</td><td>"; my @resellers = &list_resellers($astpp_db); - print STDERR "RESELLER LIST: $record->{resellers}" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER LIST: $record->{resellers}"); foreach my $reseller (@resellers) { my $reseller_enabled; - -# my $regex_pattern = "m\/'" . $reseller . "'\/"; # This cryptic bit of code searches for $reseller surrounded by quotation marks. -# print STDERR "REGEX PATTERN: $regex_pattern" if $config->{debug} == 1; if ( $record->{resellers} =~ m/'$reseller'/ ) { $reseller_enabled = 1; } else { $reseller_enabled = 0; } - print STDERR "RESELLER_ENABLED: $reseller_enabled" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER_ENABLED: $reseller_enabled"); $body .= checkbox( -name => "reseller-$reseller", -checked => $reseller_enabled, @@ -8697,22 +8685,17 @@ -default => $record->{precedence} ) . "</td><td>"; my @resellers = &list_resellers($astpp_db); - print STDERR "RESELLER LIST: $record->{resellers}" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER LIST: $record->{resellers}"); foreach my $reseller (@resellers) { my $reseller_enabled; - -# my $regex_pattern = "m\/'" . $reseller . "'\/"; # This cryptic bit of code searches for $reseller surrounded by quotation marks. -# print STDERR "REGEX PATTERN: $regex_pattern" if $config->{debug} == 1; if ( $record->{resellers} =~ m/'$reseller'/ ) { $reseller_enabled = 1; } else { $reseller_enabled = 0; } - print STDERR "RESELLER_ENABLED: $reseller_enabled" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER_ENABLED: $reseller_enabled"); $body .= checkbox( -name => "reseller-$reseller", -checked => $reseller_enabled, @@ -8772,7 +8755,7 @@ gettext("Outbound Route: ") . " '" . $params->{pattern} . "' " . gettext("FAILED to create!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); } $params->{action} = gettext("Information..."); } @@ -8820,7 +8803,7 @@ gettext("Outbound Route:") . " '" . $params->{id} . "' " . gettext("FAILED to saved!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -8828,7 +8811,7 @@ my $tmp = "UPDATE outbound_routes SET status = 2 WHERE id = " . $astpp_db->quote( $params->{id} ); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Outbound Route: ") @@ -8840,7 +8823,7 @@ gettext("Outbound Route: ") . $params->{id} . gettext(" Failed to Deactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -8923,21 +8906,16 @@ -size => 2 ) . "</td><td>"; my @resellers = &list_resellers($astpp_db); - print STDERR "RESELLER LIST: $record->{resellers}" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER LIST: $record->{resellers}"); foreach my $reseller (@resellers) { my $reseller_enabled; - -# my $regex_pattern = "m\/'" . $reseller . "'\/"; # This cryptic bit of code searches for $reseller surrounded by quotation marks. -# print STDERR "REGEX PATTERN: $regex_pattern" if $config->{debug} == 1; if ( $record->{resellers} =~ m/'$reseller'/ ) { $reseller_enabled = 1; } else { $reseller_enabled = 0; } - print STDERR "RESELLER_ENABLED: $reseller_enabled" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER_ENABLED: $reseller_enabled"); $body .= checkbox( -name => "reseller-$reseller", -checked => $reseller_enabled, @@ -9144,10 +9122,9 @@ else { $increment = $branddata->{inc}; } - print STDERR "$numdata->{connectcost}, $numdata->{cost}, " + $ASTPP->debug( user=> $param->{username}, debug => "$numdata->{connectcost}, $numdata->{cost}, " . $params->{length} * 60 - . ", $increment, $numdata->{includedseconds}" - if $config->{debug} == 1; + . ", $increment, $numdata->{includedseconds}"); my $cost = &calc_call_cost( $numdata->{connectcost}, $numdata->{cost}, $params->{length} * 60, $increment, @@ -9216,7 +9193,7 @@ "SELECT * FROM system WHERE reseller = " . $astpp_db->quote( $params->{username} ) . " ORDER BY name"; } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); my $sql = $astpp_db->prepare($tmp); $sql->execute; while ( my $record = $sql->fetchrow_hashref ) { @@ -9357,9 +9334,7 @@ . $rt_db->quote( $params->{rt_sip_cancallforward} ) . " WHERE id = " . $rt_db->quote( $params->{devicenumber} ); - if ( $config->{debug} == 1 ) { - print STDERR " $tmp \n" if $config->{debug} == 1; - } + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $rt_db->do($tmp) ) { $status .= gettext("Updated Device:") . " $params->{name}<br>"; } @@ -9733,7 +9708,7 @@ . int( rand() * 9000 + 1000 ); $sipid = substr( $sipid, 0, 5 ); $sipid = $name . $sipid; - print STDERR "SIPID: $sipid\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "SIPID: $sipid" ); $sql = $rt_db->prepare( "SELECT COUNT(*) FROM $config->{rt_sip_table} WHERE name = " @@ -9821,9 +9796,7 @@ . $rt_db->quote( $params->{rt_codec_allow} ) . " WHERE name = " . $rt_db->quote( $params->{devicenumber} ); - if ( $config->{debug} == 1 ) { - print STDERR " $tmp \n" if $config->{debug} == 1; - } + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $rt_db->do($tmp) ) { $status .= gettext("Updated Device:") . " $params->{devicenumber}<br>"; @@ -10161,7 +10134,7 @@ . int( rand() * 9000 + 1000 ); $iaxid = substr( $iaxid, 0, 5 ); $iaxid = $name . $iaxid; - print STDERR "IAXID: $iaxid\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "IAXID: $iaxid"); $sql = $rt_db->prepare( "SELECT COUNT(*) FROM $config->{rt_iax_table} WHERE name = " @@ -10234,9 +10207,7 @@ . $rt_db->quote( $params->{appdata} ) . " WHERE id = " . $rt_db->quote( $params->{id} ); - if ( $config->{debug} == 1 ) { - print STDERR " $tmp \n" if $config->{debug} == 1; - } + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $rt_db->do($tmp) ) { $status .= gettext("Updated Dialplan Entry:") . " $params->{id}<br>"; @@ -10507,7 +10478,7 @@ . $astpp_db->quote( $params->{osc_dbuser} ) . ", " . $astpp_db->quote( $params->{osc_dbhost} ) . ", " . $astpp_db->quote( $params->{osc_site} ) . ", 1)"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("CallShop Added Successfully!"); } @@ -10555,7 +10526,7 @@ $tmp = "DELETE FROM callshops WHERE name = " . $astpp_db->quote( $params->{callshop} ); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("CallShop") @@ -10625,7 +10596,7 @@ . $astpp_db->quote( $params->{number} ) . " LIMIT 1" ); if ( $params->{SIP} ) { - print STDERR gettext("Adding SIP Device!") if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => gettext("Adding SIP Device!")); $config->{rt_sip_type} = "friend"; #$params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; if ( $config->{users_dids_rt} == 1 ) { @@ -10663,8 +10634,7 @@ } } if ( $params->{IAX2} ) { - print STDERR gettext("Adding IAX2 Device!") - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => gettext("Adding IAX2 Device!")); $config->{rt_iax_type} = "friend"; #$params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; if ( $config->{users_dids_amp} == 1 ) { @@ -10715,7 +10685,7 @@ . $osc_db->quote( $params->{number} ) . ",''," . $osc_db->quote( $config->{emailadd} ) . ",''," . $osc_db->quote( $params->{accountpassword} ) . ",'')"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $osc_db->prepare($tmp); $sql->execute; my $customerid = $sql->{'mysql_insertid'}; @@ -10723,7 +10693,7 @@ $tmp = "INSERT INTO customers_info (customers_info_id) VALUES (" . $osc_db->quote($customerid) . ")"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $osc_db->prepare($tmp); $sql->execute; $sql->finish; @@ -10735,7 +10705,7 @@ . $osc_db->quote( $params->{number} ) . ",''," . "'Address','Postal Code','City','State'," . $osc_db->quote( $record->{countries_id} ) . ",'0')"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $osc_db->prepare($tmp); $sql->execute; my $addressid = $sql->{'mysql_insertid'}; @@ -10786,7 +10756,7 @@ . $astpp_db->quote( $params->{booth_name} ) . " AND reseller = " . $astpp_db->quote( $params->{username} ); - print STDERR $sql if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); if ( $astpp_db->do($sql) ) { $status .= gettext("Booth:") . " " @@ -10803,9 +10773,7 @@ #If this account doesn't exist we don't go through the rest if ( $accountinfo->{number} ) { if ( $config->{users_dids_rt} == 1 ) { - print STDERR - "NUMBER: $accountinfo->{number} CC: $accountinfo->{cc}" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "NUMBER: $accountinfo->{number} CC: $accountinfo->{cc}"); my @iax_devicelist = &list_iax_account_rt( $rt_db, $config, $accountinfo->{number}, @@ -10826,9 +10794,7 @@ } } if ( $config->{users_dids_amp} == 1 ) { - print STDERR - "NUMBER: $accountinfo->{number} CC: $accountinfo->{cc}" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "NUMBER: $accountinfo->{number} CC: $accountinfo->{cc}" ); my @iax_devicelist = &list_iax_account_amp( $freepbx_db, $config, $accountinfo->{number}, @@ -10874,11 +10840,15 @@ if ( $params->{action} eq gettext("Deactivate Booth") ) { $astpp_db->do( "UPDATE accounts SET status = 0 WHERE number = " . $astpp_db->quote( $params->{booth_name} ) ); + &hangup_call($astpp_db,$config,$params->{channel}); } elsif ( $params->{action} eq gettext("Restore Booth") ) { $astpp_db->do( "UPDATE accounts SET status = 1 WHERE number = " . $astpp_db->quote( $params->{booth_name} ) ); } + elsif ( $params->{action} eq gettext("Hangup Call") ) { + &hangup_call($astpp_db,$config,$params->{channel}); + } foreach my $name (@booth_list) { my ( %row, $balance, $tmp, $sql ); my $boothinfo = &get_account_including_closed( $astpp_db, $name ); @@ -10902,7 +10872,7 @@ . " WHERE accountcode = " . $rt_db->quote( $boothinfo->{cc} ) . " LIMIT 1"; - print STDERR $tmp; # if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); my $sql = $rt_db->prepare($tmp); $sql->execute; $sip_login = $sql->fetchrow_hashref; @@ -10913,7 +10883,7 @@ . " WHERE accountcode = " . $rt_db->quote( $boothinfo->{cc} ) . " LIMIT 1"; - print STDERR $tmp; # if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $rt_db->prepare($tmp); $sql->execute; $iax2_login = $sql->fetchrow_hashref; @@ -10940,7 +10910,7 @@ . " ORDER BY id DESC LIMIT 1"; } if ( $tmp ne "" ) { - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); $sql->execute; $booth_status = $sql->fetchrow_hashref; @@ -10949,10 +10919,11 @@ if ( $row{callstart} ne "" && $booth_status->{status} eq "Dial" || $booth_status->{status} eq "Answer" ) { + $row{channel} = $booth_status->{Channel}; $row{number} = $booth_status->{number}; my $tmp = "SELECT TIMEDIFF(NOW(),'$row{callstart}') AS length"; - print STDERR $tmp; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); $sql = $astpp_db->prepare($tmp); $sql->execute; my $record = $sql->fetchrow_hashref; @@ -11006,11 +10977,9 @@ } push( @booths, \%row ); $sql->finish; - if ( $config->{debug} == 1 ) { - print STDERR $tmp; - print STDERR $record->{"COUNT(*)"}; - print STDERR $balance / 10000; - } + $ASTPP->debug( user=> $param->{username}, debug => $tmp); + $ASTPP->debug( user=> $param->{username}, debug => $record->{"COUNT(*)"}); + $ASTPP->debug( user=> $param->{username}, debug => $balance / 10000); } my $template = @@ -11052,9 +11021,9 @@ if ( $config->{externalbill} eq "oscommerce" ) { if ( $accountinfo->{posttoexternal} == 1 ) { - print STDERR gettext("Connecting to OSCommerce."); + $ASTPP->debug( user=> $param->{username}, debug => gettext("Connecting to OSCommerce.")); my $osc_db = &osc_connect_db( $config ); - print STDERR gettext("Generating Invoice"); + $ASTPP->debug( user=> $param->{username}, debug => gettext("Generating Invoice")); $invoiceno = &osc_charges( $astpp_db, $osc_db, $config, $params->{booth_name} ); @@ -11097,7 +11066,7 @@ . " WHERE accountcode = " . $rt_db->quote( $accountinfo->{cc} ) . " LIMIT 1"; - print STDERR $tmp; # if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); my $sql = $rt_db->prepare($tmp); $sql->execute; $sip_login = $sql->fetchrow_hashref; @@ -11108,7 +11077,7 @@ . " WHERE accountcode = " . $rt_db->quote( $accountinfo->{cc} ) . " LIMIT 1"; - print STDERR $tmp; # if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $rt_db->prepare($tmp); $sql->execute; $iax2_login = $sql->fetchrow_hashref; @@ -11124,7 +11093,7 @@ . $astpp_db->quote( $params->{booth_name} ) . "and status = 0" . " ORDER BY callstart DESC"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); $sql = $astpp_db->prepare($tmp); $sql->execute; @@ -11158,7 +11127,7 @@ else { $record->{credit} = "-"; } - print STDERR $record->{id} if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $record->{id}); $record->{profit} = ( $record->{debit} - $record->{cost} ); push( @cdrs, $record ); } @@ -11170,7 +11139,7 @@ my $balance = &accountbalance( $astpp_db, $params->{booth_name} ) / 10000; my $unrated = &count_unrated_cdrs_account( $cdr_db, $accountinfo->{number}, $accountinfo->{cc} ); - print STDERR $balance; + $ASTPP->debug( user=> $param->{username}, debug => $balance); $template->param( unrated_cdrs => $unrated ); $template->param( booths => $booths ); $template->param( balance => $balance ); @@ -11189,7 +11158,7 @@ die_on_bad_params => $config->{template_die_on_bad_params} ); foreach my $param ( param() ) { $params->{$param} = param($param); - print STDERR "$param $params->{$param}\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "$param $params->{$param}" ); } if ( !$params->{mode} ) { $params->{mode} = gettext("Home"); @@ -11208,9 +11177,9 @@ if ( $loginstat == 1 ) { # In here we setup privileges for the different account levels - print STDERR "LOGIN TYPE = $params->{logintype}\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "LOGIN TYPE = $params->{logintype}"); if ( $params->{logintype} == 0 ) { # User Login - Not allowed to do anything - print STDERR "ASTPP USER LOGIN - DISABLED\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "ASTPP USER LOGIN - DISABLED"); @modes = (); } elsif ( $params->{logintype} == 1 ) { # Reseller Login @@ -11222,7 +11191,7 @@ if $config->{users_dids_amp} == 1; $rt_db = &rt_connect_db( $config, @output ) if $config->{users_dids_rt} == 1; - print STDERR "ASTPP RESELLER LOGIN\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "ASTPP RESELLER LOGIN" ); @modes = ( gettext("Accounts"), gettext("Rates"), gettext("DIDs"), gettext("Logout"), @@ -11252,7 +11221,7 @@ $params->{logged_in_reseller} = $params->{username}; } elsif ( $params->{logintype} == 2 ) { - print STDERR "ASTPP ADMINISTRATOR LOGIN\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "ASTPP ADMINISTRATOR LOGIN"); @modes = ( gettext("Accounts"), gettext("Rates"), gettext("DIDs"), gettext("Statistics"), @@ -11286,14 +11255,14 @@ } elsif ( $params->{logintype} == 3 ) { # Vendor Login - Vendors are only allowed to look at stuff that pertains to them. - print STDERR "ASTPP VENDOR LOGIN\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "ASTPP VENDOR LOGIN" ); @modes = ( gettext("Trunk Statistics"), gettext("View CDRs"), gettext("Home"), gettext("Outbound Routes") ); } elsif ( $params->{logintype} == 4 ) { # Customer Service Login - print STDERR "ASTPP CUSTOMER SERVICE LOGIN\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "ASTPP CUSTOMER SERVICE LOGIN" ); @modes = ( gettext("Accounts"), gettext("DIDs"), gettext("Statistics"), gettext("Home") @@ -11320,7 +11289,7 @@ if $config->{users_dids_rt} == 1; $osc_db = &osc_connect_db( $config, $config, @output ) if $config->{externalbill} eq "oscommerce"; - print STDERR "ASTPP CALLSHOP LOGIN\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "ASTPP CALLSHOP LOGIN" ); @modes = ( gettext("Booths"), gettext("Home"), gettext("Routes"), gettext("Pricelists"), gettext("CallShop Reports") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-18 00:26:30
|
Revision: 2161 http://astpp.svn.sourceforge.net/astpp/?rev=2161&view=rev Author: darrenkw Date: 2007-11-17 16:26:27 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Resolved: FS#335 ?\194?\151 Show list of SIP and IAX2 accounts in "View Details" Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-common.pl trunk/templates/account-info.tpl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-17 23:15:16 UTC (rev 2160) +++ trunk/astpp-admin.cgi 2007-11-18 00:26:27 UTC (rev 2161) @@ -1915,6 +1915,59 @@ } $template->param( account_ip_list => \@account_ip_list); $template->param( currency => $currency[0]); + +## List the SIP/IAX2 devices belonging to this account. ## + my @account_device_list; + if ($rt_db) { + my @sip_names = &list_sip_account_rt($rt_db,$config,$accountinfo->{number}, $accountinfo->{cc}); + my @iax_names = &list_iax_account_rt($rt_db,$config,$accountinfo->{number}, $accountinfo->{cc}); + foreach my $name (@sip_names) { + my $deviceinfo = &get_sip_account_rt($rt_db,$config,$name); + my %row; + $row{tech} = "SIP"; + $row{type} = $deviceinfo->{type}; + $row{username} = $deviceinfo->{username}; + $row{secret} = $deviceinfo->{secret}; + $row{context} = $deviceinfo->{context}; + push(@account_device_list, \%row); + } + foreach my $name (@iax_names) { + my $deviceinfo = &get_iax_account_rt($rt_db,$config,$name); + my %row; + $row{tech} = "IAX2"; + $row{type} = $deviceinfo->{type}; + $row{username} = $deviceinfo->{username}; + $row{secret} = $deviceinfo->{secret}; + $row{context} = $deviceinfo->{context}; + push(@account_device_list, \%row); + } + } + if ($freepbx_db) { + my @sip_names = &list_sip_account_freepbx($freepbx_db,$config,$accountinfo->{number}, $accountinfo->{cc}); + my @iax_names = &list_iax_account_freepbx($freepbx_db,$config,$accountinfo->{number}, $accountinfo->{cc}); + foreach my $name (@sip_names) { + my $deviceinfo = &get_sip_account_freepbx($freepbx_db,$config,$name); + my %row; + $row{tech} = "SIP"; + $row{type} = $deviceinfo->{type}; + $row{username} = $deviceinfo->{username}; + $row{secret} = $deviceinfo->{secret}; + $row{context} = $deviceinfo->{context}; + push(@account_device_list, \%row); + } + foreach my $name (@iax_names) { + my $deviceinfo = &get_iax_account_freepbx($freepbx_db,$config,$name); + my %row; + $row{tech} = "IAX2"; + $row{type} = $deviceinfo->{type}; + $row{username} = $deviceinfo->{username}; + $row{secret} = $deviceinfo->{secret}; + $row{context} = $deviceinfo->{context}; + push(@account_device_list, \%row); + } + } + $template->param(account_device_list => \@account_device_list); +### End Section ### ($sql, $pagination) = $ASTPP->pagination( sql_select => "SELECT * FROM cdrs WHERE cardnum =" . $astpp_db->quote( $accountinfo->{number} ) @@ -9197,6 +9250,9 @@ $rt_db = &rt_connect_db( $config, @output ); push @modes, gettext("Switch Config"); } + if ( $config->{users_dids_amp} == 1 ) { + $freepbx_db = &freepbx_connect_db( $config, @output ); + } if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-17 23:15:16 UTC (rev 2160) +++ trunk/astpp-common.pl 2007-11-18 00:26:27 UTC (rev 2161) @@ -2341,10 +2341,10 @@ sub list_sip_account_rt() { my ( $rt_db, $config, $name, $cc) = @_; my ($tmp,$row, $sql, @devicelist); -# if ($config->{debug} == 1) { + if ($config->{debug} == 1) { print STDERR "NAME: $name"; print STDERR "CC: $cc"; -# } + } $tmp = "SELECT name FROM $config->{rt_sip_table} WHERE accountcode IN (" . $rt_db->quote($name) . "," . $rt_db->quote($cc) . ")"; @@ -2358,6 +2358,30 @@ return @devicelist; } +sub get_sip_account_rt() { + my ($rt_db,$config,$name) = @_; + my $tmp = "SELECT * FROM $config->{rt_sip_table} WHERE name = " + . $rt_db->quote($name) . " LIMIT 1"; + print STDERR "$tmp\n" if $config->{debug} == 1; + my $sql = $rt_db->prepare($tmp); + $sql->execute; + my $record = $sql->fetchrow_hashref; + $sql->finish; + return $record; +} + +sub get_iax_account_rt() { + my ($rt_db,$config,$name) = @_; + my $tmp = "SELECT * FROM $config->{rt_iax_table} WHERE name = " + . $rt_db->quote($name) . " LIMIT 1"; + print STDERR "$tmp\n" if $config->{debug} == 1; + my $sql = $rt_db->prepare($tmp); + $sql->execute; + my $record = $sql->fetchrow_hashref; + $sql->finish; + return $record; +} + # Add a SIP user to the asterisk realtime DB. sub add_sip_user_rt() { my ( $rt_dbh, $config, $name, $secret, $context, $username, @@ -2598,6 +2622,83 @@ ####### OpenSER Integration Ends ############### ####### FreePBX subroutines start here ########### +sub get_iax_account_freepbx(){ + my ($freepbx_db,$config,$name) = @_; + my ($tmp,$record,$sql,$deviceinfo); + $tmp = "SELECT value FROM $config->{freepbx_iax_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'context' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{context} = $record; + $tmp = "SELECT value FROM $config->{freepbx_iax_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'secret' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{secret} = $record; + $tmp = "SELECT value FROM $config->{freepbx_iax_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'type' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{type} = $record; + $tmp = "SELECT value FROM $config->{freepbx_iax_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'username' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{username} = $record; + return $deviceinfo; +} + +sub get_sip_account_freepbx(){ + my ($freepbx_db,$config,$name) = @_; + my ($tmp,$record,$sql,$deviceinfo); + $tmp = "SELECT value FROM $config->{freepbx_sip_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'context' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{context} = $record; + $tmp = "SELECT value FROM $config->{freepbx_sip_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'secret' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{secret} = $record; + $tmp = "SELECT value FROM $config->{freepbx_sip_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'type' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{type} = $record; + $tmp = "SELECT value FROM $config->{freepbx_sip_table} WHERE id = " . $freepbx_db->quote($name) + . " AND keyword = 'username' LIMIT 1)"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $freepbx_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{username} = $record; + return $deviceinfo; +} + + # Return a list of sip devices belong to a specific account sub list_sip_account_freepbx() { my ( $freepbx_db, $config, $name, $cc) = @_; Modified: trunk/templates/account-info.tpl =================================================================== --- trunk/templates/account-info.tpl 2007-11-17 23:15:16 UTC (rev 2160) +++ trunk/templates/account-info.tpl 2007-11-18 00:26:27 UTC (rev 2161) @@ -176,7 +176,30 @@ <td><input name="action" value="Post Charge..." type="submit"></td> </tr> </table> + +<table class="default"> + <tr class="header"> + <td colspan=5>IAX2 & SIP Accounts</td> + </tr> + <tr class="header"> + <td>Tech</td> + <td>Type</td> + <td>Username</td> + <td>Password</td> + <td>Context</td> + </tr> + <TMPL_LOOP NAME="account_device_list"> + <tr> + <td><TMPL_VAR NAME="tech"></td> + <td><TMPL_VAR NAME="type"></td> + <td><TMPL_VAR NAME="username"></td> + <td><TMPL_VAR NAME="secret"></td> + <td><TMPL_VAR NAME="context"></td> + </tr> + </TMPL_LOOP> +</table> + <table class="default"> <tr class="header"> <td>UniqueID</td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-17 23:15:23
|
Revision: 2160 http://astpp.svn.sourceforge.net/astpp/?rev=2160&view=rev Author: darrenkw Date: 2007-11-17 15:15:16 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Resolved: [ 1827828 ] SIP user not created due to type = NULL Also resolved an issue preventing pricelists from showing when creating a callshop. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/templates/account-create.tpl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-17 22:28:28 UTC (rev 2159) +++ trunk/astpp-admin.cgi 2007-11-17 23:15:16 UTC (rev 2160) @@ -2252,6 +2252,13 @@ ) ); $template->param( + devicetype => popup_menu( + -name => "devicetype", + -values => \@devicetypes, + -default => $config->{rt_sip_type} + ) + ); + $template->param( sweep_menu => popup_menu( -name => "sweep", -values => \%sweeplist ) ); $template->param( default_context => $config->{default_context} ); $template->param( @@ -10543,7 +10550,7 @@ -values => \@language, -default => $config->{default_language} ); - @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); $pricelists = popup_menu( -name => "pricelist", -values => \@pricelists @@ -11273,6 +11280,7 @@ '4' => gettext("Customer Service"), '5' => gettext("CallShops") ); + $params->{logged_in_reseller} = $params->{username}; } else { Modified: trunk/templates/account-create.tpl =================================================================== --- trunk/templates/account-create.tpl 2007-11-17 22:28:28 UTC (rev 2159) +++ trunk/templates/account-create.tpl 2007-11-17 23:15:16 UTC (rev 2160) @@ -60,7 +60,8 @@ <tr class="rowtwo"> <td><input type="text" name="postal_code" size="20" /></td> <td><input type="text" name="province" size="20" /></td> - <td colspan=2><TMPL_VAR NAME="country_menu"></td> + <td colspan=2><TMPL_VAR NAME="country_menu"></td> + <td><TMPL_VAR NAME="devicetype"></td> </tr> <tr class="header"> <td>Telephone #1</td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-17 22:28:24
|
Revision: 2159 http://astpp.svn.sourceforge.net/astpp/?rev=2159&view=rev Author: darrenkw Date: 2007-11-17 14:28:28 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Cleaned up some duplicated code. Modified Paths: -------------- trunk/astpp-refill.agi Modified: trunk/astpp-refill.agi =================================================================== --- trunk/astpp-refill.agi 2007-11-17 21:42:32 UTC (rev 2158) +++ trunk/astpp-refill.agi 2007-11-17 22:28:28 UTC (rev 2159) @@ -207,21 +207,6 @@ $retries++; } } -$cardstatus = &check_card_status( $astpp_db, $sourcecardinfo ); -# This subroutine returns the status of the card: -if ( $cardstatus == 1 ) { - $AGI->stream_file($sound->{card_inuse}); - $AGI->stream_file($sound->{goodbye}); - exit(0); -} elsif ( $cardstatus == 2 ) { - $AGI->stream_file($sound->{card_has_expired}); - $AGI->stream_file($sound->{goodbye}); - exit(0) -} elsif ( $cardstatus == 3 ) { - $AGI->stream_file($sound->{card_is_empty}); - $AGI->stream_file($sound->{goodbye}); - exit(0) -} $retries = 0; while ( $sourcecardinfo->{pin} != $sourcepin && $retries < $config->{pin_retries} ) { $sourcepin = $AGI->get_data( $sound->{astpp_please_pin_card_empty}, $input_timeout ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-17 21:42:28
|
Revision: 2158 http://astpp.svn.sourceforge.net/astpp/?rev=2158&view=rev Author: darrenkw Date: 2007-11-17 13:42:32 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Add a couple of new templates. Added Paths: ----------- trunk/templates/callingcards-create.tpl trunk/templates/packages-list.tpl Added: trunk/templates/callingcards-create.tpl =================================================================== --- trunk/templates/callingcards-create.tpl (rev 0) +++ trunk/templates/callingcards-create.tpl 2007-11-17 21:42:32 UTC (rev 2158) @@ -0,0 +1,25 @@ +<table class="default"> +<input type="hidden" name="mode" value="Add Cards" /> + <tr class="header"> + <td>Account Number</td> + <td>Brand</td> + <td>Value in Pennies</td> + <td>Quantity</td> + <td>Status</td> + </tr> + <tr> + <td><input type="text" name="account" size="20" /></td> + <td><TMPL_VAR NAME="brand_list"></td> + <td><input type="text" name="value" size="10" /></td> + <td><input type="text" name="count" size="5" /></td> + <td><TMPL_VAR NAME="status_list"></td> + <td><input type="submit" name="action" value="Generate Card(s)" /></td> + </tr> +</table> + +<table> + <tr> + <td><TMPL_VAR NAME="status"></td> + </tr> + </table> +</form> Added: trunk/templates/packages-list.tpl =================================================================== --- trunk/templates/packages-list.tpl (rev 0) +++ trunk/templates/packages-list.tpl 2007-11-17 21:42:32 UTC (rev 2158) @@ -0,0 +1,57 @@ +<table class="default"> +<input type="hidden" name="mode" value="Packages" /> + <tr class="header"> + <td colspan=5>Add / Edit / List Packages</td> + </tr> + <tr class="header"> + <td>Package Name</td> + <td>Pricelist</td> + <td>Pattern</td> + <td>Included Seconds</td> + <td>Action</td> + </tr> + <tr class="header"> + <td colspan=5>Add Package</td> + </tr> + <tr> + <td><input type="text" name="name" size="20" /></td> + <td><TMPL_VAR NAME="pricelists"></td> + <td><input type="text" name="pattern" size="30" /></td> + <td><input type="text" name="includedseconds" size="6" /></td> + <td><input type="submit" name="action" value="Insert..." /></td> + </tr> + <tr class="header"> + <td colspan=5>Edit Package</td> + </tr> + <tr> + <input type="hidden" name="id" value="<TMPL_VAR NAME="id">" /> + <td><input type="text" name="edit_name" size="20" value="<TMPL_VAR NAME="current_name">"/></td> + <td><TMPL_VAR NAME="edit_pricelists"></td> + <td><input type="text" name="edit_pattern" size="30" value="<TMPL_VAR NAME="current_pattern">"/></td> + <td><input type="text" name="edit_includedseconds" size="6" value="<TMPL_VAR NAME="current_includedseconds">"</></td> + <td><input type="submit" name="action" value="Save..." /></td> + </tr> + <tr class="header"> + <td colspan=5>List Package</td> + </tr> + <tr class="header"> + </tr> + <TMPL_LOOP NAME="package_list"> + <TR> + <TD><TMPL_VAR NAME="name"></TD> + <TD><TMPL_VAR NAME="pricelist"></TD> + <TD><TMPL_VAR NAME="pattern"></TD> + <TD><TMPL_VAR NAME="includedseconds"></TD> + <td><a href="astpp-admin.cgi?mode=Packages&action=Edit...&id=<TMPL_VAR NAME="id">">Edit...</a> + <a href="astpp-admin.cgi?mode=Packages&action=Deactivate...&id=<TMPL_VAR NAME="id">">Deactivate...</a></td> + </TD> + </TR> + </TMPL_LOOP> +</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...> - 2007-11-17 21:21:02
|
Revision: 2157 http://astpp.svn.sourceforge.net/astpp/?rev=2157&view=rev Author: darrenkw Date: 2007-11-17 13:21:04 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Added more logging functionality in the database. Added Paths: ----------- trunk/sql/astpp-2007-11-03.sql trunk/sql/astpp-2007-11-17.sql Added: trunk/sql/astpp-2007-11-03.sql =================================================================== --- trunk/sql/astpp-2007-11-03.sql (rev 0) +++ trunk/sql/astpp-2007-11-03.sql 2007-11-17 21:21:04 UTC (rev 2157) @@ -0,0 +1,1264 @@ +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?'); + +-- +-- Enough Configuration settings +-- + +DROP TABLE IF EXISTS `countrycode`; +CREATE TABLE `countrycode` ( + `country` varchar(255) NOT NULL, + PRIMARY KEY (`country`), + KEY `country` (`country`) +); + +INSERT INTO `countrycode` (`country`) VALUES + ('Afghanistan'), + ('Alaska'), + ('Albania'), + ('Algeria'), + ('AmericanSamoa'), + ('Andorra'), + ('Angola'), + ('Antarctica'), + ('Argentina'), + ('Armenia'), + ('Aruba'), + ('Ascension'), + ('Australia'), + ('Austria'), + ('Azerbaijan'), + ('Bahrain'), + ('Bangladesh'), + ('Belarus'), + ('Belgium'), + ('Belize'), + ('Benin'), + ('Bhutan'), + ('Bolivia'), + ('Bosnia & Herzegovina'), + ('Botswana'), + ('Brazil'), + ('Brunei Darussalam'), + ('Bulgaria'), + ('Burkina Faso'), + ('Burundi'), + ('Cambodia'), + ('Cameroon'), + ('Canadda'), + ('Cape Verde Islands'), + ('Central African Republic'), + ('Chad'), + ('Chile'), + ('China'), + ('Colombia'), + ('Comoros'), + ('Congo'), + ('Cook Islands'), + ('Costa Rica'), + ('Croatia'), + ('Cuba'), + ('Cuba Guantanamo Bay'), + ('Cyprus'), + ('Czech Republic'), + ('Denmark'), + ('Diego Garcia'), + ('Djibouti'), + ('Dominican Republic'), + ('East Timor'), + ('Ecuador'), + ('Egypt'), + ('El Salvador'), + ('Equatorial Guinea'), + ('Eritrea'), + ('Estonia'), + ('Ethiopia'), + ('Faroe Islands'); +INSERT INTO `countrycode` (`country`) VALUES + ('Fiji Islands'), + ('Finland'), + ('France'), + ('French Guiana'), + ('French Polynesia'), + ('Gabonese Republic'), + ('Gambia'), + ('Georgia'), + ('Germany'), + ('Ghana'), + ('Gibraltar'), + ('Greece'), + ('Greenland'), + ('Guadeloupe'), + ('Guam'), + ('Guatemala'), + ('Guinea'), + ('Guyana'), + ('Haiti'), + ('Honduras'), + ('Hong Kong'), + ('Hungary'), + ('Iceland'), + ('India'), + ('Indonesia'), + ('Iran'), + ('Iraq'), + ('Ireland'), + ('Israel'), + ('Italy'), + ('Jamaica'), + ('Japan'), + ('Jordan'), + ('Kazakstan'), + ('Kenya'), + ('Kiribati'), + ('Kuwait'), + ('Kyrgyz Republic'), + ('Laos'), + ('Latvia'), + ('Lebanon'), + ('Lesotho'), + ('Liberia'), + ('Libya'), + ('Liechtenstein'), + ('Lithuania'), + ('Luxembourg'), + ('Macao'), + ('Madagascar'), + ('Malawi'), + ('Malaysia'), + ('Maldives'), + ('Mali Republic'), + ('Malta'), + ('Marshall Islands'), + ('Martinique'), + ('Mauritania'), + ('Mauritius'), + ('MayotteIsland'), + ('Mexico'), + ('Midway Islands'), + ('Moldova'), + ('Monaco'), + ('Mongolia'), + ('Morocco'); +INSERT INTO `countrycode` (`country`) VALUES + ('Mozambique'), + ('Myanmar'), + ('Namibia'), + ('Nauru'), + ('Nepal'), + ('Netherlands'), + ('Netherlands Antilles'), + ('New Caledonia'), + ('New Zealand'), + ('Nicaragua'), + ('Niger'), + ('Nigeria'), + ('Niue'), + ('Norfolk Island'), + ('North Korea'), + ('Norway'), + ('Oman'), + ('Pakistan'), + ('Palau'), + ('Palestinian Settlements'), + ('Panama'), + ('PapuaNew Guinea'), + ('Paraguay'), + ('Peru'), + ('Philippines'), + ('Poland'), + ('Portugal'), + ('Puerto Rico'), + ('Qatar'), + ('RéunionIsland'), + ('Romania'), + ('Russia'), + ('Rwandese Republic'), + ('San Marino'), + ('São Tomé and Principe'), + ('Saudi Arabia'), + ('Senegal '), + ('Serbia and Montenegro'), + ('Seychelles Republic'), + ('Sierra Leone'), + ('Singapore'), + ('Slovak Republic'), + ('Slovenia'), + ('Solomon Islands'), + ('Somali Democratic Republic'), + ('South Africa'), + ('South Korea'), + ('Spain'), + ('Sri Lanka'), + ('St Kitts - Nevis'), + ('St. Helena'), + ('St. Lucia'), + ('St. Pierre & Miquelon'), + ('St. Vincent & Grenadines'), + ('Sudan'); +INSERT INTO `countrycode` (`country`) VALUES + ('Suriname'), + ('Swaziland'), + ('Sweden'), + ('Switzerland'), + ('Syria'), + ('Taiwan'), + ('Tajikistan'), + ('Tanzania'), + ('Thailand'), + ('Togolese Republic'), + ('Tokelau'), + ('Tonga Islands'), + ('Trinidad & Tobago'), + ('Tunisia'), + ('Turkey'), + ('Turkmenistan'), + ('Tuvalu'), + ('Uganda'), + ('Ukraine'), + ('United Arab Emirates'), + ('United Kingdom'), + ('United States of America'), + ('Uruguay'), + ('Uzbekistan'), + ('Vanuatu'), + ('Venezuela'), + ('Vietnam'), + ('Wake Island'), + ('Wallisand Futuna Islands'), + ('Western Samoa'), + ('Yemen'), + ('Zambia'), + ('Zimbabwe'); + +DROP TABLE IF EXISTS `currency`; +CREATE TABLE `currency` ( + `Currency` varchar(3) NOT NULL default '', + `CurrencyName` varchar(40) NOT NULL default '', + PRIMARY KEY (`Currency`) +); + +INSERT INTO `currency` (`Currency`,`CurrencyName`) VALUES + ('USD','US Dollars'), + ('CAD','Canadian Dollars'), + ('AUD','Australian Dollars'); + +CREATE TABLE `language` ( + `language` varchar(5) NOT NULL, + `languagename` varchar(40) NOT NULL, + `active` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`language`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `language` (`language`,`languagename`,`active`) VALUES + ('en','English',1), + ('fr','French',1), + ('de','German',1); + +CREATE TABLE `resellers` ( + name varchar(40) NOT NULL default '', + status int(11) NOT NULL default '1', + posttoexternal int(11) NOT NULL default '0', + agile_site_id int(11) NOT NULL default '0', + config_file char(80) NOT NULL default 'reseller.conf', + companyname varchar(255) default NULL, + slogan varchar(255) default NULL, + footer varchar(255) default NULL, + pricelist varchar(255) default NULL, + currency varchar(255) default NULL, + logo varchar(255) default NULL, + website varchar(255) default NULL, + adminemail varchar(255) default NULL, + salesemail varchar(255) default NULL, + phone varchar(45) default NULL, + fax varchar(45) default NULL, + address1 varchar(255) default NULL, + address2 varchar(255) default NULL, + city varchar(255) default NULL, + state varchar(255) default NULL, + postcode varchar(255) default NULL, + country varchar(255) default NULL, + defaultbrand varchar(45) NOT NULL default 'default', + defaultcurrency varchar(45) NOT NULL default 'USD', + defaultcredit varchar(45) NOT NULL default '0.00', + externalbill varchar(45) NOT NULL default '', + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +CREATE TABLE templates ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +reseller VARCHAR(45) NOT NULL default '', +template TEXT NOT NULL default '', + PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +INSERT INTO templates (name,template) VALUES +('voip_account_refilled','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been refilled. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('voip_reactivate_account','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been reactivated. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_add_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been added. +Your Username is -- $vars->{extension} -- +Your Password is -- $vars->{secret} -- +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('add_sip_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In sip.conf: +[$config->{company_name}-in] +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=from-pstn +accountcode=$config->{company_name} +[$config->{company_name}] +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid= <555-555-5555> +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +In the [globals] section add: +register => $vars->{user}:password@$config->{asterisk_server}'); + +INSERT INTO templates (name,template) VALUES +('add_iax_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In iax.conf: +At the bottom of the file add: +[$config->{company_name}-in] +;trunk=yes ;optional .. only works if you have a zaptel or ztdummy driver running +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=incoming +accountcode=$config->{company_name} ;for call tracking in the cdr +[$config->{company_name}] +;to simplify and config outgoing calls +;trunk=yes ;optional .. only works if you have a zaptel driver running +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid=<555-555-5555> ;only the number will really be used +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_remove_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP Termination with $config->{company_name} has been removed +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_calling_card','You have added a $vars->{pricelist} callingcard in the amount of $vars->{pennies} cents. +Card Number $cc Pin: $pin +Thanks for your patronage. +The $config->{company_name} sales team'); + +INSERT INTO templates (name,template) VALUES +('email_add_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been added +The number is: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team +Here is a sample setup which would call a few sip phones with incoming calls: +[incoming] +exten => _1$did,1,Wait(2) +exten => _1$did,2,Dial(SIP/2201&SIP/2202,15,Ttm) ; dial a couple of phones for 15 secs +exten => _1$did,3,Voicemail(u1000) ; go to unavailable voicemail (vm box 1000) +exten => _1$did,103,Voicemail(b1000) ; go to busy voicemail (vm box 1000)'); + +INSERT INTO templates (name,template) VALUES +('email_remove_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been removed +The number was: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_new_invoice','Invoice # $invoice in the amount of \$$total has been added to your account. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_low_balance','Your VOIP account with $config->{company_name} has a balance of \$$balance. +Please visit our website to refill your account to ensure uninterrupted service. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +CREATE TABLE `sweeplist` ( + `Id` int(10) unsigned NOT NULL default '0', + `sweep` varchar(45) NOT NULL default '', + PRIMARY KEY (`Id`) +); + +INSERT INTO sweeplist (Id,sweep) VALUES +(0,'daily'), +(1,'weekly'), +(2,'monthly'), +(3,'quarterly'), +(4,'semi-annually'), +(5,'annually') +; + +CREATE TABLE userlevels ( +userlevelid int(11) NOT NULL, +userlevelname varchar(50) NOT NULL, +PRIMARY KEY (`userlevelid`) +); + +INSERT INTO `userlevels` (`userlevelid`,`userlevelname`) VALUES + (-1,'Administrator'), + (0,'Anonymous'), + (1,'Reseller'), + (2,'Admin'), + (3,'Vendor'), + (4,'Customer Service'), + (5,'Users'); + +CREATE TABLE reseller_pricing ( +id INTEGER NOT NULL AUTO_INCREMENT, +reseller VARCHAR(50) NOT NULL, +type INTEGER NOT NULL DEFAULT 1, +monthlycost INTEGER NOT NULL DEFAULT 0, +prorate INTEGER NOT NULL DEFAULT 0, +setup INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +note VARCHAR(50) NOT NULL DEFAULT '', +disconnectionfee INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +inc CHAR(10) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE callshops ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(50) NOT NULL, +osc_dbname VARCHAR(50) NOT NULL DEFAULT '', +osc_dbpass VARCHAR(50) NOT NULL DEFAULT '', +osc_dbuser VARCHAR(50) NOT NULL DEFAULT '', +osc_dbhost VARCHAR(50) NOT NULL DEFAULT '', +osc_site VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), +KEY `name` (`name`) +); + +CREATE TABLE extensions_status ( +id INTEGER NOT NULL AUTO_INCREMENT, +tech VARCHAR(6) NULL, +extension VARCHAR(20) NULL, +number VARCHAR(255) NULL, +status VARCHAR(255) NULL, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +PRIMARY KEY (`id`), +KEY `extension` (`extension`)); + +CREATE TABLE activity_logs ( +id INTEGER NOT NULL AUTO_INCREMENT, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +message TEXT NOT NULL DEFAULT '', +user VARCHAR(50), +PRIMARY KEY (`id`)); + Added: trunk/sql/astpp-2007-11-17.sql =================================================================== --- trunk/sql/astpp-2007-11-17.sql (rev 0) +++ trunk/sql/astpp-2007-11-17.sql 2007-11-17 21:21:04 UTC (rev 2157) @@ -0,0 +1,1280 @@ +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','... [truncated message content] |
From: <son...@us...> - 2007-11-06 22:58:35
|
Revision: 2156 http://astpp.svn.sourceforge.net/astpp/?rev=2156&view=rev Author: sonalikh Date: 2007-11-06 14:58:39 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Some minor bug fixes to reseller reports Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-06 03:33:07 UTC (rev 2155) +++ trunk/astpp-admin.cgi 2007-11-06 22:58:39 UTC (rev 2156) @@ -108,11 +108,20 @@ ); # Report added by Sonia Ali Khan <son...@gm...> -my @AdminReports = ( gettext("Reseller Report"), gettext("Vendor Report") ); -my @CallShopReports = ( gettext("Booth Report") ); +my @AdminReports = ( + gettext("Reseller Report"), + gettext("Vendor Report") +); + +my @CallShopReports = ( + gettext("Booth Report") +); + my @ResellerReports = ( - gettext("Brand Report"), gettext("CallShop Report"), - gettext("Reseller Report"), gettext("User Report") +# gettext("Brand Report"), + gettext("CallShop Report"), + gettext("Reseller Report"), + gettext("User Report") ); @@ -513,8 +522,8 @@ if $params->{mode} eq gettext("Create CallShop"); return &build_remove_callshop() if $params->{mode} eq gettext("Remove CallShop"); - return &build_reseller_brand_report() - if $params->{mode} eq gettext("Brand Report"); +# return &build_reseller_brand_report() +# if $params->{mode} eq gettext("Brand Report"); return &build_reseller_callshop_report() if $params->{mode} eq gettext("CallShop Report"); return &build_reseller_reseller_report() @@ -790,12 +799,16 @@ return &build_report("Booth","6"); } +sub build_reseller_callshop_report() { + return &build_report("Booth","6"); +} + sub build_reseller_reseller_report() { return &build_report("Reseller","1"); } sub build_reseller_user_report() { - return &build_report("User","1,6"); + return &build_report("User","0"); } sub build_list_box($$) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-06 03:33:04
|
Revision: 2155 http://astpp.svn.sourceforge.net/astpp/?rev=2155&view=rev Author: darrenkw Date: 2007-11-05 19:33:07 -0800 (Mon, 05 Nov 2007) Log Message: ----------- Resolve problem with packages. Modified Paths: -------------- trunk/astpp-common.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-04 22:32:27 UTC (rev 2154) +++ trunk/astpp-common.pl 2007-11-06 03:33:07 UTC (rev 2155) @@ -3686,7 +3686,7 @@ print STDERR "pricelistData: $branddata->{name} $branddata->{markup} $branddata->{inc} $branddata->{status}\n"; - my $package = &get_package( $astpp_db, $carddata, $cdrinfo->{dst} ); + $package = &get_package( $astpp_db, $carddata, $cdrinfo->{dst} ); if ($package->{id}) { my $counter = &get_counter( $astpp_db, $package->{id}, @@ -3859,18 +3859,15 @@ print STDERR "----------------------\n"; } elsif ( $cdrinfo->{accountcode} ) { - my $savedcdrinfo = $cdrinfo; $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata); - $cdrinfo = $savedcdrinfo; + $cdrinfo = &get_cdr( $cdr_db, $uniqueid ); if ( $status == 1 ) { my $previous_account = $carddata->{number}; while ( $carddata->{reseller} ne "" ) { -# my $cdrinfo = &get_cdr( $cdr_db, $uniqueid ); -# my $reseller = $carddata->{reseller}; + $cdrinfo = &get_cdr( $cdr_db, $uniqueid ); 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); - $cdrinfo = $savedcdrinfo; my $tmp = "SELECT id FROM cdrs WHERE uniqueid = '" . $uniqueid . "' AND cardnum = '" . $previous_account . "' LIMIT 1"; print STDERR "$tmp\n" if $config->{debug} == 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-04 22:32:25
|
Revision: 2154 http://astpp.svn.sourceforge.net/astpp/?rev=2154&view=rev Author: darrenkw Date: 2007-11-04 14:32:27 -0800 (Sun, 04 Nov 2007) Log Message: ----------- Updated the packages/counters code. Modified Paths: -------------- trunk/astpp-common.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-03 23:06:13 UTC (rev 2153) +++ trunk/astpp-common.pl 2007-11-04 22:32:27 UTC (rev 2154) @@ -3859,7 +3859,9 @@ print STDERR "----------------------\n"; } elsif ( $cdrinfo->{accountcode} ) { + my $savedcdrinfo = $cdrinfo; $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata); + $cdrinfo = $savedcdrinfo; if ( $status == 1 ) { my $previous_account = $carddata->{number}; while ( $carddata->{reseller} ne "" ) { @@ -3868,7 +3870,7 @@ 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); - + $cdrinfo = $savedcdrinfo; my $tmp = "SELECT id FROM cdrs WHERE uniqueid = '" . $uniqueid . "' AND cardnum = '" . $previous_account . "' LIMIT 1"; print STDERR "$tmp\n" if $config->{debug} == 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-03 23:06:09
|
Revision: 2153 http://astpp.svn.sourceforge.net/astpp/?rev=2153&view=rev Author: darrenkw Date: 2007-11-03 16:06:13 -0700 (Sat, 03 Nov 2007) Log Message: ----------- Start with enhanced logging. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-03 22:29:23 UTC (rev 2152) +++ trunk/astpp-admin.cgi 2007-11-03 23:06:13 UTC (rev 2153) @@ -65,7 +65,7 @@ $freepbx_db $rt_db $openser_db $ASTPP); my $starttime = [gettimeofday]; $ASTPP = ASTPP->new; -$ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to be. +$ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. $ASTPP->set_asterisk_agi($AGI); $ASTPP->set_pagination_script("astpp-admin.cgi"); my @Home = ( gettext("Home Page") ); @@ -220,14 +220,10 @@ $status .= gettext("Login Failed") . "<br>"; print header(); } - print STDERR gettext("ASTPP-USER:") . " $params->{username}\n" - if $config->{debug} == 1; - print STDERR gettext("ASTPP-PASS:") . " $params->{password}\n" - if $config->{debug} == 1; - print STDERR gettext("ASTPP-AUTHCODE:") . " $config->{auth}\n" - if $config->{debug} == 1; - print STDERR gettext("ASTPP-USER-COUNT:") . " $count" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-USER:") . " $params->{username}"); + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-PASS:") . " $params->{password}"); + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-AUTHCODE:") . " $config->{auth}"); + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-USER-COUNT:") . " $count"); return ( $params->{mode}, $count ); } @@ -272,13 +268,13 @@ $status .= gettext("Login Failed") . "<br>"; $count = 0; } - print STDERR gettext("ASTPP-USER:") . " $params->{username}\n" + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-USER:") . " $params->{username}") if $config->{debug} == 1 && $params->{username}; - print STDERR gettext("ASTPP-PASS:") . " $params->{password}\n" + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-PASS:") . " $params->{password}") if $config->{debug} == 1 && $params->{password}; - print STDERR gettext("ASTPP-AUTHCODE:") . " $config->{auth}\n" + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-AUTHCODE:") . " $config->{auth}") if $config->{debug} == 1; - print STDERR gettext("ASTPP-USER-COUNT:") . " $count" + $ASTPP->debug( user=> $param->{username}, debug => gettext("ASTPP-USER-COUNT:") . " $count") if $config->{debug} == 1; print header(); return $count; @@ -305,9 +301,7 @@ my ($selected) = @_; my ( $tmp, $body, $x ); my $i = 0; - print STDERR "START OF MENU" if $config->{debug} == 1; foreach $tmp (@modes) { - print STDERR $tmp . "\n" if $config->{debug} == 1; $body .= "<div class=\"ts_ddm\" name=tt$i id=tt$i style=\"visibility:hidden;width:200;background-color:#CCCCFF;\"onMouseover=\"clearhidemenu()\" onMouseout=\"dynamichide(event)\"><table width=100\% border=0 cellspacing=0 cellpadding=0>"; my $j = 0; @@ -334,9 +328,6 @@ sub build_body() { if ( $params->{logintype} == 2 ) { #Admin Login - - # return &build_configure() - # if $params->{mode} eq gettext("Configuration"); return &build_providers() if $params->{mode} eq gettext("Providers"); return &build_trunks() if $params->{mode} eq gettext("Trunks"); return &build_outbound_routes() @@ -991,7 +982,7 @@ my ($bth,$dst,$idd,$atmpt,$cmplt,$asr,$acd,$mcd,$act,$bill,$price,$cost); my $query = "CREATE TEMPORARY TABLE $table SELECT * FROM cdrs WHERE uniqueid != '' AND $where"; $sth = $astpp_db->do($query) || return gettext("Something is wrong with astpp database"). "\n"; - print STDERR " SQL: $query \n " if $config->{debug} == 1; + $ASTPP->debug( user => $param->{username}, debug => " SQL: $query ");; my $sql = $astpp_db->prepare("SELECT DISTINCT cardnum AS $name FROM $table"); $sql->execute() || return gettext("Something is wrong with astpp database"). "\n"; @@ -1041,7 +1032,6 @@ $in = substr($in,0,-1) if length($in) > 0; $sql3->finish; - print STDERR " SQL: SELECT SUM(duration) AS actual FROM cdr WHERE uniqueid IN ($in) \n " if $config->{debug} == 1; my $sql4 = $cdr_db->prepare("SELECT SUM(duration) AS actual FROM cdr WHERE uniqueid IN ($in)"); $sql4->execute() || return gettext("Something is wrong with cdr database"). "\n"; my $row4 = $sql4->fetchrow_hashref(); @@ -1156,7 +1146,7 @@ and calldate <= " . $cdr_db->quote($ed) . " and (dstchannel like '$row->{tech}/$row->{path}%' or dstchannel like '$row->{tech}\[$row->{path}\]%' ) "; - print STDERR " SQL: $sql1 \n " if $config->{debug} == 1; + $ASTPP->debug( user => $param->{username}, debug => " SQL: $sql1 \n "); my $sth1 = $cdr_db->prepare($sql1); $sth1->execute(); my $ref1 = $sth1->fetchrow_hashref(); @@ -1172,7 +1162,7 @@ or dstchannel like '$row->{tech}\[$row->{path}\]%' ) "; my $sth2 = $cdr_db->prepare($sql2); - print STDERR " SQL: $sql2 \n " if $config->{debug} == 1; + $ASTPP->debug( user => $param->{username}, debug =>" SQL: $sql2"); $sth2->execute(); my $ref2 = $sth2->fetchrow_hashref(); $sth2->finish; @@ -1185,7 +1175,7 @@ or dstchannel like '$row->{tech}\[$row->{path}\]%' ) "; my $sth3 = $cdr_db->prepare($sql3); - print STDERR " SQL: $sql3 \n " if $config->{debug} == 1; + $ASTPP->debug( user => $param->{username}, debug =>" SQL: $sql3"); $sth3->execute(); my $ref3 = $sth3->fetchrow_hashref(); $sth3->finish; Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2007-11-03 22:29:23 UTC (rev 2152) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2007-11-03 23:06:13 UTC (rev 2153) @@ -34,7 +34,7 @@ my ($class,%arg) = @_; bless { _astpp_db => $_[1], - _verbosity => $arg{verbosity_level} || 1, + _verbosity_level => $arg{verbosity_level} || 1, _asterisk_agi => $_[3], _cdr_db => $_[4], _verbosity_item_level => $arg{verbosity_item_level} || 1, @@ -44,7 +44,7 @@ } sub set_verbosity_level { $_[0]->{_verbosity_level} } #Sets the verbosity level. -sub set_verbosity { $_[0]->{_verbosity_level} } #Sets the verbosity level. +sub set_verbosity { $_[0]->{_verbosity_level} } #Sets the verbosity level. One of these needs to be deprecated. sub set_astpp_db { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-03 22:29:22
|
Revision: 2152 http://astpp.svn.sourceforge.net/astpp/?rev=2152&view=rev Author: darrenkw Date: 2007-11-03 15:29:23 -0700 (Sat, 03 Nov 2007) Log Message: ----------- Resolve bug #305 Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-common.pl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-03 22:03:16 UTC (rev 2151) +++ trunk/astpp-admin.cgi 2007-11-03 22:29:23 UTC (rev 2152) @@ -6373,7 +6373,8 @@ . "</td><td>" . popup_menu( -name => 'account', - -values => \@accountlist + -values => \@accountlist, + -default => "" ) . "</td><td>" . textfield( Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-03 22:03:16 UTC (rev 2151) +++ trunk/astpp-common.pl 2007-11-03 22:29:23 UTC (rev 2152) @@ -4014,7 +4014,7 @@ sub update_list_cards() { my ($astpp_db, $config, $sweep) = @_; my ( $sql, @cardlist, $row ); - if ( $sweep eq "" ) { + if (!$sweep || $sweep eq "" ) { $sql = $astpp_db->prepare( "SELECT number FROM accounts WHERE status < 2 AND reseller IN (NULL,'') AND posttoexternal = 0 " @@ -4445,14 +4445,14 @@ sub calc_charges() { my ($astpp_db, $config, $cardno, @output) = @_; - my $cost; + my $cost = 0; my @chargelist = &get_charges($astpp_db, $config, $cardno); foreach my $id (@chargelist) { print STDERR "ID: $id\n" if $config->{debug} == 1; my $chargeinfo = &get_astpp_cdr( $astpp_db, $id ); - $cost = $cost + $chargeinfo->{debit}; + $cost = $cost + $chargeinfo->{debit} if $chargeinfo->{debit}; print STDERR "Debit: $chargeinfo->{debit} Credit: $chargeinfo->{credit}\n" if $config->{debug} == 1; - $cost = $cost - $chargeinfo->{credit}; + $cost = $cost - $chargeinfo->{credit} if $chargeinfo->{credit}; &markbilled( $astpp_db, $id, 1 ); } return $cost; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-03 22:03:18
|
Revision: 2151 http://astpp.svn.sourceforge.net/astpp/?rev=2151&view=rev Author: darrenkw Date: 2007-11-03 15:03:16 -0700 (Sat, 03 Nov 2007) Log Message: ----------- Resolved a bug that was trying to incorrectly pass a hash to the ASTPP module. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-callingcards.agi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-03 21:35:25 UTC (rev 2150) +++ trunk/astpp-admin.cgi 2007-11-03 22:03:16 UTC (rev 2151) @@ -423,11 +423,6 @@ return &build_admin_vendor_report() if $params->{mode} eq gettext("Vendor Report"); -# return &build_add_booth() if $params->{mode} eq gettext("Create Booth"); -# return &build_remove_booth() if $params->{mode} eq gettext("Remove Booth"); -# return &build_list_booths() if $params->{mode} eq gettext("List Booths"); -# return &build_view_booth() if $params->{mode} eq gettext("View Booth"); - return &build_homepage() if $params->{mode} eq gettext("Home Page") || $params->{mode} eq gettext("Home") @@ -552,9 +547,6 @@ elsif ( $params->{logintype} == 5 ) { #Call Shop Login return &build_pricelists() if $params->{mode} eq gettext("Pricelists"); return &build_routes() if $params->{mode} eq gettext("Routes"); - -# return &build_add_callshop() if $params->{mode} eq gettext("Create CallShop"); -# return &build_remove_callshop() if $params->{mode} eq gettext("Remove CallShop"); return &build_add_booth() if $params->{mode} eq gettext("Create Booth"); return &build_remove_booth() if $params->{mode} eq gettext("Remove Booth"); @@ -9153,12 +9145,12 @@ HTML::Template->new( filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); if ( $params->{logintype} == 2 ) { - $tmp = "SELECT * FROM system"; + $tmp = "SELECT * FROM system ORDER BY reseller,name"; } elsif ( $params->{logintype} == 1 ) { $tmp = "SELECT * FROM system WHERE reseller = " - . $astpp_db->quote( $params->{username} ); + . $astpp_db->quote( $params->{username} ) . " ORDER BY name"; } print STDERR $tmp if $config->{debug} == 1; my $sql = $astpp_db->prepare($tmp); @@ -9201,7 +9193,6 @@ push @currency, $config->{currency}; $ASTPP->set_astpp_db($astpp_db); $ASTPP->set_cdr_db($cdr_db); -# $ASTPP->set_config(\%config); } ############### Integration with Realtime starts here ####################### Modified: trunk/astpp-callingcards.agi =================================================================== --- trunk/astpp-callingcards.agi 2007-11-03 21:35:25 UTC (rev 2150) +++ trunk/astpp-callingcards.agi 2007-11-03 22:03:16 UTC (rev 2151) @@ -58,7 +58,6 @@ } $cdr_db = &cdr_connect_db( $config, @output ); $ASTPP->set_cdr_db($cdr_db); - $ASTPP->set_config($config); $sound = &define_sounds($astpp_db); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-03 21:35:25
|
Revision: 2150 http://astpp.svn.sourceforge.net/astpp/?rev=2150&view=rev Author: darrenkw Date: 2007-11-03 14:35:25 -0700 (Sat, 03 Nov 2007) Log Message: ----------- Many minor fixes. Moved some of the get_pricelist subroutines to the perl module. Also, added more pagination support directly in the perl module. Also corrected the issues with bug: [ 1800044 ] Debug Packages. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-callingcards.agi trunk/astpp-common.pl trunk/modules/ASTPP/lib/ASTPP.pm trunk/templates/account-info.tpl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-03 03:07:15 UTC (rev 2149) +++ trunk/astpp-admin.cgi 2007-11-03 21:35:25 UTC (rev 2150) @@ -42,7 +42,7 @@ use Locale::gettext_pp qw(:locale_h); use Data::Dumper; use lib './lib', '../lib'; -#use warnings; +use warnings; use Asterisk::Manager; use Text::CSV; use HTML::Template; @@ -65,8 +65,7 @@ $freepbx_db $rt_db $openser_db $ASTPP); my $starttime = [gettimeofday]; $ASTPP = ASTPP->new; -$ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to -be. +$ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to be. $ASTPP->set_asterisk_agi($AGI); $ASTPP->set_pagination_script("astpp-admin.cgi"); my @Home = ( gettext("Home Page") ); @@ -536,6 +535,10 @@ if $params->{mode} eq gettext("Reseller Report"); return &build_reseller_user_report() if $params->{mode} eq gettext("User Report"); + return &build_packages() + if $params->{mode} eq gettext("Packages"); + return &build_counters() + if $params->{mode} eq gettext("Counters"); return &build_homepage() if $params->{mode} eq gettext("Home Page") @@ -1096,7 +1099,7 @@ return gettext("Cannot display reports until database is configured") unless $cdr_db; - return gettext("Comming Soon!"); + return gettext("Coming Soon!"); } # End of code changes by Sonia Ali Khan. @@ -1570,13 +1573,7 @@ filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); return gettext("Cannot view account until database is configured") unless $astpp_db; - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } - +@pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); return gettext("Cannot view account until pricelists configured") unless @pricelists; @@ -1873,7 +1870,7 @@ -values => \%applyablecharges )); - my (@account_did_list); + my (@account_did_list,$sql,$pagination); my @did_list = &list_dids_account( $astpp_db, $accountinfo->{number} ); foreach my $did_info (@did_list) { my (%row); @@ -1894,7 +1891,7 @@ "SELECT * FROM ani_map WHERE account = " . $astpp_db->quote( $accountinfo->{'number'} ) . " ORDER BY number"; - my $sql = $astpp_db->prepare($tmp); + $sql = $astpp_db->prepare($tmp); $sql->execute; my @account_ani_list; while ( my $record = $sql->fetchrow_hashref ) { @@ -1923,60 +1920,25 @@ } $template->param( account_ip_list => \@account_ip_list); $template->param( currency => $currency[0]); - ## START PAGINATION CODE - # set total_entries *once* then pass it around - # in the object's links from then on for efficiency: + ($sql, $pagination) = + $ASTPP->pagination( sql_select => "SELECT * FROM cdrs WHERE cardnum =" + . $astpp_db->quote( $accountinfo->{number} ) + . "and status IN (NULL, '', 0, 1)" + . " ORDER BY callstart DESC ", + sql_count => "SELECT COUNT(*) FROM cdrs WHERE cardnum =" + . $astpp_db->quote( $accountinfo->{number} ) + . "and status IN (NULL, '', 0, 1)", + results_per_page=> $config->{results_per_page}, + ve => $params->{ve}, + te => $params->{ee}, - my $verify = CGI::param('ve') || ''; - my $total_entries = int( CGI::param('te') ); - my $te_match = - $total_entries - ? Digest::MD5::md5_hex("unique_cypher-$total_entries-$where") - : ''; - if ( !$total_entries || $verify ne $te_match ) { - - # its not ok so re-fetch - $tmp = - "SELECT COUNT(*) FROM cdrs WHERE cardnum =" - . $astpp_db->quote( $accountinfo->{number} ) - . "and status IN (NULL, '', 0, 1)" - . " ORDER BY callstart DESC"; + ); + my $results = $astpp_db->prepare($sql); + $results->execute; $sql = $astpp_db->prepare($tmp); $sql->execute; - $record = $sql->fetchrow_hashref; - $total_entries = $record->{"COUNT(*)"}; - $sql->finish; - $te_match = Digest::MD5::md5_hex("unique_cypher-$total_entries-$where"); - } - if ( $total_entries <= 0 ) { $total_entries = 1; } - my $pgr = Data::Paginate->new( - { - 'start_array_index_at_zero' => 1, - 'total_entries' => $total_entries, - 'entries_per_page' => $results_per_page, - 'total_entries_verify_param_value' => $te_match - } - ); - - # only SELECT current page's records: - if ( $total_entries > $pgr->get_entries_on_this_page() ) { - $tmp = - "SELECT * FROM cdrs WHERE cardnum =" - . $astpp_db->quote( $accountinfo->{number} ) - . "and status IN (NULL, '', 0, 1)" - . " ORDER BY callstart DESC " - . " LIMIT ". ($pgr->get_first() - 1) . ", " . $pgr->get_entries_on_this_page(); - } else { - $tmp = - "SELECT * FROM cdrs WHERE cardnum =" - . $astpp_db->quote( $accountinfo->{'number'} ) - . "and status IN (NULL, '', 0, 1)" - . " ORDER BY callstart DESC "; - } - $sql = $astpp_db->prepare($tmp); - $sql->execute; my @account_cdr_list; - while ( my $record = $sql->fetchrow_hashref ) { + while ( my $record = $results->fetchrow_hashref ) { my %row; if (!$record->{callerid}) { $row{callerid} = gettext("N/A"); @@ -1984,11 +1946,14 @@ $row{callerid} = $record->{callerid}; } if (!$record->{uniqueid}) { $row{uniqueid} = gettext("N/A");} else { $row{uniqueid} = $record->{uniqueid};} - if (!$record->{disposition}) {$row{disposition} = gettext("N/A");} else {$row{disposition} = $record->{dispositio}; } + if (!$record->{disposition}) {$row{disposition} = gettext("N/A");} else {$row{disposition} = $record->{disposition}; } if (!$record->{notes}) { $row{notes} = ""; } else { $row{notes} = $record->{notes} ;} if (!$record->{callstart}) { $row{callstart} = ""; } else { $row{callstart} = $record->{callstart}; } if (!$record->{callednum}) { $row{callednum} = ""; } else {$row{callednum} = $record->{callednum};} if (!$record->{billseconds}) { $row{billseconds} = ""; } else { $row{billseconds} = $record->{billseconds};} + if (!$record->{cost}) { $row{cost} = ""; } else { $row{cost} = $record->{cost};} + $row{profit} = sprintf( "%.6f", ($record->{debit} - $record->{cost})/10000); + $row{cost} = sprintf( "%.6f", $row{cost}); if ( $record->{debit} ) { $row{debit} = $record->{debit} / 10000; @@ -2007,30 +1972,7 @@ push(@account_cdr_list, \%row); } $template->param( account_cdr_list => \@account_cdr_list); - if ( $total_entries => 1 ) - { #This section only applies if we have more than 1 page. - $pagination = - "<a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") . "&ve=" - . $params->{ve} . "&te=" - . $total_entries - . "&pg=1\">" - . gettext("First Page") - . "</a> | "; - $pagination .= scalar $pgr->get_navi_html(); - $pagination .= - "<a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") . "&ve=" - . $params->{ve} . "&te=" - . $total_entries . "&pg=" - . $pgr->get_last_page() . "\">" - . gettext("Last Page") . "</a>"; - } - else { - $pagination = gettext("Page 1 of 1"); - } - - $template->param( pagination => $pagination ); + $template->param( pagination => $pagination ); } else { $status .= @@ -2226,12 +2168,7 @@ filename => '/var/lib/astpp/templates/account-create.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); return gettext("Database is NOT configured!") . " \n" unless $astpp_db; - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); return gettext("Please configure 'Pricelists'") . "\n" unless @pricelists; if ( $params->{action} eq gettext("Generate Account") ) { @@ -2370,12 +2307,7 @@ my $active = gettext("ACTIVE"); my $inactive = gettext("INACTIVE"); my $deleted = gettext("DELETED"); - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0; } @@ -2859,6 +2791,9 @@ sub build_create_card() { my ( @pricelists, $status, $body, @brands ); + my $template = + HTML::Template->new( + filename => '/var/lib/astpp/templates/callingcards-create.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); return gettext("Database is NOT configured!") . " \n" unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { @brands = &list_cc_brands_reseller( $astpp_db, $params->{username} ); @@ -2879,41 +2814,10 @@ } $status .= &generatecallingcards( $params, $config ); } - $body = start_multipart_form; - $body .= "<table class=\"default\">"; - $body .= "<tr class=\"header\"><td>"; - $body .= - gettext("Account Number") - . "</td><td>" - . gettext("Brand") - . "</td><td>" - . gettext("Value in pennies") - . "</td><td>" - . gettext("Quantity") - . "</td><td>" - . gettext("Status") - . "</td></tr>" - . "<tr class=\"rowone\"><td>" - . hidden( -name => "mode", -value => gettext("Create Card") ) - . textfield( -name => "account", -size => 20 ) - . "</td><td>" - . popup_menu( -name => "brand", -values => \@brands ) - . "</td><td>" - . textfield( -name => "value", -size => 8 ) - . "</td><td>" - . textfield( -name => "count", -size => 8 ) - . "</td><td>" - . popup_menu( - -name => "status", - -values => \@cardstatus - ) - . "</td><td>" - . "</td></tr><tr><td>" - . submit( - -name => 'action', - -value => gettext("Generate Card(s)") - ) . "</td></tr></table>"; - return $body; + $template->param(brand_list => popup_menu( -name=>"brand", -values => \@brands)); + $template->param(status_list => popup_menu( -name => "status", -values => \@cardstatus)); + $template->param(status => $status); + return $template->output; } sub build_update_card_status() { @@ -2925,12 +2829,7 @@ else { @brands = &list_cc_brands($astpp_db); } - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); return gettext("Please configure 'Pricelists'!") . "\n" unless @pricelists; if ( $params->{action} eq gettext("Update Status on Card(s)") ) { @@ -4338,12 +4237,7 @@ else { $number = $params->{number}; } - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); my @resellerlist = &list_resellers($astpp_db); unshift( @resellerlist, "" ); $accountinfo = &get_account( $astpp_db, $number ); @@ -4646,12 +4540,7 @@ $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Add...") ) { - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); return gettext("Please configure 'Pricelists'!") . "\n" unless @pricelists; push @pricelists, ""; @@ -4698,12 +4587,7 @@ "; } elsif ( $params->{action} eq gettext("Edit...") ) { - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); return gettext("Please configure 'Pricelists'!") . "\n" unless @pricelists; push @pricelists, ""; @@ -7403,12 +7287,7 @@ sub build_routes() { my ( @pricelists, $sql, $count, $tmp ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); return gettext("Pricelists Do NOT Exist!") . "\n" unless @pricelists; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } my $results_per_page = $config->{results_per_page}; @@ -7684,12 +7563,7 @@ $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Add...") ) { - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); $body = start_form . "<table class=\"default\">" . "<tr class=\"header\"><td colspan=2>" @@ -7908,110 +7782,41 @@ } sub build_counters() { - my ($tmp,@counter_list); + my ($tmp,@counter_list,$sql_select,$sql_count); my $template = HTML::Template->new( filename => '/var/lib/astpp/templates/counters-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); - my $results_per_page = $config->{results_per_page}; - if ( $results_per_page eq "" || $results_per_page < 2 ) { - $results_per_page = 25; + if ( $params->{logintype} == 2 ) { + $sql_select = "SELECT counters.id AS id, packages.name AS name,counters.account AS account, counters.seconds AS seconds, counters.status AS status FROM counters,packages WHERE package IN(SELECT id FROM packages WHERE pricelist IN (SELECT name from pricelists WHERE reseller IS NULL)) AND counters.package = packages.id;"; + $sql_count = "SELECT COUNT(*) FROM counters WHERE package IN(SELECT id FROM packages WHERE pricelist IN (SELECT name from pricelists WHERE reseller IS NULL)) AND counters.package = packages.id;"; } - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - $tmp = - "SELECT * FROM pricelists WHERE status < 2 AND reseller = " - . $astpp_db->quote( $params->{username} ); + elsif ( $params->{logintype} == 1 ) { + $sql_select = + "SELECT counters.id AS id, packages.name AS name,counters.account AS account, counters.seconds AS seconds, counters.status AS status FROM counters,packages WHERE package IN(SELECT id FROM packages WHERE pricelist IN(SELECT name FROM pricelists WHERE reseller = " + . $astpp_db->quote( $params->{username} ) . ")) AND counters.package = packages.id;"; + $sql_count = + "SELECT COUNT(*) FROM counters WHERE package IN(SELECT id FROM packages WHERE pricelist IN(SELECT name FROM pricelists WHERE reseller = " + . $astpp_db->quote( $params->{username} ) . ") AND counters.package = packages.id;"; } - else { - $tmp = - "SELECT * FROM pricelists WHERE status < 2 AND reseller IS NULL"; - } - my $sql = $astpp_db->do($sql); - print STDERR $tmp if $config->{debug} == 1; - $sql = $astpp_db->prepare($tmp); - ## START PAGINATION CODE - # set total_entries *once* then pass it around - # in the object's links from then on for efficiency: - - my $verify = CGI::param('ve') || ''; - my $total_entries = int( CGI::param('te') ); - my $te_match = - $total_entries - ? Digest::MD5::md5_hex("unique_cypher-$total_entries-$where") - : ''; - if ( !$total_entries || $verify ne $te_match ) { - - # its not ok so re-fetch - $sql = $astpp_db->prepare("SELECT COUNT(*) FROM counters"); - $sql->execute; - $record = $sql->fetchrow_hashref; - $total_entries = $record->{"COUNT(*)"}; - $sql->finish; - $te_match = Digest::MD5::md5_hex("unique_cypher-$total_entries-$where"); - } - - #if ($te_match <= 0) { $te_match = 0; } - if ( $total_entries <= 0 ) { $total_entries = 1; } - - # otherwise its all ok so use it - my $pgr = Data::Paginate->new( - { - 'start_array_index_at_zero' => 1, - 'total_entries' => $total_entries, - 'entries_per_page' => $results_per_page, - 'total_entries_verify_param_value' => $te_match - } - ); - - # only SELECT current page's records: - if ( $total_entries > $pgr->get_entries_on_this_page() ) { - $sql = - "SELECT * FROM counters ORDER BY id LIMIT " - . ( $pgr->get_first() - 1 ) . ", " - . $pgr->get_entries_on_this_page(); - } - else { - $sql = "SELECT * FROM counters ORDER BY id"; - } - print STDERR $sql if $config->{debug} == 1; - $sql = $astpp_db->prepare($sql); - $sql->execute; - - # END OF PAGINATION CODE - while ( my $counterinfo = $sql->fetchrow_hashref ) { + my ($sql, $pagination) = + $ASTPP->pagination( sql_select => $sql_select, + sql_count => $sql_count, + results_per_page=> $config->{results_per_page}, + ve => $params->{ve}, + te => $params->{ee}, + + ); + my $results = $astpp_db->prepare($sql); + $results->execute; + while ( my $counterinfo = $results->fetchrow_hashref ) { print STDERR "COUNTER: " . $counterinfo->{id} if $config->{debug} == 1; my (%row); - - # $row{} = $name; - # $row{balance} = $balance / 10000; - # $row{call_count} = $record->{"COUNT(*)"}; $row{id} = $counterinfo->{id}; - $row{package} = $counterinfo->{package}; + $row{package} = $counterinfo->{name}; $row{account} = $counterinfo->{account}; $row{seconds} = $counterinfo->{seconds}; push( @counter_list, \%row ); } - if ( $total_entries >= 1 ) - { #This section only applies if we have more than 1 page. - $pagination = - "<a href=\"astpp-admin.cgi?mode=" - . gettext("Counters") . "&ve=" - . $params->{ve} . "&te=" - . $total_entries - . "&pg=1\">" - . gettext("First Page") - . "</a> | "; - $pagination .= scalar $pgr->get_navi_html(); - $pagination .= - "<a href=\"astpp-admin.cgi?mode=" - . gettext("Counters") . "&ve=" - . $params->{ve} . "&te=" - . $total_entries . "&pg=" - . $pgr->get_last_page() . "\">" - . gettext("Last Page") . "</a>"; - } - else { - $pagination = gettext("Page 1 of 1"); - } $template->param( counter_list => \@counter_list ); $template->param( pagination => $pagination ); return $template->output; @@ -8020,72 +7825,33 @@ sub build_packages() { my ( $sql, $record, $count, $tmp, $pageno, $pagesrequired ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; + my $template = + HTML::Template->new( + filename => '/var/lib/astpp/templates/packages-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); if ( $params->{limit} < 1 ) { $params->{limit} = 0 } my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } - if ( !$params->{action} ) { - $params->{action} = gettext("Information..."); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); + $template->param( pricelists => popup_menu( + -name => 'pricelist', + -values => \@pricelists + )); if ( $params->{action} eq gettext("Edit...") ) { - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } - $tmp = + $tmp = "SELECT * FROM packages WHERE id = " . $astpp_db->quote( $params->{id} ); $sql = $astpp_db->prepare($tmp); $sql->execute; $record = $sql->fetchrow_hashref; $sql->finish; - $body = start_form; - $body .= - "<table class=\"default\">" - . "<tr class=\"header\"><td>" - . hidden( -name => "mode", -value => gettext("Packages") ) - . hidden( -name => "id", -value => $params->{id} ) - . gettext("Counter Name") - . "</td><td>" - . gettext("Pricelist") - . "</td><td>" - . gettext("Pattern") - . "</td><td>" - . gettext("Included Seconds") - . "</td><td>" - . gettext("Action") - . "</td></tr>"; - $body .= "<tr><td>" - . textfield( - -name => 'name', - -size => 20, - -default => $record->{name} - ) - . "</td><td>" - . popup_menu( - -name => 'pricelist', + $template->param(id => $params->{id} ); + $template->param(current_name => $record->{name} ); + $template->param(edit_pricelists => popup_menu( + -name => 'edit_pricelist', -values => \@pricelists, - -default => $record->{pricelist} - ) - . "</td><td>" - . textfield( - -name => 'pattern', - -size => 30, - -default => $record->{pattern} - ) - . "</td><td>" - . textfield( - -name => 'includedseconds', - -size => 6, - -default => $record->{includedseconds} - ) - . "</td><td>" - . submit( -name => 'action', -value => gettext("Save...") ) - . "</td></tr> -</table> -"; - return $body; + -default => $record->{pricelist} )); + $template->param(current_pattern => $record->{pattern}); + $template->param(current_includedseconds => $record->{includedseconds}); } elsif ( $params->{action} eq gettext("Insert...") ) { my $tmp = @@ -8111,13 +7877,14 @@ } elsif ( $params->{action} eq gettext("Save...") ) { my $tmp = - "UPDATE pricelists SET" . " name=" - . $astpp_db->quote( $params->{name} ) . ", " . " inc=" - . $astpp_db->quote( $params->{inc} ) . ", " - . " markup=" - . $astpp_db->quote( $params->{markup} ) + "UPDATE packages SET name= " + . $astpp_db->quote( $params->{edit_name} ) . ", pricelist = " + . $astpp_db->quote( $params->{edit_pricelist} ) . ", pattern=" + . $astpp_db->quote( $params->{edit_pattern} ) . ", includedseconds=" + . $astpp_db->quote( $params->{edit_includedseconds} ) . " WHERE id = " . $astpp_db->quote( $params->{id} ); + print STDERR $tmp if $config->{debug} == 1; if ( $astpp_db->do($tmp) ) { $status .= gettext("Package: ") @@ -8129,7 +7896,6 @@ gettext("Package: ") . $params->{name} . gettext(" Failed to Update!"); - print STDERR $tmp if $config->{debug} == 1; } $params->{action} = gettext("Information..."); } @@ -8152,158 +7918,44 @@ } $params->{action} = gettext("Information..."); } - elsif ( $params->{action} eq gettext("Add...") ) { - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = ( $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } - $body = start_form; - $body .= - "<table class=\"default\">" - . "<tr class=\"header\"><td>" - . hidden( -name => "mode", -value => gettext("Packages") ) - . gettext("Counter Name") - . "</td><td>" - . gettext("Pricelist") - . "</td><td>" - . gettext("Pattern") - . "</td><td>" - . gettext("Included Seconds") - . "</td><td>" - . gettext("Action") - . "</td></tr> -"; - $body .= "<tr><td>" - . textfield( - -name => 'name', - -size => 20 - ) - . "</td><td>" - . popup_menu( - -name => 'pricelist', - -values => \@pricelists - ) - . "</td><td>" - . textfield( - -name => 'pattern', - -size => 30 - ) - . "</td><td>" - . textfield( - -name => 'includedseconds', - -size => 6 - ) - . "</td><td>" - . submit( -name => 'action', -value => gettext("Insert...") ) - . "</td></tr> -</table> -"; - return $body; + if ( $params->{logintype} == 2 ) { + $sql_select = + "SELECT * FROM packages WHERE status < 2 AND pricelist IN(SELECT name FROM pricelists WHERE reseller IS NULL) ORDER BY id"; + $sql_count = + "SELECT * FROM packages WHERE status < 2 AND pricelist IN(SELECT name FROM pricelists WHERE reseller IS NULL) ORDER BY id"; } - if ( $params->{action} eq gettext("Information...") ) { - $body = start_form; - $body .= - "<table class=\"default\">" - . "<tr><td>" - . submit( -name => 'action', -value => gettext("Add...") ) - . "</td></tr> -" - . "<tr class=\"header\"><td>" - . hidden( -name => "mode", -value => gettext("Packages") ) - . gettext("Counter Name") - . "</td><td>" - . gettext("Pricelist") - . "</td><td>" - . gettext("Pattern") - . "</td><td>" - . gettext("Included Seconds") - . "</td><td>" - . gettext("Action") - . "</td></tr> -"; - $tmp = "SELECT * FROM packages WHERE status < 2"; - $sql = $astpp_db->prepare($tmp); - $sql->execute - || return gettext("Something is wrong with the ASTPP database!") - . "\n"; - my $results = $sql->rows; - my $pagesrequired = ceil( $results / $results_per_page ); - print gettext("Pages Required:") . " $pagesrequired\n" - if ( $config->{debug} == 1 ); - $sql->finish; - $sql = - $astpp_db->prepare( -"SELECT * FROM packages WHERE status < 2 ORDER BY name limit $params->{limit} , $results_per_page" - ); - $sql->execute - || return gettext("Something is wrong with the ASTPP database!") - . "\n"; - $count = 0; - - while ( my $packageinfo = $sql->fetchrow_hashref ) { - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $count++; - $body .= - "<td>$packageinfo->{name}" - . "</td><td>$packageinfo->{pricelist}" - . "</td><td>$packageinfo->{pattern}" - . "</td><td>$packageinfo->{includedseconds}" - . "</td><td><a href=\"astpp-admin.cgi?mode=" - . gettext("Packages") - . "&action=" - . gettext("Edit...") . "&id=" - . $packageinfo->{id} . "\">" - . gettext("Edit...") . "</a>" - . " <a href=\"astpp-admin.cgi?mode=" - . gettext("Packages") - . "&action=" - . gettext("Deactivate...") . "&id=" - . $packageinfo->{id} . "\">" - . gettext("Deactivate...") . "</a>" - . "</td></tr>"; - } - $body .= "</table>"; - for ( my $i = 0 ; $i <= $pagesrequired - 1 ; $i++ ) { - if ( $i == 0 ) { - if ( $params->{limit} != 0 ) { - $body .= - "<a href=\"astpp-admin.cgi?mode=" - . gettext("Packages") - . "&limit=0\">"; - $body .= $i + 1; - $body .= "</a>"; - } - else { - $body .= $i + 1; - } - } - if ( $i > 0 ) { - if ( $params->{limit} != ( $i * $results_per_page ) ) { - $body .= - "<a href=\"astpp-admin.cgi?mode=" - . gettext("Packages") - . "&limit="; - $body .= ( $i * $results_per_page ); - $body .= "\">\n"; - $body .= $i + 1 . "</a>"; - } - else { - $pageno = $i + 1; - $body .= " |"; - } - } - } - $body .= ""; - $body .= - gettext("Page") . " $pageno " . gettext("of") . " $pagesrequired"; + elsif ( $params->{logintype} == 1 ) { + $sql_select = + "SELECT * FROM packages WHERE status < 2 AND pricelist IN(SELECT name FROM pricelists WHERE reseller = " + . $astpp_db->quote( $params->{username} ) . ") ORDER BY id"; + $sql_count = + "SELECT * FROM packages WHERE status < 2 AND pricelist IN(SELECT name FROM pricelists WHERE reseller = " + . $astpp_db->quote( $params->{username} ) . ") ORDER BY id"; } + my ($sql, $pagination) = + $ASTPP->pagination( sql_select => $sql_select, + sql_count => $sql_count, + results_per_page=> $config->{results_per_page}, + ve => $params->{ve}, + te => $params->{ee}, + + ); + my $results = $astpp_db->prepare($sql); + $results->execute; + while ( my $packageinfo = $results->fetchrow_hashref ) { + print STDERR "PACKAGE: " . $packgeinfo->{id} if $config->{debug} == 1; + my (%row); + $row{id} = $packageinfo->{id}; + $row{name} = $packageinfo->{name}; + $row{pattern} = $packageinfo->{pattern}; + $row{pricelist} = $packageinfo->{pricelist}; + $row{includedseconds} = $packageinfo->{includedseconds}; + push( @package_list, \%row ); + } + $template->param( package_list => \@package_list ); + $template->param( pagination => $pagination ); + $template->param( status => $status ); + return $template->output; return $body; } @@ -9418,12 +9070,7 @@ sub build_calc_charge() { my ( $status, $body, $cost, $length, $increment ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = ( $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); if ( $params->{action} eq gettext("Price Call...") ) { my $branddata = &get_pricelist( $astpp_db, $params->{pricelist} ); my $numdata = &get_route( $astpp_db, $config, $params->{phonenumber}, @@ -9552,6 +9199,9 @@ } @modes = sort @modes; push @currency, $config->{currency}; + $ASTPP->set_astpp_db($astpp_db); + $ASTPP->set_cdr_db($cdr_db); +# $ASTPP->set_config(\%config); } ############### Integration with Realtime starts here ####################### @@ -10898,12 +10548,7 @@ -values => \@language, -default => $config->{default_language} ); - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - @pricelists = &list_pricelists( $astpp_db, $params->{username} ); - } - else { - @pricelists = &list_pricelists($astpp_db); - } + @pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); $pricelists = popup_menu( -name => "pricelist", -values => \@pricelists @@ -11546,6 +11191,7 @@ '1' => gettext("Reseller"), '5' => gettext("CallShop") ); + $params->{logged_in_reseller} = $params->{username}; } elsif ( $params->{logintype} == 2 ) { print STDERR "ASTPP ADMINISTRATOR LOGIN\n" if $config->{debug} == 1; @@ -11578,6 +11224,7 @@ '4' => gettext("Customer Service"), '5' => gettext("CallShop") ); + $params->{logged_in_reseller} = ""; } elsif ( $params->{logintype} == 3 ) { # Vendor Login - Vendors are only allowed to look at stuff that pertains to them. Modified: trunk/astpp-callingcards.agi =================================================================== --- trunk/astpp-callingcards.agi 2007-11-03 03:07:15 UTC (rev 2149) +++ trunk/astpp-callingcards.agi 2007-11-03 21:35:25 UTC (rev 2150) @@ -58,6 +58,7 @@ } $cdr_db = &cdr_connect_db( $config, @output ); $ASTPP->set_cdr_db($cdr_db); + $ASTPP->set_config($config); $sound = &define_sounds($astpp_db); } Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-03 03:07:15 UTC (rev 2149) +++ trunk/astpp-common.pl 2007-11-03 21:35:25 UTC (rev 2150) @@ -3121,7 +3121,7 @@ . $astpp_db->quote($number) . " RLIKE pattern AND pricelist = " . $astpp_db->quote( $carddata->{pricelist} ) - . " ORDER BY LENGTH(pattern) DESC" ); + . " ORDER BY LENGTH(pattern) DESC LIMIT 1" ); $sql->execute; $record = $sql->fetchrow_hashref; $sql->finish; @@ -3663,7 +3663,7 @@ sub rating() { # This routine recieves a specific cdr and takes care of rating it and of marking it as rated. It bills resellers as appropriate. my ( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, @output ) = @_; my ( $increment, $numdata, $package, $notes, $status ); - print STDERR "----------------------\n"; + print STDERR "----------------------------------------------------------------\n"; print STDERR "uniqueid: $cdrinfo->{uniqueid}, cardno: $carddata->{number}, phoneno: $cdrinfo->{dst}, Userfield: $cdrinfo->{userfield}\n"; print STDERR @@ -3678,7 +3678,7 @@ if $config->{astcdr} == 1; print STDERR "ERROR - ERROR - ERROR - ERROR - ERROR \n"; print STDERR "NO MATCHING PATTERN\n"; - print STDERR "----------------------\n"; + print STDERR "----------------------------------------------------------------\n"; } else { print STDERR "FOUND A MATCHING PATTERN.\n"; @@ -3687,21 +3687,22 @@ "pricelistData: $branddata->{name} $branddata->{markup} $branddata->{inc} $branddata->{status}\n"; my $package = &get_package( $astpp_db, $carddata, $cdrinfo->{dst} ); - if ($package->{name}) { + if ($package->{id}) { my $counter = - &get_counter( $astpp_db, $package->{name}, + &get_counter( $astpp_db, $package->{id}, $carddata->{number} ); my $difference; if ( !$counter->{id}) { my $tmp = "INSERT INTO counters (package,account) VALUES (" - . $astpp_db->quote( $package->{name} ) . ", " + . $astpp_db->quote( $package->{id} ) . ", " . $astpp_db->quote( $carddata->{number} ) . ")"; - print STDERR $tmp . "/n" if $config->{debug} == 1; + print STDERR "/n" . $tmp . "/n" if $config->{debug} == 1; $astpp_db->do($tmp); $counter = - &get_counter( $astpp_db, $package->{name}, + &get_counter( $astpp_db, $package->{id}, $carddata->{number} ); + print STDERR "JUST CREATED COUNTER: $counter->{id}\n" if $config->{debug} == 1; } if ( $package->{includedseconds} > $counter->{seconds}) { my $availableseconds = $package->{includedseconds} - $counter->{seconds}; @@ -3859,10 +3860,10 @@ } elsif ( $cdrinfo->{accountcode} ) { $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata); - $cdrinfo = $savedcdrinfo; if ( $status == 1 ) { my $previous_account = $carddata->{number}; while ( $carddata->{reseller} ne "" ) { +# my $cdrinfo = &get_cdr( $cdr_db, $uniqueid ); # my $reseller = $carddata->{reseller}; print STDERR "Charge $uniqueid to $carddata->{reseller}" if $config->{debug} == 1; $carddata = &get_account( $astpp_db, $carddata->{reseller} ); Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2007-11-03 03:07:15 UTC (rev 2149) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2007-11-03 21:35:25 UTC (rev 2150) @@ -33,22 +33,49 @@ { my ($class,%arg) = @_; bless { - _astpp_db => $_[1], - _verbosity_level => $arg{verbosity_level} || 1, - _asterisk_agi => $_[3], - _cdr_db => $_[4], - _verbosity_item_level => $arg{verbosity_item_level} || 1, - _pagination_script => $arg{pagination_script} || "astpp-admin.cgi", + _astpp_db => $_[1], + _verbosity => $arg{verbosity_level} || 1, + _asterisk_agi => $_[3], + _cdr_db => $_[4], + _verbosity_item_level => $arg{verbosity_item_level} || 1, + _script => $arg{script} || "astpp-admin.cgi", + _config => $_[7], }, $class; } +sub set_verbosity_level { $_[0]->{_verbosity_level} } #Sets the verbosity level. sub set_verbosity { $_[0]->{_verbosity_level} } #Sets the verbosity level. -sub set_asterisk_agi { $_[0]->{_asterisk_agi} } #Sets the verbosity level. -sub set_astpp_db { $_[0]->{_astpp_db} } #Sets the verbosity level. -sub set_cdr_db {$_[0]->{_cdr_db} } #Sets the verbosity level. -sub set_pagination_script {$_[00]->{_pagination_script} } +sub set_astpp_db +{ + my ($self, $astpp_db) = @_; + $self->{_astpp_db} = $astpp_db if $astpp_db; +} +sub set_cdr_db +{ + my ($self, $cdr_db) = @_; + $self->{_cdr_db} = $cdr_db if $cdr_db; +} + +sub set_asterisk_agi +{ + my ($self, $asterisk_agi) = @_; + $self->{_asterisk_agi} = $asterisk_agi if $asterisk_agi; +} + +sub set_pagination_script #Set the location of the script we are working in. +{ + my ($self, $script) = @_; + $self->{_script} = $script if $script; +} + +#sub set_config +#{ +# my ($self, %config_hash) = @_; +# $self->{_config} = %config_hash if %config_hash; +#} + sub debug #Prints debugging if appropriate # { @@ -64,43 +91,110 @@ sub pagination #Returns the pagination html code to assist with navigation. { -my ($self, %arg) = @_; + my ($self, %arg) = @_; # We are using Data::Paginate for the real tough stuff. # Therefore we need to pass the Data::Paginate stuff # as well as the total number of pages. - # total_entries = Total number of pages. - # pagination_script = Script name. + # # mode = What mode do we want. - # pgr = Pass along Data::Paginate - # ve = - # navi_html = - # last_page = + # sql = SQL to select what we want without the limit commands. + # + # Check to see if there is a parameter called "results_per_page" set. If it's set it overrides our defaults. + if (!$arg{results_per_page} || $arg{results_per_page} > 1 ) { + $arg{results_per_page} = 25; + } + ## START PAGINATION CODE + # set total_entries *once* then pass it around + # in the object's links from then on for efficiency: + my ($record,$sql); + my $verify = $arg{ve} || ''; + my $total_entries = int( $arg{te} ); + my $te_match = $total_entries + ? Digest::MD5::md5_hex("unique_cypher-$total_entries-$arg{sql_check}") : ''; + if ( !$total_entries || $verify ne $te_match ) { + # its not ok so re-fetch + $sql = $self->{_astpp_db}->prepare($arg{sql_count}); + $sql->execute; + $record = $sql->fetchrow_hashref; + $total_entries = $record->{"COUNT(*)"}; + $sql->finish; + $te_match = Digest::MD5::md5_hex("unique_cypher-$total_entries-$arg{sql_check}"); + } + + #if ($te_match <= 0) { $te_match = 0; } + if ( $total_entries <= 0 ) { $total_entries = 1; } + + # otherwise its all ok so use it + my $pgr = Data::Paginate->new( + { + 'start_array_index_at_zero' => 1, + 'total_entries' => $total_entries, + 'entries_per_page' => $arg{results_per_page}, + 'total_entries_verify_param_value' => $te_match + } + ); + + # only SELECT current page's records: + if ( $total_entries > $pgr->get_entries_on_this_page() ) { + $sql = + $arg{sql_select} . " LIMIT " + . ( $pgr->get_first() - 1 ) . ", " + . $pgr->get_entries_on_this_page(); + } + else { + $sql = $arg{sql_select}; + } + # First we decide if we have multiple pages... + if ($arg{total_entries} > 1) { my $html; $html = - "<a href=\"" . $self->{_pagination_script} . "?mode=" + "<a href=\"" . $self->{_script} . "?mode=" . $arg{mode} . "&ve=" . $arg{ve} . "&te=" - . $arg{total_entries} + . $total_entries . "&pg=1\">" - . gettext("First Page") + . "First Page" . "</a> | " - . scalar $arg{navi_html} - . "<a href=\"" . $self->{_pagination_script} . "?mode=" + . scalar $pgr->get_navi_html() + . "<a href=\"" . $self->{_script} . "?mode=" . $arg{mode} . "&ve=" . $arg{ve} . "&te=" . $arg{total_entries} . "&pg=" . $arg{last_page} . "\">" - . gettext("Last Page") . "</a>"; - return $html; + . "Last Page" . "</a>"; + return ($sql,$html); } else { - return gettext("Page 1 of 1"); + return ($sql,"Page 1 of 1"); } } +sub list_pricelists +{ + my ($self, %arg) = @_; # Return a list of all pricelists either for the appropriate reseller or without reseller. + my ( $sql, @pricelistlist, $row, $tmp ); + if ( !$arg{reseller} || $arg{reseller} eq "") { + $tmp = + "SELECT name FROM pricelists WHERE status < 2 AND reseller IS NULL ORDER BY name"; + } + else { + $tmp = + "SELECT name FROM pricelists WHERE status < 2 AND reseller = " + . $self->{_astpp_db}->quote($arg{reseller}) + . " ORDER BY name"; + } + $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + while ( $row = $sql->fetchrow_hashref ) { + push @pricelistlist, $row->{name}; + } + $sql->finish; + return @pricelistlist; +} + # Preloaded methods go here. 1; Modified: trunk/templates/account-info.tpl =================================================================== --- trunk/templates/account-info.tpl 2007-11-03 03:07:15 UTC (rev 2149) +++ trunk/templates/account-info.tpl 2007-11-03 21:35:25 UTC (rev 2150) @@ -183,12 +183,13 @@ <td>Date & Time</td> <td>Caller*ID</td> <td>Called Number</td> - <td>Trunk</td> <td>Disposition</td> <td>Billable Seconds</td> <td>Charge</td> <td>Credit</td> <td>Notes</td> + <td>Cost</td> + <td>Profit</td> </tr> <TMPL_LOOP NAME="account_cdr_list"> <TR> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-03 03:07:20
|
Revision: 2149 http://astpp.svn.sourceforge.net/astpp/?rev=2149&view=rev Author: darrenkw Date: 2007-11-02 20:07:15 -0700 (Fri, 02 Nov 2007) Log Message: ----------- Resolved: [ 1820671 ] HTML::TEmplate die_on_bad_params => 0 Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-callingcards.agi trunk/astpp-users.cgi trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-02 05:39:54 UTC (rev 2148) +++ trunk/astpp-admin.cgi 2007-11-03 03:07:15 UTC (rev 2149) @@ -50,7 +50,9 @@ use Time::HiRes qw( gettimeofday tv_interval ); use Data::Paginate; use DateTime; -use DateTime::TimeZone +use DateTime::TimeZone; +use ASTPP; + ; # We use DateTime::TimeZone to show users cdrs in their own timezones. require "/usr/local/astpp/astpp-common.pl"; @@ -60,8 +62,13 @@ textdomain("astpp"); use vars qw(@output $astpp_db $params $config $status $config $limit $accountinfo - $freepbx_db $rt_db $openser_db); + $freepbx_db $rt_db $openser_db $ASTPP); my $starttime = [gettimeofday]; +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to +be. +$ASTPP->set_asterisk_agi($AGI); +$ASTPP->set_pagination_script("astpp-admin.cgi"); my @Home = ( gettext("Home Page") ); my @Accounts = ( gettext("Create Account"), gettext("Process Payment"), @@ -1470,7 +1477,7 @@ sub build_homepage() { my $template = - HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); if ( $params->{logintype} == 1 || $params->{logintype} == 5 @@ -1560,7 +1567,7 @@ ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); return gettext("Cannot view account until database is configured") unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { @@ -2039,7 +2046,7 @@ my ( $body, $total, $count, $reseller, @accountdetaillist ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/account-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params}); my $yes = gettext("YES"); my $no = gettext("NO"); return gettext("Cannot view account until database is configured") @@ -2216,7 +2223,7 @@ my ( @pricelists, $status, $body ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/account-create.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); return gettext("Database is NOT configured!") . " \n" unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { @@ -5442,7 +5449,7 @@ $accountinfo ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/account-remove.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); if ( $params->{action} eq gettext("Deactivate...") ) { if ( $params->{number} ne "" ) { $number = $params->{number}; @@ -5501,7 +5508,7 @@ my ( $status, $body, $number, $reseller ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-process-payment.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/account-process-payment.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); return gettext("Database not configured!") unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $reseller = $params->{username}; @@ -7901,14 +7908,26 @@ } sub build_counters() { - my (@counter_list); + my ($tmp,@counter_list); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/counters-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/counters-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" || $results_per_page < 2 ) { $results_per_page = 25; } + if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { + $tmp = + "SELECT * FROM pricelists WHERE status < 2 AND reseller = " + . $astpp_db->quote( $params->{username} ); + } + else { + $tmp = + "SELECT * FROM pricelists WHERE status < 2 AND reseller IS NULL"; + } + my $sql = $astpp_db->do($sql); + print STDERR $tmp if $config->{debug} == 1; + $sql = $astpp_db->prepare($tmp); ## START PAGINATION CODE # set total_entries *once* then pass it around # in the object's links from then on for efficiency: @@ -9485,7 +9504,7 @@ my ( $tmp, $template, @configuration_list ); $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); if ( $params->{logintype} == 2 ) { $tmp = "SELECT * FROM system"; } @@ -10755,7 +10774,7 @@ sub build_add_callshop() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/callshop-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/callshop-create.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); if ( $params->{action} eq gettext("Add...") ) { if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $params->{pricelist} = $params->{username}; @@ -10813,7 +10832,7 @@ sub build_remove_callshop() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/callshop-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/callshop-remove.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); my ( @callshops, $tmp ); if ( $params->{logintype} == 1 ) { @callshops = &list_callshops_reseller( $astpp_db, $params->{username} ); @@ -10868,7 +10887,7 @@ my ( $template, $currency, $pricelist, $language, $status ); $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/booth-create.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); $params->{reseller} = $params->{username}; $currency = popup_menu( -name => "currency", @@ -11046,7 +11065,7 @@ sub build_remove_booth() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/booth-remove.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); my ( @booth_list, $accountinfo ); ######## # Decide which booth name to use. The one in the box has priority over the selected list one. @@ -11293,7 +11312,7 @@ my $template = HTML::Template::Expr->new( - filename => '/var/lib/astpp/templates/booths-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/booths-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); $template->param( booth_list => \@booths ); return $template->output; } @@ -11443,7 +11462,7 @@ } my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); $template->param( booth_name => $params->{booth_name} ); my $balance = &accountbalance( $astpp_db, $params->{booth_name} ) / 10000; my $unrated = &count_unrated_cdrs_account( $cdr_db, $accountinfo->{number}, @@ -11463,7 +11482,8 @@ ###################Start of Application ################### &initialize(); my $template = - HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); + HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl', + die_on_bad_params => $config->{template_die_on_bad_params} ); foreach my $param ( param() ) { $params->{$param} = param($param); print STDERR "$param $params->{$param}\n" if $config->{debug} == 1; Modified: trunk/astpp-callingcards.agi =================================================================== --- trunk/astpp-callingcards.agi 2007-11-02 05:39:54 UTC (rev 2148) +++ trunk/astpp-callingcards.agi 2007-11-03 03:07:15 UTC (rev 2149) @@ -438,6 +438,7 @@ . $astpp_db->quote($answeredtime) . ", " . $astpp_db->quote($charge) . ")"; $astpp_db->do($sql); + $ASTPP->debug( debug => "$sql", verbosity => $verbosity ); $ASTPP->debug( debug => "Resetting CDR Variables", verbosity => $verbosity ); $AGI->set_variable( "\"ANSWEREDTIME\"", "0" ); $AGI->set_variable( "\"DIALEDTIME\"", "0" ); Modified: trunk/astpp-users.cgi =================================================================== --- trunk/astpp-users.cgi 2007-11-02 05:39:54 UTC (rev 2148) +++ trunk/astpp-users.cgi 2007-11-03 03:07:15 UTC (rev 2149) @@ -226,7 +226,7 @@ $cost, $pagesrequired, $record, $debit, $credit, $pageno, $credit_limit ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-account-info.tpl', die_on_bad_params => $config->{template_die_on_bad_params}); return gettext("Cannot view account until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -421,7 +421,7 @@ $cardstat, $cardinfo, $count, $sql, $value, $used, $pageno, $pagesrequired); my (@cdr_list, @card_list); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-list-callingcards.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-list-callingcards.tpl', die_on_bad_params => $config->{template_die_on_bad_params}); my $no = gettext("NO"); my $yes = gettext("YES"); my $active = gettext("ACTIVE"); @@ -587,7 +587,7 @@ sub build_dids() { my ( $total, $body, $status, $description, $pricelist, $pageno, $pagesrequired ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-dids.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'}); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-dids.tpl', die_on_bad_params => $config->{template_die_on_bad_params}); return gettext("Cannot view DIDs until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -783,7 +783,7 @@ sub build_ani_map() { my ( @ani_list,$total, $body, $status, $description, $pricelist, $pageno, $pagesrequired ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-map-ani.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-map-ani.tpl', die_on_bad_params => $config->{template_die_on_bad_params}); return gettext("Not available until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -881,7 +881,7 @@ $ENV{LANGUAGE} = $cardinfo->{language}; print STDERR gettext("Interface language is set to:") . " $ENV{LANGUAGE}\n" if $config->{debug} == 1; -my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); +my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-main.tpl', die_on_bad_params => $config->{template_die_on_bad_params}); my ($body, $menu); if ( $loginstat == 1 && $params->{mode} ne gettext("Download")) { $params->{mode} = gettext("Home") Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2007-11-02 05:39:54 UTC (rev 2148) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2007-11-03 03:07:15 UTC (rev 2149) @@ -4,6 +4,7 @@ use strict; use warnings; use DBI; +use Data::Paginate; require Exporter; @@ -37,6 +38,7 @@ _asterisk_agi => $_[3], _cdr_db => $_[4], _verbosity_item_level => $arg{verbosity_item_level} || 1, + _pagination_script => $arg{pagination_script} || "astpp-admin.cgi", }, $class; } @@ -44,6 +46,7 @@ sub set_asterisk_agi { $_[0]->{_asterisk_agi} } #Sets the verbosity level. sub set_astpp_db { $_[0]->{_astpp_db} } #Sets the verbosity level. sub set_cdr_db {$_[0]->{_cdr_db} } #Sets the verbosity level. +sub set_pagination_script {$_[00]->{_pagination_script} } sub debug #Prints debugging if appropriate @@ -59,6 +62,43 @@ return 0; } +sub pagination #Returns the pagination html code to assist with navigation. +{ +my ($self, %arg) = @_; + # We are using Data::Paginate for the real tough stuff. + # Therefore we need to pass the Data::Paginate stuff + # as well as the total number of pages. + # total_entries = Total number of pages. + # pagination_script = Script name. + # mode = What mode do we want. + # pgr = Pass along Data::Paginate + # ve = + # navi_html = + # last_page = + # First we decide if we have multiple pages... + if ($arg{total_entries} > 1) { + my $html; + $html = + "<a href=\"" . $self->{_pagination_script} . "?mode=" + . $arg{mode} . "&ve=" + . $arg{ve} . "&te=" + . $arg{total_entries} + . "&pg=1\">" + . gettext("First Page") + . "</a> | " + . scalar $arg{navi_html} + . "<a href=\"" . $self->{_pagination_script} . "?mode=" + . $arg{mode} . "&ve=" + . $arg{ve} . "&te=" + . $arg{total_entries} . "&pg=" + . $arg{last_page} . "\">" + . gettext("Last Page") . "</a>"; + return $html; + } + else { + return gettext("Page 1 of 1"); + } +} # Preloaded methods go here. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-02 05:39:51
|
Revision: 2148 http://astpp.svn.sourceforge.net/astpp/?rev=2148&view=rev Author: darrenkw Date: 2007-11-01 22:39:54 -0700 (Thu, 01 Nov 2007) Log Message: ----------- A test for the packages issue. Modified Paths: -------------- trunk/astpp-common.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-02 05:13:00 UTC (rev 2147) +++ trunk/astpp-common.pl 2007-11-02 05:39:54 UTC (rev 2148) @@ -3686,7 +3686,7 @@ print STDERR "pricelistData: $branddata->{name} $branddata->{markup} $branddata->{inc} $branddata->{status}\n"; -my $package = &get_package( $astpp_db, $carddata, $cdrinfo->{dst} ); + my $package = &get_package( $astpp_db, $carddata, $cdrinfo->{dst} ); if ($package->{name}) { my $counter = &get_counter( $astpp_db, $package->{name}, @@ -3829,6 +3829,7 @@ my $uniqueid = $_; print STDERR gettext("Processing Uniqueid: ") . $_; my $cdrinfo = &get_cdr( $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'" @@ -3858,6 +3859,7 @@ } elsif ( $cdrinfo->{accountcode} ) { $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata); + $cdrinfo = $savedcdrinfo; if ( $status == 1 ) { my $previous_account = $carddata->{number}; while ( $carddata->{reseller} ne "" ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-02 05:13:05
|
Revision: 2147 http://astpp.svn.sourceforge.net/astpp/?rev=2147&view=rev Author: darrenkw Date: 2007-11-01 22:13:00 -0700 (Thu, 01 Nov 2007) Log Message: ----------- Resolve issues with Packages and Counters. Also fixed incorrect formatting of "template_die_on_bad_param" variable. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-common.pl trunk/astpp-users.cgi trunk/templates/counters-list.tpl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-02 04:25:04 UTC (rev 2146) +++ trunk/astpp-admin.cgi 2007-11-02 05:13:00 UTC (rev 2147) @@ -1470,7 +1470,7 @@ sub build_homepage() { my $template = - HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); if ( $params->{logintype} == 1 || $params->{logintype} == 5 @@ -1560,7 +1560,7 @@ ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); return gettext("Cannot view account until database is configured") unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { @@ -2039,7 +2039,7 @@ my ( $body, $total, $count, $reseller, @accountdetaillist ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/account-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); my $yes = gettext("YES"); my $no = gettext("NO"); return gettext("Cannot view account until database is configured") @@ -2216,7 +2216,7 @@ my ( @pricelists, $status, $body ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/account-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); return gettext("Database is NOT configured!") . " \n" unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { @@ -5442,7 +5442,7 @@ $accountinfo ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/account-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); if ( $params->{action} eq gettext("Deactivate...") ) { if ( $params->{number} ne "" ) { $number = $params->{number}; @@ -5501,7 +5501,7 @@ my ( $status, $body, $number, $reseller ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-process-payment.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/account-process-payment.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); return gettext("Database not configured!") unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $reseller = $params->{username}; @@ -7904,7 +7904,7 @@ my (@counter_list); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/counters-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/counters-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" || $results_per_page < 2 ) { $results_per_page = 25; @@ -7960,7 +7960,7 @@ # END OF PAGINATION CODE while ( my $counterinfo = $sql->fetchrow_hashref ) { print STDERR "COUNTER: " . $counterinfo->{id} if $config->{debug} == 1; - my ($row); + my (%row); # $row{} = $name; # $row{balance} = $balance / 10000; @@ -7969,7 +7969,7 @@ $row{package} = $counterinfo->{package}; $row{account} = $counterinfo->{account}; $row{seconds} = $counterinfo->{seconds}; - push( @counter_list, $counterinfo ); + push( @counter_list, \%row ); } if ( $total_entries >= 1 ) { #This section only applies if we have more than 1 page. @@ -9485,7 +9485,7 @@ my ( $tmp, $template, @configuration_list ); $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); if ( $params->{logintype} == 2 ) { $tmp = "SELECT * FROM system"; } @@ -10755,7 +10755,7 @@ sub build_add_callshop() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/callshop-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/callshop-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); if ( $params->{action} eq gettext("Add...") ) { if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $params->{pricelist} = $params->{username}; @@ -10813,7 +10813,7 @@ sub build_remove_callshop() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/callshop-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/callshop-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); my ( @callshops, $tmp ); if ( $params->{logintype} == 1 ) { @callshops = &list_callshops_reseller( $astpp_db, $params->{username} ); @@ -10868,7 +10868,7 @@ my ( $template, $currency, $pricelist, $language, $status ); $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/booth-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); $params->{reseller} = $params->{username}; $currency = popup_menu( -name => "currency", @@ -11046,7 +11046,7 @@ sub build_remove_booth() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/booth-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); my ( @booth_list, $accountinfo ); ######## # Decide which booth name to use. The one in the box has priority over the selected list one. @@ -11293,7 +11293,7 @@ my $template = HTML::Template::Expr->new( - filename => '/var/lib/astpp/templates/booths-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/booths-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); $template->param( booth_list => \@booths ); return $template->output; } @@ -11443,7 +11443,7 @@ } my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); $template->param( booth_name => $params->{booth_name} ); my $balance = &accountbalance( $astpp_db, $params->{booth_name} ) / 10000; my $unrated = &count_unrated_cdrs_account( $cdr_db, $accountinfo->{number}, @@ -11463,7 +11463,7 @@ ###################Start of Application ################### &initialize(); my $template = - HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); + HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' ); foreach my $param ( param() ) { $params->{$param} = param($param); print STDERR "$param $params->{$param}\n" if $config->{debug} == 1; Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-02 04:25:04 UTC (rev 2146) +++ trunk/astpp-common.pl 2007-11-02 05:13:00 UTC (rev 2147) @@ -1036,6 +1036,7 @@ my ( $connect, $cost, $answeredtime, $increment, $inc_seconds ) = @_; print STDERR "Connect: $connect Cost: $cost Answered: $answeredtime \n"; print STDERR " Inc: $increment included: $inc_seconds \n"; + if ($answeredtime > 0) { my ($total_seconds); $total_seconds = ( $answeredtime - $inc_seconds ) / $increment if $inc_seconds; $total_seconds = ( $answeredtime ) / $increment if !$inc_seconds; @@ -1049,6 +1050,10 @@ print STDERR "Increment: $increment Total Increments: $total_seconds\n"; print STDERR "Bill Seconds: $billseconds Total cost is $cost\n"; return $cost; + } else { + print STDERR "NO CHARGE - ANSWEREDTIME = 0\n"; + return 0; + } } # Return a list of all trunk names. Used mostly for menus. @@ -3686,28 +3691,35 @@ my $counter = &get_counter( $astpp_db, $package->{name}, $carddata->{number} ); - my $difference; + my $difference; if ( !$counter->{id}) { my $tmp = "INSERT INTO counters (package,account) VALUES (" . $astpp_db->quote( $package->{name} ) . ", " . $astpp_db->quote( $carddata->{number} ) . ")"; - print STDERR $tmp . "/n"; + print STDERR $tmp . "/n" if $config->{debug} == 1; $astpp_db->do($tmp); $counter = &get_counter( $astpp_db, $package->{name}, $carddata->{number} ); } if ( $package->{includedseconds} > $counter->{seconds}) { - $cdrinfo->{billsec} = $cdrinfo->{billsec} - ($package->{includedseconds} - $counter -->{seconds}); + my $availableseconds = $package->{includedseconds} - $counter->{seconds}; + my $freeseconds; + if ($availableseconds >= $cdrinfo->{billsec}) { + $freeseconds = $cdrinfo->{billsec}; + $cdrinfo->{billsec} = 0; + } else { + $freeseconds = $availableseconds; + $cdrinfo->{billsec} = $cdrinfo->{billsec} - $availableseconds; + } my $tmp = "UPDATE counters SET seconds = " . $astpp_db->quote( - $counter->{seconds} + $difference ) + $counter->{seconds} + $freeseconds ) . " WHERE id = " . $astpp_db->quote( $counter->{id} ); - print STDERR $tmp . "/n"; + print STDERR $tmp . "/n" if $config->{debug} == 1; $astpp_db->do($tmp); } } Modified: trunk/astpp-users.cgi =================================================================== --- trunk/astpp-users.cgi 2007-11-02 04:25:04 UTC (rev 2146) +++ trunk/astpp-users.cgi 2007-11-02 05:13:00 UTC (rev 2147) @@ -226,7 +226,7 @@ $cost, $pagesrequired, $record, $debit, $credit, $pageno, $credit_limit ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); return gettext("Cannot view account until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -421,7 +421,7 @@ $cardstat, $cardinfo, $count, $sql, $value, $used, $pageno, $pagesrequired); my (@cdr_list, @card_list); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-list-callingcards.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-list-callingcards.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); my $no = gettext("NO"); my $yes = gettext("YES"); my $active = gettext("ACTIVE"); @@ -587,7 +587,7 @@ sub build_dids() { my ( $total, $body, $status, $description, $pricelist, $pageno, $pagesrequired ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-dids.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-dids.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'}); return gettext("Cannot view DIDs until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -783,7 +783,7 @@ sub build_ani_map() { my ( @ani_list,$total, $body, $status, $description, $pricelist, $pageno, $pagesrequired ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-map-ani.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-map-ani.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); return gettext("Not available until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -881,7 +881,7 @@ $ENV{LANGUAGE} = $cardinfo->{language}; print STDERR gettext("Interface language is set to:") . " $ENV{LANGUAGE}\n" if $config->{debug} == 1; -my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); +my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}'); my ($body, $menu); if ( $loginstat == 1 && $params->{mode} ne gettext("Download")) { $params->{mode} = gettext("Home") Modified: trunk/templates/counters-list.tpl =================================================================== --- trunk/templates/counters-list.tpl 2007-11-02 04:25:04 UTC (rev 2146) +++ trunk/templates/counters-list.tpl 2007-11-02 05:13:00 UTC (rev 2147) @@ -22,5 +22,10 @@ <tr> <td><TMPL_VAR NAME="pagination"></td> </tr> +<tr> + <td> + <TMPL_VAR NAME="status"> + </td> +</tr> </table> </form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-02 04:25:03
|
Revision: 2146 http://astpp.svn.sourceforge.net/astpp/?rev=2146&view=rev Author: darrenkw Date: 2007-11-01 21:25:04 -0700 (Thu, 01 Nov 2007) Log Message: ----------- Patch: [ 1820688 ] bad matching for prefix in ip-map.agi Modified Paths: -------------- trunk/astpp-ip-map.agi Modified: trunk/astpp-ip-map.agi =================================================================== --- trunk/astpp-ip-map.agi 2007-11-02 03:48:23 UTC (rev 2145) +++ trunk/astpp-ip-map.agi 2007-11-02 04:25:04 UTC (rev 2146) @@ -54,7 +54,8 @@ # $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 = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-02 03:48:19
|
Revision: 2145 http://astpp.svn.sourceforge.net/astpp/?rev=2145&view=rev Author: darrenkw Date: 2007-11-01 20:48:23 -0700 (Thu, 01 Nov 2007) Log Message: ----------- A tentative fix for the IP mapping problems. Modified Paths: -------------- trunk/astpp-ip-map.agi Modified: trunk/astpp-ip-map.agi =================================================================== --- trunk/astpp-ip-map.agi 2007-11-02 03:41:50 UTC (rev 2144) +++ trunk/astpp-ip-map.agi 2007-11-02 03:48:23 UTC (rev 2145) @@ -48,8 +48,13 @@ sub get_ip() { my ($number,$extension) = @_; my ($sql,$tmp); - $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); + +##### 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"; +########### + print STDERR $tmp if $config->{debug} == 1; $AGI->verbose( "$tmp\n", $verbose ) if $config->{debug} == 1; $sql = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-02 03:41:45
|
Revision: 2144 http://astpp.svn.sourceforge.net/astpp/?rev=2144&view=rev Author: darrenkw Date: 2007-11-01 20:41:50 -0700 (Thu, 01 Nov 2007) Log Message: ----------- Patched: FS#269: links in home.tpl Modified Paths: -------------- trunk/templates/home.tpl Modified: trunk/templates/home.tpl =================================================================== --- trunk/templates/home.tpl 2007-11-02 03:20:33 UTC (rev 2143) +++ trunk/templates/home.tpl 2007-11-02 03:41:50 UTC (rev 2144) @@ -21,13 +21,13 @@ <td>Total Funds Owed Me</td> <td>Total Funds I Owe</td> <td>DIDs</td> - <td>Unbilled CDRS</td> + <td>Unbilled CDRs</td> </tr> <tr class="rowone"> <td>$<TMPL_VAR NAME="total_owing"></td> <td>$<TMPL_VAR NAME="total_due"></td> - <td><TMPL_VAR NAME="dids"></td> - <td><TMPL_VAR NAME="unbilled_cdrs"></td> + <td align=center><a href="/cgi-bin/astpp-admin/astpp-admin.cgi?mode=Manage%20DIDs"><TMPL_VAR NAME="dids"></a></td> + <td align=center><a href="/cgi-bin/astpp-admin/astpp-admin.cgi?mode=List%20Errors"><TMPL_VAR NAME="unbilled_cdrs"></a></td> </tr> <tr class="header"> <td>Calling Cards in use</td> @@ -36,9 +36,9 @@ <td>Used Card Balance</td> </tr> <tr class="rowone"> - <td><TMPL_VAR NAME="calling_cards_in_use"></td> - <td><TMPL_VAR NAME="calling_cards_active"></td> - <td><TMPL_VAR NAME="calling_cards_unused"></td> - <td><TMPL_VAR NAME="calling_cards_used"></td> + <td align=center><a href="/cgi-bin/astpp-admin/astpp-admin.cgi?mode=List%20Cards"><TMPL_VAR NAME="calling_cards_in_use"></a></td> + <td align=center><a href="/cgi-bin/astpp-admin/astpp-admin.cgi?mode=List%20Cards"><TMPL_VAR NAME="calling_cards_active"></a></td> + <td align=center><a href="/cgi-bin/astpp-admin/astpp-admin.cgi?mode=List%20Cards"><TMPL_VAR NAME="calling_cards_unused"></a></td> + <td align=center><a href="/cgi-bin/astpp-admin/astpp-admin.cgi?mode=List%20Cards"><TMPL_VAR NAME="calling_cards_used"></a></td> </tr> </table> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-02 03:20:31
|
Revision: 2143 http://astpp.svn.sourceforge.net/astpp/?rev=2143&view=rev Author: darrenkw Date: 2007-11-01 20:20:33 -0700 (Thu, 01 Nov 2007) Log Message: ----------- Corrected the variable setting code. Modified Paths: -------------- trunk/astpp-did-map.agi Modified: trunk/astpp-did-map.agi =================================================================== --- trunk/astpp-did-map.agi 2007-11-02 02:46:14 UTC (rev 2142) +++ trunk/astpp-did-map.agi 2007-11-02 03:20:33 UTC (rev 2143) @@ -138,7 +138,7 @@ $variable =~ s/"//g; #Strip off quotation marks my ($name,$value) = split(m/=/m, $variable); # This will split the variable into a "name" and "value" as needed $AGI->exec( 'Set', "$name=$value" ); - $AGI->set_variable( '$name', "\"$value\"" ); + $AGI->set_variable( "$name", "\"$value\"" ); } } if ($extension_info->{limittime} == 1) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-02 02:46:17
|
Revision: 2142 http://astpp.svn.sourceforge.net/astpp/?rev=2142&view=rev Author: darrenkw Date: 2007-11-01 19:46:14 -0700 (Thu, 01 Nov 2007) Log Message: ----------- Patch Resolves: FS#282: WWW Create trunks, reseller not added Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-02 02:24:30 UTC (rev 2141) +++ trunk/astpp-admin.cgi 2007-11-02 02:46:14 UTC (rev 2142) @@ -8397,6 +8397,7 @@ return $body; } elsif ( $params->{action} eq gettext("Insert...") ) { + my @resellers = &list_resellers($astpp_db); my $resellerlist = ""; foreach my $reseller (@resellers) { my $resellerparam = "reseller-" . $reseller; @@ -8416,6 +8417,7 @@ . $astpp_db->quote( $params->{precedence} ) . ", " . $astpp_db->quote($resellerlist) . ", " . $astpp_db->quote( $params->{provider} ) . ")"; + print STDERR $tmp if $config->{debug} == 1; if ( $astpp_db->do($tmp) ) { $status .= gettext("Trunk: ") @@ -8425,7 +8427,6 @@ else { $status .= gettext("Trunk: ") . $params->{name} . gettext(" Failed to Add!"); - print STDERR $tmp if $config->{debug} == 1; } $params->{action} = gettext("Information..."); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-02 02:31:38
|
Revision: 2141 http://astpp.svn.sourceforge.net/astpp/?rev=2141&view=rev Author: darrenkw Date: 2007-11-01 19:24:30 -0700 (Thu, 01 Nov 2007) Log Message: ----------- Patch Regarding: [ 1820671 ] HTML::TEmplate die_on_bad_params => 0 Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-users.cgi trunk/sql/astpp-2007-10-31.sql Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-01 06:15:04 UTC (rev 2140) +++ trunk/astpp-admin.cgi 2007-11-02 02:24:30 UTC (rev 2141) @@ -1470,7 +1470,7 @@ sub build_homepage() { my $template = - HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl' ); + HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); if ( $params->{logintype} == 1 || $params->{logintype} == 5 @@ -1560,7 +1560,7 @@ ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-info.tpl' ); + filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); return gettext("Cannot view account until database is configured") unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { @@ -2039,7 +2039,7 @@ my ( $body, $total, $count, $reseller, @accountdetaillist ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-list.tpl' ); + filename => '/var/lib/astpp/templates/account-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); my $yes = gettext("YES"); my $no = gettext("NO"); return gettext("Cannot view account until database is configured") @@ -2216,7 +2216,7 @@ my ( @pricelists, $status, $body ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-create.tpl' ); + filename => '/var/lib/astpp/templates/account-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); return gettext("Database is NOT configured!") . " \n" unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { @@ -5442,7 +5442,7 @@ $accountinfo ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-remove.tpl' ); + filename => '/var/lib/astpp/templates/account-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); if ( $params->{action} eq gettext("Deactivate...") ) { if ( $params->{number} ne "" ) { $number = $params->{number}; @@ -5501,7 +5501,7 @@ my ( $status, $body, $number, $reseller ); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/account-process-payment.tpl' ); + filename => '/var/lib/astpp/templates/account-process-payment.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); return gettext("Database not configured!") unless $astpp_db; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $reseller = $params->{username}; @@ -7904,7 +7904,7 @@ my (@counter_list); my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/counters-list.tpl' ); + filename => '/var/lib/astpp/templates/counters-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" || $results_per_page < 2 ) { $results_per_page = 25; @@ -9484,7 +9484,7 @@ my ( $tmp, $template, @configuration_list ); $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/configuration-list.tpl' ); + filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); if ( $params->{logintype} == 2 ) { $tmp = "SELECT * FROM system"; } @@ -10754,7 +10754,7 @@ sub build_add_callshop() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/callshop-create.tpl' ); + filename => '/var/lib/astpp/templates/callshop-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); if ( $params->{action} eq gettext("Add...") ) { if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $params->{pricelist} = $params->{username}; @@ -10812,7 +10812,7 @@ sub build_remove_callshop() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/callshop-remove.tpl' ); + filename => '/var/lib/astpp/templates/callshop-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); my ( @callshops, $tmp ); if ( $params->{logintype} == 1 ) { @callshops = &list_callshops_reseller( $astpp_db, $params->{username} ); @@ -10867,7 +10867,7 @@ my ( $template, $currency, $pricelist, $language, $status ); $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-create.tpl' ); + filename => '/var/lib/astpp/templates/booth-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); $params->{reseller} = $params->{username}; $currency = popup_menu( -name => "currency", @@ -11045,7 +11045,7 @@ sub build_remove_booth() { my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-remove.tpl' ); + filename => '/var/lib/astpp/templates/booth-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); my ( @booth_list, $accountinfo ); ######## # Decide which booth name to use. The one in the box has priority over the selected list one. @@ -11292,7 +11292,7 @@ my $template = HTML::Template::Expr->new( - filename => '/var/lib/astpp/templates/booths-list.tpl' ); + filename => '/var/lib/astpp/templates/booths-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); $template->param( booth_list => \@booths ); return $template->output; } @@ -11442,7 +11442,7 @@ } my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/booth-view.tpl' ); + filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); $template->param( booth_name => $params->{booth_name} ); my $balance = &accountbalance( $astpp_db, $params->{booth_name} ) / 10000; my $unrated = &count_unrated_cdrs_account( $cdr_db, $accountinfo->{number}, @@ -11462,7 +11462,7 @@ ###################Start of Application ################### &initialize(); my $template = - HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl' ); + HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params' ); foreach my $param ( param() ) { $params->{$param} = param($param); print STDERR "$param $params->{$param}\n" if $config->{debug} == 1; Modified: trunk/astpp-users.cgi =================================================================== --- trunk/astpp-users.cgi 2007-11-01 06:15:04 UTC (rev 2140) +++ trunk/astpp-users.cgi 2007-11-02 02:24:30 UTC (rev 2141) @@ -226,7 +226,7 @@ $cost, $pagesrequired, $record, $debit, $credit, $pageno, $credit_limit ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-account-info.tpl'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); return gettext("Cannot view account until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -421,7 +421,7 @@ $cardstat, $cardinfo, $count, $sql, $value, $used, $pageno, $pagesrequired); my (@cdr_list, @card_list); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-list-callingcards.tpl'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-list-callingcards.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); my $no = gettext("NO"); my $yes = gettext("YES"); my $active = gettext("ACTIVE"); @@ -587,7 +587,7 @@ sub build_dids() { my ( $total, $body, $status, $description, $pricelist, $pageno, $pagesrequired ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-dids.tpl'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-dids.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); return gettext("Cannot view DIDs until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -783,7 +783,7 @@ sub build_ani_map() { my ( @ani_list,$total, $body, $status, $description, $pricelist, $pageno, $pagesrequired ); - my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-map-ani.tpl'); + my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-map-ani.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); return gettext("Not available until database is configured") unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } @@ -881,7 +881,7 @@ $ENV{LANGUAGE} = $cardinfo->{language}; print STDERR gettext("Interface language is set to:") . " $ENV{LANGUAGE}\n" if $config->{debug} == 1; -my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-main.tpl'); +my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'); my ($body, $menu); if ( $loginstat == 1 && $params->{mode} ne gettext("Download")) { $params->{mode} = gettext("Home") Modified: trunk/sql/astpp-2007-10-31.sql =================================================================== --- trunk/sql/astpp-2007-10-31.sql 2007-11-01 06:15:04 UTC (rev 2140) +++ trunk/sql/astpp-2007-10-31.sql 2007-11-02 02:24:30 UTC (rev 2141) @@ -555,6 +555,9 @@ INSERT INTO system (name, value, comment, timestamp) VALUES ( 'callingcards_max_length','9000','What is the maximum length (in ms) of a callingcard call?',''); + +INSERT INTO system (name,value,comment,timestamp) VALUES ( +'template_die_on_bad_params','0','Should HTML::Template die on bad parameters?',''); -- -- This is where the old "enh-config" settings start -- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-01 06:15:01
|
Revision: 2140 http://astpp.svn.sourceforge.net/astpp/?rev=2140&view=rev Author: darrenkw Date: 2007-10-31 23:15:04 -0700 (Wed, 31 Oct 2007) Log Message: ----------- We have support for multiple pricelists for resellers but when an account was created by a reseller it was always taking the default resellers pricelist. This has been resolved and is ready for final testing. Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-01 06:01:57 UTC (rev 2139) +++ trunk/astpp-admin.cgi 2007-11-01 06:15:04 UTC (rev 2140) @@ -2229,7 +2229,8 @@ unless @pricelists; if ( $params->{action} eq gettext("Generate Account") ) { if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - $params->{pricelist} = $params->{username}; + my $pricelistinfo = &get_pricelist($astpp_db, $params->{pricelist}); + $params->{pricelist} = $params->{username} if $pricelistinfo->{reseller} ne $params->{username}; $params->{reseller} = $params->{username}; } $params->{count} = 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-01 06:01:54
|
Revision: 2139 http://astpp.svn.sourceforge.net/astpp/?rev=2139&view=rev Author: darrenkw Date: 2007-10-31 23:01:57 -0700 (Wed, 31 Oct 2007) Log Message: ----------- Resolve issue where the list of "counters" for packages was throwing an error over a missing template. Modified Paths: -------------- trunk/astpp-admin.cgi Added Paths: ----------- trunk/templates/counters-list.tpl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-01 05:17:42 UTC (rev 2138) +++ trunk/astpp-admin.cgi 2007-11-01 06:01:57 UTC (rev 2139) @@ -7992,9 +7992,8 @@ else { $pagination = gettext("Page 1 of 1"); } - $template->param( pagination => $pagination ); - $template->param( status => $status ); $template->param( counter_list => \@counter_list ); + $template->param( pagination => $pagination ); return $template->output; } Added: trunk/templates/counters-list.tpl =================================================================== --- trunk/templates/counters-list.tpl (rev 0) +++ trunk/templates/counters-list.tpl 2007-11-01 06:01:57 UTC (rev 2139) @@ -0,0 +1,26 @@ +<table class="default"> + <tr class="header"> + <td colspan=10>List Package Counters with time in them</td> + </tr> + <tr class="header"> + <td>ID</td> + <td>Package Name</td> + <td>Account Name</td> + <td>Seconds Used</td> + </tr> + <TMPL_LOOP NAME="counter_list"> + <TR> + <TD><TMPL_VAR NAME="id"></TD> + <TD><TMPL_VAR NAME="package"></TD> + <TD><TMPL_VAR NAME="account"></TD> + <TD><TMPL_VAR NAME="seconds"></TD> + </TR> + </TMPL_LOOP> +</table> + +<table> + <tr> + <td><TMPL_VAR NAME="pagination"></td> + </tr> + </table> +</form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-01 05:17:41
|
Revision: 2138 http://astpp.svn.sourceforge.net/astpp/?rev=2138&view=rev Author: darrenkw Date: 2007-10-31 22:17:42 -0700 (Wed, 31 Oct 2007) Log Message: ----------- Patch Regarding: http://www.astpp.org/bugtracker/?do=details&task_id=274 FS#274 . table cdrs should have pricelist, pattern, notes Modified Paths: -------------- trunk/astpp-common.pl Added Paths: ----------- trunk/sql/astpp-2007-10-31.sql Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-11-01 04:29:12 UTC (rev 2137) +++ trunk/astpp-common.pl 2007-11-01 05:17:42 UTC (rev 2138) @@ -1982,23 +1982,27 @@ # Write cdr to the ASTPP cdr database. This is also used to apply charges and credits to an account. sub write_account_cdr() { - my ( $astpp_db, $account, $amount, $description, $timestamp, $answeredtime, $uniqueid, $clid ) + my ( $astpp_db, $account, $amount, $description, $timestamp, $answeredtime, $uniqueid, $clid, $pricelist, $pattern ) = @_; # The amount shall be passed in 100ths of a penny. my ( $sql, $status ); $description = "" if !$timestamp; + $pricelist = "" if !$pricelist; + $pattern = "" if !$pattern; $answeredtime = "0" if !$answeredtime; $uniqueid = "N/A" if $uniqueid eq "" || !$uniqueid; $clid = "N/A" if $clid eq "" || !$clid; $timestamp = &prettytimestamp if !$timestamp; my $tmp = -"INSERT INTO cdrs (uniqueid, cardnum, callednum, debit, billseconds, callstart,callerid) VALUES (" +"INSERT INTO cdrs (uniqueid, cardnum, callednum, debit, billseconds, callstart,callerid,pricelist,pattern) VALUES (" . $astpp_db->quote($uniqueid) . ", " . $astpp_db->quote($account) . "," . $astpp_db->quote($description) . ", " . $astpp_db->quote($amount) . ", " . $astpp_db->quote($answeredtime) . ", " . $astpp_db->quote($timestamp) . ", " - . $astpp_db->quote($clid) . ")"; + . $astpp_db->quote($clid) . "," + . $astpp_db->quote($pricelist) . "," + . $astpp_db->quote($pattern) . ")"; if ( $astpp_db->do($tmp) ) { $status = "POSTED CDR: $account in the amount of: " . $amount / 10000 . "\n"; @@ -2168,7 +2172,7 @@ my ( $astpp_db, $config, $uniqueid, $account, $clid, $dest, $disp, $seconds, $cost, $callstart, - $postexternal, $trunk, $notes + $postexternal, $trunk, $notes,$pricelist,$pattern ) = @_; @@ -2176,10 +2180,12 @@ my ( $tmp, $status ); $trunk = gettext("N/A") if ( !$trunk ); $uniqueid = gettext("N/A") if ( !$uniqueid ); + $pricelist = gettext("N/A") if ( !$pricelist ); + $pattern = gettext("N/A") if ( !$pattern ); $status = 0; $tmp = "INSERT INTO cdrs(uniqueid,cardnum,callerid,callednum,trunk,disposition,billseconds," - . "debit,callstart,status,notes) VALUES (" + . "debit,callstart,status,notes,pricelist,pattern) VALUES (" . $astpp_db->quote($uniqueid) . ", " . $astpp_db->quote($account) . ", " . $astpp_db->quote($clid) . ", " @@ -2190,7 +2196,9 @@ . $astpp_db->quote($cost) . ", " . $astpp_db->quote($callstart) . ", " . $astpp_db->quote($status) . ", " - . $astpp_db->quote($notes) . ")"; + . $astpp_db->quote($notes) . "," + . $astpp_db->quote($pricelist) . "," + . $astpp_db->quote($pattern) . ")"; print STDERR "$tmp\n"; $astpp_db->do($tmp); } @@ -3749,7 +3757,7 @@ $cdrinfo->{disposition}, $cdrinfo->{billsec}, $cost, $cdrinfo->{calldate}, "", $cdrinfo->{trunk}, - $notes + $notes,$numdata->{pricelist}, $numdata->{pattern} ) if $config->{posttoastpp} == 1; &print_csv( Added: trunk/sql/astpp-2007-10-31.sql =================================================================== --- trunk/sql/astpp-2007-10-31.sql (rev 0) +++ trunk/sql/astpp-2007-10-31.sql 2007-11-01 05:17:42 UTC (rev 2138) @@ -0,0 +1,1259 @@ +DROP TABLE IF EXISTS `routes`; +CREATE TABLE routes ( +id INTEGER NOT NULL AUTO_INCREMENT, +pattern CHAR(40), +comment CHAR(80), +connectcost INTEGER NOT NULL, +includedseconds INTEGER NOT NULL, +cost INTEGER NOT NULL, +pricelist CHAR(80), +inc INTEGER, +reseller CHAR(50) default NULL, +precedence INT(4) NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), +KEY `pattern` (`pattern`), +KEY `pricelist` (`pricelist`), +KEY `reseller` (`reseller`), +KEY `status` (`status`) +); + +DROP TABLE IF EXISTS `pricelists`; +CREATE TABLE pricelists ( +name CHAR(40) NOT NULL, +markup INTEGER NOT NULL DEFAULT 0, +inc INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +reseller CHAR(50) default NULL, +PRIMARY KEY (`name`) +); + +DROP TABLE IF EXISTS `callingcardbrands`; +CREATE TABLE callingcardbrands ( +name CHAR(40) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +validfordays CHAR(4) NOT NULL DEFAULT '', +pin INTEGER NOT NULL DEFAULT 0, +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `pricelist` (`pricelist`) +); + +DROP TABLE IF EXISTS `callingcardcdrs`; +CREATE TABLE callingcardcdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(50) NOT NULL DEFAULT '', +clid CHAR(80) NOT NULL DEFAULT '', +destination CHAR(40) NOT NULL DEFAULT '', +disposition CHAR(20)NOT NULL DEFAULT '', +callstart CHAR(40) NOT NULL DEFAULT '', +seconds INTEGER NOT NULL DEFAULT 0, +debit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +credit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +status INTEGER DEFAULT 0 NOT NULL, +uniqueid VARCHAR(32) NOT NULL DEFAULT '', +notes CHAR(80) NOT NULL DEFAULT '', +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `cardnumber` (`cardnumber`) +); + +DROP TABLE IF EXISTS `trunks`; +CREATE TABLE trunks ( +name VARCHAR(30) NOT NULL, +tech CHAR(10) NOT NULL DEFAULT '', +path CHAR(40) NOT NULL DEFAULT '', +provider CHAR(100) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +dialed_modify TEXT NOT NULL DEFAULT '', +resellers TEXT NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +maxchannels INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (`name`), + KEY `provider` (`provider`), + KEY `provider_2` (`provider`) +); + +DROP TABLE IF EXISTS `outbound_routes`; +CREATE TABLE outbound_routes ( +pattern CHAR(40), +id INTEGER NOT NULL AUTO_INCREMENT, +comment CHAR(80) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +trunk CHAR(80) NOT NULL DEFAULT '', +inc CHAR(10) NOT NULL DEFAULT '', +strip CHAR(40) NOT NULL DEFAULT '', +prepend CHAR(40) NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +resellers TEXT NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `trunk` (`trunk`), + KEY `pattern` (`pattern`) +); + +DROP TABLE IF EXISTS `dids`; +CREATE TABLE dids ( +number CHAR(40) NOT NULL, +account CHAR(50) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +monthlycost INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +inc CHAR(10) NOT NULL DEFAULT '', +extensions CHAR(180) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +provider CHAR(40) NOT NULL DEFAULT '', +country CHAR (80)NOT NULL DEFAULT '', +province CHAR (80) NOT NULL DEFAULT '', +city CHAR (80) NOT NULL DEFAULT '', +prorate int(1) NOT NULL default 0, +setup int(11) NOT NULL default 0, +limittime int(1) NOT NULL default 1, +disconnectionfee INT(11) NOT NULL default 0, +variables TEXT NOT NULL DEFAULT '', +options varchar(40) default NULL, +maxchannels int(4) NOT NULL default 0, +chargeonallocation int(1) NOT NULL default 1, +allocation_bill_status int(1) NOT NULL default 0, +dial_as CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `account` (`account`) +); + +DROP TABLE IF EXISTS `accounts`; +CREATE TABLE accounts ( +cc CHAR(20) NOT NULL DEFAULT '', +number CHAR(50) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(24) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +credit INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +creation TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +pin INTEGER NOT NULL DEFAULT 0, +credit_limit INTEGER NOT NULL DEFAULT 0, +posttoexternal INTEGER NOT NULL DEFAULT 0, +balance DECIMAL(20,6) NOT NULL DEFAULT 0, +password CHAR(80) NOT NULL DEFAULT '', +first_name CHAR(40) NOT NULL DEFAULT '', +middle_name CHAR(40) NOT NULL DEFAULT '', +last_name CHAR(40) NOT NULL DEFAULT '', +company_name CHAR(40) NOT NULL DEFAULT '', +address_1 CHAR(80) NOT NULL DEFAULT '', +address_2 CHAR(80) NOT NULL DEFAULT '', +address_3 CHAR(80) NOT NULL DEFAULT '', +postal_code CHAR(12) NOT NULL DEFAULT '', +province CHAR(40) NOT NULL DEFAULT '', +city CHAR(80) NOT NULL DEFAULT '', +country CHAR(40) NOT NULL DEFAULT '', +telephone_1 CHAR(40) NOT NULL DEFAULT '', +telephone_2 CHAR(40) NOT NULL DEFAULT '', +fascimile CHAR(40) NOT NULL DEFAULT '', +email CHAR(80) NOT NULL DEFAULT '', +language CHAR(2) NOT NULL DEFAULT '', +currency CHAR(3) NOT NULL DEFAULT '', +maxchannels INTEGER DEFAULT 1 NOT NULL, +routing_technique INT(4) NOT NULL DEFAULT 0, +dialed_modify TEXT NOT NULL DEFAULT '', +type INTEGER DEFAULT 0, +tz CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +DROP TABLE IF EXISTS `counters`; +CREATE TABLE counters ( +id INTEGER NOT NULL AUTO_INCREMENT, +package CHAR(40) NOT NULL DEFAULT '', +account VARCHAR(50) NOT NULL, +seconds INTEGER NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +DROP TABLE IF EXISTS `callingcards`; +CREATE TABLE callingcards ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(20) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +value INTEGER NOT NULL DEFAULT 0, +used INTEGER NOT NULL DEFAULT 0, +brand VARCHAR(20) NOT NULL DEFAULT '', +created DATETIME, +firstused DATETIME, +expiry DATETIME, +validfordays CHAR(4) NOT NULL DEFAULT '', +inuse INTEGER NOT NULL DEFAULT 0, +pin CHAR(20), +account VARCHAR(50) NOT NULL DEFAULT '', +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +maint_day INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +timeused INTEGER NOT NULL DEFAULT 0, +invoice CHAR(20) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `brand` (`brand`) +); + +CREATE TABLE charge_to_account ( +id INTEGER NOT NULL AUTO_INCREMENT, +charge_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(50) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +CREATE TABLE queue_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +queue_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE pbx_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +pbx_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE extension_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +extension_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE cdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +uniqueid varchar(32) NOT NULL DEFAULT '', +cardnum CHAR(50), +callerid CHAR(80), +callednum varchar(80) NOT NULL DEFAULT '', +billseconds INT DEFAULT 0 NOT NULL, +trunk VARCHAR(30), +disposition varchar(45) NOT NULL DEFAULT '', +callstart varchar(80) NOT NULL DEFAULT '', +debit DECIMAL (20,6) NOT NULL DEFAULT 0, +credit DECIMAL (20,6) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 0 NOT NULL, +notes CHAR(80), +provider CHAR(50), +cost DECIMAL(20,6) NOT NULL DEFAULT 0, +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `cardnum` (`cardnum`), + KEY `provider` (`provider`), + KEY `trunk` (`trunk`), + KEY `uniqueid` (`uniqueid`), + KEY `status` (`status`) +); + +CREATE TABLE packages ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +pattern CHAR(40) NOT NULL DEFAULT '', +includedseconds INTEGER NOT NULL DEFAULT 0, +reseller VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE ani_map ( +number char(20) NOT NULL, +account char(50) NOT NULL default '', +status int(11) NOT NULL default '0', +context varchar(20) NOT NULL, + PRIMARY KEY (`number`), +KEY `account` (`account`) +); + +CREATE TABLE `ip_map` ( +ip char(15) NOT NULL default '', +account char(20) NOT NULL default '', +prefix varchar(20) NULL, +context varchar(20) NOT NULL, +PRIMARY KEY (`ip`,`prefix`), +KEY `account` (`account`) +); + +CREATE TABLE charges ( +id INTEGER NOT NULL AUTO_INCREMENT, +pricelist CHAR(40) NOT NULL DEFAULT '', +description VARCHAR(80) NOT NULL DEFAULT '', +charge INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +reseller CHAR(40) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`) +); + +CREATE TABLE manager_action_variables ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(60) NOT NULL DEFAULT '', +value CHAR(60) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE callingcard_stats ( +uniqueid VARCHAR(48) NOT NULL, +total_time VARCHAR(48) NOT NULL, +billable_time VARCHAR(48) NOT NULL, +timestamp DATETIME NULL, +PRIMARY KEY (`uniqueid`) +); + +CREATE TABLE system ( +name VARCHAR(48) NULL, +value VARCHAR(255) NULL, +comment VARCHAR(255) NULL, +timestamp DATETIME NULL, +reseller VARCHAR(48) NULL, +brand VARCHAR(48) NULL, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `brand` (`brand`) +); + + +INSERT INTO system (name, value, comment) VALUES ( +'callout_accountcode','admin','Call Files: What accountcode should we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'lcrcontext', +'astpp-outgoing', +'This is the Local context we use to route our outgoing calls through esp for callbacks'); + + +INSERT INTO system (name, value, comment) VALUES ( +'maxretries', +'3', +'Call Files: How many times do we retry?'); + +INSERT INTO system (name, value, comment) VALUES ( +'retrytime', +'30', +'Call Files: How long do we wait between retries?'); + +INSERT INTO system (name, value, comment) VALUES ( +'waittime', +'15', +'Call Files: How long do we wait before the initial call?'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidname', +'Private', +'Call Files: Outgoing CallerID Name'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidnumber', +'0000000000', +'Call Files: Outgoing CallerID Number'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_context', +'astpp-callingcards', +'Call Files: For callingcards what context do we end up in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_extension', 's', +'Call Files: For callingcards what extension do we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser_dbengine', '0', +'For now this must be MySQL'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser', '0', +'Use OPENSER? 1 for yes or 0 for no'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbname', '0', +'OPENSER Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbuser', '0', +'OPENSER Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbhost', '0', +'OPENSER Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbpass', '0', +'OPENSER Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_domain', NULL, +'OPENSER Domain', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_email', 'em...@as...', +'Email address that email should appear to be from', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_dir', '/etc/asterisk', +'Which directory are asterisk configuration files stored in?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_website', 'http://www.astpp.org', +'Link to your company website', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_name', 'ASTPP.ORG', +'The name of your company. Used in emails.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'email', '1', +'Send out email? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'user_email', '1', +'Email user on account changes? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'debug', '0', +'Enable debugging output? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'emailadd', 'em...@as...', +'Administrator email address', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'startingdigit', '0', +'The digit that all calling cards must start with. 0=disabled', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'enablelcr', '1', +'Use least cost routing 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'log_file', '/var/log/astpp/astpp.log', +'ASTPP Log file', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key_home', 'http://www.astpp.org/astpp.pub', +'Asterisk RSA Key location (optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rate_engine_csv_file', '/var/log/astpp/astpp.csv', +'CSV File for call rating data', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'csv_dir', '/var/log/astpp/', +'CSV File Directory', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_brand', 'default', +'Default pricelist. If a price is not found in the customers pricelist we check this one.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'new_user_brand', 'default', +'What is the default pricelist for new customers?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_context', 'custom-astpp', +'What is the default context for new devices?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cardlength', '10', +'Number of digits in calling cards and cc codes.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_server', 'voip.astpp.org', +'Your default voip server. Used in outgoing email.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'currency', 'CAD', +'Name of the currency you use', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'iax_port', '4569', +'Default IAX2 Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sip_port', '5060', +'Default SIP Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'ipaddr', 'dynamic', +'Default IP Address for new devices', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key', 'astpp.pub', +'Asterisk RSA Key Name (Optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pinlength', '6', +'For those calling cards that are using pins this is the number of digits it will have.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'credit_limit', '0', +'Default credit limit in dollars.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints', '4', +'How many decimal points do we bill to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'max_free_length', '100', +'What is the maximum length (in minutes) of calls that are at no charge?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'trackvendorcharges', '1', +'Do we track the amount of money we spend with specific providers? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_logo', 'http://www.astpp.org/logo.png', +'', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_slogan', 'Welcome to ASTPP', +'', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'version', '1.5Beta', 'ASTPP Version', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_language', 'en', 'Default ASTPP Language',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'card_retries','3', 'How many retries do we allow for calling card numbers?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pin_retries','3', 'How many retries do we allow for pins?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'number_retries','3','How many retries do we allow calling card users when dialing a number?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'booth_context','callshop_booth','Please enter the default context for a callshop booth.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards_max_length','9000','What is the maximum length (in ms) of a callingcard call?',''); +-- +-- This is where the old "enh-config" settings start +-- + +INSERT INTO system (name, value, comment, timestamp) VALUES ('results_per_page','30','How many results per page do we should in the web interface?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astpp_dir','/var/lib/astpp','Where do the astpp configs live?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'auth','a23asudf9810-zalkj32423','This is the override authorization code and will allow access to the system.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_dbengine','MySQL','Database type for Asterisk(tm) -Realtime',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbengine','MySQL','Database type for the cdr database',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_dbengine','MySQL','Database type for OSCommerce',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbengine','MySQL','Database type for AgileBill(tm)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_dbengine','MySQL','Database type for FreePBX',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'externalbill','oscommerce','Please specify the external billing application to use. If you are not using any then leave it blank. Valid options are "agile" and "oscommerce".',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards','1','Do you wish to enable calling cards? 1 for yes and 2 for no.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astcdr','1','Change this one at your own peril. If you switch it off, calls will not be marked as billed in asterisk once they are billed.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'posttoastpp','1','Change this one at your own peril. If you switch it off, calls will not be written to astpp when they are calculated.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sleep','10','How long shall the rating engine sleep after it has been notified of a hangup? (in seconds)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_amp','0','If this is enabled, ASTPP will create users and DIDs in the FreePBX (www.freepbx.org) database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_rt','1','If this is enabled, ASTPP will create users and DIDs in the Asterisk Realtime database.',''); + +INSERT INTO system (name, value, comment) VALUES ( +'service_prepend','778',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_length,','7',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_filler','4110000',''); + +INSERT INTO system (name, value, comment) VALUES ( +'asterisk_cdr_table','cdr','Which table of the Asterisk(TM) database are the cdrs in?' +); + +-- AgileBill(Trademark of AgileCo) Settings: +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_db','agile','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_site_id','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_charge_status','0','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_taxable','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbprefix','_','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_service_prepend','778','',''); + +-- OSCommerce Settings (www.oscommerce.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_db','oscommerce','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_pass','password','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_product_id','99999999','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_payment_method','"Charge"','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_order_status','1','',''); + +-- FreePBX Settings (www.freepbx.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_db','asterisk','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_pass','passw0rd','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_dtmfmode','rfc2833','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_callgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_pickupgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_notransfer','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_qualify','yes','',''); + +-- Asterisk -realtime Settings +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_db','realtime','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_insecure','very','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_type','friend','',''); +INSERT INTO system (name, value, comment) VALUES ( +'rt_voicemail_table','voicemail_users',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_rate_announce','1','Do we want the calling cards script to announce the rate on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_timelimit_announce','1','Do we want the calling cards script to announce the timelimit on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_cancelled_prompt','1','Do we want the calling cards script to announce that the call was cancelled?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_menu','1','Do we want the calling cards script to present a menu before exiting?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_connection_prompt','1','Do we want the calling cards script to announce that it is connecting the call?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_pin_input_timeout','15000','How long do we wait when entering the calling card pin? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_number_input_timeout','15000','How long do we wait when entering the calling card number? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_dial_input_timeout','15000','How long do we wait when entering the destination number in calling cards? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_general_input_timeout','15000','How long do we wait for input in general menus? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_welcome_file','silence/1','What do we play for a welcome file?'); + +-- +-- Enough Configuration settings +-- + +DROP TABLE IF EXISTS `countrycode`; +CREATE TABLE `countrycode` ( + `country` varchar(255) NOT NULL, + PRIMARY KEY (`country`), + KEY `country` (`country`) +); + +INSERT INTO `countrycode` (`country`) VALUES + ('Afghanistan'), + ('Alaska'), + ('Albania'), + ('Algeria'), + ('AmericanSamoa'), + ('Andorra'), + ('Angola'), + ('Antarctica'), + ('Argentina'), + ('Armenia'), + ('Aruba'), + ('Ascension'), + ('Australia'), + ('Austria'), + ('Azerbaijan'), + ('Bahrain'), + ('Bangladesh'), + ('Belarus'), + ('Belgium'), + ('Belize'), + ('Benin'), + ('Bhutan'), + ('Bolivia'), + ('Bosnia & Herzegovina'), + ('Botswana'), + ('Brazil'), + ('Brunei Darussalam'), + ('Bulgaria'), + ('Burkina Faso'), + ('Burundi'), + ('Cambodia'), + ('Cameroon'), + ('Canadda'), + ('Cape Verde Islands'), + ('Central African Republic'), + ('Chad'), + ('Chile'), + ('China'), + ('Colombia'), + ('Comoros'), + ('Congo'), + ('Cook Islands'), + ('Costa Rica'), + ('Croatia'), + ('Cuba'), + ('Cuba Guantanamo Bay'), + ('Cyprus'), + ('Czech Republic'), + ('Denmark'), + ('Diego Garcia'), + ('Djibouti'), + ('Dominican Republic'), + ('East Timor'), + ('Ecuador'), + ('Egypt'), + ('El Salvador'), + ('Equatorial Guinea'), + ('Eritrea'), + ('Estonia'), + ('Ethiopia'), + ('Faroe Islands'); +INSERT INTO `countrycode` (`country`) VALUES + ('Fiji Islands'), + ('Finland'), + ('France'), + ('French Guiana'), + ('French Polynesia'), + ('Gabonese Republic'), + ('Gambia'), + ('Georgia'), + ('Germany'), + ('Ghana'), + ('Gibraltar'), + ('Greece'), + ('Greenland'), + ('Guadeloupe'), + ('Guam'), + ('Guatemala'), + ('Guinea'), + ('Guyana'), + ('Haiti'), + ('Honduras'), + ('Hong Kong'), + ('Hungary'), + ('Iceland'), + ('India'), + ('Indonesia'), + ('Iran'), + ('Iraq'), + ('Ireland'), + ('Israel'), + ('Italy'), + ('Jamaica'), + ('Japan'), + ('Jordan'), + ('Kazakstan'), + ('Kenya'), + ('Kiribati'), + ('Kuwait'), + ('Kyrgyz Republic'), + ('Laos'), + ('Latvia'), + ('Lebanon'), + ('Lesotho'), + ('Liberia'), + ('Libya'), + ('Liechtenstein'), + ('Lithuania'), + ('Luxembourg'), + ('Macao'), + ('Madagascar'), + ('Malawi'), + ('Malaysia'), + ('Maldives'), + ('Mali Republic'), + ('Malta'), + ('Marshall Islands'), + ('Martinique'), + ('Mauritania'), + ('Mauritius'), + ('MayotteIsland'), + ('Mexico'), + ('Midway Islands'), + ('Moldova'), + ('Monaco'), + ('Mongolia'), + ('Morocco'); +INSERT INTO `countrycode` (`country`) VALUES + ('Mozambique'), + ('Myanmar'), + ('Namibia'), + ('Nauru'), + ('Nepal'), + ('Netherlands'), + ('Netherlands Antilles'), + ('New Caledonia'), + ('New Zealand'), + ('Nicaragua'), + ('Niger'), + ('Nigeria'), + ('Niue'), + ('Norfolk Island'), + ('North Korea'), + ('Norway'), + ('Oman'), + ('Pakistan'), + ('Palau'), + ('Palestinian Settlements'), + ('Panama'), + ('PapuaNew Guinea'), + ('Paraguay'), + ('Peru'), + ('Philippines'), + ('Poland'), + ('Portugal'), + ('Puerto Rico'), + ('Qatar'), + ('RéunionIsland'), + ('Romania'), + ('Russia'), + ('Rwandese Republic'), + ('San Marino'), + ('São Tomé and Principe'), + ('Saudi Arabia'), + ('Senegal '), + ('Serbia and Montenegro'), + ('Seychelles Republic'), + ('Sierra Leone'), + ('Singapore'), + ('Slovak Republic'), + ('Slovenia'), + ('Solomon Islands'), + ('Somali Democratic Republic'), + ('South Africa'), + ('South Korea'), + ('Spain'), + ('Sri Lanka'), + ('St Kitts - Nevis'), + ('St. Helena'), + ('St. Lucia'), + ('St. Pierre & Miquelon'), + ('St. Vincent & Grenadines'), + ('Sudan'); +INSERT INTO `countrycode` (`country`) VALUES + ('Suriname'), + ('Swaziland'), + ('Sweden'), + ('Switzerland'), + ('Syria'), + ('Taiwan'), + ('Tajikistan'), + ('Tanzania'), + ('Thailand'), + ('Togolese Republic'), + ('Tokelau'), + ('Tonga Islands'), + ('Trinidad & Tobago'), + ('Tunisia'), + ('Turkey'), + ('Turkmenistan'), + ('Tuvalu'), + ('Uganda'), + ('Ukraine'), + ('United Arab Emirates'), + ('United Kingdom'), + ('United States of America'), + ('Uruguay'), + ('Uzbekistan'), + ('Vanuatu'), + ('Venezuela'), + ('Vietnam'), + ('Wake Island'), + ('Wallisand Futuna Islands'), + ('Western Samoa'), + ('Yemen'), + ('Zambia'), + ('Zimbabwe'); + +DROP TABLE IF EXISTS `currency`; +CREATE TABLE `currency` ( + `Currency` varchar(3) NOT NULL default '', + `CurrencyName` varchar(40) NOT NULL default '', + PRIMARY KEY (`Currency`) +); + +INSERT INTO `currency` (`Currency`,`CurrencyName`) VALUES + ('USD','US Dollars'), + ('CAD','Canadian Dollars'), + ('AUD','Australian Dollars'); + +CREATE TABLE `language` ( + `language` varchar(5) NOT NULL, + `languagename` varchar(40) NOT NULL, + `active` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`language`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `language` (`language`,`languagename`,`active`) VALUES + ('en','English',1), + ('fr','French',1), + ('de','German',1); + +CREATE TABLE `resellers` ( + name varchar(40) NOT NULL default '', + status int(11) NOT NULL default '1', + posttoexternal int(11) NOT NULL default '0', + agile_site_id int(11) NOT NULL default '0', + config_file char(80) NOT NULL default 'reseller.conf', + companyname varchar(255) default NULL, + slogan varchar(255) default NULL, + footer varchar(255) default NULL, + pricelist varchar(255) default NULL, + currency varchar(255) default NULL, + logo varchar(255) default NULL, + website varchar(255) default NULL, + adminemail varchar(255) default NULL, + salesemail varchar(255) default NULL, + phone varchar(45) default NULL, + fax varchar(45) default NULL, + address1 varchar(255) default NULL, + address2 varchar(255) default NULL, + city varchar(255) default NULL, + state varchar(255) default NULL, + postcode varchar(255) default NULL, + country varchar(255) default NULL, + defaultbrand varchar(45) NOT NULL default 'default', + defaultcurrency varchar(45) NOT NULL default 'USD', + defaultcredit varchar(45) NOT NULL default '0.00', + externalbill varchar(45) NOT NULL default '', + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +CREATE TABLE templates ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +reseller VARCHAR(45) NOT NULL default '', +template TEXT NOT NULL default '', + PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +INSERT INTO templates (name,template) VALUES +('voip_account_refilled','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been refilled. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('voip_reactivate_account','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been reactivated. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_add_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been added. +Your Username is -- $vars->{extension} -- +Your Password is -- $vars->{secret} -- +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('add_sip_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In sip.conf: +[$config->{company_name}-in] +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=from-pstn +accountcode=$config->{company_name} +[$config->{company_name}] +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid= <555-555-5555> +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +In the [globals] section add: +register => $vars->{user}:password@$config->{asterisk_server}'); + +INSERT INTO templates (name,template) VALUES +('add_iax_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In iax.conf: +At the bottom of the file add: +[$config->{company_name}-in] +;trunk=yes ;optional .. only works if you have a zaptel or ztdummy driver running +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=incoming +accountcode=$config->{company_name} ;for call tracking in the cdr +[$config->{company_name}] +;to simplify and config outgoing calls +;trunk=yes ;optional .. only works if you have a zaptel driver running +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid=<555-555-5555> ;only the number will really be used +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_remove_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP Termination with $config->{company_name} has been removed +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_calling_card','You have added a $vars->{pricelist} callingcard in the amount of $vars->{pennies} cents. +Card Number $cc Pin: $pin +Thanks for your patronage. +The $config->{company_name} sales team'); + +INSERT INTO templates (name,template) VALUES +('email_add_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been added +The number is: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team +Here is a sample setup which would call a few sip phones with incoming calls: +[incoming] +exten => _1$did,1,Wait(2) +exten => _1$did,2,Dial(SIP/2201&SIP/2202,15,Ttm) ; dial a couple of phones for 15 secs +exten => _1$did,3,Voicemail(u1000) ; go to unavailable voicemail (vm box 1000) +exten => _1$did,103,Voicemail(b1000) ; go to busy voicemail (vm box 1000)'); + +INSERT INTO templates (name,template) VALUES +('email_remove_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been removed +The number was: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_new_invoice','Invoice # $invoice in the amount of \$$total has been added to your account. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_low_balance','Your VOIP account with $config->{company_name} has a balance of \$$balance. +Please visit our website to refill your account to ensure uninterrupted service. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +CREATE TABLE `sweeplist` ( + `Id` int(10) unsigned NOT NULL default '0', + `sweep` varchar(45) NOT NULL default '', + PRIMARY KEY (`Id`) +); + +INSERT INTO sweeplist (Id,sweep) VALUES +(0,'daily'), +(1,'weekly'), +(2,'monthly'), +(3,'quarterly'), +(4,'semi-annually'), +(5,'annually') +; + +CREATE TABLE userlevels ( +userlevelid int(11) NOT NULL, +userlevelname varchar(50) NOT NULL, +PRIMARY KEY (`userlevelid`) +); + +INSERT INTO `userlevels` (`userlevelid`,`userlevelname`) VALUES + (-1,'Administrator'), + (0,'Anonymous'), + (1,'Reseller'), + (2,'Admin'), + (3,'Vendor'), + (4,'Customer Service'), + (5,'Users'); + +CREATE TABLE reseller_pricing ( +id INTEGER NOT NULL AUTO_INCREMENT, +reseller VARCHAR(50) NOT NULL, +type INTEGER NOT NULL DEFAULT 1, +monthlycost INTEGER NOT NULL DEFAULT 0, +prorate INTEGER NOT NULL DEFAULT 0, +setup INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +note VARCHAR(50) NOT NULL DEFAULT '', +disconnectionfee INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +inc CHAR(10) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE callshops ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(50) NOT NULL, +osc_dbname VARCHAR(50) NOT NULL DEFAULT '', +osc_dbpass VARCHAR(50) NOT NULL DEFAULT '', +osc_dbuser VARCHAR(50) NOT NULL DEFAULT '', +osc_dbhost VARCHAR(50) NOT NULL DEFAULT '', +osc_site VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), +KEY `name` (`name`) +); + +CREATE TABLE extensions_status ( +id INTEGER NOT NULL AUTO_INCREMENT, +tech VARCHAR(6) NULL, +extension VARCHAR(20) NULL, +number VARCHAR(255) NULL, +status VARCHAR(255) NULL, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +PRIMARY KEY (`id`), +KEY `extension` (`extension`)); + +CREATE TABLE activity_logs ( +id INTEGER NOT NULL AUTO_INCREMENT, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +message TEXT NOT NULL DEFAULT '', +user VARCHAR(50), +PRIMARY KEY (`id`)); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |