add customer status column to customer & most other reports. also put the C in ACL...
[freeside.git] / httemplate / graph / cust_bill_pkg.cgi
index 0dbd222..4070069 100644 (file)
@@ -1,5 +1,26 @@
-<%
+<% include('elements/monthly.html',
+                'title'        => $title. 'Sales Report (Gross)',
+                'graph_type'   => 'Mountain',
+                'items'        => \@items,
+                'params'       => \@params,
+                'labels'       => \@labels,
+                'graph_labels' => \@labels,
+                'colors'       => \@colors,
+                'links'        => \@links,
+                'remove_empty' => 1,
+                'bottom_total' => 1,
+                'bottom_link'  => "$link;",
+                'start_month'  => $smonth,
+                'start_year'   => $syear,
+                'end_month'    => $emonth,
+                'end_year'     => $eyear,
+                'agentnum'     => $agentnum,
+             )
+%>
+<%init>
 
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
 
 #find first month
 my $syear = $cgi->param('start_year'); # || 1899+$curyear;
@@ -18,6 +39,7 @@ if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
 }
 my $title = $sel_agent ? $sel_agent->agent.' ' : '';
 
+#false lazinessish w/search/cust_pkg.cgi
 my $classnum = 0;
 my @pkg_class = ();
 if ( $cgi->param('classnum') =~ /^(\d*)$/ ) {
@@ -34,19 +56,25 @@ if ( $cgi->param('classnum') =~ /^(\d*)$/ ) {
     push @pkg_class, '(empty class)';
   }
 }
+#eslaf
 
 my $hue = 0;
-my $hue_increment = 145;
+#my $hue_increment = 170;
+#my $hue_increment = 145;
+my $hue_increment = 125;
 
-my @items = ();
+my @items  = ();
 my @params = ();
 my @labels = ();
 my @colors = ();
+my @links  = ();
+
+my $link = "${p}search/cust_bill_pkg.cgi?nottax=1;include_comp_cust=1";
 
 foreach my $agent ( $sel_agent || qsearch('agent', { 'disabled' => '' } ) ) {
 
   my $col_scheme = Color::Scheme->new
-                     ->from_hue($hue)
+                     ->from_hue($hue) #->from_hex($agent->color)
                      ->scheme('analogic')
                    ;
   my @recur_colors = ();
@@ -67,9 +95,13 @@ foreach my $agent ( $sel_agent || qsearch('agent', { 'disabled' => '' } ) ) {
           : ''
       );
 
-    # push some params
-    push @params,
-      [ 'classnum' => ( ref($pkg_class) ? $pkg_class->classnum : '' ) ];
+    my $row_classnum = ref($pkg_class) ? $pkg_class->classnum : 0;
+    my $row_agentnum = $agent->agentnum;
+    push @params, [ 'classnum' => $row_classnum,
+                    'agentnum' => $row_agentnum,
+                  ];
+
+    push @links, "$link;agentnum=$row_agentnum;classnum=$row_classnum;";
 
     @recur_colors = ($col_scheme->colors)[0,4,8,1,5,9]
       unless @recur_colors;
@@ -83,22 +115,7 @@ foreach my $agent ( $sel_agent || qsearch('agent', { 'disabled' => '' } ) ) {
 
 }
 
-use Data::Dumper;
-warn Dumper(\@items);
+#use Data::Dumper;
+#warn Dumper(\@items);
 
-%><%= include('elements/monthly.html',
-                'title'        => $title. 'Sales Report',
-                'graph_type'   => 'Mountain',
-                'items'        => \@items,
-                'params'       => \@params,
-                'labels'       => \@labels,
-                'graph_labels' => \@labels,
-                'colors'       => \@colors,
-                #'links'        => \%link,
-                'start_month'  => $smonth,
-                'start_year'   => $syear,
-                'end_month'    => $emonth,
-                'end_year'     => $eyear,
-                'agentnum'     => $agentnum,
-             )
-%>
+</%init>