[Astpp-commit] SF.net SVN: astpp: [2149] trunk
Brought to you by:
darrenkw
|
From: <dar...@us...> - 2007-11-03 03:07:20
|
Revision: 2149
http://astpp.svn.sourceforge.net/astpp/?rev=2149&view=rev
Author: darrenkw
Date: 2007-11-02 20:07:15 -0700 (Fri, 02 Nov 2007)
Log Message:
-----------
Resolved: [ 1820671 ] HTML::TEmplate die_on_bad_params => 0
Modified Paths:
--------------
trunk/astpp-admin.cgi
trunk/astpp-callingcards.agi
trunk/astpp-users.cgi
trunk/modules/ASTPP/lib/ASTPP.pm
Modified: trunk/astpp-admin.cgi
===================================================================
--- trunk/astpp-admin.cgi 2007-11-02 05:39:54 UTC (rev 2148)
+++ trunk/astpp-admin.cgi 2007-11-03 03:07:15 UTC (rev 2149)
@@ -50,7 +50,9 @@
use Time::HiRes qw( gettimeofday tv_interval );
use Data::Paginate;
use DateTime;
-use DateTime::TimeZone
+use DateTime::TimeZone;
+use ASTPP;
+
; # We use DateTime::TimeZone to show users cdrs in their own timezones.
require "/usr/local/astpp/astpp-common.pl";
@@ -60,8 +62,13 @@
textdomain("astpp");
use vars qw(@output $astpp_db $params $config
$status $config $limit $accountinfo
- $freepbx_db $rt_db $openser_db);
+ $freepbx_db $rt_db $openser_db $ASTPP);
my $starttime = [gettimeofday];
+$ASTPP = ASTPP->new;
+$ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to
+be.
+$ASTPP->set_asterisk_agi($AGI);
+$ASTPP->set_pagination_script("astpp-admin.cgi");
my @Home = ( gettext("Home Page") );
my @Accounts = (
gettext("Create Account"), gettext("Process Payment"),
@@ -1470,7 +1477,7 @@
sub build_homepage() {
my $template =
- HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
if ( $params->{logintype} == 1
|| $params->{logintype} == 5
@@ -1560,7 +1567,7 @@
);
my $template =
HTML::Template->new(
- filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
return gettext("Cannot view account until database is configured")
unless $astpp_db;
if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) {
@@ -2039,7 +2046,7 @@
my ( $body, $total, $count, $reseller, @accountdetaillist );
my $template =
HTML::Template->new(
- filename => '/var/lib/astpp/templates/account-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ filename => '/var/lib/astpp/templates/account-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params});
my $yes = gettext("YES");
my $no = gettext("NO");
return gettext("Cannot view account until database is configured")
@@ -2216,7 +2223,7 @@
my ( @pricelists, $status, $body );
my $template =
HTML::Template->new(
- filename => '/var/lib/astpp/templates/account-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ filename => '/var/lib/astpp/templates/account-create.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
return gettext("Database is NOT configured!") . " \n"
unless $astpp_db;
if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) {
@@ -5442,7 +5449,7 @@
$accountinfo );
my $template =
HTML::Template->new(
- filename => '/var/lib/astpp/templates/account-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ filename => '/var/lib/astpp/templates/account-remove.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
if ( $params->{action} eq gettext("Deactivate...") ) {
if ( $params->{number} ne "" ) {
$number = $params->{number};
@@ -5501,7 +5508,7 @@
my ( $status, $body, $number, $reseller );
my $template =
HTML::Template->new(
- filename => '/var/lib/astpp/templates/account-process-payment.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ filename => '/var/lib/astpp/templates/account-process-payment.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
return gettext("Database not configured!") unless $astpp_db;
if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) {
$reseller = $params->{username};
@@ -7901,14 +7908,26 @@
}
sub build_counters() {
- my (@counter_list);
+ my ($tmp,@counter_list);
my $template =
HTML::Template->new(
- filename => '/var/lib/astpp/templates/counters-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ filename => '/var/lib/astpp/templates/counters-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
my $results_per_page = $config->{results_per_page};
if ( $results_per_page eq "" || $results_per_page < 2 ) {
$results_per_page = 25;
}
+ if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) {
+ $tmp =
+ "SELECT * FROM pricelists WHERE status < 2 AND reseller = "
+ . $astpp_db->quote( $params->{username} );
+ }
+ else {
+ $tmp =
+ "SELECT * FROM pricelists WHERE status < 2 AND reseller IS NULL";
+ }
+ my $sql = $astpp_db->do($sql);
+ print STDERR $tmp if $config->{debug} == 1;
+ $sql = $astpp_db->prepare($tmp);
## START PAGINATION CODE
# set total_entries *once* then pass it around
# in the object's links from then on for efficiency:
@@ -9485,7 +9504,7 @@
my ( $tmp, $template, @configuration_list );
$template =
HTML::Template->new(
- filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
if ( $params->{logintype} == 2 ) {
$tmp = "SELECT * FROM system";
}
@@ -10755,7 +10774,7 @@
sub build_add_callshop() {
my $template =
HTML::Template->new(
- filename => '/var/lib/astpp/templates/callshop-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ filename => '/var/lib/astpp/templates/callshop-create.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
if ( $params->{action} eq gettext("Add...") ) {
if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) {
$params->{pricelist} = $params->{username};
@@ -10813,7 +10832,7 @@
sub build_remove_callshop() {
my $template =
HTML::Template->new(
- filename => '/var/lib/astpp/templates/callshop-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ filename => '/var/lib/astpp/templates/callshop-remove.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
my ( @callshops, $tmp );
if ( $params->{logintype} == 1 ) {
@callshops = &list_callshops_reseller( $astpp_db, $params->{username} );
@@ -10868,7 +10887,7 @@
my ( $template, $currency, $pricelist, $language, $status );
$template =
HTML::Template->new(
- filename => '/var/lib/astpp/templates/booth-create.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ filename => '/var/lib/astpp/templates/booth-create.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
$params->{reseller} = $params->{username};
$currency = popup_menu(
-name => "currency",
@@ -11046,7 +11065,7 @@
sub build_remove_booth() {
my $template =
HTML::Template->new(
- filename => '/var/lib/astpp/templates/booth-remove.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ filename => '/var/lib/astpp/templates/booth-remove.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
my ( @booth_list, $accountinfo );
########
# Decide which booth name to use. The one in the box has priority over the selected list one.
@@ -11293,7 +11312,7 @@
my $template =
HTML::Template::Expr->new(
- filename => '/var/lib/astpp/templates/booths-list.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ filename => '/var/lib/astpp/templates/booths-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
$template->param( booth_list => \@booths );
return $template->output;
}
@@ -11443,7 +11462,7 @@
}
my $template =
HTML::Template->new(
- filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
$template->param( booth_name => $params->{booth_name} );
my $balance = &accountbalance( $astpp_db, $params->{booth_name} ) / 10000;
my $unrated = &count_unrated_cdrs_account( $cdr_db, $accountinfo->{number},
@@ -11463,7 +11482,8 @@
###################Start of Application ###################
&initialize();
my $template =
- HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}' );
+ HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl',
+ die_on_bad_params => $config->{template_die_on_bad_params} );
foreach my $param ( param() ) {
$params->{$param} = param($param);
print STDERR "$param $params->{$param}\n" if $config->{debug} == 1;
Modified: trunk/astpp-callingcards.agi
===================================================================
--- trunk/astpp-callingcards.agi 2007-11-02 05:39:54 UTC (rev 2148)
+++ trunk/astpp-callingcards.agi 2007-11-03 03:07:15 UTC (rev 2149)
@@ -438,6 +438,7 @@
. $astpp_db->quote($answeredtime) . ", "
. $astpp_db->quote($charge) . ")";
$astpp_db->do($sql);
+ $ASTPP->debug( debug => "$sql", verbosity => $verbosity );
$ASTPP->debug( debug => "Resetting CDR Variables", verbosity => $verbosity );
$AGI->set_variable( "\"ANSWEREDTIME\"", "0" );
$AGI->set_variable( "\"DIALEDTIME\"", "0" );
Modified: trunk/astpp-users.cgi
===================================================================
--- trunk/astpp-users.cgi 2007-11-02 05:39:54 UTC (rev 2148)
+++ trunk/astpp-users.cgi 2007-11-03 03:07:15 UTC (rev 2149)
@@ -226,7 +226,7 @@
$cost, $pagesrequired, $record, $debit,
$credit, $pageno, $credit_limit
);
- my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-account-info.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}');
+ my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-account-info.tpl', die_on_bad_params => $config->{template_die_on_bad_params});
return gettext("Cannot view account until database is configured")
unless $astpp_db;
if ( $params->{limit} < 1 ) { $params->{limit} = 0 }
@@ -421,7 +421,7 @@
$cardstat, $cardinfo, $count, $sql, $value,
$used, $pageno, $pagesrequired);
my (@cdr_list, @card_list);
- my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-list-callingcards.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}');
+ my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-list-callingcards.tpl', die_on_bad_params => $config->{template_die_on_bad_params});
my $no = gettext("NO");
my $yes = gettext("YES");
my $active = gettext("ACTIVE");
@@ -587,7 +587,7 @@
sub build_dids() {
my ( $total, $body, $status, $description, $pricelist, $pageno, $pagesrequired );
- my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-dids.tpl', die_on_bad_params => '$config->{template_die_on_bad_params'});
+ my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-dids.tpl', die_on_bad_params => $config->{template_die_on_bad_params});
return gettext("Cannot view DIDs until database is configured")
unless $astpp_db;
if ( $params->{limit} < 1 ) { $params->{limit} = 0 }
@@ -783,7 +783,7 @@
sub build_ani_map() {
my ( @ani_list,$total, $body, $status, $description, $pricelist, $pageno,
$pagesrequired );
- my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-map-ani.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}');
+ my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-map-ani.tpl', die_on_bad_params => $config->{template_die_on_bad_params});
return gettext("Not available until database is configured")
unless $astpp_db;
if ( $params->{limit} < 1 ) { $params->{limit} = 0 }
@@ -881,7 +881,7 @@
$ENV{LANGUAGE} = $cardinfo->{language};
print STDERR gettext("Interface language is set to:") . " $ENV{LANGUAGE}\n" if $config->{debug} == 1;
-my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-main.tpl', die_on_bad_params => '$config->{template_die_on_bad_params}');
+my $template = HTML::Template->new(filename => '/var/lib/astpp/templates/users-main.tpl', die_on_bad_params => $config->{template_die_on_bad_params});
my ($body, $menu);
if ( $loginstat == 1 && $params->{mode} ne gettext("Download")) {
$params->{mode} = gettext("Home")
Modified: trunk/modules/ASTPP/lib/ASTPP.pm
===================================================================
--- trunk/modules/ASTPP/lib/ASTPP.pm 2007-11-02 05:39:54 UTC (rev 2148)
+++ trunk/modules/ASTPP/lib/ASTPP.pm 2007-11-03 03:07:15 UTC (rev 2149)
@@ -4,6 +4,7 @@
use strict;
use warnings;
use DBI;
+use Data::Paginate;
require Exporter;
@@ -37,6 +38,7 @@
_asterisk_agi => $_[3],
_cdr_db => $_[4],
_verbosity_item_level => $arg{verbosity_item_level} || 1,
+ _pagination_script => $arg{pagination_script} || "astpp-admin.cgi",
}, $class;
}
@@ -44,6 +46,7 @@
sub set_asterisk_agi { $_[0]->{_asterisk_agi} } #Sets the verbosity level.
sub set_astpp_db { $_[0]->{_astpp_db} } #Sets the verbosity level.
sub set_cdr_db {$_[0]->{_cdr_db} } #Sets the verbosity level.
+sub set_pagination_script {$_[00]->{_pagination_script} }
sub debug #Prints debugging if appropriate
@@ -59,6 +62,43 @@
return 0;
}
+sub pagination #Returns the pagination html code to assist with navigation.
+{
+my ($self, %arg) = @_;
+ # We are using Data::Paginate for the real tough stuff.
+ # Therefore we need to pass the Data::Paginate stuff
+ # as well as the total number of pages.
+ # total_entries = Total number of pages.
+ # pagination_script = Script name.
+ # mode = What mode do we want.
+ # pgr = Pass along Data::Paginate
+ # ve =
+ # navi_html =
+ # last_page =
+ # First we decide if we have multiple pages...
+ if ($arg{total_entries} > 1) {
+ my $html;
+ $html =
+ "<a href=\"" . $self->{_pagination_script} . "?mode="
+ . $arg{mode} . "&ve="
+ . $arg{ve} . "&te="
+ . $arg{total_entries}
+ . "&pg=1\">"
+ . gettext("First Page")
+ . "</a> | "
+ . scalar $arg{navi_html}
+ . "<a href=\"" . $self->{_pagination_script} . "?mode="
+ . $arg{mode} . "&ve="
+ . $arg{ve} . "&te="
+ . $arg{total_entries} . "&pg="
+ . $arg{last_page} . "\">"
+ . gettext("Last Page") . "</a>";
+ return $html;
+ }
+ else {
+ return gettext("Page 1 of 1");
+ }
+}
# Preloaded methods go here.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|