X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=httemplate%2Fsearch%2Felements%2Fsearch.html;h=6cf574164d9ef519175548306e23e44d2fce8f7a;hb=1a033848671cad2cbe7687b37fc718b3b2a68b83;hp=b14bded1058bd43393180202de5ab5a8f94d9635;hpb=600a0939e7e7e589dae4f4f5bfef3650728940b7;p=freeside.git
diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html
index b14bded10..6cf574164 100644
--- a/httemplate/search/elements/search.html
+++ b/httemplate/search/elements/search.html
@@ -8,8 +8,12 @@
# 'name' => 'items', #name for the records returned
#
# # some HTML callbacks...
- # 'menubar' => '', #menubar arrayref
- # 'html_init' => '', #after the header/menubar and before the pager
+ # 'menubar' => '', #menubar arrayref
+ # 'html_init' => '', #after the header/menubar and before the pager
+ # 'html_foot' => '', #at the bottom
+ # 'html_posttotal' => '', #at the bottom
+ # # (these three can be strings or coderefs)
+ #
#
# #literal SQL query string or qsearch hashref, required
# 'query' => {
@@ -39,6 +43,10 @@
# # (if not specified the database column names will be used)
# 'header' => [ '#', 'Item' ],
#
+ # 'disable_download' => '', # set true to hide the CSV/Excel download links
+ # 'disable_nonefound' => '', # set true to disable the "No matching Xs found"
+ # # message
+ #
# #listref - each item is a literal column name (or method) or coderef
# #if not specified all columns will be shown
# 'fields' => [
@@ -68,6 +76,8 @@
# # or a coderef that returns the same
# 'redirect' =>
+ my $DEBUG = 0;
+
my(%opt) = @_;
#warn join(' / ', map { "$_ => $opt{$_}" } keys %opt ). "\n";
@@ -118,6 +128,7 @@
my $header = $opt{'header'};
my $rows;
if ( ref($opt{'query'}) ) {
+
#eval "use FS::$opt{'query'};";
$rows = [ qsearch(
$opt{'query'}->{'table'},
@@ -127,7 +138,9 @@
'',
(exists($opt{'query'}->{'addl_from'}) ? $opt{'query'}->{'addl_from'} : '')
) ];
+
} else {
+
my $sth = dbh->prepare("$opt{'query'} $limit")
or die "Error preparing $opt{'query'}: ". dbh->errstr;
$sth->execute
@@ -137,8 +150,15 @@
$rows = $sth->fetchall_arrayref;
$header ||= $sth->{NAME};
+
}
+ warn scalar(@$rows). ' rows returned from '.
+ ( ref($opt{'query'}) ? 'qsearch query' : 'literal SQL query' )
+ if $DEBUG || $opt{'debug'};
+
+ # display the results - csv, xls or html
+
if ( $type eq 'csv' ) {
#http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes
@@ -274,7 +294,13 @@
include( '/elements/menubar.html', @menubar )
)
%>
- <%= defined($opt{'html_init'}) ? $opt{'html_init'} : '' %>
+ <%= defined($opt{'html_init'})
+ ? ( ref($opt{'html_init'})
+ ? &{$opt{'html_init'}}()
+ : $opt{'html_init'}
+ )
+ : ''
+ %>
<% my $pager = include ( '/elements/pager.html',
'offset' => $offset,
'num_rows' => scalar(@$rows),
@@ -283,26 +309,38 @@
);
%>
<% unless ( $total ) { %>
- No matching <%= $opt{'name'} %> found.
+ <% unless ( $opt{'disable_nonefound'} ) { %>
+ No matching <%= $opt{'name'} %> found.
+ <% } %>
<% } else { %>
- <%= $total %> total <%= $opt{'name'} %> + <%= $total %> total <%= $opt{'name'} %> + <%= defined($opt{'html_posttotal'}) + ? ( ref($opt{'html_posttotal'}) + ? &{$opt{'html_posttotal'}}() + : $opt{'html_posttotal'} + ) + : '' + %> + <% if ( $opt{'count_addl'} ) { %> <% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) { %> <%= sprintf( $count, $count_arrayref->[++$n] ) %> <% } %> <% } %> |
-
- <% $cgi->param('_type', "$xlsname.xls" ); %>
- Download full results - as Excel spreadsheet - <% $cgi->param('_type', 'csv'); %> - as CSV file - |
+ <% unless ( $opt{'disable_download'} ) { %>
+
+ <% $cgi->param('_type', "$xlsname.xls" ); %>
+ Download full results + as Excel spreadsheet + <% $cgi->param('_type', 'csv'); %> + as CSV file + |
+ <% } %>
|
@@ -437,7 +475,7 @@ <% } %> <% } else { %> <% foreach ( @$row ) { %> - | <%= $_ %> | +<%= $_ %> | <% } %> <% } %>