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' ) {
37 : include( '/elements/header-popup.html', $opt{'title'} )
40 % } elsif ( $type eq 'select' ) {
44 : include( '/elements/header-popup.html', $opt{'title'} )
46 <% defined($opt{'html_init'})
47 ? ( ref($opt{'html_init'})
48 ? &{$opt{'html_init'}}()
57 % if ( $opt{'menubar'} ) {
58 % @menubar = @{ $opt{'menubar'} };
60 % # @menubar = ( 'Main menu' => $p );
65 : include( '/elements/header.html', $opt{'title'},
66 include( '/elements/menubar.html', @menubar )
70 <% defined($opt{'html_init'})
71 ? ( ref($opt{'html_init'})
72 ? &{$opt{'html_init'}}()
81 % unless ( $opt{'disable_nonefound'} ) {
82 No matching <% $opt{'name'} %> found.<BR>
86 % if ( $total || $opt{'disableable'} ) { #hmm... and there *are* ones to show??
95 % if (! $opt{'disable_total'}) {
96 <% $total %> total <% $opt{'name'} %>
99 % if ( $confmax && $total > $confmax
100 % && ! $opt{'disable_maxselect'}
101 % && $type ne 'html-print' )
103 % $cgi->delete('maxrecords');
104 % $cgi->param('_dummy', 1);
106 ( show <SELECT NAME="maxrecords" onChange="window.location = '<% "$self_url?". $cgi->query_string %>;maxrecords=' + this.options[this.selectedIndex].value;">
108 % foreach my $max ( map { $_ * $confmax } qw( 1 5 10 25 ) ) {
109 <OPTION VALUE="<% $max %>" <% ( $maxrecords == $max ) ? 'SELECTED' : '' %>><% $max %></OPTION>
114 % $cgi->param('maxrecords', $maxrecords);
117 % if ( defined($opt{'html_posttotal'}) && $type ne 'html-print' ) {
118 <% ref($opt{'html_posttotal'})
119 ? &{$opt{'html_posttotal'}}()
120 : $opt{'html_posttotal'}
125 % if ( $opt{'count_addl'} ) {
127 % foreach my $count ( @{$opt{'count_addl'}} ) {
128 % my $data = $count_arrayref->[++$n];
129 % if ( ref($count) ) {
130 <% &{ $count }( $data ) %>
132 <% sprintf( $count, $data ) %><BR>
140 % unless ( $opt{'disable_download'} || $type eq 'html-print' ) {
144 Download full results<BR>
146 % $cgi->param('_type', "$xlsname.xls" );
147 as <A HREF="<% "$self_url?". $cgi->query_string %>">Excel spreadsheet</A><BR>
149 % $cgi->param('_type', 'csv');
150 as <A HREF="<% "$self_url?". $cgi->query_string %>">CSV file</A><BR>
152 % if ( defined($opt{xml_elements}) ) {
153 % $cgi->param('_type', 'xml');
154 as <A HREF="<% "$self_url?". $cgi->query_string %>">XML file</A><BR>
157 % $cgi->param('_type', 'html-print');
158 as <A HREF="<% "$self_url?". $cgi->query_string %>">printable copy</A>
161 % $cgi->param('_type', "html" );
169 % unless ( $type eq 'html_print' ) {
171 <% $pager = include( '/elements/pager.html',
173 'num_rows' => scalar(@$rows),
175 'maxrecords' => $maxrecords,
179 <% defined($opt{'html_form'})
180 ? ( ref($opt{'html_form'})
181 ? &{$opt{'html_form'}}()
189 <% include('/elements/table-grid.html') %>
194 % foreach my $header ( @{ $opt{header} } ) {
195 % $colspan-- if $colspan > 0;
198 % my $label = ref($header) ? $header->{label} : $header;
199 % $colspan = ref($header) ? $header->{colspan} : 0;
202 % if ( $opt{header2} ) {
203 % if ( !length($opt{header2}->[$h2]) ) {
205 % splice @{ $opt{header2} }, $h2, 1;
208 % $style = 'STYLE="border-bottom: none"'
213 ROWSPAN = "<% $rowspan %>"
214 <% $colspan ? 'COLSPAN = "'.$colspan.'"' : '' %>
223 % if ( $opt{header2} ) {
225 % foreach my $header ( @{ $opt{header2} } ) {
226 % my $label = ref($header) ? $header->{label} : $header;
227 <TH CLASS="grid" BGCOLOR="#cccccc">
228 <FONT SIZE="-1"><% $label %></FONT>
234 % my $bgcolor1 = '#eeeeee';
235 % my $bgcolor2 = '#ffffff';
238 % foreach my $row ( @$rows ) {
240 % if ( $bgcolor eq $bgcolor1 ) {
241 % $bgcolor = $bgcolor2;
243 % $bgcolor = $bgcolor1;
248 % if ( $opt{'fields'} ) {
250 % my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : '';
251 % my $onclicks = $opt{'link_onclicks'} ? [ @{$opt{'link_onclicks'}} ] : [];
252 % my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : '';
253 % my $colors = $opt{'color'} ? [ @{$opt{'color'}} ] : [];
254 % my $sizes = $opt{'size'} ? [ @{$opt{'size'}} ] : [];
255 % my $styles = $opt{'style'} ? [ @{$opt{'style'}} ] : [];
256 % my $cstyles = $opt{'cell_style'} ? [ @{$opt{'cell_style'}} ] : [];
258 % foreach my $field (
261 % if ( ref($_) eq 'ARRAY' ) {
265 % '<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0 WIDTH="100%">'.
279 % uc($_).'="'. $e->{$_}. '"';
281 % grep exists($e->{$_}),
282 % qw( align bgcolor colspan rowspan
283 % style valign width )
288 % ? '<A HREF="'. $e->{'link'}. '">'
292 % ? '<FONT SIZE="'.uc($e->{'size'}).'">'
295 % ( $e->{'data_style'}
296 % ? '<'. uc($e->{'data_style'}). '>'
300 % ( $e->{'data_style'}
301 % ? '</'. uc($e->{'data_style'}). '>'
304 % ( $e->{'size'} ? '</FONT>' : '' ).
305 % ( $e->{'link'} ? '</A>' : '' ).
321 % if ( ref($_) eq 'CODE' ) {
331 % my $class = ( $field =~ /^<TABLE/i ) ? 'inv' : 'grid';
333 % my $align = $aligns ? shift @$aligns : '';
334 % $align = " ALIGN=$align" if $align;
338 % my $link = shift @$links;
339 % my $onclick = shift @$onclicks;
341 % if ( ! $opt{'agent_virt'}
342 % || ( $null_link && ! $row->agentnum )
343 % || grep { $row->agentnum == $_ }
347 % $link = &{$link}($row)
348 % if ref($link) eq 'CODE';
350 % $onclick = &{$onclick}($row)
351 % if ref($onclick) eq 'CODE';
352 % $onclick = qq( onClick="$onclick") if $onclick;
355 % my( $url, $method ) = @{$link};
356 % if ( ref($method) eq 'CODE' ) {
357 % $a = $url. &{$method}($row);
359 % $a = $url. $row->$method();
361 % $a = qq(<A HREF="$a"$onclick>);
363 % elsif ( $onclick ) {
364 % $a = qq(<A HREF="javascript:void(0);"$onclick>);
371 % my $color = shift @$colors;
372 % $color = &{$color}($row) if ref($color) eq 'CODE';
373 % my $size = shift @$sizes;
374 % $size = &{$size}($row) if ref($size) eq 'CODE';
375 % if ( $color || $size ) {
377 % ( $color ? "COLOR=#$color " : '' ).
378 % ( $size ? qq(SIZE="$size" ) : '' ).
382 % my($s, $es) = ( '', '' );
383 % my $style = shift @$styles;
384 % $style = &{$style}($row) if ref($style) eq 'CODE';
386 % $s = join( '', map "<$_>", split('', $style) );
387 % $es = join( '', map "</$_>", split('', $style) );
390 % my $cstyle = shift @$cstyles;
391 % $cstyle = &{$cstyle}($row) if ref($cstyle) eq 'CODE';
392 % $cstyle = qq(STYLE="$cstyle")
395 <TD CLASS="<% $class %>" BGCOLOR="<% $bgcolor %>" <% $align %> <% $cstyle %>><% $font %><% $a %><% $s %><% $field %><% $es %><% $a ? '</A>' : '' %><% $font ? '</FONT>' : '' %></TD>
401 % foreach ( @$row ) {
402 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $_ %></TD>
411 % if ( $opt{'footer'} ) {
415 % foreach my $footer ( @{ $opt{'footer'} } ) {
416 <TD CLASS="grid" BGCOLOR="#dddddd" STYLE="border-top: dashed 1px black;"><i><% $footer %></i></TD>
431 % if ( $type eq 'html-print' ) {
432 % unless ( $opt{nohtmlheader} ) {
439 <% defined($opt{'html_foot'})
440 ? ( ref($opt{'html_foot'})
441 ? &{$opt{'html_foot'}}()
447 <% $opt{nohtmlheader}
449 : include( '/elements/footer.html' )
458 my $type = $args{'type'};
459 my $header = $args{'header'};
460 my $rows = $args{'rows'};
461 my @link_agentnums = @{ $args{'link_agentnums'} };
462 my $null_link = $args{'null_link'};
463 my $confmax = $args{'confmax'};
464 my $maxrecords = $args{'maxrecords'};
465 my $offset = $args{'offset'};
466 my %opt = %{ $args{'opt'} };
467 my $self_url = $opt{'url'} || $cgi->url('-path_info' => 1, '-full' =>1);
469 my $count_sth = dbh->prepare($opt{'count_query'})
470 or die "Error preparing $opt{'count_query'}: ". dbh->errstr;
472 or die "Error executing $opt{'count_query'}: ". $count_sth->errstr;
473 my $count_arrayref = $count_sth->fetchrow_arrayref;
474 my $total = $count_arrayref->[0];