diff options
Diffstat (limited to 'httemplate/search/elements')
-rw-r--r-- | httemplate/search/elements/cust_main_dayranges.html | 23 | ||||
-rw-r--r-- | httemplate/search/elements/search-html.html | 13 | ||||
-rw-r--r-- | httemplate/search/elements/search.html | 2 |
3 files changed, 12 insertions, 26 deletions
diff --git a/httemplate/search/elements/cust_main_dayranges.html b/httemplate/search/elements/cust_main_dayranges.html index 9b8b08f47..c53e68016 100644 --- a/httemplate/search/elements/cust_main_dayranges.html +++ b/httemplate/search/elements/cust_main_dayranges.html @@ -11,7 +11,6 @@ Example: my( $start, $end ) = @_; "SQL EXPRESSION BASED ON $start AND $end"; - # where $start and $end are unix timestamps }; </%doc> @@ -146,7 +145,7 @@ unless ( $cgi->param('all_customers') ) { } push @where, - call_range_sub($range_sub, $days, 0, 'offset' => $offset, 'no_as'=>1). ' > 0'; # != 0'; + call_range_sub($range_sub, $days + $offset, 0, 'no_as'=>1). ' > 0'; # != 0'; } if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { @@ -249,25 +248,11 @@ my $money_char = $conf->config('money_char') || '$'; # ) sub call_range_sub { - my($range_sub, $startdays, $enddays, %opt) = @_; + my($range_sub, $start, $end, %opt) = @_; - my $as = $opt{'no_as'} ? '' : " AS rangecol_${startdays}_$enddays"; + my $as = $opt{'no_as'} ? '' : " AS rangecol_${start}_$end"; - my $offset = $opt{'offset'} || 0; - # Always use $offset - 1day + 1sec = the last second of that day - my $cutoff = DateTime->now->set(hour => 23, minute => 59, second => 59); - $cutoff->subtract(days => $offset); - - my $start = $cutoff->clone; - $start->subtract(days => $startdays); - - my $end = $cutoff->clone; - $end->subtract(days => $enddays); - - #warn "offset $offset (".$cutoff->epoch."), range $startdays-$enddays (".$start->epoch . '-' . ($enddays ? $end->epoch : '').")\n"; - my $sql = &{$range_sub}( $start->epoch, - $enddays ? $end->epoch : '', - $cutoff->epoch ); #%opt? + my $sql = &{$range_sub}( $start, $end, $opt{'offset'} ); #%opt? $sql = "SUM($sql)" if $opt{'sum'}; diff --git a/httemplate/search/elements/search-html.html b/httemplate/search/elements/search-html.html index 98f9c4476..e5e6ca954 100644 --- a/httemplate/search/elements/search-html.html +++ b/httemplate/search/elements/search-html.html @@ -1,3 +1,4 @@ +% % if ( exists($opt{'redirect'}) && $opt{'redirect'} % && scalar(@$rows) == 1 && $total == 1 % && $type ne 'html-print' @@ -102,7 +103,7 @@ % $cgi->delete('maxrecords'); % $cgi->param('_dummy', 1); - ( show <SELECT NAME="maxrecords" onChange="window.location = '<% "$self_url?". $cgi->query_string %>;maxrecords=' + this.options[this.selectedIndex].value;"> + ( show <SELECT NAME="maxrecords" onChange="window.location = '<% $self_url %>;maxrecords=' + this.options[this.selectedIndex].value;"> % foreach my $max ( map { $_ * $confmax } qw( 1 5 10 25 ) ) { <OPTION VALUE="<% $max %>" <% ( $maxrecords == $max ) ? 'SELECTED' : '' %>><% $max %></OPTION> @@ -143,18 +144,18 @@ Download full results<BR> % $cgi->param('_type', "$xlsname.xls" ); - as <A HREF="<% "$self_url?". $cgi->query_string %>">Excel spreadsheet</A><BR> + as <A HREF="<% $self_url %>">Excel spreadsheet</A><BR> % $cgi->param('_type', 'csv'); - as <A HREF="<% "$self_url?". $cgi->query_string %>">CSV file</A><BR> + as <A HREF="<% $self_url %>">CSV file</A><BR> % if ( defined($opt{xml_elements}) ) { % $cgi->param('_type', 'xml'); - as <A HREF="<% "$self_url?". $cgi->query_string %>">XML file</A><BR> + as <A HREF="<% $self_url %>">XML file</A><BR> % } % $cgi->param('_type', 'html-print'); - as <A HREF="<% "$self_url?". $cgi->query_string %>">printable copy</A> + as <A HREF="<% $self_url %>">printable copy</A> </TD> % $cgi->param('_type', "html" ); @@ -464,7 +465,7 @@ my $confmax = $args{'confmax'}; my $maxrecords = $args{'maxrecords'}; my $offset = $args{'offset'}; my %opt = %{ $args{'opt'} }; -my $self_url = $opt{'url'} || $cgi->url('-path_info' => 1, '-full' =>1); +my $self_url = $opt{'url'} || $cgi->self_url; my $count_sth = dbh->prepare($opt{'count_query'}) or die "Error preparing $opt{'count_query'}: ". dbh->errstr; diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 218816938..a258f1721 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -335,7 +335,7 @@ if ( $opt{'disableable'} ) { my $limit = ''; my($confmax, $maxrecords, $offset ); -unless ( $type =~ /^(csv|\w*.xls)$/) { +if ( !$type =~ /^(csv|\w*.xls)$/) { # html mode unless (exists($opt{count_query}) && length($opt{count_query})) { ( $opt{count_query} = $opt{query} ) =~ |