summaryrefslogtreecommitdiff
path: root/httemplate/search/elements/search.html
diff options
context:
space:
mode:
authorivan <ivan>2009-02-19 07:57:52 +0000
committerivan <ivan>2009-02-19 07:57:52 +0000
commite832eb872042cb27881402c5c92a17ce4c0506e9 (patch)
treef35c7348bc6937b9644aae5ef781c942240e947d /httemplate/search/elements/search.html
parent1c051d721533307ff9d1879deb3107e3a51058fa (diff)
redirect pending payment report back to customer when the pending payment is resolved, RT#4837, and fix otaker fallout from the pending stuff, RT#4866
Diffstat (limited to 'httemplate/search/elements/search.html')
-rw-r--r--httemplate/search/elements/search.html21
1 files changed, 19 insertions, 2 deletions
diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html
index 23fe8f470..8835f8cae 100644
--- a/httemplate/search/elements/search.html
+++ b/httemplate/search/elements/search.html
@@ -60,7 +60,15 @@ Example:
#redirect if there's only one item...
# listref of URL base and column name (or method)
# or a coderef that returns the same
- 'redirect' =>
+ 'redirect' => sub { my( $record, $cgi ) = @_;
+ [ popurl(2).'view/item.html', 'primary_key' ];
+ },
+
+ #redirect if there's no items
+ # scalar URL or a coderef that returns a URL
+ 'redirect_empty' => sub { my( $cgi ) = @_;
+ popurl(2).'view/item.html';
+ },
###
# optional
@@ -277,9 +285,18 @@ Example:
% && $type ne 'html-print'
% ) {
% my $redirect = $opt{'redirect'};
-% $redirect = &{$redirect}($rows->[0]) if ref($redirect) eq 'CODE';
+% $redirect = &{$redirect}($rows->[0], $cgi) if ref($redirect) eq 'CODE';
% my( $url, $method ) = @$redirect;
% redirect( $url. $rows->[0]->$method() );
+% } elsif ( exists($opt{'redirect_empty'}) && ! scalar(@$rows) && $total == 0
+% && $type ne 'html-print'
+% && $opt{'redirect_empty'}
+% && ( ref($opt{'redirect_empty'}) ne 'CODE'
+% || &{$opt{'redirect_empty'}}($cgi) )
+% ) {
+% my $redirect = $opt{'redirect_empty'};
+% $redirect = &{$redirect}($cgi) if ref($redirect) eq 'CODE';
+% redirect( $redirect );
% } else {
% if ( $opt{'name_singular'} ) {
% $opt{'name'} = PL($opt{'name_singular'});