2 % if ( exists($opt{'redirect'}) && $opt{'redirect'}
3 % && scalar(@$rows) == 1 && $total == 1
4 % && $type ne 'html-print'
6 % my $redirect = $opt{'redirect'};
7 % $redirect = &{$redirect}($rows->[0], $cgi) if ref($redirect) eq 'CODE';
8 % my( $url, $method ) = @$redirect;
9 % redirect( $url. $rows->[0]->$method() );
10 % } elsif ( exists($opt{'redirect_empty'}) && ! scalar(@$rows) && $total == 0
11 % && $type ne 'html-print'
12 % && $opt{'redirect_empty'}
13 % && ( ref($opt{'redirect_empty'}) ne 'CODE'
14 % || &{$opt{'redirect_empty'}}($cgi) )
16 % my $redirect = $opt{'redirect_empty'};
17 % $redirect = &{$redirect}($cgi) if ref($redirect) eq 'CODE';
18 % redirect( $redirect );
20 % if ( $opt{'name_singular'} ) {
21 % $opt{'name'} = PL($opt{'name_singular'});
23 % ( my $xlsname = $opt{'name'} ) =~ s/\W//g;
24 % if ( $total == 1 ) {
25 % if ( $opt{'name_singular'} ) {
26 % $opt{'name'} = $opt{'name_singular'}
28 % #$opt{'name'} =~ s/s$// if $total == 1;
29 % $opt{'name'} =~ s/((s)e)?s$/$2/ if $total == 1;
33 % if ( $type eq 'html-print' ) {
35 <% include( '/elements/header-popup.html', $opt{'title'} ) %>
37 % } elsif ( $type eq 'select' ) {
39 <% include( '/elements/header-popup.html', $opt{'title'} ) %>
40 <% defined($opt{'html_init'})
41 ? ( ref($opt{'html_init'})
42 ? &{$opt{'html_init'}}()
51 % if ( $opt{'menubar'} ) {
52 % @menubar = @{ $opt{'menubar'} };
54 % # @menubar = ( 'Main menu' => $p );
57 <% include( '/elements/header.html', $opt{'title'},
58 include( '/elements/menubar.html', @menubar )
62 <% defined($opt{'html_init'})
63 ? ( ref($opt{'html_init'})
64 ? &{$opt{'html_init'}}()
73 % unless ( $opt{'disable_nonefound'} ) {
74 No matching <% $opt{'name'} %> found.<BR>
78 % if ( $total || $opt{'disableable'} ) { #hmm... and there *are* ones to show??
87 % if (! $opt{'disable_total'}) {
88 <% $total %> total <% $opt{'name'} %>
91 % if ( $confmax && $total > $confmax
92 % && ! $opt{'disable_maxselect'}
93 % && $type ne 'html-print' )
95 % $cgi->delete('maxrecords');
96 % $cgi->param('_dummy', 1);
98 ( show <SELECT NAME="maxrecords" onChange="window.location = '<% $cgi->self_url %>;maxrecords=' + this.options[this.selectedIndex].value;">
100 % foreach my $max ( map { $_ * $confmax } qw( 1 5 10 25 ) ) {
101 <OPTION VALUE="<% $max %>" <% ( $maxrecords == $max ) ? 'SELECTED' : '' %>><% $max %></OPTION>
106 % $cgi->param('maxrecords', $maxrecords);
109 % if ( defined($opt{'html_posttotal'}) && $type ne 'html-print' ) {
110 <% ref($opt{'html_posttotal'})
111 ? &{$opt{'html_posttotal'}}()
112 : $opt{'html_posttotal'}
117 % if ( $opt{'count_addl'} ) {
119 % foreach my $count ( @{$opt{'count_addl'}} ) {
120 % my $data = $count_arrayref->[++$n];
121 % if ( ref($count) ) {
122 <% &{ $count }( $data ) %>
124 <% sprintf( $count, $data ) %><BR>
132 % unless ( $opt{'disable_download'} || $type eq 'html-print' ) {
136 Download full results<BR>
138 % $cgi->param('_type', "$xlsname.xls" );
139 as <A HREF="<% $cgi->self_url %>">Excel spreadsheet</A><BR>
141 % $cgi->param('_type', 'csv');
142 as <A HREF="<% $cgi->self_url %>">CSV file</A><BR>
144 % $cgi->param('_type', 'html-print');
145 as <A HREF="<% $cgi->self_url %>">printable copy</A>
148 % $cgi->param('_type', "html" );
156 % unless ( $type eq 'html_print' ) {
158 <% $pager = include( '/elements/pager.html',
160 'num_rows' => scalar(@$rows),
162 'maxrecords' => $maxrecords,
166 <% defined($opt{'html_form'})
167 ? ( ref($opt{'html_form'})
168 ? &{$opt{'html_form'}}()
176 <% include('/elements/table-grid.html') %>
181 % foreach my $header ( @{ $opt{header} } ) {
182 % $colspan-- if $colspan > 0;
185 % my $label = ref($header) ? $header->{label} : $header;
186 % $colspan = ref($header) ? $header->{colspan} : 0;
189 % if ( $opt{header2} ) {
190 % if ( !length($opt{header2}->[$h2]) ) {
192 % splice @{ $opt{header2} }, $h2, 1;
195 % $style = 'STYLE="border-bottom: none"'
200 ROWSPAN = "<% $rowspan %>"
201 <% $colspan ? 'COLSPAN = "'.$colspan.'"' : '' %>
210 % if ( $opt{header2} ) {
212 % foreach my $header ( @{ $opt{header2} } ) {
213 % my $label = ref($header) ? $header->{label} : $header;
214 <TH CLASS="grid" BGCOLOR="#cccccc">
215 <FONT SIZE="-1"><% $label %></FONT>
221 % my $bgcolor1 = '#eeeeee';
222 % my $bgcolor2 = '#ffffff';
225 % foreach my $row ( @$rows ) {
227 % if ( $bgcolor eq $bgcolor1 ) {
228 % $bgcolor = $bgcolor2;
230 % $bgcolor = $bgcolor1;
235 % if ( $opt{'fields'} ) {
237 % my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : '';
238 % my $onclicks = $opt{'link_onclicks'} ? [ @{$opt{'link_onclicks'}} ] : [];
239 % my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : '';
240 % my $colors = $opt{'color'} ? [ @{$opt{'color'}} ] : [];
241 % my $sizes = $opt{'size'} ? [ @{$opt{'size'}} ] : [];
242 % my $styles = $opt{'style'} ? [ @{$opt{'style'}} ] : [];
243 % my $cstyles = $opt{'cell_style'} ? [ @{$opt{'cell_style'}} ] : [];
245 % foreach my $field (
248 % if ( ref($_) eq 'ARRAY' ) {
252 % '<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0 WIDTH="100%">'.
266 % uc($_).'="'. $e->{$_}. '"';
268 % grep exists($e->{$_}),
269 % qw( align bgcolor colspan rowspan
270 % style valign width )
275 % ? '<A HREF="'. $e->{'link'}. '">'
279 % ? '<FONT SIZE="'.uc($e->{'size'}).'">'
282 % ( $e->{'data_style'}
283 % ? '<'. uc($e->{'data_style'}). '>'
287 % ( $e->{'data_style'}
288 % ? '</'. uc($e->{'data_style'}). '>'
291 % ( $e->{'size'} ? '</FONT>' : '' ).
292 % ( $e->{'link'} ? '</A>' : '' ).
308 % if ( ref($_) eq 'CODE' ) {
318 % my $class = ( $field =~ /^<TABLE/i ) ? 'inv' : 'grid';
320 % my $align = $aligns ? shift @$aligns : '';
321 % $align = " ALIGN=$align" if $align;
325 % my $link = shift @$links;
326 % my $onclick = shift @$onclicks;
328 % if ( ! $opt{'agent_virt'}
329 % || ( $null_link && ! $row->agentnum )
330 % || grep { $row->agentnum == $_ }
334 % $link = &{$link}($row)
335 % if ref($link) eq 'CODE';
337 % $onclick = &{$onclick}($row)
338 % if ref($onclick) eq 'CODE';
339 % $onclick = qq( onClick="$onclick") if $onclick;
342 % my( $url, $method ) = @{$link};
343 % if ( ref($method) eq 'CODE' ) {
344 % $a = $url. &{$method}($row);
346 % $a = $url. $row->$method();
348 % $a = qq(<A HREF="$a"$onclick>);
350 % elsif ( $onclick ) {
351 % $a = qq(<A HREF="javascript:void(0);"$onclick>);
358 % my $color = shift @$colors;
359 % $color = &{$color}($row) if ref($color) eq 'CODE';
360 % my $size = shift @$sizes;
361 % $size = &{$size}($row) if ref($size) eq 'CODE';
362 % if ( $color || $size ) {
364 % ( $color ? "COLOR=#$color " : '' ).
365 % ( $size ? qq(SIZE="$size" ) : '' ).
369 % my($s, $es) = ( '', '' );
370 % my $style = shift @$styles;
371 % $style = &{$style}($row) if ref($style) eq 'CODE';
373 % $s = join( '', map "<$_>", split('', $style) );
374 % $es = join( '', map "</$_>", split('', $style) );
377 % my $cstyle = shift @$cstyles;
378 % $cstyle = &{$cstyle}($row) if ref($cstyle) eq 'CODE';
379 % $cstyle = qq(STYLE="$cstyle")
382 <TD CLASS="<% $class %>" BGCOLOR="<% $bgcolor %>" <% $align %> <% $cstyle %>><% $font %><% $a %><% $s %><% $field %><% $es %><% $a ? '</A>' : '' %><% $font ? '</FONT>' : '' %></TD>
388 % foreach ( @$row ) {
389 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $_ %></TD>
398 % if ( $opt{'footer'} ) {
402 % foreach my $footer ( @{ $opt{'footer'} } ) {
403 % $footer = &{$footer}() if ref($footer) eq 'CODE';
404 <TD CLASS="grid" BGCOLOR="#dddddd" STYLE="border-top: dashed 1px black;"><i><% $footer %></i></TD>
419 % if ( $type eq 'html-print' ) {
425 <% defined($opt{'html_foot'})
426 ? ( ref($opt{'html_foot'})
427 ? &{$opt{'html_foot'}}()
433 <% include( '/elements/footer.html' ) %>
441 my $type = $args{'type'};
442 my $header = $args{'header'};
443 my $rows = $args{'rows'};
444 my @link_agentnums = @{ $args{'link_agentnums'} };
445 my $null_link = $args{'null_link'};
446 my $confmax = $args{'confmax'};
447 my $maxrecords = $args{'maxrecords'};
448 my $offset = $args{'offset'};
449 my %opt = %{ $args{'opt'} };
451 my $count_sth = dbh->prepare($opt{'count_query'})
452 or die "Error preparing $opt{'count_query'}: ". dbh->errstr;
454 or die "Error executing $opt{'count_query'}: ". $count_sth->errstr;
455 my $count_arrayref = $count_sth->fetchrow_arrayref;
456 my $total = $count_arrayref->[0];