summaryrefslogtreecommitdiff
path: root/httemplate/search/elements
diff options
context:
space:
mode:
authormark <mark>2010-07-29 16:41:30 +0000
committermark <mark>2010-07-29 16:41:30 +0000
commit6bb9ed43ce2f094d5b36c7882e9efb85bdd3bfe1 (patch)
tree591f25cd5db64b7cd9508f48f2eb1b02ef078b1b /httemplate/search/elements
parent69034061e197dfcbc20b1fafd0cf8c4cf698c7ae (diff)
aging report now uses DateTime, RT#9417
Diffstat (limited to 'httemplate/search/elements')
-rw-r--r--httemplate/search/elements/cust_main_dayranges.html25
1 files changed, 15 insertions, 10 deletions
diff --git a/httemplate/search/elements/cust_main_dayranges.html b/httemplate/search/elements/cust_main_dayranges.html
index 8b7b89b..9b8b08f 100644
--- a/httemplate/search/elements/cust_main_dayranges.html
+++ b/httemplate/search/elements/cust_main_dayranges.html
@@ -249,20 +249,25 @@ my $money_char = $conf->config('money_char') || '$';
# )
sub call_range_sub {
- my($range_sub, $start, $end, %opt) = @_;
+ my($range_sub, $startdays, $enddays, %opt) = @_;
- my $as = $opt{'no_as'} ? '' : " AS rangecol_${start}_$end";
+ my $as = $opt{'no_as'} ? '' : " AS rangecol_${startdays}_$enddays";
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?
+ 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?
$sql = "SUM($sql)" if $opt{'sum'};