summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-03-05 19:31:01 -0800
committerMark Wells <mark@freeside.biz>2012-03-05 19:31:01 -0800
commit01ea05e688db67a832764bae7356fe460e314ec7 (patch)
tree4a7da9d63519e4c8eed65557609cbf18191c3e67
parent1fc6e684436955f6980dd8d9129f6a95d5af595e (diff)
printer-friendly daily sales report, #16533
-rw-r--r--FS/FS/Mason.pm2
-rw-r--r--FS/FS/Report/Table/Daily.pm4
-rw-r--r--httemplate/elements/freeside.css1
-rw-r--r--httemplate/elements/header.html12
-rw-r--r--httemplate/elements/menu.html1
-rw-r--r--httemplate/graph/elements/monthly.html1
-rw-r--r--httemplate/graph/elements/report.html185
7 files changed, 123 insertions, 83 deletions
diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm
index 63eb47cab..60b0b5fe0 100644
--- a/FS/FS/Mason.pm
+++ b/FS/FS/Mason.pm
@@ -55,7 +55,7 @@ if ( -e $addl_handler_use_file ) {
#use CGI::Carp qw(fatalsToBrowser);
use CGI::Cookie;
- use List::Util qw( max min );
+ use List::Util qw( max min sum );
use Data::Dumper;
use Date::Format;
use Time::Local;
diff --git a/FS/FS/Report/Table/Daily.pm b/FS/FS/Report/Table/Daily.pm
index 5bbd6e4e7..3b21fa800 100644
--- a/FS/FS/Report/Table/Daily.pm
+++ b/FS/FS/Report/Table/Daily.pm
@@ -58,7 +58,7 @@ sub data {
my $sdate = timelocal(0,0,0,$sday,$smonth-1,$syear);
my $edate = timelocal(0,0,0,$eday,$emonth-1,$eyear);
- warn "daily range $sdate $edate\n";
+ #warn "daily range $sdate $edate\n";
# XXX: use date_format config for the labels since we have day in the labels now?
# XXX: leap seconds / DST
@@ -66,7 +66,7 @@ sub data {
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($sdate);
$mon++;
$year += 1900;
- warn "label=$mday/$mon/$year\n";
+ #warn "label=$mday/$mon/$year\n";
push @{$data{label}}, "$mday/$mon/$year";
my $speriod = $sdate;
diff --git a/httemplate/elements/freeside.css b/httemplate/elements/freeside.css
index 90c7291f6..79c98cdd9 100644
--- a/httemplate/elements/freeside.css
+++ b/httemplate/elements/freeside.css
@@ -223,3 +223,4 @@ div.fstabcontainer {
.background {
background-color:#f8f8f8;
}
+
diff --git a/httemplate/elements/header.html b/httemplate/elements/header.html
index 61d031376..d0ab3055d 100644
--- a/httemplate/elements/header.html
+++ b/httemplate/elements/header.html
@@ -47,7 +47,7 @@ Example:
</HEAD>
<BODY BGCOLOR="#f8f8f8" <% $etc |n %> STYLE="margin-top:0; margin-bottom:0; margin-left:0px; margin-right:0px">
- <table width="100%" CELLPADDING=0 CELLSPACING=0 STYLE="padding-left:0px; padding-right:4px">
+ <table width="100%" CELLPADDING=0 CELLSPACING=0 STYLE="padding-left:0px; padding-right:4px" CLASS="fshead">
<tr>
<td BGCOLOR="#ffffff"><IMG BORDER=0 ALT="freeside" HEIGHT="36" SRC="<%$fsurl%>view/REAL_logo.cgi"></td>
<td align=left BGCOLOR="#ffffff"> <!-- valign="top" -->
@@ -69,7 +69,7 @@ Example:
% if ( $menu_position eq 'top' ) {
- <TR>
+ <TR CLASS="fsmenubar">
% if ( $mobile ) {
@@ -92,7 +92,7 @@ Example:
</TR>
- <TR>
+ <TR CLASS="fssearchbar">
<TD COLSPAN=1 BGCOLOR="#cccccc" ALIGN="right" STYLE="padding-left:2px">
<% include('searchbar-prospect.html') |n %>
@@ -124,7 +124,7 @@ Example:
% } else { #$menu_position eq 'left'
- <TR>
+ <TR CLASS="fsmenubar">
<TD COLSPAN="7" WIDTH="100%" STYLE="padding:1px 0px 0px 0px;border-top: 1px solid #7e0079" BGCOLOR="#cccccc">
</TD>
@@ -140,7 +140,7 @@ Example:
% if ( $menu_position eq 'left' ) {
- <TD BGCOLOR="#cccccc" ALIGN="left" HEIGHT="100%" WIDTH="154" VALIGN="top" ALIGN="right">
+ <TD BGCOLOR="#cccccc" ALIGN="left" HEIGHT="100%" WIDTH="154" VALIGN="top" ALIGN="right" CLASS="fsmenubar">
<SCRIPT TYPE="text/javascript">
document.write(myBar);
</SCRIPT>
@@ -156,7 +156,7 @@ Example:
</TD>
% }
-
+%# page content starts here
<TD CLASS="background" HEIGHT="100%" VALIGN="top"> <!-- WIDTH="100%"> -->
<FONT SIZE=6>
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index 3b1064f02..b3a555a9f 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -14,6 +14,7 @@
% unless ( $opt{'nocss'} ) {
<link href="<%$fsurl%>elements/freeside.css" type="text/css" rel="stylesheet">
+ <link href="<%$fsurl%>elements/freeside-print.css" type="text/css" rel="stylesheet" media="print">
% }
<link href="<%$fsurl%>elements/freeside-menu.css" type="text/css" rel="stylesheet">
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' ) {
-<IMG SRC="<% "$myself;_type=png" %>" WIDTH="976" HEIGHT="384">
+<IMG SRC="<% "$myself;_type=png" %>" WIDTH="976" HEIGHT="384"
+ STYLE="page-break-after:always;">
% }
-<P ALIGN="right">
+<P ALIGN="right" CLASS="noprint">
% unless ( $opt{'disable_download'} ) {
Download full results<BR>
@@ -180,88 +196,109 @@ any delimiter and linked from the elements in @data.
% }
%
</P>
-<% include('/elements/table.html', 'f8f8f8') %>
-
-<TR>
-
- <TD></TD>
-
+%# 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/ /\<BR\>/; # working on a smarter way to do this
- <TH><% $column %></TH>
-% }
-
-% unless ( $opt{'nototal'} ) {
- <TH>Total</TH>
-% }
+% $column =~ s/ /\<BR\>/;
+% push @{$cell[0]}, $column;
+% }
+% if ( ! $opt{'nototal'} ) {
+% $num_entries++;
+% push @{$cell[0]}, emt('Total');
+% }
-</TR>
+% # 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 = '<A CLASS="cell" HREF="'.$link_prefix if $link_prefix;
+% my $label = shift @row_labels;
+% $cell[$i] = [ $label ];
%
-% my $color = shift( @{ $opt{'colors'} } );
-% my @links = @{ shift( @{ $opt{'links'} } ) };
-% # $opt{'links'} is an array parallel to items.
-% # Each element of that is an array containing a prefix,
-% # followed by suffixes matched to the cells of the table.
-% my $link_prefix = shift @links;
-% $link_prefix = $link_prefix ? qq(<A HREF="$link_prefix) : ''; #"
-% my $label = shift( @row_labels );
-
- <TR>
-
- <TH>
- <FONT COLOR="#<% $color %>"><% $label %></FONT>
- </TH>
+% 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</A>" 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</A>" if $link_prefix;
+% push @{$cell[$i]}, $entry;
+% }
+% }
-% my $total = 0;
-% my $col = 0;
-% foreach my $column ( @{ shift( @data ) } ) {
+<STYLE type="text/css">
+a.cell {
+ color: inherit !important;
+}
+td.cell {
+ border-color: #000;
+}
+<% join("\n", @styles) %>
+%# item labels
+.e0 {
+ text-align: center;
+ font-weight: bold;
+}
+%# totals
+% if ( ! $opt{'nototal'} ) {
+.e<% $num_entries %> {
+ text-align: right;
+ background-color: #f5f6be;
+}
+% }
+%# date labels
+.i0 {
+ text-align: center;
+ font-weight: bold;
+}
+</STYLE>
- <TD ALIGN="right" BGCOLOR="#ffffff">
- <% $link_prefix ? $link_prefix . shift(@links) . '">' : '' %><FONT COLOR="#<% $color %>"><% $money_char %><% sprintf($sprintf,, $column) %></FONT><% $link_prefix ? '</A>' : '' %>
- </TD>
+<% include('/elements/table.html', 'f8f8f8') %>
+% if ( $opt{'transpose'} ) {
+% for ( my $e = 0; $e < $num_entries + 1; $e++ ) {
+ <TR>
+% for ( my $i = 0; $i < $num_items + 1; $i++ ) {
+ <TD CLASS="<%"cell i$i e$e"%>"><% $cell[$i][$e] %></TD>
+% }
+ </TR>
+% }
%
-% $total += $column;
-% $bottom_total[$col++] += $column;
-%
-% }
-
-% unless ( $opt{'nototal'} ) {
- <TD ALIGN="right" BGCOLOR="#f5f6be">
- <% $link_prefix ? $link_prefix. shift(@links) . '">' : '' %><FONT COLOR="#<% $color %>"><% $money_char %><% sprintf($sprintf, $total) %></FONT><% $link_prefix ? '</A>' : '' %>
- </TD>
-% $bottom_total[$col++] += $total;
-% }
-
- </TR>
-
-% }
-
-% if ( $opt{'bottom_total'} ) {
+% } else { #!transpose
+%
+% for (my $i = 0; $i < $num_items + 1; $i++) {
<TR>
- <TH>Total</TH>
-% 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 ) {
-
- <TD ALIGN="right" BGCOLOR="#f5f6be">
- <% $prefix
- ? '<A HREF="'. $prefix .shift(@bottom_links). '">'
- : ''
- %><% $money_char %><% sprintf($sprintf, $total) %><% $prefix ? '</A>' : '' %>
-
- </TD>
-
-% }
-
+% for (my $e = 0; $e < $num_entries + 1; $e++) {
+ <TD CLASS="<%"cell i$i e$e"%>"><% $cell[$i][$e] %></TD>
+% }
</TR>
-
-% }
-
+% }
</TABLE>
+% }
<% include('/elements/footer.html') %>
% }