From 01ea05e688db67a832764bae7356fe460e314ec7 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Mon, 5 Mar 2012 19:31:01 -0800 Subject: printer-friendly daily sales report, #16533 --- httemplate/graph/elements/monthly.html | 1 + httemplate/graph/elements/report.html | 185 ++++++++++++++++++++------------- 2 files changed, 112 insertions(+), 74 deletions(-) (limited to 'httemplate/graph/elements') diff --git a/httemplate/graph/elements/monthly.html b/httemplate/graph/elements/monthly.html index 275e5e6ff..2fd605d5e 100644 --- a/httemplate/graph/elements/monthly.html +++ b/httemplate/graph/elements/monthly.html @@ -54,6 +54,7 @@ Example: 'colors' => $data->{colors}, 'links' => \@links, 'bottom_link' => \@bottom_link, + 'transpose' => $opt{'daily'}, map { $_, $opt{$_} } (qw(title nototal graph_type diff --git a/httemplate/graph/elements/report.html b/httemplate/graph/elements/report.html index da2235fa9..382c41f6c 100644 --- a/httemplate/graph/elements/report.html +++ b/httemplate/graph/elements/report.html @@ -135,7 +135,21 @@ any delimiter and linked from the elements in @data. % my $class = "Chart::$graph_type"; % % my $chart = $class->new(976,384); -% +% # the chart area itself is 900 pixels wide, and the date labels are ~60 each. +% # staggered, we can fit about 28 of them. +% # they're about 12 pixels high, so vertically, we can fit about 60 (allowing +% # space for them to be readable). +% # after that we have to start skipping labels. also remove the dots, since +% # they're just a blob at that point. +% my $num_labels = scalar(@{ $opt{axis_labels} }); +% my %chart_opt; +% if ( $num_labels > 28 ) { +% $chart_opt{x_ticks} = 'vertical'; +% if ( $num_labels > 60 ) { +% $chart_opt{skip_x_ticks} = int($num_labels / 60) + 1; +% $chart_opt{pt_size} = 1; +% } +% } % my $d = 0; % $chart->set( % #'min_val' => 0, @@ -152,6 +166,7 @@ any delimiter and linked from the elements in @data. % }, % 'legend_labels' => $opt{'graph_labels'}, % 'brush_size' => 4, +% %chart_opt, % ); % % http_header('Content-Type' => 'image/png' ); @@ -169,9 +184,10 @@ any delimiter and linked from the elements in @data. <% include('/elements/header.html', $opt{'title'} ) %> % unless ( $opt{'graph_type'} eq 'none' ) { -" WIDTH="976" HEIGHT="384"> +" WIDTH="976" HEIGHT="384" + STYLE="page-break-after:always;"> % } -

+

% unless ( $opt{'disable_download'} ) { Download full results
@@ -180,88 +196,109 @@ any delimiter and linked from the elements in @data. % } %

-<% include('/elements/table.html', 'f8f8f8') %> - - - - - +%# indexed by item, then by entry (the element indices of @{$data[$i]}). +% my @cell = (); +% my @styles; +% my $num_entries = scalar(@col_labels); +% my $num_items = scalar(@items); +% $cell[0] = ['']; #top left corner % foreach my $column ( @col_labels ) { -% $column =~ s/ /\/; # working on a smarter way to do this - <% $column %> -% } - -% unless ( $opt{'nototal'} ) { - Total -% } +% $column =~ s/ /\/; +% push @{$cell[0]}, $column; +% } +% if ( ! $opt{'nototal'} ) { +% $num_entries++; +% push @{$cell[0]}, emt('Total'); +% } - +% # i for item, e for entry -% my @bottom_total = (); +% my $i = 1; % foreach my $row ( @items ) { +% #make a style +% my $color = shift @{ $opt{'colors'} }; +% push @styles, ".i$i { text-align: right; color: #$color; }"; +% #create the data row +% my $links = shift @{$opt{'links'}} || ['']; +% my $link_prefix = shift @$links; +% $link_prefix = ' - - - <% $label %> - +% my $data_row = shift @data; +% if ( ! $opt{'nototal'} ) { +% push @$data_row, sum(@$data_row); +% } +% foreach my $entry ( @$data_row ) { +% $entry = $money_char . sprintf($sprintf, $entry); +% $entry = $link_prefix . shift(@$links) . "\">$entry" if $link_prefix; +% push @{$cell[$i]}, $entry; +% } +% $i++; +% } +% if ( $opt{'bottom_total'} ) { +% # it's an extra item +% $num_items++; +% push @styles, ".i$i { text-align: right; background-color: #f5f6be; }"; +% my $links = $opt{'bottom_link'} || []; +% my $link_prefix = shift @$links; +% $cell[$i] = [ emt('Total') ]; +% for (my $e = 0; $e < $num_entries + 1; $e++) { +% my $entry = sum(map { $_->[$e] } @data); +% $entry = $money_char . sprintf($sprintf, $entry); +% $entry = $link_prefix . shift(@$links) . "\">$entry" if $link_prefix; +% push @{$cell[$i]}, $entry; +% } +% } -% my $total = 0; -% my $col = 0; -% foreach my $column ( @{ shift( @data ) } ) { + - - <% $link_prefix ? $link_prefix . shift(@links) . '">' : '' %><% $money_char %><% sprintf($sprintf,, $column) %><% $link_prefix ? '' : '' %> - +<% include('/elements/table.html', 'f8f8f8') %> +% if ( $opt{'transpose'} ) { +% for ( my $e = 0; $e < $num_entries + 1; $e++ ) { + +% for ( my $i = 0; $i < $num_items + 1; $i++ ) { + "><% $cell[$i][$e] %> +% } + +% } % -% $total += $column; -% $bottom_total[$col++] += $column; -% -% } - -% unless ( $opt{'nototal'} ) { - - <% $link_prefix ? $link_prefix. shift(@links) . '">' : '' %><% $money_char %><% sprintf($sprintf, $total) %><% $link_prefix ? '' : '' %> - -% $bottom_total[$col++] += $total; -% } - - - -% } - -% if ( $opt{'bottom_total'} ) { +% } else { #!transpose +% +% for (my $i = 0; $i < $num_items + 1; $i++) { - Total -% my @bottom_links = $opt{'bottom_link'} ? @{ $opt{'bottom_link'} } : (); -% my $prefix = shift(@bottom_links); -% pop @bottom_links if $opt{'nototal'}; -% foreach my $total ( @bottom_total ) { - - - <% $prefix - ? '' - : '' - %><% $money_char %><% sprintf($sprintf, $total) %><% $prefix ? '' : '' %> - - - -% } - +% for (my $e = 0; $e < $num_entries + 1; $e++) { + "><% $cell[$i][$e] %> +% } - -% } - +% } +% } <% include('/elements/footer.html') %> % } -- cgit v1.2.1