X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FSearch.pm;h=ad24ff86e95c016c62ede957e0097c78d62e3343;hb=74e058c8a010ef6feb539248a550d0bb169c1e94;hp=b9a30a55276be3d3e601c713f64d902375891b3e;hpb=a22ee6a5bbf86485d0c65adfbe9b742b9bfbe7f3;p=freeside.git diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm index b9a30a552..ad24ff86e 100644 --- a/FS/FS/cust_main/Search.pm +++ b/FS/FS/cust_main/Search.pm @@ -541,11 +541,13 @@ sub search { "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') { + if ($dbh->{Driver}->{Name} =~ /Pg/i) { push @where, "extract(hour from to_timestamp(cust_main.$field)) = $hour"; } + elsif( $dbh->{Driver}->{Name} =~ /mysql/i) { + push @where, "hour(from_unixtime(cust_main.$field)) = $hour" + } else { warn "search by time of day not supported on ".$dbh->{Driver}->{Name}." databases"; } @@ -656,6 +658,21 @@ sub search { push @where, "cust_main.custbatch = '$1'"; } + + if ( $params->{'tagnum'} ) { + my @tagnums = ref( $params->{'tagnum'} ) ? @{ $params->{'tagnum'} } : ( $params->{'tagnum'} ); + + @tagnums = grep /^(\d+)$/, @tagnums; + + if ( @tagnums ) { + my $tags_where = "0 < (select count(1) from cust_tag where " + . " cust_tag.custnum = cust_main.custnum and tagnum in (" + . join(',', @tagnums) . "))"; + + push @where, $tags_where; + } + } + ## # setup queries, subs, etc. for the search