From c1e2f536974812f05b8d3534ad2bf9c9ba40c24d Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 29 Mar 2010 09:18:23 +0000 Subject: RT#884: search customers by signup time of day --- FS/FS/Mason.pm | 1 + FS/FS/cust_main.pm | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'FS') diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm index 4c8c808cd..82e64f245 100644 --- a/FS/FS/Mason.pm +++ b/FS/FS/Mason.pm @@ -102,6 +102,7 @@ if ( -e $addl_handler_use_file ) { use String::Approx qw(amatch); use Chart::LinesPoints; use Chart::Mountain; + use Chart::Bars; use Color::Scheme; use HTML::Widgets::SelectLayers 0.07; #should go away in favor of #selectlayers.html diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 81b654cd7..24eb73a73 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -8521,6 +8521,15 @@ sub search { "cust_main.agentnum = $1"; } + ## + # do the same for user + ## + + if ( $params->{'usernum'} =~ /^(\d+)$/ and $1 ) { + push @where, + "cust_main.usernum = $1"; + } + ## # parse status ## @@ -8556,13 +8565,23 @@ sub search { next unless exists($params->{$field}); - my($beginning, $ending) = @{$params->{$field}}; + my($beginning, $ending, $hour) = @{$params->{$field}}; push @where, "cust_main.$field IS NOT NULL", "cust_main.$field >= $beginning", "cust_main.$field <= $ending"; + # XXX: do this for mysql and/or pull it out of here + if(defined $hour) { + if ($dbh->{Driver}->{Name} eq 'Pg') { + push @where, "extract(hour from to_timestamp(cust_main.$field)) = $hour"; + } + else { + warn "search by time of day not supported on ".$dbh->{Driver}->{Name}." databases"; + } + } + $orderby ||= "ORDER BY cust_main.$field"; } -- cgit v1.2.1