summaryrefslogtreecommitdiff
path: root/httemplate/search/elements
diff options
context:
space:
mode:
authormark <mark>2010-07-22 07:25:36 +0000
committermark <mark>2010-07-22 07:25:36 +0000
commitf4658067b9a1dd0564be8fd590a1e541681bfe27 (patch)
tree2ce49bb2b66631161f9a14691bd3ffbbff525279 /httemplate/search/elements
parent342e2bfbe6aad470ab9dee40640f8ac7d9653003 (diff)
Fix weird behavior of aging report, RT#9234
Diffstat (limited to 'httemplate/search/elements')
-rw-r--r--httemplate/search/elements/cust_main_dayranges.html12
1 files changed, 11 insertions, 1 deletions
diff --git a/httemplate/search/elements/cust_main_dayranges.html b/httemplate/search/elements/cust_main_dayranges.html
index 45d605e6e..8b7b89bd2 100644
--- a/httemplate/search/elements/cust_main_dayranges.html
+++ b/httemplate/search/elements/cust_main_dayranges.html
@@ -11,6 +11,7 @@ Example:
my( $start, $end ) = @_;
"SQL EXPRESSION BASED ON $start AND $end";
+ # where $start and $end are unix timestamps
};
</%doc>
@@ -252,7 +253,16 @@ sub call_range_sub {
my $as = $opt{'no_as'} ? '' : " AS rangecol_${start}_$end";
- my $sql = &{$range_sub}( $start, $end, $opt{'offset'} ); #%opt?
+ my $offset = $opt{'offset'} || 0;
+ # Time::ParseDate for excruciating correctness
+ # Always use $offset - 1day + 1sec = the last second of that day
+ $start = parsedate('00:00 '.($start + $offset - 1).' days ago') - 1;
+ $end = $end ?
+ parsedate('00:00 '.($end + $offset - 1).' days ago') - 1 :
+ '';
+ my $cutoff = parsedate('00:00 '.($offset - 1).' days ago') - 1;
+
+ my $sql = &{$range_sub}( $start, $end, $cutoff ); #%opt?
$sql = "SUM($sql)" if $opt{'sum'};