-%
% if ( exists($opt{'redirect'}) && $opt{'redirect'}
% && scalar(@$rows) == 1 && $total == 1
% && $type ne 'html-print'
% }
% }
%
-% if ( $type eq 'html-print' ) {
-
- <% include( '/elements/header-popup.html', $opt{'title'} ) %>
-
-% } elsif ( $type eq 'select' ) {
-
- <% include( '/elements/header-popup.html', $opt{'title'} ) %>
- <% defined($opt{'html_init'})
- ? ( ref($opt{'html_init'})
- ? &{$opt{'html_init'}}()
- : $opt{'html_init'}
- )
- : ''
- %>
-
-% } else {
+% unless ( $opt{nohtmlheader} ) {
%
-% my @menubar = ();
-% if ( $opt{'menubar'} ) {
-% @menubar = @{ $opt{'menubar'} };
-% #} else {
-% # @menubar = ( 'Main menu' => $p );
+% if ( $type eq 'html-print' ) {
+ <& /elements/header-popup.html, $opt{'title'} &>
+% } else {
+% if ( $type eq 'select' ) {
+ <&/elements/header-popup.html, $opt{'title'} &>
+% } else {
+%
+% my @menubar = ();
+% if ( $opt{'menubar'} ) {
+% @menubar = @{ $opt{'menubar'} };
+% #} else {
+% # @menubar = ( 'Main menu' => $p );
+% }
+
+ <& /elements/header.html, $opt{'title'},
+ include( '/elements/menubar.html', @menubar )
+ &>
+
+% }
% }
+%
+% }
+%
+% unless ( $type eq 'html-print' ) {
- <% include( '/elements/header.html', $opt{'title'},
- include( '/elements/menubar.html', @menubar )
- )
- %>
+% if ( $opt{'add_link'} ) { #or after html_init?
+ <A HREF="<%$p%>edit/<% $opt{query}->{table} %>.html"><I>Add a <% $opt{'name_singular'} %></I></A><BR><BR>
+% }
<% defined($opt{'html_init'})
? ( ref($opt{'html_init'})
% unless ( $total ) {
% unless ( $opt{'disable_nonefound'} ) {
- No matching <% $opt{'name'} %> found.<BR>
+ <BR><BR>No matching <% $opt{'name'} %> found.<BR>
% }
% }
%
% $cgi->delete('maxrecords');
% $cgi->param('_dummy', 1);
- ( show <SELECT NAME="maxrecords" onChange="window.location = '<% $cgi->self_url %>;maxrecords=' + this.options[this.selectedIndex].value;">
+ ( show <SELECT NAME="maxrecords" onChange="window.location = '<% "$self_url?". $cgi->query_string %>;maxrecords=' + this.options[this.selectedIndex].value;">
% foreach my $max ( map { $_ * $confmax } qw( 1 5 10 25 ) ) {
<OPTION VALUE="<% $max %>" <% ( $maxrecords == $max ) ? 'SELECTED' : '' %>><% $max %></OPTION>
</TD>
-% unless ( $opt{'disable_download'} || $type eq 'html-print' ) {
+% if ( $curuser->access_right('Download report data')
+% and !$opt{'disable_download'}
+% and $type ne 'html-print' ) {
- <TD ALIGN="right">
+ <TD ALIGN="right" CLASS="noprint">
- Download full results<BR>
+ <% $opt{'download_label'} || 'Download full results' %><BR>
% $cgi->param('_type', "$xlsname.xls" );
- as <A HREF="<% $cgi->self_url %>">Excel spreadsheet</A><BR>
+ as <A HREF="<% "$self_url?". $cgi->query_string %>">Excel spreadsheet</A><BR>
% $cgi->param('_type', 'csv');
- as <A HREF="<% $cgi->self_url %>">CSV file</A><BR>
+ as <A HREF="<% "$self_url?". $cgi->query_string %>">CSV file</A><BR>
-% $cgi->param('_type', 'html-print');
- as <A HREF="<% $cgi->self_url %>">printable copy</A>
+% if ( defined($opt{xml_elements}) ) {
+% $cgi->param('_type', 'xml');
+ as <A HREF="<% "$self_url?". $cgi->query_string %>">XML file</A><BR>
+% }
- <% $opt{'extra_choices_callback'}
- ? &{$opt{'extra_choices_callback'}}($cgi->query_string)
- : ''
- %>
+% $cgi->param('_type', 'html-print');
+ as <A HREF="<% "$self_url?". $cgi->query_string %>">printable copy</A>
</TD>
% $cgi->param('_type', "html" );
<TR>
% my $h2 = 0;
+% my $colspan = 0;
+% my @fields = @{ $opt{'sort_fields'} || $opt{'fields'} || [] };
+% my $order_by = $cgi->param('order_by');
% foreach my $header ( @{ $opt{header} } ) {
+%
+% my $field = shift @fields;
+%
+% $colspan-- if $colspan > 0;
+% next if $colspan;
+%
% my $label = ref($header) ? $header->{label} : $header;
+% unless ( ref($field) || !$field ) {
+% if ( $order_by eq $field ) {
+% $cgi->param('order_by', "$field DESC");
+% } else {
+% $cgi->param('order_by', $field);
+% }
+% $label = qq(<A HREF="$self_url?). $cgi->query_string.
+% qq(">$label</A>);
+% }
+%
+% $colspan = ref($header) ? $header->{colspan} : 0;
% my $rowspan = 1;
% my $style = '';
% if ( $opt{header2} ) {
<TH CLASS = "grid"
BGCOLOR = "#cccccc"
ROWSPAN = "<% $rowspan %>"
+ <% $colspan ? 'COLSPAN = "'.$colspan.'"' : '' %>
<% $style %>
>
%
% my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : '';
% my $onclicks = $opt{'link_onclicks'} ? [ @{$opt{'link_onclicks'}} ] : [];
+% my $tooltips = $opt{'tooltips'} ? [ @{$opt{'tooltips'}} ] : [];
% my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : '';
% my $colors = $opt{'color'} ? [ @{$opt{'color'}} ] : [];
% my $sizes = $opt{'size'} ? [ @{$opt{'size'}} ] : [];
% ? '<A HREF="'. $e->{'link'}. '">'
% : ''
% ).
+% ( $e->{'onclick'} # don't use with 'link'
+% ? '<A HREF="#" onclick="' .
+% $e->{'onclick'}.'">'
+% : ''
+% ).
% ( $e->{'size'}
% ? '<FONT SIZE="'.uc($e->{'size'}).'">'
% : ''
% : ''
% ).
% ( $e->{'size'} ? '</FONT>' : '' ).
-% ( $e->{'link'} ? '</A>' : '' ).
+% ( $e->{'link'} || $e->{'onclick'}
+% ? '</A>'
+% : '' ).
% '</td>';
%
% } @$rowref ).
% if ( ref($_) eq 'CODE' ) {
% &{$_}($row);
% } else {
-% $row->$_();
+% encode_entities($row->$_());
% }
% }
% @{$opt{'fields'}}
% if ( $links ) {
% my $link = shift @$links;
% my $onclick = shift @$onclicks;
+% my $tooltip = shift @$tooltips;
%
% if ( ! $opt{'agent_virt'}
% || ( $null_link && ! $row->agentnum )
% if ref($onclick) eq 'CODE';
% $onclick = qq( onClick="$onclick") if $onclick;
%
+% $tooltip = &{$tooltip}($row)
+% if ref($tooltip) eq 'CODE';
+% $tooltip = qq! id="a$id" !.
+% qq! onmouseover="return overlib(!.
+% $m->interp->apply_escapes($tooltip, 'h', 'js_string').
+% qq!, FGCLASS, 'tooltip', REF, 'a$id', !.
+% qq!REFC, 'LL', REFP, 'UL')"! if $tooltip;
+%
% if ( $link ) {
% my( $url, $method ) = @{$link};
% if ( ref($method) eq 'CODE' ) {
% } else {
% $a = $url. $row->$method();
% }
-% $a = qq(<A HREF="$a"$onclick>);
+% $a = qq(<A HREF="$a"$onclick$tooltip>);
% }
-%
+% elsif ( $onclick ) {
+% $a = qq(<A HREF="javascript:void(0);"$onclick>);
+% }
+% elsif ( $tooltip ) {
+% $a = qq(<A $tooltip>);
+% }
+% $id++;
+
% }
%
% }
% }
-% if ( $opt{'footer'} ) {
+% if ( $opt{'footer'} ) {
<TR>
% foreach my $footer ( @{ $opt{'footer'} } ) {
+% $footer = &{$footer}() if ref($footer) eq 'CODE';
<TD CLASS="grid" BGCOLOR="#dddddd" STYLE="border-top: dashed 1px black;"><i><% $footer %></i></TD>
% }
% }
% if ( $type eq 'html-print' ) {
+% unless ( $opt{nohtmlheader} ) {
</BODY></HTML>
+% }
% } else {
<% defined($opt{'html_foot'})
: ''
%>
- <% include( '/elements/footer.html' ) %>
+ <% $opt{nohtmlheader}
+ ? ''
+ : include( '/elements/footer.html' )
+ %>
% }
% }
<%init>
+my $curuser = $FS::CurrentUser::CurrentUser;
+
my %args = @_;
my $type = $args{'type'};
my $header = $args{'header'};
my $maxrecords = $args{'maxrecords'};
my $offset = $args{'offset'};
my %opt = %{ $args{'opt'} };
+my $self_url = $opt{'url'} || $cgi->url('-path_info' => 1, '-full' =>1);
my $count_sth = dbh->prepare($opt{'count_query'})
or die "Error preparing $opt{'count_query'}: ". dbh->errstr;
my $count_arrayref = $count_sth->fetchrow_arrayref;
my $total = $count_arrayref->[0];
+my $id = 0;
</%init>