move account search (httemplate/search/svc_acct.cgi) to new template, cust-fields...
[freeside.git] / httemplate / search / elements / search.html
index 92889c5..78754fe 100644 (file)
           #  }
           #}
           if ( ref($field) eq 'CODE' ) {
-            $worksheet->write($r, $c++, &{$field}($row) );
+            foreach my $value ( &{$field}($row) ) {
+              $worksheet->write($r, $c++, $value );
+            }
           } else {
             $worksheet->write($r, $c++, $row->$field() );
           }
                  include( '/elements/menubar.html', @menubar )
              )
   %>
+  <%= defined($opt{'html_init'}) ? $opt{'html_init'} : '' %>
   <% my $pager = include ( '/elements/pager.html',
                              'offset'     => $offset,
                              'num_rows'   => scalar(@$rows),
               %>
                    <TR>
                    <% if ( $opt{'fields'} ) {
-                        my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : '';
+
+                        my $links  = $opt{'links'} ? [ @{$opt{'links'}} ] : '';
                         my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : '';
-                        foreach my $field ( @{$opt{'fields'}} ) {
+                        my $colors = $opt{'color'} ? [ @{$opt{'color'}} ] : [];
+                        my $sizes  = $opt{'size'}  ? [ @{$opt{'size'}}  ] : [];
+                        my $styles = $opt{'style'} ? [ @{$opt{'style'}} ] : [];
+
+                        foreach my $field (
+
+                          map {
+                                if ( ref($_) eq 'CODE' ) {
+                                  &{$_}($row);
+                                } else {
+                                  $row->$_();
+                                }
+                              }
+                          @{$opt{'fields'}}
+
+                        ) {
+
                           my $align = $aligns ? shift @$aligns : '';
                           $align = " ALIGN=$align" if $align;
+
                           my $a = '';
                           if ( $links ) {
                             my $link = shift @$links;
                               $a = qq(<A HREF="$a">);
                             }
                           }
+
+                          my $font = '';
+                          my $color = shift @$colors;
+                          $color = &{$color}($row) if ref($color) eq 'CODE';
+                          my $size = shift @$sizes;
+                          $size = &{$size}($row) if ref($size) eq 'CODE';
+                          if ( $color || $size ) {
+                            $font = '<FONT '.
+                                    ( $color ? "COLOR=#$color "   : '' ).
+                                    ( $size  ? qq(SIZE="$size" )  : '' ).
+                                    '>';
+                          }
+
+                          my($s, $es) = ( '', '' );
+                          my $style = shift @$styles;
+                          $style = &{$style}($row) if ref($style) eq 'CODE';
+                          if ( $style ) {
+                            $s = join( '', map "<$_>", split('', $style) );
+                            $es = join( '', map "</$_>", split('', $style) );
+                          }
+
                        %>
-                       <% if ( ref($field) eq 'CODE' ) { %>
-                         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"<%= $align %>><%= $a %><%= &{$field}($row) %><%= $a ? '</A>' : '' %></TD>
-                       <% } else { %>
-                         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"<%= $align %>><%= $a %><%= $row->$field() %><%= $a ? '</A>' : '' %></TD>
-                       <% } %>
+                       <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"<%= $align %>><%= $font %><%= $a %><%= $s %><%= $field %><%= $es %><%= $a ? '</A>' : '' %><%= $font ? '</FONT>' : '' %></TD>
                      <% } %>
                    <% } else { %>
                      <% foreach ( @$row ) { %>
                    <% } %>
                    </TR>
               <% } %>
+
+              <% if ( $opt{'footer'} ) { %>
+                <TR>
+                <% foreach my $footer ( @{ $opt{'footer'} } ) { %>
+                     <TD CLASS="grid" BGCOLOR="#dddddd" STYLE="border-top: dashed 1px black;"><i><%= $footer %></i></TH>
+                <% } %>
+                </TR>
+              <% } %>
             
             </TABLE>
             <%= $pager %>