[Astpp-commit] SF.net SVN: astpp: [2131] trunk/astpp-admin.cgi
Brought to you by:
darrenkw
|
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.
|