From c9860506278274605e76c1a8c18084db134d7409 Mon Sep 17 00:00:00 2001 From: "C.J. Adams-Collier" Date: Mon, 8 Sep 2014 14:14:20 -0700 Subject: [PATCH] moved WHERE/AND logic in to calling code. FS RT #884 --- FS/FS/Record.pm | 21 +-------------------- httemplate/graph/signupdate.cgi | 5 +++-- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 1b7ac8a7c..c53c9ae3c 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -402,26 +402,7 @@ sub qsearch { get_real_fields($table, $record, \@real_fields)); } - if( defined($extra_sql) ){ - if( $statement =~ /\sWHERE\s/i ){ - if( $extra_sql =~ /^\s*AND /i ){ - # correct format - }elsif($extra_sql =~ /^\s*WHERE /i ){ - $extra_sql =~ s/WHERE /AND /i; - }else{ - $extra_sql = " AND $extra_sql"; - } - }else{ - if( $extra_sql =~ /^\s*AND /i ){ - $extra_sql =~ s/AND /WHERE /i; - }elsif($extra_sql =~ /^\s*WHERE /i ){ - # correct format - }else{ - $extra_sql = " WHERE $extra_sql"; - } - } - $statement .= " $extra_sql"; - } + $statement .= " $extra_sql" if defined($extra_sql); $statement .= " $order_by" if defined($order_by); push @statement, $statement; diff --git a/httemplate/graph/signupdate.cgi b/httemplate/graph/signupdate.cgi index 011817c3a..8261257f3 100644 --- a/httemplate/graph/signupdate.cgi +++ b/httemplate/graph/signupdate.cgi @@ -43,8 +43,9 @@ my $edate = DateTime->new( month => $cgi->param('end_month') )->add( months => 1 )->epoch(); -my $where .= " AND signupdate >= $sdate ". - " AND signupdate < $edate "; +my $where = (%where ? ' AND ' : ' WHERE '); +$where .= " signupdate >= $sdate ". + " AND signupdate < $edate "; foreach my $cust (qsearch({ table => 'cust_main', hashref => \%where, -- 2.11.0