add agent selection to payment and credit reports, add link to agent browse, closes...
[freeside.git] / httemplate / search / elements / search.html
index e739afb..712d63a 100644 (file)
@@ -2,9 +2,19 @@
 
   my(%opt) = @_;
 
-  if ( ref($opt{'query'}) ) {
+  my %align = (
+    'l' => 'left',
+    'r' => 'right',
+    'c' => 'center',
+    ' ' => '',
+    '.' => '',
+  );
+  $opt{align} = [ map $align{$_}, split(//, $opt{align}) ],
+    unless !$opt{align} || ref($opt{align});
 
-  }
+  #if ( ref($opt{'query'}) ) {
+  #
+  #}
 
   unless (exists($opt{'count_query'}) && length($opt{'count_query'})) {
     ( $opt{'count_query'} = $opt{'query'} ) =~
@@ -37,6 +47,8 @@
       $opt{'query'}->{'hashref'} || {}, 
       $opt{'query'}->{'select'},
       $opt{'query'}->{'extra_sql'}. " $limit",
+      '',
+      (exists($opt{'query'}->{'addl_from'}) ? $opt{'query'}->{'addl_from'} : '')
     ) ];
   } else {
     my $sth = dbh->prepare("$opt{'query'} $limit")
                            'maxrecords' => $maxrecords,
                        );
 %>
-<%= $total %> total <%= $opt{'name'} %><BR>
-<% if ( $opt{'count_addl'} ) { %>
-  <% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) { %>
-    <%= sprintf( $count, $count_arrayref->[++$n] ) %><BR>
+<% unless ( $total ) { %>
+  No matching <%= $opt{'name'} %> found.<BR>
+<% } else { %>
+  <%= $total %> total <%= $opt{'name'} %><BR>
+  <% if ( $opt{'count_addl'} ) { %>
+    <% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) { %>
+      <%= sprintf( $count, $count_arrayref->[++$n] ) %><BR>
+    <% } %>
   <% } %>
-<% } %>
-<BR><%= $pager %>
-<%= include( '/elements/table.html' ) %>
-  <TR>
-  <% foreach my $header ( @$header ) { %>
-       <TH><%= $header %></TH>
-  <% } %>
-  </TR>
-  <% foreach my $row ( @$rows ) { %>
-       <TR>
-       <% 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();
+  <BR><%= $pager %>
+  <%= include( '/elements/table.html' ) %>
+    <TR>
+    <% foreach my $header ( @$header ) { %>
+         <TH><%= $header %></TH>
+    <% } %>
+    </TR>
+    <% foreach my $row ( @$rows ) { %>
+         <TR>
+         <% if ( $opt{'fields'} ) {
+              my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : '';
+              my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : '';
+              foreach my $field ( @{$opt{'fields'}} ) {
+                my $align = $aligns ? shift @$aligns : '';
+                $align = " ALIGN=$align" if $align;
+                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(<A HREF="$a">);
                   }
-                  $a = qq(<A HREF="$a">);
                 }
-              }
-           %>
-           <% if ( ref($field) eq 'CODE' ) { %>
-             <TD><%= $a %><%= &{$field}($row) %><%= $a ? '</A>' : '' %></TD>
-           <% } else { %>
-             <TD><%= $a %><%= $row->$field() %><%= $a ? '</A>' : '' %></TD>
+             %>
+             <% if ( ref($field) eq 'CODE' ) { %>
+               <TD<%= $align %>><%= $a %><%= &{$field}($row) %><%= $a ? '</A>' : '' %></TD>
+             <% } else { %>
+               <TD<%= $align %>><%= $a %><%= $row->$field() %><%= $a ? '</A>' : '' %></TD>
+             <% } %>
+           <% } %>
+         <% } else { %>
+           <% foreach ( @$row ) { %>
+                <TD><%= $_ %></TD>
            <% } %>
          <% } %>
-       <% } else { %>
-         <% foreach ( @$row ) { %>
-              <TD><%= $_ %></TD>
-         <% } %>
-       <% } %>
-       </TR>
-  <% } %>
-
-</TABLE>
-<%= $pager %>
+         </TR>
+    <% } %>
+  
+  </TABLE>
+  <%= $pager %>
+<% } %>
 </BODY>
 </HTML>
 <% } %>
+