astpp-commit Mailing List for ASTPP - Open Source Voip Billing (Page 9)
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-01 04:29:08
|
Revision: 2137 http://astpp.svn.sourceforge.net/astpp/?rev=2137&view=rev Author: darrenkw Date: 2007-10-31 21:29:12 -0700 (Wed, 31 Oct 2007) Log Message: ----------- Patch for: [ 1820676 ] missing context in account-info template Modified Paths: -------------- trunk/templates/account-info.tpl Modified: trunk/templates/account-info.tpl =================================================================== --- trunk/templates/account-info.tpl 2007-11-01 04:20:57 UTC (rev 2136) +++ trunk/templates/account-info.tpl 2007-11-01 04:29:12 UTC (rev 2137) @@ -150,6 +150,7 @@ <tr> <td><TMPL_VAR NAME="ip"></td> <td><TMPL_VAR NAME="prefix"></td> + <td><TMPL_VAR NAME="context"></td> <td><a href="astpp-admin.cgi?mode=View Details&accountnum=<TMPL_VAR NAME="accountnum">&prefix=<TMPL_VAR NAME="prefix">&ip=<TMPL_VAR NAME="ip">&action=Remove IP">Remove IP</a></td> </tr> </TMPL_LOOP> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-01 04:20:53
|
Revision: 2136 http://astpp.svn.sourceforge.net/astpp/?rev=2136&view=rev Author: darrenkw Date: 2007-10-31 21:20:57 -0700 (Wed, 31 Oct 2007) Log Message: ----------- Patch regarding: [ 1820633 ] Calling Card ${BRAND} variable has no effect Modified Paths: -------------- trunk/astpp-callingcards.agi trunk/samples/sample.astpp-dialplan.conf Modified: trunk/astpp-callingcards.agi =================================================================== --- trunk/astpp-callingcards.agi 2007-10-25 19:34:44 UTC (rev 2135) +++ trunk/astpp-callingcards.agi 2007-11-01 04:20:57 UTC (rev 2136) @@ -654,7 +654,7 @@ exit(0); } ################# Program Starts Here ################################# -my ( $cardnum, $pin, $destination, $connectsurcharge, $perminsurcharge ) = +my ( $cardnum, $pin, $destination, $connectsurcharge, $perminsurcharge, $brand ) = @ARGV; %input = $AGI->ReadParse(); my ( $retries, $cardinfo, $numberinfo, $pricelistinfo, @outboundroutes, Modified: trunk/samples/sample.astpp-dialplan.conf =================================================================== --- trunk/samples/sample.astpp-dialplan.conf 2007-10-25 19:34:44 UTC (rev 2135) +++ trunk/samples/sample.astpp-dialplan.conf 2007-11-01 04:20:57 UTC (rev 2136) @@ -50,7 +50,7 @@ exten => 1,1,AGI(astpp-ani-map.agi,${CALLERID(number)},"ANI","ACCOUNT") exten => 1,n,Set(CARDNUMBER=${ANI_ACCOUNT}) exten => 1,n,GotoIf($["${ACCOUNT}"]?:60) -exten => 1,n,DeadAGI(astpp-callingcards.agi,${CARDNUMBER},${PIN},${DESTINATION},${CONNECTSURCHARGE},${PERMINUTESURCHARGE}) +exten => 1,n,DeadAGI(astpp-callingcards.agi,${CARDNUMBER},${PIN},${DESTINATION},${CONNECTSURCHARGE},${PERMINUTESURCHARGE},${BRAND}) exten => 1,n,GotoIf($["${NEWCALL}" = "1"]?4) exten => 2,1,AGI(astpp-ani-map.agi,${CALLERID(number)},"ANI") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <son...@us...> - 2007-10-25 19:34:42
|
Revision: 2135 http://astpp.svn.sourceforge.net/astpp/?rev=2135&view=rev Author: sonalikh Date: 2007-10-25 12:34:44 -0700 (Thu, 25 Oct 2007) Log Message: ----------- Fixed SF Bug ID: 1820203 Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-update-balance.pl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-09-27 11:20:49 UTC (rev 2134) +++ trunk/astpp-admin.cgi 2007-10-25 19:34:44 UTC (rev 2135) @@ -2116,7 +2116,7 @@ print STDERR "BRAND: $params->{brand}\n" if $config->{debug} == 1; while ( $count < $params->{count} ) { my ( $number, $pin ) = - &add_callingcard( $astpp_db, $config, $config, $brandinfo, + &add_callingcard( $astpp_db, $config, $brandinfo, $params->{status}, $params->{value} * 100, $params->{account}, $brandinfo->{pin} ); $count++; Modified: trunk/astpp-update-balance.pl =================================================================== --- trunk/astpp-update-balance.pl 2007-09-27 11:20:49 UTC (rev 2134) +++ trunk/astpp-update-balance.pl 2007-10-25 19:34:44 UTC (rev 2135) @@ -79,9 +79,8 @@ ## Update calling cards and expire them and mark them as being empty. # $astpp_db->do("UPDATE callingcards SET status = 2 WHERE value - used <= 0"); -$astpp_db->do("UPDATE callingcards SET status = 2 WHERE expiry <= NOW()"); +$astpp_db->do("UPDATE callingcards SET status = 2 WHERE expiry <= NOW() AND expiry != '0000-00-00 00:00:00'"); - if ( $params->{sweep} == 0 ) { #Here comes our daily maintenance. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <son...@us...> - 2007-09-27 11:20:48
|
Revision: 2134 http://astpp.svn.sourceforge.net/astpp/?rev=2134&view=rev Author: sonalikh Date: 2007-09-27 04:20:49 -0700 (Thu, 27 Sep 2007) Log Message: ----------- Conversion in time and amount to standard formats Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-09-22 07:12:03 UTC (rev 2133) +++ trunk/astpp-admin.cgi 2007-09-27 11:20:49 UTC (rev 2134) @@ -155,7 +155,7 @@ my @timezones = DateTime::TimeZone->all_names; @timezones = sort(@timezones); my ( - $rt_db, $astpp_db, $config, $config, $params, + $rt_db, $astpp_db, $config, $params, $param, $cdr_db, $agile_db, $body, $menu, $status, $msg, $loginstat, @modes, $openser_db ); @@ -1045,10 +1045,18 @@ my $row4 = $sql4->fetchrow_hashref(); $act = $row4->{'actual'}; $sql4->finish; - + + $act = int($act/60) . ":" . ($act%60); + $acd = int($acd/60) . ":" . ($acd%60); + $mcd = int($mcd/60) . ":" . ($mcd%60); + $bill = int($bill/60) . ":" . ($bill%60); + $price = $price/10000.0; + $cost = $cost/10000.0; + $body .= "<tr>" . "<td>$bth</td><td>$dst</td><td>$idd</td><td>$atmpt</td><td>$cmplt</td><td>$asr</td>" - . "<td>$acd</td><td>$mcd</td><td>$act</td><td>$bill</td><td>$price</td><td>$cost</td>" + . "<td align=right>$acd</td><td align=right>$mcd</td><td align=right>$act</td>" + . "<td align=right>$bill</td><td>$price</td><td>$cost</td>" . "</tr>"; } $sql1->finish; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-09-22 07:12:06
|
Revision: 2133 http://astpp.svn.sourceforge.net/astpp/?rev=2133&view=rev Author: darrenkw Date: 2007-09-22 00:12:03 -0700 (Sat, 22 Sep 2007) Log Message: ----------- Resolve Bug 324: Callingcard charging previous call answered time We now reset the Asterisk variables after writing the cdr the the asterisk cdr database. Modified Paths: -------------- trunk/astpp-callingcards.agi Modified: trunk/astpp-callingcards.agi =================================================================== --- trunk/astpp-callingcards.agi 2007-09-22 06:11:53 UTC (rev 2132) +++ trunk/astpp-callingcards.agi 2007-09-22 07:12:03 UTC (rev 2133) @@ -413,6 +413,9 @@ . $astpp_db->quote( $reseller ) . ", " . $astpp_db->quote( $uniqueid ) . ")"; $cdr_db->do($sql); + $AGI->set_variable( "\"ANSWEREDTIME\"", "0" ); + $AGI->set_variable( "\"DIALEDTIME\"", "0" ); + $AGI->set_variable( "\"DIALSTATUS\"", "NO ANSWER" ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-09-22 06:11:49
|
Revision: 2132 http://astpp.svn.sourceforge.net/astpp/?rev=2132&view=rev Author: darrenkw Date: 2007-09-21 23:11:53 -0700 (Fri, 21 Sep 2007) Log Message: ----------- Resolved an error that would have not allowed calling cards to be refilled. Modified Paths: -------------- trunk/astpp-refill.agi Modified: trunk/astpp-refill.agi =================================================================== --- trunk/astpp-refill.agi 2007-09-22 06:11:10 UTC (rev 2131) +++ trunk/astpp-refill.agi 2007-09-22 06:11:53 UTC (rev 2132) @@ -142,7 +142,7 @@ while ( $destcardinfo->{status} != 1 && $retries < $config->{card_retries} ) { my $cardnum = $AGI->get_data( $sound->{card_to_refill}, $input_timeout ); $destcardinfo = &get_callingcard( $astpp_db, $cardnum, $config ); - $destcardinfo = &get_account( $astpp_db, $cardnum ); + $destcardinfo = &get_account( $astpp_db, $cardnum ) if !$destcardinfo; $cc = 1 if $destcardinfo->{cc}; $AGI->verbose( "ASTPP Number: $cardnum ", $verbosity ) 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-09-22 06:11:09
|
Revision: 2131 http://astpp.svn.sourceforge.net/astpp/?rev=2131&view=rev Author: darrenkw Date: 2007-09-21 23:11:10 -0700 (Fri, 21 Sep 2007) Log Message: ----------- Converted "View Details" to use the account-info template. Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-09-22 05:17:34 UTC (rev 2130) +++ trunk/astpp-admin.cgi 2007-09-22 06:11:10 UTC (rev 2131) @@ -1543,6 +1543,7 @@ return $template->output; } + sub build_account_info() { my ( $total, $body, $status, $description, @@ -1560,8 +1561,10 @@ else { @pricelists = &list_pricelists($astpp_db); } + return gettext("Cannot view account until pricelists configured") unless @pricelists; + if ( $params->{limit} < 1 ) { $params->{limit} = 0 } $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } @@ -1601,13 +1604,14 @@ &write_account_cdr( $astpp_db, $number, $params->{amount} * 10000, $params->{desc}, $timestamp, 0 ); + $status .= "Charge Posted"; } } else { &write_account_cdr( $astpp_db, $number, $params->{amount} * 10000, $params->{desc}, $timestamp, 0 ); + $status .= "Charge Posted"; } - $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Add Charge...") ) { if ( $params->{accountnum} ne "" ) { @@ -1639,9 +1643,8 @@ . $astpp_db->quote($number) . ", " . "1)"; $astpp_db->do($tmp); } - $params->{action} = gettext("Information..."); } - elsif ( $params->{action} eq gettext("Remove Charge") ) { + elsif ( $params->{action} eq gettext("Remove Charge...") ) { if ( $params->{accountnum} ne "" ) { $number = $params->{accountnum}; } @@ -1663,7 +1666,6 @@ . $astpp_db->quote( $params->{chargeid} ); $astpp_db->do($tmp); } - $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Remove DID") ) { if ( $params->{accountnum} ne "" ) { @@ -1675,7 +1677,6 @@ $status .= &remove_did( $astpp_db, $config, $params->{DID}, $number ); - $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Purchase DID") ) { if ( $params->{accountnum} ne "" ) { @@ -1687,7 +1688,6 @@ $status .= &purchase_did( $astpp_db, $config, $params->{did_list}, $number ); - $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Map ANI") ) { if ( $params->{accountnum} ne "" ) { @@ -1713,7 +1713,6 @@ . $params->{ANI} . "' " . gettext("FAILED to create!") . "<br>"; } - $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Remove ANI") ) { if ( $params->{accountnum} ne "" ) { @@ -1739,7 +1738,6 @@ . $params->{ANI} . "' " . gettext("FAILED to remove!") . "<br>"; } - $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Map IP") ) { if ( $params->{accountnum} ne "" ) { @@ -1767,7 +1765,6 @@ . $params->{ip} . "' " . gettext("FAILED to create!") . "<br>"; } - $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Remove IP") ) { if ( $params->{accountnum} ne "" ) { @@ -1795,10 +1792,7 @@ . $params->{ip} . "' " . gettext("FAILED to remove!") . "<br>"; } - $params->{action} = gettext("Information..."); } - if ( $params->{action} eq gettext("Information...") ) { - my ($balance); if ( $number ne "" ) { $accountinfo = &get_account( $astpp_db, $number ); } @@ -1808,541 +1802,233 @@ else { $accountinfo = &get_account( $astpp_db, $params->{numberlist} ); } - $balance = &accountbalance( $astpp_db, $accountinfo->{number} ); - $balance = sprintf( "%.2f", $balance / 10000 ); if ( $accountinfo->{number} ) { - $status .= - "<table class=\"default\"><tr><td colspan=2>" - . gettext("Name: ") - . $accountinfo->{first_name} . " " - . $accountinfo->{middle_name} . " " - . $accountinfo->{last_name} - . "</td></tr><tr><td width=400>" - . gettext("Company Name: ") - . $accountinfo->{company_name} - . "</td><td>" - . gettext("Phone: ") - . $accountinfo->{telephone_1} - . "</td></tr><tr><td>" - . gettext("Address 1: ") - . $accountinfo->{address_1} - . "</td><td>" - . gettext("Phone 2: ") - . $accountinfo->{telephone_2} - . "</td></tr><tr><td>" - . gettext("Address 2: ") - . $accountinfo->{address_2} - . "</td><td>" - . gettext("Facsimile: ") - . $accountinfo->{fascimilie} - . "</td></tr><tr><td>" - . gettext("Address 3: ") - . $accountinfo->{address_3} - . "</td><td>" - . gettext("Email: ") - . $accountinfo->{email} - . "</td></tr><tr><td colspan=2>" - . gettext("City, Postal Code, Country: ") - . $accountinfo->{city} . ", " - . $accountinfo->{postal_code} . ", " - . $accountinfo->{country} - . "</td></tr>" - . "<tr><td colspan=2>" - . gettext("Dialed Number Mods: ") - . $accountinfo->{dialed_modify} - . "<tr><td>" - . gettext("Pin:") . " " - . $accountinfo->{pin} - . "</td></tr></table"; - $status .= - "<br>Account </i><b>" - . $accountinfo->{'number'} - . " </b><i>" - . gettext("balance: ") - . "</i><b>$balance $currency[0] </b></i>" - . gettext("Max Channels:") . " " - . $accountinfo->{maxchannels} . "\n"; - $status .= - gettext("with a credit limit of") - . " </i><b>\$$accountinfo->{'credit_limit'} $currency[0]</b></i>\n"; - } - else { - $status .= - gettext("No such account number") - . " '$accountinfo->{number}' " - . gettext("found!") . "\n"; - } - $body .= - "<table class=\"default\">" - . "<tr class=\"header\"><td colspan=5>" - . gettext("Charges") - . "</td></tr>" - . "<tr class=\"header\"><td>" - . gettext("Action") - . "</td><td>" - . gettext("Id") - . "</td><td>" - . gettext("Description") - . "</td><td>" - . gettext("Cycle") - . "</td><td>" - . gettext("Amount") - . "</td></tr>"; + $accountinfo->{balance} = &accountbalance( $astpp_db, $accountinfo->{number} ); + $accountinfo->{balance} = sprintf( "%.2f", $accountinfo->{balance} / 10000 ); + $template->param(first_name => $accountinfo->{first_name}); + $template->param(middle_name => $accountinfo->{middle_name}); + $template->param(last_name => $accountinfo->{last_name}); + $template->param(company => $accountinfo->{company_name}); + $template->param(telephone_1 => $accountinfo->{telephone_1}); + $template->param(telephone_2 => $accountinfo->{telephone_2}); + $template->param(fascimilie => $accountinfo->{fascimilie}); + $template->param(address_1 => $accountinfo->{address_1}); + $template->param(address_2 => $accountinfo->{address_2}); + $template->param(address_3 => $accountinfo->{address_3}); + $template->param(email => $accountinfo->{email}); + $template->param(city =>$accountinfo->{city}); + $template->param(postal_code => $accountinfo->{postal_code}); + $template->param(country => $accountinfo->{country}); + $template->param(province => $accountinfo->{province}); + $template->param(dialed_modify => $accountinfo->{dialed_modify}); + $template->param(pin => $accountinfo->{pin}); + $template->param(accountnum => $accountinfo->{number}); + $template->param(balance => $accountinfo->{balance}); + $template->param(maxchannels => $accountinfo->{maxchannels}); + $template->param(credit_limit => $accountinfo->{credit_limit}); + my @chargelist; my @account_charge_list = &list_account_charges( $astpp_db, $accountinfo->{number} ); my @pricelist_charge_list = &list_pricelist_charges( $astpp_db, $accountinfo->{pricelist} ); foreach my $charge (@account_charge_list) { - my ( $sweep, $cost ); - $count++; - print STDERR "CHARGE_ID $charge->{charge_id}\n" - if $config->{debug} == 1; + my ( %row ); + $row{accountnum} = $accountinfo->{number}; my $chargeinfo = &get_charge( $astpp_db, $charge->{charge_id} ); - print STDERR "SWEEP: " . $chargeinfo->{sweep} - if $config->{debug} == 1; - if ( $chargeinfo->{sweep} == 0 ) { - $sweep = gettext("daily"); - } - elsif ( $chargeinfo->{sweep} == 1 ) { - $sweep = gettext("weekly"); - } - elsif ( $chargeinfo->{sweep} == 2 ) { - $sweep = gettext("monthly"); - } - elsif ( $chargeinfo->{sweep} == 3 ) { - $sweep = gettext("quarterly"); - } - elsif ( $chargeinfo->{sweep} == 4 ) { - $sweep = gettext("semi-annually"); - } - elsif ( $chargeinfo->{sweep} == 5 ) { - $sweep = gettext("annually"); - } - $cost = sprintf( "%.2f", $chargeinfo->{charge} / 10000 ); - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= - "<td><a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") - . "&chargeid=" - . $charge->{id} - . "&accountnum=" - . $accountinfo->{number} - . "&action=" - . gettext("Remove Charge") . "\">" - . gettext("Remove Charge") . "</a>" - . "</td><td>" - . $charge->{id} - . "</td><td>" - . $chargeinfo->{description} - . "</td><td>" - . $sweep - . "</td><td> \$" - . $cost - . "</td></tr> -"; + $row{sweep} = $sweeplist{$chargeinfo->{Sweep}}; + $row{cost} = sprintf( "%.2f", $chargeinfo->{charge} / 10000 ); + $row{id} = $charge->{id}; + $row{description} = $chargeinfo->{description}; + push(@chargelist, \%row); } foreach my $charge (@pricelist_charge_list) { - my ($cost); - $count++; + my ( %row ); + $row{accountnum} = $accountinfo->{number}; my $chargeinfo = &get_charge( $astpp_db, $charge ); - if ( $chargeinfo->{sweep} == 0 ) { - $chargeinfo->{sweep} = gettext("daily"); - } - elsif ( $chargeinfo->{sweep} == 1 ) { - $chargeinfo->{sweep} = gettext("weekly"); - } - elsif ( $chargeinfo->{sweep} == 2 ) { - $chargeinfo->{sweep} = gettext("monthly"); - } - elsif ( $chargeinfo->{sweep} == 3 ) { - $chargeinfo->{sweep} = gettext("quarterly"); - } - elsif ( $chargeinfo->{sweep} == 4 ) { - $chargeinfo->{sweep} = gettext("semi-annually"); - } - elsif ( $chargeinfo->{sweep} == 5 ) { - $chargeinfo->{sweep} = gettext("annually"); - } - $cost = sprintf( "%.2f", $chargeinfo->{charge} / 10000 ); - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= "<td>" - . "</td><td>" - . $charge - . "</td><td>" - . $chargeinfo->{description} - . "</td><td>" - . $chargeinfo->{sweep} - . "</td><td> \$" - . $cost - . "</td></tr>"; + $row{sweep} = $sweeplist{$chargeinfo->{Sweep}}; + $row{cost} = sprintf( "%.2f", $chargeinfo->{charge} / 10000 ); + $row{id} = $charge; + $row{charge} = $chargeinfo->{description}; + push(@chargelist, \%row); } + $template->param( chargelist => \@chargelist); my %applyablecharges = &list_applyable_charges($astpp_db); - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= "<td colspan=2>" - . popup_menu( + $template->param( applyable_charges => popup_menu( -name => "id_list", -values => \%applyablecharges - ) - . "</td><td>" - . textfield( -name => "id", -size => 5 ) - . "</td><td colspan=2>" - . submit( - -name => "action", - -value => gettext("Add Charge...") - ) . "</td></tr></table>"; - $count = 0; - $body .= - "<table class=\"default\">" - . "<tr class=\"header\"><td colspan=2>" - . gettext("DIDs") - . "</td></tr>" - . "<tr class=\"header\"><td>" - . gettext("Number") - . "</td><td>" - . gettext("Monthly Fee") - . "</td><td>" - . gettext("Action") - . "</td></tr>"; + )); + + my (@account_did_list); my @did_list = &list_dids_account( $astpp_db, $accountinfo->{number} ); foreach my $did_info (@did_list) { - my $cost = sprintf( "%.2f", $did_info->{monthlycost} / 10000 ); - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= "<td>" - . $did_info->{number} - . "</td><td> \$" - . $cost - . "<td><a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") - . "&accountnum=$accountinfo->{'number'}" - . "&DID=$did_info->{number}&action=" - . gettext("Remove DID") . " \">" - . gettext("Remove DID") . "</a>" - . "</td></tr>"; + my (%row); + $row{accountnum} = $accountinfo->{number}; + $row{cost} = sprintf( "%.2f", $did_info->{monthlycost} / 10000 ); + $row{number} = $did_info->{number}; + push(@account_did_list, \%row); } + $template->param( account_did_list => \@account_did_list); my @availabledids = &list_available_dids( $astpp_db, $accountinfo->{number} ); - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= "<td>" - . popup_menu( + $template->param( available_dids => + popup_menu( -name => "did_list", -values => \@availabledids - ) - . "</td><td></td><td>" - . submit( - -name => "action", - -value => gettext("Purchase DID") - ) - . "</td></tr>" - . "<tr class=\"header\"><td colspan=2>" - . gettext("ANI & Prefix Mapping - Either enter prefix or ANI/CLID") - . "</td></tr>" - . "<tr class=\"header\"><td>" - . gettext("ANI") - . "</td><td>" - . gettext("Context - Leave blank for default") - . "</td><td>" - . gettext("ANI") - . "</td></tr> -\n"; + )); my $tmp = "SELECT * FROM ani_map WHERE account = " . $astpp_db->quote( $accountinfo->{'number'} ) . " ORDER BY number"; my $sql = $astpp_db->prepare($tmp); $sql->execute; - $count = 0; + my @account_ani_list; while ( my $record = $sql->fetchrow_hashref ) { - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= - "<td>$record->{number}</td><td>$record->{context}</td>" - . "<td><a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") - . "&accountnum=$accountinfo->{'number'}" - . "&ANI=$record->{number}&action=" - . gettext("Remove ANI") . " \">" - . gettext("Remove ANI") . "</a>" - . "</td></tr>"; + my (%row); + $row{accountnum} = $accountinfo->{number}; + $row{number} = $record->{number}; + $row{context} = $record->{context}; + push(@account_ani_list, \%row); } - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } + $template->param( account_ani_list => \@account_ani_list); - $body .= "<td>" - . textfield( - -name => "ANI", - -width => 20 - ) - . "</td><td>" - . textfield( - -name => "context", - -width => 20 - ) - . "</td><td>" - . submit( - -name => "action", - -value => gettext("Map ANI") - ) - . "</td></tr>" - . "<tr class=\"header\"><td colspan=2>" - . gettext("IP Address Mapping") - . "</td></tr>" - . "<tr class=\"header\"><td>" - . gettext("IP") - . "</td><td>" - . gettext("Prefix - Enter '0' for none.") - . "</td><td>" - . gettext("Context - Leave blank for default.") - . "</td><td>" - . gettext("Action") - . "</td></tr>\n"; $tmp = "SELECT * FROM ip_map WHERE account = " . $astpp_db->quote( $accountinfo->{'number'} ) . " ORDER BY ip"; $sql = $astpp_db->prepare($tmp); $sql->execute; - $count = 0; + my @account_ip_list; while ( my $record = $sql->fetchrow_hashref ) { - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= -"<td>$record->{ip}</td><td>$record->{prefix}</td><td>$record->{context}</td>" - . "<td><a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") - . "&accountnum=$accountinfo->{'number'}" - . "&prefix=$record->{prefix}" - . "&ip=$record->{ip}&action=" - . gettext("Remove IP") . " \">" - . gettext("Remove IP") . "</a>" - . "</td></tr>"; + my %row; + $row{accountnum} = $accountinfo->{number}; + $row{ip} = $record->{ip}; + $row{prefix} = $record->{prefix}; + $row{context} = $record->{context}; + push(@account_ip_list, \%row); } - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= "<td>" - . textfield( - -name => "ip", - -width => 16 - ) - . "</td><td>" - . textfield( - -name => "prefix", - -width => 16 - ) - . "</td><td>" - . textfield( - -name => "ipcontext", - -width => 16 - ) - . "</td><td>" - . submit( - -name => "action", - -value => gettext("Map IP") - ) - . "</td></tr>" - . "<tr class=\"header\">" - . "<td colspan=2>" - . gettext("Post Charge to Account") - . "</td></tr> -<tr class=\"header\"><td>" - . gettext("Description") - . "</td><td>" - . gettext("Charge in: ") - . $currency[0] - . "</td><td>" - . gettext("Action") - . "</td></tr>" - . "<tr class=\"rowone\"><td>" - . textfield( - -name => "desc", - -width => 16 - ) - . "</td><td>" - . textfield( - -name => "amount", - -width => 16 - ) - . "</td><td>" - . submit( - -name => "action", - -value => gettext("Post Charge...") - ) - . "</td></tr>" - . "</table>" - . "<br><table class=\"default\">" - . "<tr class=\"header\"><td>" - . gettext("UniqueID") - . "</td><td>" - . gettext("Date & Time") - . "</td><td>" - . gettext("Caller*ID") - . "</td><td>" - . gettext("Called Number") - . "</td><td>" - . gettext("Trunk") - . "</td><td>" - . gettext("Disposition") - . "</td><td>" - . gettext("Billable Seconds") - . "</td><td>" - . gettext("Charge") - . "</td><td>" - . gettext("Credit") - . "</td><td>" - . gettext("Notes") - . "</td></tr>\n"; + $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: + + 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 * FROM cdrs WHERE cardnum =" - . $astpp_db->quote( $accountinfo->{'number'} ) + "SELECT COUNT(*) 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; - $results = $sql->rows; - $pagesrequired = ceil( $results / $results_per_page ); + $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'} ) + . $astpp_db->quote( $accountinfo->{number} ) . "and status IN (NULL, '', 0, 1)" . " ORDER BY callstart DESC " - . " limit $params->{limit} , $results_per_page"; + . " 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; - $count = 0; - + my @account_cdr_list; while ( my $record = $sql->fetchrow_hashref ) { - my ( $debit, $credit ); - $count++; - $record->{callerid} = gettext("unknown") unless $record->{callerid}; - $record->{uniqueid} = gettext("N/A") unless $record->{uniqueid}; - $record->{disposition} = gettext("N/A") - unless $record->{disposition}; - $record->{notes} = "" unless $record->{notes}; - $record->{callstart} = "" unless $record->{callstart}; - $record->{callednum} = "" unless $record->{callednum}; - $record->{billseconds} = "" unless $record->{billseconds}; + my %row; + if (!$record->{callerid}) { + $row{callerid} = gettext("N/A"); + } else { + $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->{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->{debit} ) { - $debit = $record->{debit} / 10000; - $debit = sprintf( "%.6f", $debit ); + $row{debit} = $record->{debit} / 10000; + $row{debit} = sprintf( "%.6f", $row{debit} ); } else { - $debit = "-"; + $row{debit} = "-"; } if ( $record->{credit} ) { - $credit = $record->{credit} / 10000; - $credit = sprintf( "%.6f", $credit ); + $row{credit} = $record->{credit} / 10000; + $row{credit} = sprintf( "%.6f", $row{credit} ); } else { - $credit = "-"; + $row{credit} = "-"; } - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= - "<td>$record->{uniqueid}</td><td>$record->{callstart}</td><td>" - . "$record->{callerid}</td><td>$record->{callednum}</td><td>" - . "N/A</td><td>$record->{disposition}</td><td>$record->{billseconds}</td><td>" - . "$debit</td><td>$credit</td><td>$record->{notes}</td></tr> -"; + 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>"; } - $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("View Details") - . "&action=" - . gettext("Information...") - . "&accountnum=" - . $accountinfo->{number} - . "&limit=0\">"; - $body .= $i + 1; - $body .= "</a>"; - } - else { - $body .= $i + 1; - } + else { + $pagination = gettext("Page 1 of 1"); + } + + $template->param( pagination => $pagination ); } - if ( $i > 0 ) { - if ( $params->{limit} != ( $i * $results_per_page ) ) { - $body .= - "<a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") - . "&action=" - . gettext("Information...") - . "&accountnum=" - . $accountinfo->{number} - . "&limit="; - $body .= ( $i * $results_per_page ); - $body .= "\">\n"; - $body .= $i + 1 . "</a>"; - } - else { - $pageno = $i + 1; - $body .= " |"; - } + else { + $status .= + gettext("No such account number") + . " '$accountinfo->{number}' " + . gettext("found!") . "\n"; } - } - $body .= ""; - $body .= "Page $pageno of $pagesrequired"; - return $body; + $template->param( status => $status ); + return $template->output; } sub build_list_accounts() { - my ( $total, $count, $reseller, @accountdetaillist ); + my ( $body, $total, $count, $reseller, @accountdetaillist ); my $template = HTML::Template->new( filename => '/var/lib/astpp/templates/account-list.tpl' ); @@ -2359,7 +2045,7 @@ $reseller = ""; } $types{-1} = gettext("All"); - my $body = start_form + $body = start_form . "<table class=\"default\"><tr class=\"header\"><td colspan=9>" . hidden( -name => "mode", @@ -6859,6 +6545,7 @@ -size => 3, -default => 0 ) + . "</td><td>" . textfield( -name => 'dial_as', -size => This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-09-22 05:17:33
|
Revision: 2130 http://astpp.svn.sourceforge.net/astpp/?rev=2130&view=rev Author: darrenkw Date: 2007-09-21 22:17:34 -0700 (Fri, 21 Sep 2007) Log Message: ----------- Updated the account-info.tpl to actually be useful and cleaned up a few minor issues on the home page. Modified Paths: -------------- trunk/templates/account-info.tpl trunk/templates/home.tpl Modified: trunk/templates/account-info.tpl =================================================================== --- trunk/templates/account-info.tpl 2007-09-22 05:15:34 UTC (rev 2129) +++ trunk/templates/account-info.tpl 2007-09-22 05:17:34 UTC (rev 2130) @@ -1,42 +1,195 @@ -<input name="mode" value="Accounts" type="hidden"> +<input name="mode" value="View Details" type="hidden"> <table class="default"> <tr class="header"> <td>Either select or enter the account number:</td> <td>Action</td> </tr> <tr class="rowone"> - <td><TMPL_VAR NAME="accountlist"></td> - <td><input name="accountnum" size="20" type="text"></td> + <td><TMPL_VAR NAME="accountlist"> <input name="accountnum" size="20" type="text"></td> <td><input name="action" value="Information" type="submit"></td> </tr> </table> -View Account<br> -Booth Name: <TMPL_VAR NAME="booth_name"> + <table class="default"> <tr class="header"> - <td>Balance</td><td>Unrated CDRs</td><td colspan=10 align=center>Actions</td> + <td>Account Number</td> + <td>Name</td> + <td>Company</td> + <td>Telephone</td> + <td>Telephone 2</td> + <td>Fax</td> </tr> <tr> - <td><TMPL_VAR NAME="balance"></td> - <td><TMPL_VAR NAME="unrated_cdrs"></td> - <td colspan=10 align=center> - <input name="action" value="Generate Invoice" type="submit"> - <input name="action" value="Remove CDRs" type="submit"></td> + <td><TMPL_VAR NAME="accountnum"></td> + <td><TMPL_VAR NAME="first_name"> <TMPL_VAR NAME="middle_name"> <TMPL_VAR NAME="last_name"></td> + <td><TMPL_VAR NAME="company"></td> + <td><TMPL_VAR NAME="telephone_1"></td> + <td><TMPL_VAR NAME="telephone_2"></td> + <td><TMPL_VAR NAME="fascimilie"></td> </tr> + <tr class="header"> + <td>Address Line 1</td> + <td>Address Line 2</td> + <td>Address Line 3</td> + <td>Email</td> + <td>City</td> + <td>Province</td> + <td>Postal Code</td> + <td>Country</td> + </tr> + <tr> + <td><TMPL_VAR NAME="address_1"></td> + <td><TMPL_VAR NAME="address_2"></td> + <td><TMPL_VAR NAME="address_3"></td> + <td><TMPL_VAR NAME="email"></td> + <td><TMPL_VAR NAME="city"></td> + <td><TMPL_VAR NAME="province"></td> + <td><TMPL_VAR NAME="postal_code"></td> + <td><TMPL_VAR NAME="country"></td> + </tr> + <tr class="header"> + <td colspan=2>Dialed Number Mods</td> + <td>Max Channels</td> + <td>Pin</td> + <td>Balance</td> + <td>Credit Limit</td> + </tr> + <tr> + <td colspan=2><TMPL_VAR NAME="dialed_modify"></td> + <td><TMPL_VAR NAME="maxchannels"></td> + <td><TMPL_VAR NAME="pin"></td> + <td><TMPL_VAR NAME="balance"> <TMPL_VAR NAME="currency"></td> + <td><TMPL_VAR NAME="credit_limit"> <TMPL_VAR NAME="currency"></td> + </tr> +</table> +<table class="default"> + <tr class="header"> + <td colspan=5>Charges</td> + </tr> + <tr class="header"> + <td>Action</td> + <td>ID</td> + <td>Description</td> + <td>Cycle</td> + <td>Amount</td> + </tr> + <TMPL_LOOP NAME="chargelist"> + <tr> + <td><a href="astpp-admin.cgi?mode=View Details&chargeid=<TMPL_VAR NAME="id">&accountnum=<TMPL_VAR NAME="accountnum">&action=Remove Charge...">Remove Charge...</a></td> + <td><TMPL_VAR NAME="id"><td> + <td><TMPL_VAR NAME="description"></td> + <td><TMPL_VAR NAME="sweep"></td> + <td>$<TMPL_VAR NAME="cost"></td> + </tr> + </TMPL_LOOP> +</table> +<table class="default"> + <tr class="header"> + <td colspan=3>Add Charge</td> + </tr> + <tr> + <td><TMPL_VAR NAME="applyable_charges"></td> + <td><input name="id" size="3" type="text"></td> + <td><input name="action" value="Add Charge..." type="submit"></td> + </tr> +</table> +<table class="default"> + <tr class="header"> + <td colspan=3>DIDs</td> + </tr> + <tr class="header"> + <td>Number</td> + <td>Monthly Fee</td> + <td>Action</td> + </tr> + <TMPL_LOOP NAME="account_did_list"> + <tr> + <td><TMPL_VAR NAME="number"></td> + <td>$<TMPL_VAR NAME="cost"></td> + <td><a href="astpp-admin.cgi?mode=View Details&accountnum=<TMPL_VAR NAME="accountnum">&DID=<TMPL_VAR NAME="number">&action=Remove DID">Remove DID</a></td> + </tr> + </TMPL_LOOP> + <tr> + <td><TMPL_VAR NAME="available_dids"></td> + <td><input name="action" value="Purchase DID" type="submit"></td> + </tr> +</table> +<table class="default"> + <tr class="header"> + <td colspan=3>ANI & Prefix Mapping - Either enter prefix or ANI/CLID</td> + </tr> + <tr class="header"> + <td>ANI/CLID/PREFIX</td> + <td>Context - Blank = default</td> + <td>Action</td> + <TMPL_LOOP NAME="account_ani_list"> + <tr> + <td><TMPL_VAR NAME="number"></td> + <td><TMPL_VAR NAME="context"></td> + <td><a href=\"astpp-admin.cgi?mode=View Details&accountnum=<TMPL_VAR NAME="accountnum">&ANI=<TMPL_VAR NAME="number">&action=Remove ANI">Remove ANI</a></td> + </tr> + </TMPL_LOOP> + <tr> + <td><input name="ANI" size="20" type="text"></td> + <td><input name="context" size="20" type="text"></td> + <td><input name="action" value="Map ANI" type="submit"></td> + </tr> +</table> + +<table class="default"> + <tr class="header"> + <td colspan=4>IP Address Mapping</td> + </tr> + <tr class="header"> + <td>IP Address</td> + <td>Prefix</td> + <td>Context - blank = default</td> + <td>Action</td> + </tr> + <TMPL_LOOP NAME="account_ip_list"> + <tr> + <td><TMPL_VAR NAME="ip"></td> + <td><TMPL_VAR NAME="prefix"></td> + <td><a href="astpp-admin.cgi?mode=View Details&accountnum=<TMPL_VAR NAME="accountnum">&prefix=<TMPL_VAR NAME="prefix">&ip=<TMPL_VAR NAME="ip">&action=Remove IP">Remove IP</a></td> + </tr> + </TMPL_LOOP> + <tr> + <td><input name="ip" size="16" type="text"></td> + <td><input name="prefix" size="16" type="text"></td> + <td><input name="ipcontext" size="16" type="text"></td> + <td><input name="action" value="Map IP" type="submit"></td> + </tr> +</table> +<table class="default"> + <tr class="header"> + <td colspan=3>Post Charge to Account</td> + </tr> + <tr class="header"> + <td>Description</td> + <td>Charge in <TMPL_VAR NAME="currency"></td> + <td>Action</td> + </tr> + <tr> + <td><input name="desc" size="16" type="text"></td> + <td><input name="amount" size="8" type="text"></td> + <td><input name="action" value="Post Charge..." type="submit"></td> + </tr> +</table> + +<table class="default"> <tr class="header"> <td>UniqueID</td> <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="cdr_list"> + <TMPL_LOOP NAME="account_cdr_list"> <TR> <TD><TMPL_VAR NAME="uniqueid"></TD> <TD><TMPL_VAR NAME="callstart"></TD> @@ -55,6 +208,7 @@ <table> <tr> + <td><TMPL_VAR NAME="pagination"></td> <td><TMPL_VAR NAME="status"></td> </tr> </table> Modified: trunk/templates/home.tpl =================================================================== --- trunk/templates/home.tpl 2007-09-22 05:15:34 UTC (rev 2129) +++ trunk/templates/home.tpl 2007-09-22 05:17:34 UTC (rev 2130) @@ -26,17 +26,16 @@ <tr class="rowone"> <td>$<TMPL_VAR NAME="total_owing"></td> <td>$<TMPL_VAR NAME="total_due"></td> - <td><TMPL_VAR NAME="calling_cards_in_use"></td> <td><TMPL_VAR NAME="dids"></td> <td><TMPL_VAR NAME="unbilled_cdrs"></td> </tr> -<tr> +<tr class="header"> <td>Calling Cards in use</td> <td>Total Active Cards</td> <td>Unused Card Balance</td> <td>Used Card Balance</td> </tr> -<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> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-09-22 05:15:37
|
Revision: 2129 http://astpp.svn.sourceforge.net/astpp/?rev=2129&view=rev Author: darrenkw Date: 2007-09-21 22:15:34 -0700 (Fri, 21 Sep 2007) Log Message: ----------- Resolve Bug: [ 1800039 ] Call rating issue The "post_cdr" subroutine was being called incorrectly. Modified Paths: -------------- trunk/astpp-common.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2007-09-19 01:57:11 UTC (rev 2128) +++ trunk/astpp-common.pl 2007-09-22 05:15:34 UTC (rev 2129) @@ -1077,21 +1077,21 @@ $didinfo = &get_did_reseller($astpp_db,$did,$accountdata->{reseller}); if ($didinfo->{disconnectionfee} != 0) { $dest = gettext("DID:") . $did . gettext(" disconnection fee"); - &post_cdr($astpp_db,'',$accountdata->{number},'',$dest,'','',$didinfo->{disconnectionfee},$callstart,$accountdata->{postexternal},'',$notes); + &post_cdr($astpp_db,$config,'',$accountdata->{number},'',$dest,'','',$didinfo->{disconnectionfee},$callstart,$accountdata->{postexternal},'',$notes); } $accountdata = &get_account($astpp_db, $accountdata->{reseller}); } $didinfo = &get_did($astpp_db,$did,$account); if ($didinfo->{disconnectionfee} != 0) { $dest = gettext("DID:") . $did . gettext(" disconnection fee"); - &post_cdr($astpp_db,'',$accountdata->{number},'',$dest,'','',$didinfo->{disconnectionfee},$callstart,$accountdata->{postexternal},'',$notes); + &post_cdr($astpp_db,$config,'',$accountdata->{number},'',$dest,'','',$didinfo->{disconnectionfee},$callstart,$accountdata->{postexternal},'',$notes); } $accountdata = &get_account($astpp_db,$account); } else { $didinfo = &get_did($astpp_db,$did,$account); if ($didinfo->{disconnectionfee} != 0) { $dest = gettext("DID:") . $did . gettext(" disconnection fee"); - &post_cdr($astpp_db,,'',$accountdata->{number},'',$dest,'','',$didinfo->{disconnectionfee},$callstart,$accountdata->{postexternal},'',$notes); + &post_cdr($astpp_db,$config,'',$accountdata->{number},'',$dest,'','',$didinfo->{disconnectionfee},$callstart,$accountdata->{postexternal},'',$notes); } } # If we got this far the cdrs have been posted and we're ready to cancel the DID. @@ -1196,11 +1196,11 @@ if ($didinfo->{chargeonallocation} == 1) { my $dest = gettext("DID:") . $did . gettext(" from ") . $start_date . gettext(" to ") . $end_date; - &post_cdr($astpp_db,'',$accountdata->{number},'',$dest,'','',$cost,$callstart,$accountinfo->{postexternal},'',$notes); + &post_cdr($astpp_db,$config,'',$accountdata->{number},'',$dest,'','',$cost,$callstart,$accountinfo->{postexternal},'',$notes); } if ($didinfo->{setup} != 0) { my $dest = gettext("DID:") . $did . gettext(" setup fee"); - &post_cdr($astpp_db,'',$accountdata->{number},'',$dest,'','',$didinfo->{setup},$callstart,$accountinfo->{postexternal},'',$notes); + &post_cdr($astpp_db,$config,'',$accountdata->{number},'',$dest,'','',$didinfo->{setup},$callstart,$accountinfo->{postexternal},'',$notes); } $accountdata = &get_account($astpp_db,$accountdata->{reseller}); } @@ -1215,11 +1215,11 @@ if ($didinfo->{chargeonallocation} == 1) { my $dest = gettext("DID:") . $did . gettext(" from ") . $start_date . gettext(" to ") . $end_date; - &post_cdr($astpp_db,'',$accountdata->{number},'',$dest,'','',$cost,$callstart,$accountdata->{postexternal},'',$notes); + &post_cdr($astpp_db,$config,'',$accountdata->{number},'',$dest,'','',$cost,$callstart,$accountdata->{postexternal},'',$notes); } if ($didinfo->{setup} != 0) { $dest = gettext("DID:") . $did . gettext(" setup fee"); - &post_cdr($astpp_db,'',$accountdata->{number},'',$dest,'','',$didinfo->{setup},$callstart,$accountdata->{postexternal},'',$notes); + &post_cdr($astpp_db,$config,'',$accountdata->{number},'',$dest,'','',$didinfo->{setup},$callstart,$accountdata->{postexternal},'',$notes); } } else { my $did_min_available = $didinfo->{monthlycost} + $didinfo->{setup} + $didinfo->{disconnectionfee}; @@ -1235,11 +1235,11 @@ if ($didinfo->{chargeonallocation} == 1) { my $dest = gettext("DID:") . $did . gettext(" from ") . $start_date . gettext(" to ") . $end_date; - &post_cdr($astpp_db,'',$accountinfo->{number},'',$dest,'','',$cost,$callstart,$accountinfo->{postexternal},'',$notes); + &post_cdr($astpp_db,$config,'',$accountinfo->{number},'',$dest,'','',$cost,$callstart,$accountinfo->{postexternal},'',$notes); } if ($didinfo->{setup} != 0) { $dest = gettext("DID:") . $did . gettext(" setup fee"); - &post_cdr($astpp_db,'',$accountinfo->{number},'',$dest,'','',$didinfo->{setup},$callstart,$accountinfo->{postexternal},'',$notes); + &post_cdr($astpp_db,$config,'',$accountinfo->{number},'',$dest,'','',$didinfo->{setup},$callstart,$accountinfo->{postexternal},'',$notes); } } } @@ -2166,7 +2166,7 @@ # Write ASTPP cdr. I think this one is mostly deprecated but should probably be completely removed. sub post_cdr() { my ( - $astpp_db, $uniqueid, $account, $clid, + $astpp_db, $config, $uniqueid, $account, $clid, $dest, $disp, $seconds, $cost, $callstart, $postexternal, $trunk, $notes ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-09-19 01:57:08
|
Revision: 2128 http://astpp.svn.sourceforge.net/astpp/?rev=2128&view=rev Author: darrenkw Date: 2007-09-18 18:57:11 -0700 (Tue, 18 Sep 2007) Log Message: ----------- Added reporting functionality from Sonia Khan. Bug number 167. Thanks Sonia Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-09-19 01:37:31 UTC (rev 2127) +++ trunk/astpp-admin.cgi 2007-09-19 01:57:11 UTC (rev 2128) @@ -100,17 +100,30 @@ gettext("Create Booth"), gettext("Remove Booth"), gettext("List Booths"), gettext("View Booth") ); + +# Report added by Sonia Ali Khan <son...@gm...> +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") +); + + my %menumap = ( - gettext('Accounts') => \@Accounts, - gettext('Rates') => \@Rates, - gettext('DIDs') => \@DIDs, - gettext('Statistics') => \@Statistics, - gettext('System') => \@System, - gettext('LCR') => \@LCR, - gettext('Calling Cards') => \@Callingcards, - gettext('Switch Config') => \@SwitchConfig, - gettext('Booths') => \@Booths, - gettext('Call Shops') => \@CallShops + gettext('Accounts') => \@Accounts, + gettext('Rates') => \@Rates, + gettext('DIDs') => \@DIDs, + gettext('Statistics') => \@Statistics, + gettext('System') => \@System, + gettext('LCR') => \@LCR, + gettext('Calling Cards') => \@Callingcards, + gettext('Switch Config') => \@SwitchConfig, + gettext('Booths') => \@Booths, + gettext('Call Shops') => \@CallShops, + gettext('Admin Reports') => \@AdminReports, + gettext('CallShop Reports') => \@CallShopReports, + gettext('Reseller Reports') => \@ResellerReports ); my @months = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', @@ -399,6 +412,11 @@ return &build_remove_callshop() if $params->{mode} eq gettext("Remove CallShop"); + return &build_admin_reseller_report() + if $params->{mode} eq gettext("Reseller Report"); + 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"); @@ -503,6 +521,15 @@ 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_callshop_report() + if $params->{mode} eq gettext("CallShop Report"); + return &build_reseller_reseller_report() + if $params->{mode} eq gettext("Reseller Report"); + return &build_reseller_user_report() + if $params->{mode} eq gettext("User Report"); + return &build_homepage() if $params->{mode} eq gettext("Home Page") || $params->{mode} eq gettext("Home") @@ -539,6 +566,8 @@ if $params->{mode} eq gettext("Delete Card"); return &build_refill_card() if $params->{mode} eq gettext("Refill Card"); + return &build_callshop_callshop_report() + if $params->{mode} eq gettext("Booth Report"); return &build_list_booths() if $params->{mode} eq gettext("Home Page") @@ -648,7 +677,11 @@ ######## Reporting Module ################ # -sub build_reporting() { +# Modified and Extended By Sonia Ali Khan <son...@gm...> +# Last updated: Sept. 11, 2007 at 1445hours GMT. + +sub build_filter($$) { + my ($additional_fields, $submit_title) = @_; my ($body); return gettext("ASTPP Database Not Available!") . "<br>" unless $astpp_db; $cdr_db = &cdr_connect_db( $config, @output ); @@ -679,7 +712,7 @@ $end_second = "59"; } else { - $start_year = $params->{star_year}; + $start_year = $params->{start_year}; $start_month = sprintf( "%02d", $params->{start_month} + 1 ); $start_day = sprintf( "%02d", $params->{start_day} ); $start_hour = sprintf( "%02d", $params->{start_hour} ); @@ -692,101 +725,383 @@ $end_minute = sprintf( "%02d", $params->{end_minute} ); $end_second = sprintf( "%02d", $params->{end_second} ); } -} -#################### Stats stuff ########################### -sub build_stats_acd() { - my ( $body, $id ); - return gettext("Cannot display stats until database is configured") - unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, @output ); - return gettext("Cannot display stats until database is configured") - unless $cdr_db; - my ( undef, undef, undef, $day, $mnth, $yr ) = localtime(); - my ( - $sd_yr, $sd_mnth, $sd_day, $st_hr, $st_min, $st_sec, - $ed_yr, $ed_mnth, $ed_day, $et_hr, $et_min, $et_sec - ); - my $count = 0; - if ( param('sd_mnth') eq "" ) { - $sd_yr = $yr + 1900; - $sd_mnth = sprintf( "%02d", $mnth + 1 ); - $sd_day = "01"; - $st_hr = "00"; - $st_min = "00"; - $st_sec = "00"; - $ed_yr = $yr + 1900; - $ed_mnth = sprintf( "%02d", $mnth + 1 ); - $ed_day = $day; - $et_hr = "23"; - $et_min = "59"; - $et_sec = "59"; - } - else { - $sd_yr = param('sd_yr'); - $sd_mnth = sprintf( "%02d", param('sd_mnth') + 1 ); - $sd_day = sprintf( "%02d", param('sd_day') ); - $st_hr = sprintf( "%02d", param('st_hr') ); - $st_min = sprintf( "%02d", param('st_min') ); - $st_sec = sprintf( "%02d", param('st_sec') ); - $ed_yr = param('ed_yr'); - $ed_mnth = sprintf( "%02d", param('ed_mnth') + 1 ); - $ed_day = sprintf( "%02d", param('ed_day') ); - $et_hr = sprintf( "%02d", param('et_hr') ); - $et_min = sprintf( "%02d", param('et_min') ); - $et_sec = sprintf( "%02d", param('et_sec') ); - } - $body .= - "<form method=get><input type=hidden name=mode value=\"" - . param('mode') - . "\"><table class=\"default\" width=100%>"; - $body .= - "<tr><td width=50%>" - . gettext("Start date:") - . "</td><td><input type=text name=sd_yr value=\"$sd_yr\" size=5><select name=sd_mnth>"; + $body .= "<form method=get><input type=hidden name=mode value=\"". param('mode') + . "\"><table class=\"default\" width=100%>"; + $body .= "<tr><td width=50%>". gettext("Start date:") + . "</td><td><input type=text name=start_year value=\"$start_year\" size=5><select name=start_month>"; + for ( $id = 0 ; $id < 12 ; $id++ ) { - if ( $id == ( $sd_mnth - 1 ) ) { + if ( $id == ( $start_month - 1 ) ) { $body .= "<option value=$id selected>$months[$id]"; } else { $body .= "<option value=$id>$months[$id]"; } } - $body .= - "</select><input type=text name=sd_day value=\"$sd_day\" size=3></td></tr> - -"; - $body .= "<tr><td>" - . gettext("Start time:") - . "</td><td><input type=text name=st_hr value=\"$st_hr\" size=3><input type=text name=st_min value=\"$st_min\" size=3><input type=text name=st_sec value=\"$st_sec\" size=3></td></tr> -"; - $body .= "<tr><td>" - . gettext("End date:") - . "</td><td><input type=text name=ed_yr value=\"$ed_yr\" size=5><select name=ed_mnth>"; + $body .= "</select><input type=text name=start_day value=\"$start_day\" size=3></td></tr>"; + $body .= "<tr><td>". gettext("Start time:") + . "</td><td><input type=text name=start_hour value=\"$start_hour\" size=3>" + . "<input type=text name=start_minute value=\"$start_minute\" size=3>" + . "<input type=text name=start_second value=\"$start_second\" size=3></td></tr>"; + $body .= "<tr><td>". gettext("End date:") + . "</td><td><input type=text name=end_year value=\"$end_year\" size=5><select name=end_month>"; for ( $id = 0 ; $id < 12 ; $id++ ) { - if ( $id == ( $ed_mnth - 1 ) ) { + if ( $id == ( $end_month - 1 ) ) { $body .= "<option value=$id selected>$months[$id]"; } else { $body .= "<option value=$id>$months[$id]"; } } - $body .= - "</select><input type=text name=ed_day value=\"$ed_day\" size=3></td></tr> -"; - $body .= "<tr><td>" - . gettext("End time:") - . "</td><td><input type=text name=et_hr value=\"$et_hr\" size=3><input type=text name=et_min value=\"$et_min\" size=3><input type=text name=et_sec value=\"$et_sec\" size=3></td></tr> -"; - $body .= -"<tr><td align=center colspan=2><input type=submit value=Filter!></td></tr> -"; - $body .= "</table> -</form>"; - my $sd = "$sd_yr-$sd_mnth-$sd_day $st_hr:$st_min:$st_sec"; - my $ed = "$ed_yr-$ed_mnth-$ed_day $et_hr:$et_min:$et_sec"; - my $sth; + $submit_title = "Filter!" if !$submit_title; + $body .= "</select><input type=text name=end_day value=\"$end_day\" size=3></td></tr>"; + $body .= "<tr><td>". gettext("End time:") + . "</td><td><input type=text name=end_hour value=\"$end_hour\" size=3>" + . "<input type=text name=end_minute value=\"$end_minute\" size=3>" + . "<input type=text name=end_second value=\"$end_second\" size=3></td></tr>\n"; + $body .= $additional_fields if $additional_fields; + $body .= "<tr><td align=center colspan=2><input type=submit value=$submit_title></td></tr>"; + $body .= "</table>\n</form>"; + + my %report_filter = ( + 'start_year' => $start_year, + 'start_month' => $start_month, + 'start_day' => $start_day, + 'start_hour' => $start_hour, + 'start_minute'=> $start_minute, + 'start_second'=> $start_second, + 'end_year' => $end_year, + 'end_month' => $end_month, + 'end_day' => $end_day, + 'end_hour' => $end_hour, + 'end_minute' => $end_minute, + 'end_second' => $end_second, + 'start_date' => "$start_year-$start_month-$start_day $start_hour:$start_minute:$start_second", + 'end_date' => "$end_year-$end_month-$end_day $end_hour:$end_minute:$end_second", + 'form_body' => $body + ); + return \%report_filter; +} + +sub build_admin_reseller_report() { + return &build_report("Reseller","1"); +} + +sub build_admin_vendor_report() { + return &build_report("Vendor","3"); +} + +sub build_callshop_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"); +} + +sub build_list_box($$) { + my ($in, $selected) = @_; + my $body = ""; + undef %list; + @list{@$in} = (); + my @out = sort keys %list; # remove sort if undesired + for(my $i=0; $i < @out; $i++) { + if($out[$i] eq $selected) { + $body .= "<option value='$out[$i]' selected>$out[$i]</option>\n"; + } else { + $body .= "<option value='$out[$i]'>$out[$i]</option>\n"; + } + } + return $body; +} + +sub build_report($$) { + + return gettext("Cannot display reports until database is configured") + unless $astpp_db; + $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + return gettext("Cannot display reports until database is configured") + unless $cdr_db; + + my $name = shift; + my $type = shift; + my ($sth,$body); + + my $destination = $params->{destination}; + my $pattern = $params->{pattern}; + + if ($params->{logintype} == 1 || $params->{logintype} == 5) { + $sth = + $astpp_db->prepare( "SELECT * FROM accounts WHERE reseller = " + . $astpp_db->quote( $params->{username} ) + . " AND type IN ($type)"); + } + else { + $sth = $astpp_db->prepare("SELECT * FROM accounts WHERE type IN ($type)"); + } + + $sth->execute() || return gettext("Something is wrong with astpp database"). "\n"; + + $body = "<tr><td align=right> $name:" + . "<select name=$name value='$params->{$name}'>\n<option value='ALL'>ALL</option>\n"; + + while (my $row = $sth->fetchrow_hashref) { + if($row->{'number'} eq $params->{$name}) { + $body .= "<option value='$row->{'number'}' selected>$row->{'number'}</option>\n"; + } else { + $body .= "<option value='$row->{'number'}'>$row->{'number'}</option>\n"; + } + } + + $sth->finish; + + $body .= "</select> <strong>AND</strong> "; + + if ($params->{logintype} == 1 || $params->{logintype} == 5) { + $sth = + $astpp_db->prepare("SELECT DISTINCT notes FROM cdrs WHERE notes LIKE " + . $astpp_db->quote($params->{username}."|%")); + } + else { + $sth = $astpp_db->prepare("SELECT DISTINCT notes FROM cdrs"); + } + + $sth->execute() || return gettext("Something is wrong with astpp database"). "\n"; + + my ($dest,$ptrn); + my (@dst,@ptn,$i); + $dest = "Destination: </td><td align=left><select name=destination value='Destination'>\n" + . "<option value='ALL'>ALL</option>\n"; + $ptrn = " <strong>OR</strong> " + . "IDD Code: <select name=pattern value='IDD Code'>\n" + . "<option value='ALL'>ALL</option>\n"; + + while (my $notes = $sth->fetchrow_hashref) { + my @note = split(m/(\^|DID:)/,$notes->{'notes'},2); + $ptn[$i] = $note[1].$note[2]; + @note = split(/\|/,$note[0]); + $dst[$i] = (@note == 1) ? $note[0] : $note[1] if $note[0] ne ""; + $i++; + } + $sth->finish; + + $dest .= build_list_box(\@dst,$destination); + $dest .= "</select>\n"; + + $ptrn .= build_list_box(\@ptn,$pattern); + $ptrn .= "</select>\n"; + + $body .= $dest . $ptrn . "</td></tr>"; + + my $filter = build_filter($body,undef); + my $sd = $filter->{'start_date'}; + my $ed = $filter->{'end_date'}; + $body = $filter->{'form_body'}; + + my $where = "callstart BETWEEN ".$astpp_db->quote($sd) + ." AND ".$astpp_db->quote($ed)." "; + + if($params->{$name} eq 'ALL') { + if ($params->{logintype} == 1 || $params->{logintype} == 5) { + $where .= "AND cardnum IN (SELECT `number` FROM accounts WHERE reseller = " + .$astpp_db->quote($params->{username})." AND type IN ($type)) "; + } else { + if(index($type,"1") != -1) { + $where .= "AND cardnum IN (SELECT `number` FROM accounts WHERE type IN ($type)) "; + } elsif(index($type,"3") != -1) { + $where .= "AND provider = ".$astpp_db->quote($params->{$name}); + } + } + } else { + if ($params->{logintype} == 1 || $params->{logintype} == 5) { + $where .= "AND cardnum = ".$astpp_db->quote($params->{$name})." "; + } else { + if(index($type,"1") != -1) { + $where .= "AND cardnum IN (SELECT `number` FROM accounts WHERE `number` = " + .$astpp_db->quote($params->{$name})." AND type IN ($type)) "; + } elsif(index($type,"3") != -1) { + $where .= "AND provider = ".$astpp_db->quote($params->{$name}); + } + } + } + + if($destination eq 'ALL') { + if($pattern eq 'ALL') { + $where .= ""; + } else { + $where .= "AND notes LIKE ".$astpp_db->quote("%|".$pattern)." "; + } + } else { + if($pattern eq 'ALL') { + $where .= "AND notes LIKE ".$astpp_db->quote("%|".$destination."|%")." "; + } else { + $where .= "AND (notes LIKE ".$astpp_db->quote("%|".$destination."|%")." "; + $where .= "OR notes LIKE ".$astpp_db->quote("%|".$pattern).") "; + } + } + + $where = 0 if $param->{$name} eq "" && $destination eq "" && $pattern eq ""; + + $body .= start_form() + . "<table class=\"default\" width=100%><tr><td colspan=12 align=center><b>$sd - $ed</b></td></tr>" + . "<tr class=\"header\"><td>" + . gettext("$name") + . "</td><td>" + . gettext("Destination") + . "</td><td>" + . gettext("IDD Code") + . "</td><td>" + . gettext("Attempted Calls") + . "</td><td>" + . gettext("Completed Calls") + . "</td><td>" + . "<acronym title=\"" + . gettext("Answer Seizure Rate") . "\">" + . gettext("ASR") + . "</acronym>" + . "</td><td>" + . "<acronym title=\"" + . gettext("Average Call Duration") . "\">" + . gettext("ACD") + . "</acronym>" + . "</td><td>" + . "<acronym title=\"" + . gettext("Maximum Call Duration") . "\">" + . gettext("MCD") + . "</acronym>" + . "</td><td>" + . gettext("Actual") + . "</td><td>" + . gettext("Billable") + . "</td><td>" + . gettext("Price") + . "</td><td>" + . gettext("Cost") + . "</td></tr>\n"; + + my $table = "tmp_".time(); + 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; + + my $sql = $astpp_db->prepare("SELECT DISTINCT cardnum AS $name FROM $table"); + $sql->execute() || return gettext("Something is wrong with astpp database"). "\n"; + + while(my $row = $sql->fetchrow_hashref) { + $bth = $row->{$name}; + my $sql1 = $astpp_db->prepare("SELECT notes, COUNT(*) AS attempts, AVG(billseconds) AS acd, + MAX(billseconds) AS mcd, SUM(billseconds) AS billable, + SUM(debit) AS cost, SUM(cost) AS price FROM $table + WHERE (notes IS NOT NULL AND notes != '') AND cardnum = " + .$astpp_db->quote($bth)." GROUP BY notes"); + $sql1->execute() || return gettext("Something is wrong with astpp database"). "\n"; + + while(my $row1 = $sql1->fetchrow_hashref()) { + my @note1 = split(m/(\^|DID:)/,$row1->{notes},2); + $idd = $note1[1].$note1[2]; + @note1 = split(/\|/,$note1[0]); + $dst = (@note1 == 1) ? $note1[0] : $note1[1]; + $dst = 'N/A' if $dst eq ""; + + $atmpt = $row1->{'attempts'}; + $acd = $row1->{'acd'}; + $mcd = $row1->{'mcd'}; + $bill = $row1->{'billable'}; + $price = $row1->{'price'}; + $cost = $row1->{'cost'}; + + $notes = "notes = ".$astpp_db->quote($row1->{notes}); + + my $sql2 = $astpp_db->prepare("SELECT COUNT(*) AS completed FROM $table + WHERE $notes AND disposition = 'ANSWERED'"); + $sql2->execute() || return gettext("Something is wrong with astpp database"). "\n"; + my $row2 = $sql2->fetchrow_hashref(); + $cmplt = $row2->{'completed'} || 0; + $sql2->finish; + + $asr = (($atmpt - $cmplt)/$atmpt) * 100; + + my $in = ""; + my $sql3 = $astpp_db->prepare("SELECT uniqueid FROM $table WHERE $notes "); + $sql3->execute() || return gettext("Something is wrong with astpp database"). "\n"; + + while(my $row3 = $sql3->fetchrow_hashref) { + $in .= "'".$row3->{'uniqueid'}."'," if $row3->{'uniqueid'}; + } + + $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(); + $act = $row4->{'actual'}; + $sql4->finish; + + $body .= "<tr>" + . "<td>$bth</td><td>$dst</td><td>$idd</td><td>$atmpt</td><td>$cmplt</td><td>$asr</td>" + . "<td>$acd</td><td>$mcd</td><td>$act</td><td>$bill</td><td>$price</td><td>$cost</td>" + . "</tr>"; + } + $sql1->finish; + } + $sql->finish; + + $sth = $astpp_db->do("DROP TEMPORARY TABLE $table") + || return gettext("Something is wrong with astpp database"). "\n"; + + $body .= "</table>"; + return $body; +} + +sub build_admin_report() { + my ($body); + return gettext("Cannot display reports until database is configured") + unless $astpp_db; + $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + return gettext("Cannot display reports until database is configured") + unless $cdr_db; + + return gettext("Comming Soon!"); +} + +sub build_reseller_report() { + my ($body); + return gettext("Cannot display reports until database is configured") + unless $astpp_db; + $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + return gettext("Cannot display reports until database is configured") + unless $cdr_db; + + return gettext("Comming Soon!"); +} + +# End of code changes by Sonia Ali Khan. + +#################### Stats stuff ########################### +sub build_stats_acd() { + my ( $body, $id ); + return gettext("Cannot display stats until database is configured") + unless $astpp_db; + $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + return gettext("Cannot display stats until database is configured") + unless $cdr_db; + + my $filter = build_filter(undef,undef); + my $sd = $filter->{'start_date'}; + my $ed = $filter->{'end_date'}; + $body = $filter->{'form_body'}; + + my $sth; + if ( $params->{logintype} == 3 ) { $sth = $astpp_db->prepare( "SELECT * FROM trunks WHERE provider = " @@ -799,8 +1114,7 @@ || return gettext("Something is wrong with the trunks database") . "\n"; $body .= start_form() - . "<table class=\"default\" width=100%><tr><td colspan=5 align=center><b>$sd - $ed</b></td></tr> -" + . "<table class=\"default\" width=100%><tr><td colspan=5 align=center><b>$sd - $ed</b></td></tr>" . "<tr class=\"header\"><td>" . gettext("Trunk Name") . "</td><td>" @@ -819,8 +1133,7 @@ . gettext("Success") . "</td><td>" . gettext("Congestion") - . "</td></tr> -\n"; + . "</td></tr>\n"; while ( my $row = $sth->fetchrow_hashref ) { $count++; @@ -901,12 +1214,10 @@ . " %</td><td>" . "$ref3->{ct} " . sprintf( "%.04f", $congestion_rate ) - . "%</td></tr> -\n"; + . "%</td></tr>\n"; } $sth->finish; - $body .= "</table> -"; + $body .= "</table>"; return $body; } @@ -942,85 +1253,8 @@ push( @trunklist, "" ); } @trunklist = sort @trunklist; - my ( - $sd_yr, $sd_mnth, $sd_day, $st_hr, $st_min, $st_sec, - $ed_yr, $ed_mnth, $ed_day, $et_hr, $et_min, $et_sec - ); - my $count = 0; - - if ( $params->{sd_mnth} eq "" ) { - $sd_yr = $yr + 1900; - $sd_mnth = sprintf( "%02d", $mnth + 1 ); - $sd_day = "01"; - $st_hr = "00"; - $st_min = "00"; - $st_sec = "00"; - $ed_yr = $yr + 1900; - $ed_mnth = sprintf( "%02d", $mnth + 1 ); - $ed_day = $day; - $et_hr = "23"; - $et_min = "59"; - $et_sec = "59"; - } - else { - $sd_yr = $params->{sd_yr}; - $sd_mnth = sprintf( "%02d", param('sd_mnth') + 1 ); - $sd_day = sprintf( "%02d", param('sd_day') ); - $st_hr = sprintf( "%02d", param('st_hr') ); - $st_min = sprintf( "%02d", param('st_min') ); - $st_sec = sprintf( "%02d", param('st_sec') ); - $ed_yr = param('ed_yr'); - $ed_mnth = sprintf( "%02d", param('ed_mnth') + 1 ); - $ed_day = sprintf( "%02d", param('ed_day') ); - $et_hr = sprintf( "%02d", param('et_hr') ); - $et_min = sprintf( "%02d", param('et_min') ); - $et_sec = sprintf( "%02d", param('et_sec') ); - } - $body .= - "<form method=get><input type=hidden name=mode value=\"" - . param('mode') - . "\"><table class=\"default\" width=100%>" - . "<tr><td width=50%>" - . gettext("Start date:") - . "</td><td><input type=text name=sd_yr value=\"$sd_yr\" size=5><select name=sd_mnth>"; - for ( $id = 0 ; $id < 12 ; $id++ ) { - if ( $id == ( $sd_mnth - 1 ) ) { - $body .= "<option value=$id selected>$months[$id]"; - } - else { - $body .= "<option value=$id>$months[$id]"; - } - } - $body .= - "</select><input type=text name=sd_day value=\"$sd_day\" size=3>" - . "</td></tr> -<tr><td>" - . gettext("Start time:") - . "</td><td><input type=text name=st_hr value=\"$st_hr\" size=3>" - . "<input type=text name=st_min value=\"$st_min\" size=3>" - . "<input type=text name=st_sec value=\"$st_sec\" size=3></td></tr> -" - . "<tr><td>" - . gettext("End date:") - . "</td><td><input type=text name=ed_yr value=\"$ed_yr\" size=5><select name=ed_mnth>"; - for ( $id = 0 ; $id < 12 ; $id++ ) { - if ( $id == ( $ed_mnth - 1 ) ) { - $body .= "<option value=$id selected>$months[$id]"; - } - else { - $body .= "<option value=$id>$months[$id]"; - } - } - $body .= - "</select><input type=text name=ed_day value=\"$ed_day\" size=3></td></tr> -" - . "<tr><td>" - . gettext("End time:") - . "</td><td><input type=text name=et_hr value=\"$et_hr\" size=3>" - . "<input type=text name=et_min value=\"$et_min\" size=3>" - . "<input type=text name=et_sec value=\"$et_sec\" size=3></td></tr> -" - . "<tr><td>" . gettext("Answered Calls Only?") + + $body = "<tr><td>" . gettext("Answered Calls Only?") . popup_menu( -name => "answered", -values => \%yesno @@ -1032,20 +1266,19 @@ -width => 8 ); } - $body .= "</td></tr> -" . "<tr><td>" . gettext("Select Outbound Trunk?") - . popup_menu( - -name => "trunk", - -values => \@trunklist - ) - . "</td></tr> -" - . "<tr><td align=center colspan=2><input type=submit value=Filter!></td></tr> -" - . "</table> -</form>"; - my $sd = "$sd_yr-$sd_mnth-$sd_day $st_hr:$st_min:$st_sec"; - my $ed = "$ed_yr-$ed_mnth-$ed_day $et_hr:$et_min:$et_sec"; + $body .= "</td></tr>" + . "<tr><td>" . gettext("Select Outbound Trunk?") + . popup_menu( + -name => "trunk", + -values => \@trunklist + ) + . "</td></tr>"; + + my $filter = build_filter($body,undef); + my $sd = $filter->{'start_date'}; + my $ed = $filter->{'end_date'}; + $body = $filter->{'form_body'}; + $body .= start_form() . "<table class=\"viewcdrs\" width=100%><tr><td colspan=5 align=center><b>$sd - $ed</b></td></tr> @@ -1164,31 +1397,20 @@ \n"; } $sql->finish; - $sd_month = $sd_mnth - 1; + $filter{'start_month'} = $filter{'start_month'} - 1; $string = - "&sd_yr=" . $sd_yr - . "&sd_mnth=" - . $sd_month - . "&sd_day=" - . $sd_day - . "&st_hr=" - . $st_hr - . "&st_min=" - . $st_min - . "&st_sec=" - . $st_sec - . "&ed_yr=" - . $ed_yr - . "&ed_mnth=" - . $ed_mnth - . "&ed_day=" - . $ed_day - . "&et_hr=" - . $et_hr - . "&et_min=" - . $et_min - . "&et_sec=" - . $et_sec + "&start_year=" . $filter{'start_year'} + . "&start_month=" . $filter{'start_month'} + . "&start_day=" . $filter{'start_day'} + . "&start_hour=" . $filter{'start_hour'} + . "&start_minute=". $filter{'start_minute'} + . "&start_second=". $filter{'start_second'} + . "&end_year=" . $filter{'end_year'} + . "&end_month=" . $filter{'end_month'} + . "&end_day=" . $filter{'end_day'} + . "&end_hour=" . $filter{'end_hour'} + . "&end_minute=" . $filter{'end_minute'} + . "&end_second=" . $filter{'end_second'} . "&trunk=" . $params->{trunk}; for ( my $i = 0 ; $i <= $pagesrequired - 1 ; $i++ ) { @@ -3426,7 +3648,7 @@ $body .= "</td><td>$cardstat" . "</td></tr>\n"; } $body .= "</table><table><tr><td>"; - if ( $total_entries => 1 ) { + if ( $total_entries >= 1 ) { $body .= "<a href=\"astpp-admin.cgi?mode=" . gettext("List Cards") . "&ve=" @@ -8053,7 +8275,7 @@ $row{seconds} = $counterinfo->{seconds}; push( @counter_list, $counterinfo ); } - if ( $total_entries => 1 ) + if ( $total_entries >= 1 ) { #This section only applies if we have more than 1 page. $pagination = "<a href=\"astpp-admin.cgi?mode=" @@ -11585,7 +11807,8 @@ @modes = ( gettext("Accounts"), gettext("Rates"), gettext("DIDs"), gettext("Logout"), - gettext("Call Shops"), gettext("Home") + gettext("Call Shops"), gettext("Home"), + gettext("Reseller Reports") ); @Accounts = ( gettext("Create Account"), gettext("Process Payment"), @@ -11613,7 +11836,8 @@ @modes = ( gettext("Accounts"), gettext("Rates"), gettext("DIDs"), gettext("Statistics"), - gettext("System"), gettext("Home") + gettext("System"), gettext("Home"), + gettext("Admin Reports") ); if ( $config->{enablelcr} == 1 ) { push @modes, gettext("LCR"); @@ -11678,7 +11902,7 @@ print STDERR "ASTPP CALLSHOP LOGIN\n" if $config->{debug} == 1; @modes = ( gettext("Booths"), gettext("Home"), - gettext("Routes"), gettext("Pricelists") + gettext("Routes"), gettext("Pricelists"), gettext("CallShop Reports") ); if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-09-19 01:37:31
|
Revision: 2127 http://astpp.svn.sourceforge.net/astpp/?rev=2127&view=rev Author: darrenkw Date: 2007-09-18 18:37:31 -0700 (Tue, 18 Sep 2007) Log Message: ----------- 1. Removed the old "enh-config" support as this is no longer needed. 2. Added support to refill regular accounts with a calling card. Modified Paths: -------------- trunk/Makefile trunk/astpp-admin.cgi trunk/astpp-ani-map.agi trunk/astpp-authorize.agi trunk/astpp-auto-admin.cgi trunk/astpp-callback-register.agi trunk/astpp-callback.agi trunk/astpp-callback.cgi trunk/astpp-callingcards-daily.pl trunk/astpp-callingcards.agi trunk/astpp-common.pl trunk/astpp-device-monitor.pl trunk/astpp-did-map.agi trunk/astpp-email-incoming.pl trunk/astpp-generate-invoices.pl trunk/astpp-ip-map.agi trunk/astpp-lcr.agi trunk/astpp-low-balance.pl trunk/astpp-manager-variables.agi trunk/astpp-pricelist.cgi trunk/astpp-rate-engine.pl trunk/astpp-refill.agi trunk/astpp-refill.cgi trunk/astpp-update-balance.pl trunk/astpp-users.cgi Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/Makefile 2007-09-19 01:37:31 UTC (rev 2127) @@ -42,9 +42,9 @@ install -m 644 -o $(OWNER) -g $(GROUP) style.css $(DESTDIR)$(WWWDIR)/html/_astpp/ install -m 644 -o $(OWNER) -g $(GROUP) menu.js $(DESTDIR)$(WWWDIR)/html/_astpp/ # Install Sample Configuration Files - install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.reseller-config.conf $(DESTDIR)$(ASTPPDIR)/sample.reseller-config.conf +# install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.reseller-config.conf $(DESTDIR)$(ASTPPDIR)/sample.reseller-config.conf install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-config.conf $(DESTDIR)$(ASTPPDIR)/sample.astpp-config.conf - install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-enh-config.conf $(DESTDIR)$(ASTPPDIR)/sample.astpp-enh-config.conf +# install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-enh-config.conf $(DESTDIR)$(ASTPPDIR)/sample.astpp-enh-config.conf install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-dialplan.conf $(DESTDIR)$(ASTERISKDIR)/sample.astpp-dialplan.conf install_samples: Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/astpp-admin.cgi 2007-09-19 01:37:31 UTC (rev 2127) @@ -58,7 +58,7 @@ print STDERR "Interface language is set to: " . $ENV{LANGUAGE} . "\n"; bindtextdomain( "astpp", "/usr/local/share/locale" ); textdomain("astpp"); -use vars qw(@output $astpp_db $params $enh_config +use vars qw(@output $astpp_db $params $config $status $config $limit $accountinfo $freepbx_db $rt_db $openser_db); my $starttime = [gettimeofday]; @@ -142,7 +142,7 @@ my @timezones = DateTime::TimeZone->all_names; @timezones = sort(@timezones); my ( - $rt_db, $astpp_db, $config, $enh_config, $params, + $rt_db, $astpp_db, $config, $config, $params, $param, $cdr_db, $agile_db, $body, $menu, $status, $msg, $loginstat, @modes, $openser_db ); @@ -185,7 +185,7 @@ $accountinfo = &get_account( $astpp_db, $params->{username} ); $params->{logintype} = $accountinfo->{type}; } - if ( !$params->{username} && $enh_config->{auth} eq $params->{password} ) { + if ( !$params->{username} && $config->{auth} eq $params->{password} ) { $status .= gettext("Successful Login!") . "<br>"; $count = 1; print header( -cookie => [ $cookie, $cookie1 ] ); @@ -205,7 +205,7 @@ if $config->{debug} == 1; print STDERR gettext("ASTPP-PASS:") . " $params->{password}\n" if $config->{debug} == 1; - print STDERR gettext("ASTPP-AUTHCODE:") . " $enh_config->{auth}\n" + print STDERR gettext("ASTPP-AUTHCODE:") . " $config->{auth}\n" if $config->{debug} == 1; print STDERR gettext("ASTPP-USER-COUNT:") . " $count" if $config->{debug} == 1; @@ -239,7 +239,7 @@ $params->{logintype} = $accountinfo->{type}; } } - if ( !$params->{username} && $enh_config->{auth} eq $params->{password} ) { + if ( !$params->{username} && $config->{auth} eq $params->{password} ) { $count = 1; $params->{logintype} = 2; } @@ -257,7 +257,7 @@ if $config->{debug} == 1 && $params->{username}; print STDERR gettext("ASTPP-PASS:") . " $params->{password}\n" if $config->{debug} == 1 && $params->{password}; - print STDERR gettext("ASTPP-AUTHCODE:") . " $enh_config->{auth}\n" + print STDERR gettext("ASTPP-AUTHCODE:") . " $config->{auth}\n" if $config->{debug} == 1; print STDERR gettext("ASTPP-USER-COUNT:") . " $count" if $config->{debug} == 1; @@ -651,7 +651,7 @@ sub build_reporting() { my ($body); return gettext("ASTPP Database Not Available!") . "<br>" unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + $cdr_db = &cdr_connect_db( $config, @output ); return gettext("Asterisk CDR Database Not Available!") . "<br>" unless $cdr_db; @@ -699,7 +699,7 @@ my ( $body, $id ); return gettext("Cannot display stats until database is configured") unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + $cdr_db = &cdr_connect_db( $config, @output ); return gettext("Cannot display stats until database is configured") unless $cdr_db; my ( undef, undef, undef, $day, $mnth, $yr ) = localtime(); @@ -919,11 +919,11 @@ ); return gettext("Cannot display stats until database is configured") unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + $cdr_db = &cdr_connect_db( $config, @output ); return gettext("Cannot display stats until database is configured") unless $cdr_db; if ( $params->{limit} < 1 || !$params->{limit} ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } my ( undef, undef, undef, $day, $mnth, $yr ) = localtime(); @@ -1341,7 +1341,7 @@ return gettext("Cannot view account until pricelists configured") unless @pricelists; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - $results_per_page = $enh_config->{results_per_page}; + $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( $params->{logintype} == 1 || $params->{logintype} == 5 @@ -1451,7 +1451,7 @@ $number = $params->{numberlist}; } $status .= - &remove_did( $astpp_db, $config, $enh_config, $params->{DID}, + &remove_did( $astpp_db, $config, $params->{DID}, $number ); $params->{action} = gettext("Information..."); } @@ -1463,7 +1463,7 @@ $number = $params->{numberlist}; } $status .= - &purchase_did( $astpp_db, $config, $enh_config, $params->{did_list}, + &purchase_did( $astpp_db, $config, $params->{did_list}, $number ); $params->{action} = gettext("Information..."); } @@ -2181,14 +2181,14 @@ } sub generatecallingcards() { - my ( $params, $config, $enh_config ) = @_; + my ( $params, $config ) = @_; my ( $status, $description, $pricelistdata, $number, $count ); $status = ""; $description = gettext("Account Setup"); $count = 0; if ( $config->{email} eq "YES" ) { - open( EMAIL, "| $enh_config->{mailprog} -t" ) - || die "Error - could not write to $enh_config->{mailprog}\n"; + open( EMAIL, "| $config->{mailprog} -t" ) + || die "Error - could not write to $config->{mailprog}\n"; print EMAIL"From: $config->{company_email}\n"; print EMAIL "Subject: $config->{company_name} New Account Created\n"; print EMAIL"To: $config->{emailadd}\n"; @@ -2200,7 +2200,7 @@ print STDERR "BRAND: $params->{brand}\n" if $config->{debug} == 1; while ( $count < $params->{count} ) { my ( $number, $pin ) = - &add_callingcard( $astpp_db, $config, $enh_config, $brandinfo, + &add_callingcard( $astpp_db, $config, $config, $brandinfo, $params->{status}, $params->{value} * 100, $params->{account}, $brandinfo->{pin} ); $count++; @@ -2218,26 +2218,26 @@ } sub generate_accounts() { - my ( $params, $config, $enh_config ) = @_; + my ( $params, $config ) = @_; my ( $status, $description, $pricelistdata, $cardlist ); $description = gettext("Account Setup"); $cardlist = &get_account_including_closed( $astpp_db, $params->{number} ); if ( !$cardlist->{number} ) { - &addaccount( $astpp_db, $config, $enh_config, $params ); + &addaccount( $astpp_db, $config, $params ); if ( $params->{accounttype} == 1 ) { &add_pricelist( $astpp_db, $params->{number}, 6, 0, $params->{number} ); - &add_reseller( $astpp_db, $config, $enh_config, $params->{number}, + &add_reseller( $astpp_db, $config, $params->{number}, $params->{posttoexternal} ); } if ( $params->{accounttype} == 5 ) { &add_pricelist( $astpp_db, $params->{number}, 6, 0, $params->{number} ); - &add_reseller( $astpp_db, $config, $enh_config, $params->{number}, + &add_reseller( $astpp_db, $config, $params->{number}, $params->{posttoexternal} ); } if ( $config->{email} == 1 && $params->{accounttype} == 0 ) { - &email_add_user( $astpp_db, '', $config, $params, $enh_config ); + &email_add_user( $astpp_db, '', $config, $params ); } my $timestamp = &prettytimestamp; $astpp_db->do( @@ -2283,7 +2283,7 @@ } if ( $config->{email} == 1 ) { &email_reactivate_account( $astpp_db, '', $config, $params, - $enh_config ); + ); } } else { @@ -2319,30 +2319,30 @@ $params->{count} = 1; $params->{pennies} = 0; $params->{number} = $params->{customnum}; - $status .= &generate_accounts( $params, $config, $enh_config ); + $status .= &generate_accounts( $params, $config ); my $accountinfo = &get_account( $astpp_db, $params->{number} ); ### Here we add support to add IAX and SIP devices at account creation. if ( $params->{SIP} ) { - $enh_config->{rt_sip_type} = $params->{devicetype}; + $config->{rt_sip_type} = $params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $name = &finduniquesip_rt( $params->{number} ); $status .= &add_sip_user_rt( $rt_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} ); $status .= "<br>"; } - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { my $name = - &finduniquesip_freepbx( $freepbx_db, $config, $enh_config, + &finduniquesip_freepbx( $freepbx_db, $config, $params->{number} ); $status .= &add_sip_user_freepbx( $freepbx_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} @@ -2352,7 +2352,7 @@ if ( $config->{openser} == 1 ) { $status .= $status .= &add_sip_user_openser( $openser_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params ); @@ -2360,26 +2360,26 @@ } } if ( $params->{IAX2} ) { - $enh_config->{rt_iax_type} = $params->{devicetype}; + $config->{rt_iax_type} = $params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { my $name = - &finduniqueiax_freepbx( $freepbx_db, $config, $enh_config, + &finduniqueiax_freepbx( $freepbx_db, $config, $params->{number} ); $status .= &add_iax_user_freepbx( $freepbx_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} ); $status .= "<br>"; } - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $name = &finduniqueiax_rt( $params->{number} ); $status .= &add_iax_user_rt( $rt_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} @@ -2455,7 +2455,7 @@ return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0; } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); } @@ -2953,7 +2953,7 @@ elsif ( $params->{status} eq gettext("DELETED") ) { $params->{status} = 2; } - $status .= &generatecallingcards( $params, $config, $enh_config ); + $status .= &generatecallingcards( $params, $config ); } $body = start_multipart_form; $body .= "<table class=\"default\">"; @@ -3289,7 +3289,7 @@ my $inactive = gettext("INACTIVE"); my $deleted = gettext("DELETED"); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; - $results_per_page = $enh_config->{results_per_page}; + $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } $body = "<table class=\"default\"><tr class=\"header\"><td>"; $body .= @@ -3879,11 +3879,11 @@ sub build_list_errors() { my ( $results, $body, $status, $count, $pageno, $pagesrequired ); $count = 0; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); + $cdr_db = &cdr_connect_db( $config, @output ); return gettext("Cannot list errors until database is configured!") . "\n" unless $cdr_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } my $sql = $cdr_db->prepare( "SELECT * FROM cdr WHERE cost = 'error' OR " @@ -4698,7 +4698,7 @@ return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { @@ -5629,7 +5629,7 @@ my ( $sql, $record, $valid, $count, $tmp, $pagesrequired, $pageno ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -6018,7 +6018,7 @@ @providerlist ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -6838,7 +6838,7 @@ @providerlist ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -7486,7 +7486,7 @@ } return gettext("Pricelists Do NOT Exist!") . "\n" unless @pricelists; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { @@ -7987,7 +7987,7 @@ my $template = HTML::Template->new( filename => '/var/lib/astpp/templates/counters-list.tpl' ); - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" || $results_per_page < 2 ) { $results_per_page = 25; } @@ -8085,7 +8085,7 @@ my ( $sql, $record, $count, $tmp, $pageno, $pagesrequired ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -8377,7 +8377,7 @@ my @providerlist = &list_providers($astpp_db); return gettext("No Providers Exist!") . "\n" unless @providerlist; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { @@ -8733,7 +8733,7 @@ $count++; $body .= "<td>$trunkinfo->{name}" . "</td><td>$trunkinfo->{tech}"; if ( $trunkinfo->{tech} eq "SIP" - && $enh_config->{users_dids_rt} == 1 ) + && $config->{users_dids_rt} == 1 ) { $body .= "</td><td><a href=\"astpp-admin.cgi?mode=" @@ -8817,7 +8817,7 @@ my ( $sql, $record, $count, $tmp, $pageno, $pagesrequired ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -8830,7 +8830,7 @@ $params->{count} = 1; $params->{pennies} = 0; $params->{number} = $params->{customnum}; - $status .= &generate_accounts( $params, $config, $enh_config ); + $status .= &generate_accounts( $params, $config ); $params->{action} = gettext("Information..."); } if ( $params->{action} eq gettext("Information...") ) { @@ -8944,7 +8944,7 @@ @trunklist ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); @@ -9597,24 +9597,20 @@ sub initialize() { $config = &load_config(); $status .= gettext("Main Configuration Unavailable!") unless $config; - $enh_config = &load_config_enh(); - $status .= gettext("Enhanced Configuration Unavailable!") - unless $enh_config; - $astpp_db = &connect_db( $config, $enh_config, @output ); + $astpp_db = &connect_db( $config, @output ); $status .= gettext("ASTPP Database Unavailable!") unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); - $status .= gettext("Asterisk CDR Database Unavailable!") unless $cdr_db; $config = &load_config_db( $astpp_db, $config ) if $astpp_db; - $enh_config = &load_config_enh_db( $astpp_db, $enh_config ); + $cdr_db = &cdr_connect_db( $config, @output ); + $status .= gettext("Asterisk CDR Database Unavailable!") unless $cdr_db; if ( $config->{enablelcr} == 1 ) { push @modes, gettext("LCR"); } - if ( $enh_config->{users_dids_rt} == 1 ) { - $rt_db = &rt_connect_db( $config, $enh_config, @output ); + if ( $config->{users_dids_rt} == 1 ) { + $rt_db = &rt_connect_db( $config, @output ); push @modes, gettext("Switch Config"); } - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @modes = sort @modes; @@ -9630,7 +9626,7 @@ my ( $deviceinfo, $sql ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); } @@ -9642,17 +9638,17 @@ $number = param('numberlist'); } my $name = &finduniquesip_rt($number); - $enh_config->{rt_sip_type} = $params->{devicetype}; + $config->{rt_sip_type} = $params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { $status .= - &add_sip_user_rt( $rt_db, $config, $enh_config, $name, + &add_sip_user_rt( $rt_db, $config, $name, $params->{secret}, $params->{context}, $number, $params ); $status .= "<br>"; } if ( $config->{openser} == 1 ) { $status .= - &add_sip_user_openser( $openser_db, $config, $enh_config, $name, + &add_sip_user_openser( $openser_db, $config, $name, $params->{secret}, $params->{context}, $number, $params ); $status .= "<br>"; } @@ -9661,7 +9657,7 @@ elsif ( $params->{action} eq gettext("Delete...") ) { if ( &del_sip_user_rt( - $rt_db, $config, $enh_config, $params->{devicename} + $rt_db, $config, $params->{devicename} ) ) { @@ -9678,7 +9674,7 @@ } elsif ( $params->{action} eq gettext("Save...") ) { my $tmp = - "UPDATE $enh_config->{rt_sip_table} SET" + "UPDATE $config->{rt_sip_table} SET" . " callerid=" . $rt_db->quote( $params->{clid} ) . ", " . " accountcode=" @@ -9703,7 +9699,7 @@ . " secret=" . $rt_db->quote( $params->{secret} ) . ", " . " type=" - . $rt_db->quote( $enh_config->{rt_sip_type} ) . ", " + . $rt_db->quote( $config->{rt_sip_type} ) . ", " . " name=" . $rt_db->quote( $params->{name} ) . ", " . " username=" @@ -9763,7 +9759,7 @@ . popup_menu( -name => "devicetype", -values => \@devicetypes, - -default => $enh_config->{rt_sip_type} + -default => $config->{rt_sip_type} ) . "</td><td>" . textfield( @@ -9782,7 +9778,7 @@ my @accountlist = &list_accounts($astpp_db); $sql = $rt_db->prepare( - "SELECT * FROM $enh_config->{rt_sip_table} WHERE name = " + "SELECT * FROM $config->{rt_sip_table} WHERE name = " . $rt_db->quote( $params->{devicename} ) ); $sql->execute || return gettext("Something is wrong with the SIP users database!") @@ -9982,7 +9978,7 @@ . gettext("Action") . "</td></tr> "; - my $tmp = "SELECT name FROM " . $enh_config->{rt_sip_table}; + my $tmp = "SELECT name FROM " . $config->{rt_sip_table}; $sql = $rt_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the SIP users database!") @@ -9994,7 +9990,7 @@ $sql->finish; $sql = $rt_db->prepare( -"SELECT * FROM $enh_config->{rt_sip_table} ORDER BY accountcode limit $params->{limit} , $results_per_page" +"SELECT * FROM $config->{rt_sip_table} ORDER BY accountcode limit $params->{limit} , $results_per_page" ); $sql->execute || return gettext("Something is wrong with the SIP users database!") @@ -10095,7 +10091,7 @@ print STDERR "SIPID: $sipid\n" if $config->{debug} == 1; $sql = $rt_db->prepare( - "SELECT COUNT(*) FROM $enh_config->{rt_sip_table} WHERE name = " + "SELECT COUNT(*) FROM $config->{rt_sip_table} WHERE name = " . $rt_db->quote($sipid) ); $sql->execute; $record = $sql->fetchrow_hashref; @@ -10113,7 +10109,7 @@ my ( $deviceinfo, $sql ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $enh_config->{results_per_page}; + my $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); } @@ -10125,17 +10121,17 @@ $number = param('numberlist'); } my $name = &finduniqueiax_rt($number); - $enh_config->{rt_iax_type} = $params->{devicetype}; + $config->{rt_iax_type} = $params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; $status .= - &add_iax_user_rt( $rt_db, $config, $enh_config, $name, + &add_iax_user_rt( $rt_db, $config, $name, $params->{secret}, $params->{context}, $number, $params ); $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Delete...") ) { if ( &del_sip_user_rt( - $rt_db, $config, $enh_config, $params->{devicename} + $rt_db, $config, $params->{devicename} ) ) { @@ -10149,7 +10145,7 @@ } elsif ( $params->{action} eq gettext("Save...") ) { my $tmp = - "UPDATE $enh_config->{rt_iax_table} SET" + "UPDATE $config->{rt_iax_table} SET" . " callerid=" . $rt_db->quote( $params->{clid} ) . ", " . " accountcode=" @@ -10228,7 +10224,7 @@ . popup_menu( -name => "devicetype", -values => \@devicetypes, - -default => $enh_config->{rt_iax_type} + -default => $config->{rt_iax_type} ) . "</td><td>" . textfield( @@ -10247,7 +10243,7 @@ my @accountlist = &list_accounts($astpp_db); $sql = $rt_db->prepare( - "SELECT * FROM $enh_config->{rt_iax_table} WHERE name = " + "SELECT * FROM $config->{rt_iax_table} WHERE name = " . $rt_db->quote( $params->{devicename} ) ); $sql->execute || return gettext("Something is wrong with the IAX users database!") @@ -10413,7 +10409,7 @@ . gettext("Action") . "</td></tr> "; - my $tmp = "SELECT name FROM " . $enh_config->{rt_iax_table}; + my $tmp = "SELECT name FROM " . $config->{rt_iax_table}; $sql = $rt_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the IAX users database!") @@ -10425,7 +10421,7 @@ $sql->finish; $sql = $rt_db->prepare( -"SELECT * FROM $enh_config->{rt_iax_table} ORDER BY accountcode limit $params->{limit} , $results_per_page" +"SELECT * FROM $config->{rt_iax_table} ORDER BY accountcode limit $params->{limit} , $results_per_page" ); $sql->execute || return gettext("Something is wrong with the IAX users database!") @@ -10523,7 +10519,7 @@ print STDERR "IAXID: $iaxid\n" if $config->{debug} == 1; $sql = $rt_db->prepare( - "SELECT COUNT(*) FROM $enh_config->{rt_iax_table} WHERE name = " + "SELECT COUNT(*) FROM $config->{rt_iax_table} WHERE name = " . $rt_db->quote($iaxid) ); $sql->execute; $record = $sql->fetchrow_hashref; @@ -10541,13 +10537,13 @@ ); return gettext("Database is NOT configured!") . "\n" unless $astpp_db; if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - $results_per_page = $enh_config->{results_per_page}; + $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } if ( !$params->{action} ) { $params->{action} = gettext("Information..."); } if ( $params->{action} eq gettext("Insert...") ) { my $tmp = - "INSERT INTO $enh_config->{rt_extensions_table} (context," + "INSERT INTO $config->{rt_extensions_table} (context," . "exten,priority,app,appdata) VALUES (" . $rt_db->quote( $params->{context} ) . ", " . $rt_db->quote( $params->{exten} ) . ", " @@ -10568,7 +10564,7 @@ } elsif ( $params->{action} eq gettext("Delete...") ) { my $tmp = - "DELETE FROM $enh_config->{rt_extensions_table} WHERE " . "id = " + "DELETE FROM $config->{rt_extensions_table} WHERE " . "id = " . $rt_db->quote( $params->{id} ); if ( $rt_db->do($tmp) ) { $status .= @@ -10581,7 +10577,7 @@ } elsif ( $params->{action} eq gettext("Save...") ) { my $tmp = - "UPDATE $enh_config->{rt_extensions_table} SET" + "UPDATE $config->{rt_extensions_table} SET" . " context=" . $rt_db->quote( $params->{context} ) . ", " . " exten=" @@ -10657,7 +10653,7 @@ elsif ( $params->{action} eq gettext("Edit...") ) { $sql = $rt_db->prepare( - "SELECT * FROM $enh_config->{rt_extensions_table} WHERE id = " + "SELECT * FROM $config->{rt_extensions_table} WHERE id = " . $rt_db->quote( $params->{id} ) ); $sql->execute || return gettext("Something is wrong with the dialplan database!") @@ -10749,7 +10745,7 @@ . gettext("Action") . "</td></tr> "; - my $tmp = "SELECT id FROM " . $enh_config->{rt_extensions_table}; + my $tmp = "SELECT id FROM " . $config->{rt_extensions_table}; $sql = $rt_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the SIP users database!") @@ -10761,7 +10757,7 @@ $sql->finish; $sql = $rt_db->prepare( -"SELECT * FROM $enh_config->{rt_extensions_table} ORDER BY context, exten, priority " +"SELECT * FROM $config->{rt_extensions_table} ORDER BY context, exten, priority " . "limit $params->{limit} , $results_per_page" ); $sql->execute || return gettext("Something is wrong with the dialplan database!") @@ -10852,7 +10848,7 @@ } $params->{accounttype} = 5; $params->{number} = $params->{callshop_name}; - $status .= &generate_accounts( $params, $config, $enh_config ); + $status .= &generate_accounts( $params, $config ); my $callshop_data = $astpp_db->do( "SELECT * FROM callshops WHERE name = " . $astpp_db->quote( $params->{callshop_name} ) ); @@ -10983,33 +10979,33 @@ $status .= gettext("No Reseller Name Set! Error!"); } elsif ( $params->{action} eq gettext("Generate Booth") ) { - $status .= &generate_accounts( $params, $config, $enh_config ); + $status .= &generate_accounts( $params, $config ); my $accountinfo = &get_account( $astpp_db, $params->{number} ); $astpp_db->do( "UPDATE cdrs SET status = 1 WHERE cardnum = " . $astpp_db->quote( $params->{number} ) . " LIMIT 1" ); if ( $params->{SIP} ) { print STDERR gettext("Adding SIP Device!") if $config->{debug} == 1; - $enh_config->{rt_sip_type} = "friend"; #$params->{devicetype}; + $config->{rt_sip_type} = "friend"; #$params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $name = &finduniquesip_rt( $params->{number} ); $status .= &add_sip_user_rt( $rt_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} ); $status .= "<br>"; } - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { my $name = - &finduniquesip_freepbx( $freepbx_db, $config, $enh_config, + &finduniquesip_freepbx( $freepbx_db, $config, $params->{number} ); &add_sip_user_freepbx( $freepbx_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} @@ -11019,7 +11015,7 @@ if ( $config->{openser} == 1 ) { $status .= &add_sip_user_openser( $openser_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params ); @@ -11029,26 +11025,26 @@ if ( $params->{IAX2} ) { print STDERR gettext("Adding IAX2 Device!") if $config->{debug} == 1; - $enh_config->{rt_iax_type} = "friend"; #$params->{devicetype}; + $config->{rt_iax_type} = "friend"; #$params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { my $name = - &finduniqueiax_freepbx( $freepbx_db, $config, $enh_config, + &finduniqueiax_freepbx( $freepbx_db, $config, $config, $params->{number} ); $status .= &add_iax_user_freepbx( $freepbx_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} ); $status .= "<br>"; } - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $name = &finduniqueiax_rt( $params->{number} ); $status .= &add_iax_user_rt( $rt_db, $config, - $enh_config, $name, + $name, $params->{accountpassword}, $params->{context}, $params->{number}, $params, $accountinfo->{cc} @@ -11166,49 +11162,49 @@ #If this account doesn't exist we don't go through the rest if ( $accountinfo->{number} ) { - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { print STDERR "NUMBER: $accountinfo->{number} CC: $accountinfo->{cc}" if $config->{debug} == 1; my @iax_devicelist = - &list_iax_account_rt( $rt_db, $config, $enh_config, + &list_iax_account_rt( $rt_db, $config, $accountinfo->{number}, $accountinfo->{cc} ); foreach my $name (@iax_devicelist) { - &del_iax_user_rt( $rt_db, $config, $enh_config, $name ); + &del_iax_user_rt( $rt_db, $config, $name ); $status .= gettext("Removing IAX device:") . " " . $name . "<br>"; } my @sip_devicelist = - &list_sip_account_rt( $rt_db, $config, $enh_config, + &list_sip_account_rt( $rt_db, $config, $accountinfo->{number}, $accountinfo->{cc} ); foreach my $name (@sip_devicelist) { - &del_sip_user_rt( $rt_db, $config, $enh_config, $name ); + &del_sip_user_rt( $rt_db, $config, $name ); $status .= gettext("Removing SIP device:") . " " . $name . "<br>"; } } - if ( $enh_config->{users_dids_amp} == 1 ) { + if ( $config->{users_dids_amp} == 1 ) { print STDERR "NUMBER: $accountinfo->{number} CC: $accountinfo->{cc}" if $config->{debug} == 1; my @iax_devicelist = - &list_iax_account_amp( $freepbx_db, $config, $enh_config, + &list_iax_account_amp( $freepbx_db, $config, $accountinfo->{number}, $accountinfo->{cc} ); foreach my $name (@iax_devicelist) { - &del_iax_user_rt( $freepbx_db, $config, $enh_config, + &del_iax_user_rt( $freepbx_db, $config, $name ); $status .= gettext("Removing IAX device:") . " " . $name . "<br>"; } my @sip_devicelist = - &list_sip_account_amp( $freepbx_db, $config, $enh_config, + &list_sip_account_amp( $freepbx_db, $config, $accountinfo->{number}, $accountinfo->{cc} ); foreach my $name (@sip_devicelist) { - &del_sip_user_rt( $freepbx_db, $config, $enh_config, + &del_sip_user_rt( $freepbx_db, $config, $name ); $status .= gettext("Removing SIP device:") . " " . $name . "<br>"; @@ -11259,10 +11255,10 @@ $row{call_count} = $record->{"COUNT(*)"}; $row{currency} = $boothinfo->{currency}; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $tmp = "SELECT name FROM " - . $enh_config->{rt_sip_table} + . $config->{rt_sip_table} . " WHERE accountcode = " . $rt_db->quote( $boothinfo->{cc} ) . " LIMIT 1"; @@ -11273,7 +11269,7 @@ $sql->finish; $tmp = "SELECT name FROM " - . $enh_config->{rt_iax_table} + . $config->{rt_iax_table} . " WHERE accountcode = " . $rt_db->quote( $boothinfo->{cc} ) . " LIMIT 1"; @@ -11408,19 +11404,19 @@ my $accountinfo = &get_account( $astpp_db, $params->{booth_name} ); my ( $invoiceno, $callshop_data ); $callshop_data = &get_callshop( $astpp_db, $accountinfo->{reseller} ); - $enh_config->{osc_db} = $callshop_data->{osc_dbname}; - $enh_config->{osc_user} = $callshop_data->{osc_dbuser}; - $enh_config->{osc_host} = $callshop_data->{osc_dbhost}; - $enh_config->{osc_pass} = $callshop_data->{osc_dbpass}; + $config->{osc_db} = $callshop_data->{osc_dbname}; + $config->{osc_user} = $callshop_data->{osc_dbuser}; + $config->{osc_host} = $callshop_data->{osc_dbhost}; + $config->{osc_pass} = $callshop_data->{osc_dbpass}; $params->{action} = gettext("View Booths"); - if ( $enh_config->{externalbill} eq "oscommerce" ) { + if ( $config->{externalbill} eq "oscommerce" ) { if ( $accountinfo->{posttoexternal} == 1 ) { print STDERR gettext("Connecting to OSCommerce."); - my $osc_db = &osc_connect_db( $config, $enh_config ); + my $osc_db = &osc_connect_db( $config ); print STDERR gettext("Generating Invoice"); $invoiceno = - &osc_charges( $astpp_db, $osc_db, $config, $enh_config, + &osc_charges( $astpp_db, $osc_db, $config, $params->{booth_name} ); } } @@ -11454,10 +11450,10 @@ } if ( $params->{action} eq gettext("View Booth") ) { my $accountinfo = &get_account( $astpp_db, $params->{booth_name} ); - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { my $tmp = "SELECT name,secret FROM " - . $enh_config->{rt_sip_table} + . $config->{rt_sip_table} . " WHERE accountcode = " . $rt_db->quote( $accountinfo->{cc} ) . " LIMIT 1"; @@ -11468,7 +11464,7 @@ $sql->finish; $tmp = "SELECT name,secret FROM " - . $enh_config->{rt_iax_table} + . $config->{rt_iax_table} . " WHERE accountcode = " . $rt_db->quote( $accountinfo->{cc} ) . " LIMIT 1"; @@ -11480,7 +11476,7 @@ } my @chargelist = &list_cdrs_account( $cdr_db, $accountinfo->{number}, $accountinfo->{cc} ); - &processlist( $astpp_db, $cdr_db, $enh_config, $config, @chargelist ) + &processlist( $astpp_db, $cdr_db, $config, @chargelist ) ; # Bill as many calls as we can. $status .= gettext("We rated as many CDRS as we could") . "<br>"; $tmp = @@ -11581,13 +11577,10 @@ # reload databases other than the astpp one. $config = &load_config_reseller_db( $astpp_db, $config, $params->{username} ); - $enh_config = - &load_config_reseller_db( $astpp_db, $enh_config, - $params->{username} ); - $freepbx_db = &freepbx_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_amp} == 1; - $rt_db = &rt_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_rt} == 1; + $freepbx_db = &freepbx_connect_db( $config, @output ) + if $config->{users_dids_amp} == 1; + $rt_db = &rt_connect_db( $config, @output ) + if $config->{users_dids_rt} == 1; print STDERR "ASTPP RESELLER LOGIN\n" if $config->{debug} == 1; @modes = ( gettext("Accounts"), gettext("Rates"), @@ -11605,7 +11598,7 @@ ); my @DIDs = ( gettext("Manage DIDs") ); - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @modes = sort @modes; @@ -11625,10 +11618,10 @@ if ( $config->{enablelcr} == 1 ) { push @modes, gettext("LCR"); } - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { push @modes, gettext("Switch Config"); } - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @@ -11660,7 +11653,7 @@ gettext("Accounts"), gettext("DIDs"), gettext("Statistics"), gettext("Home") ); - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @modes = sort @modes; @@ -11676,21 +11669,18 @@ elsif ( $params->{logintype} == 5 ) { # CallShop Login $config = &load_config_reseller_db( $astpp_db, $config, $params->{username} ); - $enh_config = - &load_config_reseller_db( $astpp_db, $enh_config, - $params->{username} ); - $freepbx_db = &freepbx_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_amp} == 1; - $rt_db = &rt_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_rt} == 1; - $osc_db = &osc_connect_db( $config, $enh_config, @output ) - if $enh_config->{externalbill} eq "oscommerce"; + $freepbx_db = &freepbx_connect_db( $config, @output ) + if $config->{users_dids_amp} == 1; + $rt_db = &rt_connect_db( $config, @output ) + if $config->{users_dids_rt} == 1; + $osc_db = &osc_connect_db( $config, $config, @output ) + if $config->{externalbill} eq "oscommerce"; print STDERR "ASTPP CALLSHOP LOGIN\n" if $config->{debug} == 1; @modes = ( gettext("Booths"), gettext("Home"), gettext("Routes"), gettext("Pricelists") ); - if ( $enh_config->{callingcards} == 1 ) { + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @modes = sort @modes; @@ -11710,7 +11700,7 @@ $body = &build_body( $params->{mode} ); $menu = &build_menu_ts( @modes, $params->{mode} ); $menu .= start_form; - if ( $enh_config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 ) { $status .= gettext("Realtime Database Unavailable!") unless $rt_db; } } Modified: trunk/astpp-ani-map.agi =================================================================== --- trunk/astpp-ani-map.agi 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/astpp-ani-map.agi 2007-09-19 01:37:31 UTC (rev 2127) @@ -19,7 +19,7 @@ use POSIX qw(ceil floor); use POSIX qw(strftime); use strict; -use vars qw(@output $verbose $SIG $astpp_db $config $enh_config $AGI); +use vars qw(@output $verbose $SIG $astpp_db $config $AGI); @output = ( "STDERR", "LOGFILE" ); $verbose = 2; require "/usr/local/astpp/astpp-common.pl"; @@ -28,10 +28,8 @@ sub initialize() { $SIG{HUP} = 'ignore_hup'; $config = &load_config(); - $enh_config = &load_config_enh(); - $astpp_db = &connect_db( $config, $enh_config, @output ); + $astpp_db = &connect_db( $config, @output ); $config = &load_config_db($astpp_db,$config); - $enh_config = &load_config_enh_db($astpp_db,$enh_config); } sub ignore_hup { Modified: trunk/astpp-authorize.agi =================================================================== --- trunk/astpp-authorize.agi 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/astpp-authorize.agi 2007-09-19 01:37:31 UTC (rev 2127) @@ -79,7 +79,7 @@ use DBI; use Asterisk::AGI; use strict; -use vars qw(@output $config $enh_config $astpp_db $verbosity $AGI); +use vars qw(@output $config $astpp_db $verbosity $AGI); use Locale::gettext_pp qw(:locale_h); require "/usr/local/astpp/astpp-common.pl"; $ENV{LANGUAGE} = "en"; # de, es, br - whatever @@ -96,10 +96,8 @@ $AGI->set_variable( 'ASTPP', '1' ); $AGI->verbose( "$accountcode, $phoneno", $verbosity ); $config = &load_config(); -$enh_config = &load_config_enh(); -$astpp_db = &connect_db( $config, $enh_config, @output ); +$astpp_db = &connect_db( $config, @output ); $config = &load_config_db($astpp_db,$config); -$enh_config = &load_config_enh_db($astpp_db,$enh_config); my $carddata = &get_account( $astpp_db, $accountcode ); # Fetch all the account info from the db. if ( !$carddata->{number} ) { # Check to see if the account exists. If not then exit. @@ -124,7 +122,7 @@ } print STDERR "\nFINDING LIMIT FOR: $carddata->{number}\n" if $config->{debug} == 1; -($callstatus, $maxlength) = &max_length($astpp_db, $config, $enh_config, $carddata, $phoneno); +($callstatus, $maxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist},$carddata ); print STDERR "Minimum Charge on call = $routeinfo->{cost}" if $config->{debug} == 1; my $minimumcharge = $routeinfo->{cost}; @@ -135,7 +133,7 @@ $carddata = &get_account( $astpp_db, $carddata->{reseller} ); push @reseller_list, $carddata->{number}; print STDERR "ADDING $carddata->{number} to the list of resellers for this account\n" if $config->{debug} == 1; - my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $enh_config, $carddata, $phoneno); + my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist},$carddata ); if ($resellercallstatus != 1) { $carddata->{reseller} = ""; Modified: trunk/astpp-auto-admin.cgi =================================================================== --- trunk/astpp-auto-admin.cgi 2007-09-09 02:41:23 UTC (rev 2126) +++ trunk/astpp-auto-admin.cgi 2007-09-19 01:37:31 UTC (rev 2127) @@ -105,7 +105,7 @@ use Asterisk::Manager; use lib './lib', '../lib'; use strict; -use vars qw($enh_config $config $astpp_db $agile_db $params @output +use vars qw($config $astpp_db $agile_db $params @output $rt_db $freepbx_db $status); require "/usr/local/astpp/astpp-common.pl"; $ENV{LANGUAGE} = "en"; # de, es, br - whatever @@ -161,8 +161,8 @@ $params->{sweep} = $sweep; $params->{credit_limit} = $creditlimit; $params->{password} = $password; - &addaccount( $astpp_db, $config, $enh_config, $params ); - &email_add_user($astpp_db,'', $config, $params, $enh_config); + &addaccount( $astpp_db, $config, $params ); + &email_add_user($astpp_db,'', $config, $params); } else { $astpp_db->do( "UPDATE accounts SET status = 1 WHERE number = " @@ -171,7 +171,7 @@ . $astpp_db->quote($customnum) . " WHERE number = " . $astpp_db->quote($customnum) ); - &email_refill_account($astpp_db,'', $config, $params, $enh_config); + &email_refill_account($astpp_db,'', $config, $params); } my $timestamp = &prettytimestamp; $astpp_db->do( @@ -188,16 +188,13 @@ sub initialize() { my ($reseller) = @_; $config = &load_config; - $enh_config = &load_config_enh; - $astpp_db = &connect_db( $config, $enh_config, @output ); + $astpp_db = &connect_db( $config, @output ); $config = &load_config_db($astpp_db,$config); - $enh_config = &load_config_enh_db($astpp_db,$enh_config); $config = &load_config_reseller_db($astpp_db,$config,$params->{username}) if ($reseller); - $enh_config = $config if ($reseller); - $freepbx_db = &freepbx_connect_db($config, $enh_config, @output) - if $enh_config->{users_dids_amp} == 1; - $rt_db = &rt_connect_db( $config, $enh_config, @output ) - if $enh_config->{users_dids_rt} == 1; + $freepbx_db = &freepbx_connect_db($config, @output) + if $config->{users_dids_amp} == 1; + $rt_db = &rt_connect_db( $config, @output ) + if $config->{users_dids_rt} == 1; } ############## Asterisk Manager Handling ############ sub astmanager_reload() { @@ -239,7 +236,7 @@ $params->{quantity} = 1; } if ( $params->{prepend} ne "" ) { - $enh_config->{service_prepend} = $params->{prepend}; + $config->{service_prepend} = $params->{prepend}; } if ( $params->{brand} ne "" ) { $config->{default_brand} = $params->{brand}; @@ -254,7 +251,7 @@ $params->{language} = $config->{language}; } # OSCommerce specific adjustments -if ($enh_config->{externalbill} eq "oscommerce") { +if ($config->{externalbill} eq "oscommerce") { $params->{service} = $params->{invoice}; $params->{email} = $params->{emailadd}; } @@ -270,14 +267,14 @@ . int( rand() * 9000 + 1000 ) . int( rand() * 9000 + 1000 ); } -if ( $enh_config->{service_prepend} eq "" ) { +if ( $config->{service_prepend} eq "" ) { my $passedlength = length( $params->{service} ); - my $requiredchars = $enh_config->{service_length} - $passedlength; - my $prepend = substr( $enh_config->{service_filler}, 0, $requiredchars ); + my $requiredchars = $config->{service_length} - $passedlength; + my $prepend = substr( $config->{service_filler}, 0, $requiredchars ); $params->{extension} = $prepend . $params->{service}; } else { - $params->{extension} = $enh_config->{service_prepend} . $params->{service}; + $params->{extension} = $config->{service_prepend} . $params->{service}; } # We use a random number 5 digis long for a password @@ -296,7 +293,7 @@ $config->{default_context} = $config_reseller->{default_context}; $config->{default_brand} = $config_reseller->{new_user_brand}; $params->{user} = $config_reseller->{account_prepend} . $params->{user}; - $enh_config->{auth} = $config_reseller->{auth}; + $config->{auth} = $config_reseller->{auth}; $config->{company_email} = $config_reseller->{company_name}; $config->{company_name} = $config_reseller->{company_name}; $config->{company_website} = $config_reseller->{company_website}; @@ -312,7 +309,7 @@ } ########## Check for the correct Auth Code########### -if ( $params->{auth} ne $enh_config->{auth} ) { +if ( $params->{auth} ne $config->{auth} ) { print STDERR gettext("INVALID AUTH KEY"); print "/n" . gettext("Received Authkey:") . "'" . $params->{auth} . "'"; exit(0); @@ -325,81 +322,82 @@ if ( $params->{function} eq "add_device" ) { while ( $count < $params->{quantity} ) { $count++; - if ($enh_config->{users_dids_rt} == 1) { - &add_sip_user_rt( $rt_db, $config, $enh_config, $params->{extension}, + if ($config->{users_dids_rt} == 1) { + &add_sip_user_rt( $rt_db, $config, $params->{extension}, $params->{secret}, $config->{default_context}, $params->{user}, $params ) if $params->{type} eq "SIP"; - &add_iax_user_rt( $rt_db, $config, $enh_config, + &add_iax_user_rt( $rt_db, $config, $params->{extension}, $params->{secret}, $config->{default_context}, $params->{user} ) if $params->{type} eq "IAX"; - } elsif ($enh_config->{users_dids_amp} == 1) { - &add_sip_user_freepbx( $freepbx_db, $config, $enh_config, $params->{extension}, + } elsif ($config->{users_dids_amp} == 1) { + &add_sip_user_freepbx( $freepbx_db, $config, $params->{extension}, $params->{secret}, $config->{default_context}, $params->{user}, $params ) if $params->{type} eq "SIP"; - &add_iax_user_freepbx($freepbx_db, $config, $enh_config, + &add_iax_user_freepbx($freepbx_db, $config, $params->{extension}, $params->{secret}, $config->{default_context}, $params->{user} ) if $params->{type} eq "IAX"; } - &email_add_user($astpp_db, '', $config, $params, $enh_config, $params->{type}, + &email_add_user($astpp_db, '', $config, $params, $params->{type}, $params->{secret}, $params->{extension} ) if $config->{user_email} == 1; } } elsif ( $params->{function} eq "unsuspend" ) { - if ($enh_config->{users_dids_rt} == 1) { - &update_context_sip_user_rt( $rt_db, $enh_config, $params->{extension}, + if ($config->{users_dids_rt} == 1) { + &update_context_sip_user_rt( $rt_db, $config, $params->{extension}, +i $config->{default_context} ) if $params->{type} eq "SIP"; - &update_context_iax_user_rt( $rt_db, $enh_config, $params->{extension}, + &update_context_iax_user_rt( $rt_db, $config, $params->{extension}, $config->{default_context} ) if $params->{type} eq "IAX"; - } elsif ($enh_config->{users_dids_amp} == 1) { - &update_context_sip_user_freepbx( $freepbx_db, $enh_config, $params->{extension}, + } elsif ($config->{users_dids_amp} == 1) { + &update_context_sip_user_freepbx( $freepbx_db, $config, $params->{extension}, $config->{default_context} ) if $params->{type} eq "SIP"; - &update_context_iax_user_freepbx( $freepbx_db, $enh_config, $params->{extension}, + &update_context_iax_user_freepbx( $freepbx_db, $config, $params->{extension}, $config->{default_context} ) if $params->{type} eq "IAX"; } } elsif ( $params->{function} eq "delete" ) { - if ($enh_config->{users_dids_rt} == 1) { - &del_sip_user_rt( $rt_db, $enh_config, $params->{extension} ) + if ($config->{users_dids_rt} == 1) { + &del_sip_user_rt( $rt_db, $config, $params->{extension} ) if $params->{type} eq "SIP"; - &del_iax_user_rt( $rt_db, $enh_config, $params->{extension} ) + &del_iax_user_rt( $rt_db, $config, $params->{extension} ) if $params->{type} eq "IAX"; - } elsif ($enh_config->{users_dids_amp} == 1) { - &del_sip_user_freepbx( $freepbx_db, $enh_config, $params->{extension} ) + } elsif ($config->{users_dids_amp} == 1) { + &del_sip_user_freepbx( $freepbx_db, $config, $params->{extension} ) if $params->{type} eq "SIP"; - &del_iax_user_freepbx( $freepbx_db, $enh_config, $params->{extension} ) + &del_iax_user_freepbx( $freepbx_db, $config, $params->{extension} ) if $params->{type} eq "IAX"; } - &email_del_user($astpp_db, '', $config, $params, $enh_config ) + &email_del_user($astpp_db, '', $config, $params ) if $config->{user_email} == 1; } elsif ( $params->{function} eq "suspend" ) { - if ($enh_config->{users_dids_rt} == 1) { - &update_context_sip_user_rt( $rt_db, $config, $enh_config, + if ($config->{users_dids_rt} == 1) { + &update_context_sip_user_rt( $rt_db, $config, $params->{extension}, "suspended" ) if $params->{type} eq "SIP"; - &update_context_iax_user_rt( $rt_db, $config, $enh_config, + &update_context_iax_user_rt( $rt_db, $config, $params->{extension}, "suspended" ) if $params->{type} eq "IAX"; - } elsif ($enh_config->{users_dids_amp} == 1) { - &update_context_sip_user_freepbx( $freepbx_db, $config, $enh_config, + } elsif ($config->{users_dids_amp} == 1) { + &update_context_sip_user_freepbx( $freepbx_db, $config, $params->{extension}, "suspended" ) if $params->{type} eq "SIP"; - &update_context_iax_user_freepbx( $freepbx_db, $config, $enh_config, + &update_context_iax_user_freepbx( $freepbx_db, $config, $params->{extension}, "suspended" ) if $params->{type} eq "IAX"; } - &email_del_user($astpp_db, '', $config, $params, $enh... [truncated message content] |