[freeside-commits] freeside/httemplate/graph/elements monthly.html, 1.9, 1.9.2.1 report.html, 1.4, 1.4.2.1
Mark Wells
mark at wavetail.420.am
Tue Jan 10 10:38:46 PST 2012
Update of /home/cvs/cvsroot/freeside/httemplate/graph/elements
In directory wavetail.420.am:/tmp/cvs-serv3434/httemplate/graph/elements
Modified Files:
Tag: FREESIDE_2_3_BRANCH
monthly.html report.html
Log Message:
projected sales report, #15393
Index: report.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/graph/elements/report.html,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -w -d -r1.4 -r1.4.2.1
--- report.html 21 Jan 2011 01:11:05 -0000 1.4
+++ report.html 10 Jan 2012 18:38:43 -0000 1.4.2.1
@@ -155,28 +155,28 @@
% );
%
% http_header('Content-Type' => 'image/png' );
+% http_header('Cache-Control' => 'no-cache' );
%
% $chart->_set_colors();
%
<% $chart->scalar_png([ $opt{'axis_labels'}, @data ]) %>
%
% } else {
+% # image and download links should use the cached data
+% # just directly reference this component
+% my $myself = $p.'graph/elements/report.html?session='.$session;
%
<% include('/elements/header.html', $opt{'title'} ) %>
% unless ( $opt{'graph_type'} eq 'none' ) {
-% $cgi->param('_type', 'png');
-<IMG SRC="<% $cgi->self_url %>" WIDTH="976" HEIGHT="384">
+<IMG SRC="<% "$myself;_type=png" %>" WIDTH="976" HEIGHT="384">
% }
<P ALIGN="right">
% unless ( $opt{'disable_download'} ) {
-% $cgi->param('_type', "xls" );
Download full results<BR>
- as <A HREF="<% $cgi->self_url %>">Excel spreadsheet</A><BR>
-% $cgi->param('_type', 'csv');
- as <A HREF="<% $cgi->self_url %>">CSV file</A></P>
-% $cgi->param('_type', "html" );
+ as <A HREF="<% "$myself;_type=xls" %>">Excel spreadsheet</A><BR>
+ as <A HREF="<% "$myself;_type=csv" %>">CSV file</A></P>
% }
%
</P>
@@ -271,6 +271,16 @@
<%init>
my(%opt) = @_;
+my $session;
+# load from cache if possible, to avoid recalculating
+if ( $cgi->param('session') =~ /^(\d+)$/ ) {
+ $session = $1;
+ %opt = %{ $m->cache->get($session) };
+}
+else {
+ $session = sprintf("%10d%6d", time, int(rand(1000000)));
+ $m->cache->set($session, \%opt, '1h');
+}
my $sprintf = $opt{'sprintf'} || '%.2f';
Index: monthly.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/graph/elements/monthly.html,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -w -d -r1.9 -r1.9.2.1
--- monthly.html 13 May 2011 20:03:20 -0000 1.9
+++ monthly.html 10 Jan 2012 18:38:43 -0000 1.9.2.1
@@ -64,6 +64,7 @@
<%init>
my(%opt) = @_;
+$opt{'debug'} ||= $cgi->param('debug');
my $conf = new FS::Conf;
my $money_char = $opt{'disable_money'} ? '' : $conf->config('money_char');
@@ -89,6 +90,11 @@
$opt{'end_month'} ||= $cgi->param('end_month'); # || $curmon+1;
$opt{'end_year'} ||= $cgi->param('end_year'); # || 1900+$curyear;
+#find end of projection
+$opt{'project_month'} ||= $cgi->param('project_month') || 0;
+$opt{'project_year'} ||= $cgi->param('project_year') || 0;
+# setting these to zero prevents projection on reports that don't support it
+
if ( $opt{'daily'} ) { # daily granularity
$opt{'start_day'} ||= $cgi->param('start_day');
$opt{'end_day'} ||= $cgi->param('end_day');
@@ -110,20 +116,39 @@
'end_day' => $opt{'end_day'},
'end_month' => $opt{'end_month'},
'end_year' => $opt{'end_year'},
+ 'project_day' => $opt{'project_day'},
+ 'project_month' => $opt{'project_month'},
+ 'project_year' => $opt{'project_year'},
'agentnum' => $opt{'agentnum'},
'remove_empty' => $opt{'remove_empty'},
'doublemonths' => $opt{'doublemonths'},
);
+warn Dumper({ 'REPORTOPTS' => \%reportopts }) if $opt{'debug'};
+
my $report;
$report = new FS::Report::Table::Daily(%reportopts) if $opt{'daily'};
$report = new FS::Report::Table::Monthly(%reportopts) unless $opt{'daily'};
my $data = $report->data;
+warn Dumper({'DATA' => $data}) if $opt{'debug'};
+
+if ( $data->{'error'} ) {
+ die $data->{'error'}; # could be smarter
+}
+
my $col_labels = [ map { my $m = $_; $m =~ s/^(\d+)\//$mon[$1-1] / ; $m }
@{$data->{label}} ];
$col_labels = $data->{label} if $opt{'daily'};
+if ( $opt{'remove_empty'} ) {
+ # need to filter out series labels for collapsed rows
+ $opt{'graph_labels'} = [
+ map { $opt{'graph_labels'}[$_] }
+ @{ $data->{indices} }
+ ];
+}
+
my @links;
foreach my $link (@{ $data->{'links'} }) {
my @speriod = @{$data->{'speriod'}};
More information about the freeside-commits
mailing list