[freeside-commits] freeside/httemplate/search/elements search.html, 1.45, 1.46
Jeff Finucane,420,,
jeff at wavetail.420.am
Tue Aug 25 12:08:21 PDT 2009
Update of /home/cvs/cvsroot/freeside/httemplate/search/elements
In directory wavetail.420.am:/tmp/cvs-serv26754/httemplate/search/elements
Modified Files:
search.html
Log Message:
improved 477 report #6004
Index: search.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/elements/search.html,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- search.html 4 May 2009 00:22:44 -0000 1.45
+++ search.html 25 Aug 2009 19:08:19 -0000 1.46
@@ -16,7 +16,8 @@
# (deprecated, will be singularlized
# simplisticly)
- #literal SQL query string (deprecated?) or qsearch hashref
+ #literal SQL query string (deprecated?) or qsearch hashref or arrayref
+ #of qsearch hashrefs for a union of qsearches
'query' => {
'table' => 'tablename',
#everything else is optional...
@@ -347,6 +348,15 @@
my $rows;
if ( ref($opt{query}) ) {
+ my @query;
+ if (ref($opt{query}) eq 'HASH') {
+ @query = ( $opt{query} );
+ } elsif (ref($opt{query}) eq 'ARRAY') {
+ @query = @{ $opt{query} };
+ } else {
+ die "invalid query reference";
+ }
+
if ( $opt{disableable} && ! $cgi->param('showdisabled') ) {
#%search = ( 'disabled' => '' );
$opt{'query'}->{'hashref'}->{'disabled'} = '';
@@ -354,14 +364,15 @@
}
#eval "use FS::$opt{'query'};";
- $rows = [ qsearch({
- 'select' => $opt{'query'}->{'select'},
- 'table' => $opt{'query'}->{'table'},
- 'addl_from' => (exists($opt{'query'}->{'addl_from'}) ? $opt{'query'}->{'addl_from'} : ''),
- 'hashref' => $opt{'query'}->{'hashref'} || {},
- 'extra_sql' => $opt{'query'}->{'extra_sql'},
- 'order_by' => $opt{'query'}->{'order_by'}. " $limit",
- }) ];
+ my @param = qw( select table addl_from hashref extra_sql order_by );
+ $rows = [ qsearch( [ map { my $query = $_;
+ ({ map { $_ => $query->{$_} } @param });
+ }
+ @query
+ ],
+ 'order_by' => $opt{order_by}. " ". $limit,
+ )
+ ];
} else {
my $sth = dbh->prepare("$opt{'query'} $limit")
or die "Error preparing $opt{'query'}: ". dbh->errstr;
More information about the freeside-commits
mailing list