[freeside-commits] freeside/httemplate/graph/elements monthly.html, 1.10, 1.11 report.html, 1.4, 1.5

Mark Wells mark at wavetail.420.am
Sat Jan 7 15:04:05 PST 2012


Update of /home/cvs/cvsroot/freeside/httemplate/graph/elements
In directory wavetail.420.am:/tmp/cvs-serv4642/httemplate/graph/elements

Modified Files:
	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.5
diff -u -w -d -r1.4 -r1.5
--- report.html	21 Jan 2011 01:11:05 -0000	1.4
+++ report.html	7 Jan 2012 23:04:03 -0000	1.5
@@ -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.10
retrieving revision 1.11
diff -u -w -d -r1.10 -r1.11
--- monthly.html	26 Dec 2011 20:24:17 -0000	1.10
+++ monthly.html	7 Jan 2012 23:04:03 -0000	1.11
@@ -90,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');
@@ -111,6 +116,9 @@
       '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'},
@@ -125,6 +133,10 @@
 
 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'};



More information about the freeside-commits mailing list