1 % if ( exists($opt{'redirect'}) && $opt{'redirect'}
2 % && scalar(@$rows) == 1 && $total == 1
3 % && $type ne 'html-print'
5 % my $redirect = $opt{'redirect'};
6 % $redirect = &{$redirect}($rows->[0], $cgi) if ref($redirect) eq 'CODE';
7 % my( $url, $method ) = @$redirect;
8 % redirect( $url. $rows->[0]->$method() );
9 % } elsif ( exists($opt{'redirect_empty'}) && ! scalar(@$rows) && $total == 0
10 % && $type ne 'html-print'
11 % && $opt{'redirect_empty'}
12 % && ( ref($opt{'redirect_empty'}) ne 'CODE'
13 % || &{$opt{'redirect_empty'}}($cgi) )
15 % my $redirect = $opt{'redirect_empty'};
16 % $redirect = &{$redirect}($cgi) if ref($redirect) eq 'CODE';
17 % redirect( $redirect );
19 % if ( $opt{'name_singular'} ) {
20 % $opt{'name'} = PL($opt{'name_singular'});
22 % ( my $xlsname = $opt{'name'} ) =~ s/\W//g;
23 % if ( $total == 1 ) {
24 % if ( $opt{'name_singular'} ) {
25 % $opt{'name'} = $opt{'name_singular'}
27 % #$opt{'name'} =~ s/s$// if $total == 1;
28 % $opt{'name'} =~ s/((s)e)?s$/$2/ if $total == 1;
32 % if ( $type eq 'html-print' ) {
36 : include( '/elements/header-popup.html', $opt{'title'} )
39 % } elsif ( $type eq 'select' ) {
43 : include( '/elements/header-popup.html', $opt{'title'} )
45 <% defined($opt{'html_init'})
46 ? ( ref($opt{'html_init'})
47 ? &{$opt{'html_init'}}()
56 % if ( $opt{'menubar'} ) {
57 % @menubar = @{ $opt{'menubar'} };
59 % # @menubar = ( 'Main menu' => $p );
64 : include( '/elements/header.html', $opt{'title'},
65 include( '/elements/menubar.html', @menubar )
69 <% defined($opt{'html_init'})
70 ? ( ref($opt{'html_init'})
71 ? &{$opt{'html_init'}}()
80 % unless ( $opt{'disable_nonefound'} ) {
81 No matching <% $opt{'name'} %> found.<BR>
85 % if ( $total || $opt{'disableable'} ) { #hmm... and there *are* ones to show??
94 % if (! $opt{'disable_total'}) {
95 <% $total %> total <% $opt{'name'} %>
98 % if ( $confmax && $total > $confmax
99 % && ! $opt{'disable_maxselect'}
100 % && $type ne 'html-print' )
102 % $cgi->delete('maxrecords');
103 % $cgi->param('_dummy', 1);
105 ( show <SELECT NAME="maxrecords" onChange="window.location = '<% "$self_url?". $cgi->query_string %>;maxrecords=' + this.options[this.selectedIndex].value;">
107 % foreach my $max ( map { $_ * $confmax } qw( 1 5 10 25 ) ) {
108 <OPTION VALUE="<% $max %>" <% ( $maxrecords == $max ) ? 'SELECTED' : '' %>><% $max %></OPTION>
113 % $cgi->param('maxrecords', $maxrecords);
116 % if ( defined($opt{'html_posttotal'}) && $type ne 'html-print' ) {
117 <% ref($opt{'html_posttotal'})
118 ? &{$opt{'html_posttotal'}}()
119 : $opt{'html_posttotal'}
124 % if ( $opt{'count_addl'} ) {
126 % foreach my $count ( @{$opt{'count_addl'}} ) {
127 % my $data = $count_arrayref->[++$n];
128 % if ( ref($count) ) {
129 <% &{ $count }( $data ) %>
131 <% sprintf( $count, $data ) %><BR>
139 % unless ( $opt{'disable_download'} || $type eq 'html-print' ) {
143 Download full results<BR>
145 % $cgi->param('_type', "$xlsname.xls" );
146 as <A HREF="<% "$self_url?". $cgi->query_string %>">Excel spreadsheet</A><BR>
148 % $cgi->param('_type', 'csv');
149 as <A HREF="<% "$self_url?". $cgi->query_string %>">CSV file</A><BR>
151 % if ( defined($opt{xml_elements}) ) {
152 % $cgi->param('_type', 'xml');
153 as <A HREF="<% "$self_url?". $cgi->query_string %>">XML file</A><BR>
156 % $cgi->param('_type', 'html-print');
157 as <A HREF="<% "$self_url?". $cgi->query_string %>">printable copy</A>
160 % $cgi->param('_type', "html" );
168 % unless ( $type eq 'html_print' ) {
170 <% $pager = include( '/elements/pager.html',
172 'num_rows' => scalar(@$rows),
174 'maxrecords' => $maxrecords,
178 <% defined($opt{'html_form'})
179 ? ( ref($opt{'html_form'})
180 ? &{$opt{'html_form'}}()
188 <% include('/elements/table-grid.html') %>
193 % foreach my $header ( @{ $opt{header} } ) {
194 % $colspan-- if $colspan > 0;
197 % my $label = ref($header) ? $header->{label} : $header;
198 % $colspan = ref($header) ? $header->{colspan} : 0;
201 % if ( $opt{header2} ) {
202 % if ( !length($opt{header2}->[$h2]) ) {
204 % splice @{ $opt{header2} }, $h2, 1;
207 % $style = 'STYLE="border-bottom: none"'
212 ROWSPAN = "<% $rowspan %>"
213 <% $colspan ? 'COLSPAN = "'.$colspan.'"' : '' %>
222 % if ( $opt{header2} ) {
224 % foreach my $header ( @{ $opt{header2} } ) {
225 % my $label = ref($header) ? $header->{label} : $header;
226 <TH CLASS="grid" BGCOLOR="#cccccc">
227 <FONT SIZE="-1"><% $label %></FONT>
233 % my $bgcolor1 = '#eeeeee';
234 % my $bgcolor2 = '#ffffff';
237 % foreach my $row ( @$rows ) {
239 % if ( $bgcolor eq $bgcolor1 ) {
240 % $bgcolor = $bgcolor2;
242 % $bgcolor = $bgcolor1;
247 % if ( $opt{'fields'} ) {
249 % my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : '';
250 % my $onclicks = $opt{'link_onclicks'} ? [ @{$opt{'link_onclicks'}} ] : [];
251 % my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : '';
252 % my $colors = $opt{'color'} ? [ @{$opt{'color'}} ] : [];
253 % my $sizes = $opt{'size'} ? [ @{$opt{'size'}} ] : [];
254 % my $styles = $opt{'style'} ? [ @{$opt{'style'}} ] : [];
255 % my $cstyles = $opt{'cell_style'} ? [ @{$opt{'cell_style'}} ] : [];
257 % foreach my $field (
260 % if ( ref($_) eq 'ARRAY' ) {
264 % '<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0 WIDTH="100%">'.
278 % uc($_).'="'. $e->{$_}. '"';
280 % grep exists($e->{$_}),
281 % qw( align bgcolor colspan rowspan
282 % style valign width )
287 % ? '<A HREF="'. $e->{'link'}. '">'
291 % ? '<FONT SIZE="'.uc($e->{'size'}).'">'
294 % ( $e->{'data_style'}
295 % ? '<'. uc($e->{'data_style'}). '>'
299 % ( $e->{'data_style'}
300 % ? '</'. uc($e->{'data_style'}). '>'
303 % ( $e->{'size'} ? '</FONT>' : '' ).
304 % ( $e->{'link'} ? '</A>' : '' ).
320 % if ( ref($_) eq 'CODE' ) {
330 % my $class = ( $field =~ /^<TABLE/i ) ? 'inv' : 'grid';
332 % my $align = $aligns ? shift @$aligns : '';
333 % $align = " ALIGN=$align" if $align;
337 % my $link = shift @$links;
338 % my $onclick = shift @$onclicks;
340 % if ( ! $opt{'agent_virt'}
341 % || ( $null_link && ! $row->agentnum )
342 % || grep { $row->agentnum == $_ }
346 % $link = &{$link}($row)
347 % if ref($link) eq 'CODE';
349 % $onclick = &{$onclick}($row)
350 % if ref($onclick) eq 'CODE';
351 % $onclick = qq( onClick="$onclick") if $onclick;
354 % my( $url, $method ) = @{$link};
355 % if ( ref($method) eq 'CODE' ) {
356 % $a = $url. &{$method}($row);
358 % $a = $url. $row->$method();
360 % $a = qq(<A HREF="$a"$onclick>);
362 % elsif ( $onclick ) {
363 % $a = qq(<A HREF="javascript:void(0);"$onclick>);
370 % my $color = shift @$colors;
371 % $color = &{$color}($row) if ref($color) eq 'CODE';
372 % my $size = shift @$sizes;
373 % $size = &{$size}($row) if ref($size) eq 'CODE';
374 % if ( $color || $size ) {
376 % ( $color ? "COLOR=#$color " : '' ).
377 % ( $size ? qq(SIZE="$size" ) : '' ).
381 % my($s, $es) = ( '', '' );
382 % my $style = shift @$styles;
383 % $style = &{$style}($row) if ref($style) eq 'CODE';
385 % $s = join( '', map "<$_>", split('', $style) );
386 % $es = join( '', map "</$_>", split('', $style) );
389 % my $cstyle = shift @$cstyles;
390 % $cstyle = &{$cstyle}($row) if ref($cstyle) eq 'CODE';
391 % $cstyle = qq(STYLE="$cstyle")
394 <TD CLASS="<% $class %>" BGCOLOR="<% $bgcolor %>" <% $align %> <% $cstyle %>><% $font %><% $a %><% $s %><% $field %><% $es %><% $a ? '</A>' : '' %><% $font ? '</FONT>' : '' %></TD>
400 % foreach ( @$row ) {
401 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $_ %></TD>
410 % if ( $opt{'footer'} ) {
414 % foreach my $footer ( @{ $opt{'footer'} } ) {
415 % $footer = &{$footer}() if ref($footer) eq 'CODE';
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];