X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fsearch%2Felements%2Fsearch.html;h=12ab83ba52e20429910fd604893048c10b0f2de4;hp=37a3718ce2efc714a469a3a242749086345cdb85;hb=d8ff6db2dbaec9cc8daad2d4af0254f167aa7a66;hpb=5cd995865b91204f7ce9233a8ba4d5eee62f9be4
diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html
index 37a3718ce..12ab83ba5 100644
--- a/httemplate/search/elements/search.html
+++ b/httemplate/search/elements/search.html
@@ -50,11 +50,11 @@
$header ||= $sth->{NAME};
}
- if ( exists($opt{'redirect'}) && scalar(@$rows) == 1 ) {
+ if ( exists($opt{'redirect'}) && scalar(@$rows) == 1 && $total == 1 ) {
my( $url, $method ) = @{$opt{'redirect'}};
redirect( $url. $rows->[0]->$method() );
} else {
-
+ $opt{'name'} =~ s/s$// if $total == 1;
%>
<%= include( '/elements/header.html', $opt{'title'},
include( '/elements/menubar.html', 'Main menu' => $p )
@@ -67,47 +67,60 @@
'maxrecords' => $maxrecords,
);
%>
-<%= $total %> total <%= $opt{'name'} %>
-<% if ( $opt{'count_addl'} ) { %>
- <% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) { %>
- <%= sprintf( $count, $count_arrayref->[++$n] ) %>
- <% } %>
-<% } %>
-
<%= $pager %>
-<%= include( '/elements/table.html' ) %>
-
- <% foreach my $header ( @$header ) { %>
- <%= $header %> |
+<% unless ( $total ) { %>
+ No matching <%= $opt{'name'} %> found.
+<% } else { %>
+ <%= $total %> total <%= $opt{'name'} %>
+ <% if ( $opt{'count_addl'} ) { %>
+ <% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) { %>
+ <%= sprintf( $count, $count_arrayref->[++$n] ) %>
+ <% } %>
<% } %>
-
- <% foreach my $row ( @$rows ) { %>
-
- <% if ( $opt{'fields'} ) { %>
- <% my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; %>
- <% foreach my $field ( @{$opt{'fields'}} ) { %>
- <% my $a = ''; %>
- <% if ( $links ) {
- my( $url, $method ) = @{shift @$links};
- $a = $url. $row->$method();
- $a = qq();
- }
- %>
- <% if ( ref($field) eq 'CODE' ) { %>
- <%= $a %><%= &{$field}($row) %><%= $a ? '' : '' %> |
- <% } else { %>
- <%= $a %><%= $row->$field() %><%= $a ? '' : '' %> |
+
<%= $pager %>
+ <%= include( '/elements/table.html' ) %>
+
+ <% foreach my $header ( @$header ) { %>
+ <%= $header %> |
+ <% } %>
+
+ <% foreach my $row ( @$rows ) { %>
+
+ <% if ( $opt{'fields'} ) { %>
+ <% my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; %>
+ <% foreach my $field ( @{$opt{'fields'}} ) { %>
+ <% my $a = ''; %>
+ <% if ( $links ) {
+ my $link = shift @$links;
+ $link = &{$link}($row) if ref($link) eq 'CODE';
+ if ( $link ) {
+ my( $url, $method ) = @{$link};
+ if ( ref($method) eq 'CODE' ) {
+ $a = $url. &{$method}($row);
+ } else {
+ $a = $url. $row->$method();
+ }
+ $a = qq();
+ }
+ }
+ %>
+ <% if ( ref($field) eq 'CODE' ) { %>
+ <%= $a %><%= &{$field}($row) %><%= $a ? '' : '' %> |
+ <% } else { %>
+ <%= $a %><%= $row->$field() %><%= $a ? '' : '' %> |
+ <% } %>
+ <% } %>
+ <% } else { %>
+ <% foreach ( @$row ) { %>
+ <%= $_ %> |
<% } %>
<% } %>
- <% } else { %>
- <% foreach ( @$row ) { %>
- <%= $_ %> |
- <% } %>
- <% } %>
-
- <% } %>
-
-
-<%= $pager %>
+
+ <% } %>
+
+
+ <%= $pager %>
+<% } %>