show add-on package description in sales report, #25836
[freeside.git] / httemplate / search / cust_bill_pkg.cgi
index d86641d..6b7a5e6 100644 (file)
                  'fields'      => [
                    @pkgnum,
                    sub { $_[0]->pkgnum > 0
-                           # possibly use override.pkg but i think this correct
                            ? $_[0]->get('pkgpart')
                            : ''
                        },
                    sub { $_[0]->pkgnum > 0
-                           # possibly use override.pkg but i think this correct
                            ? $_[0]->get('pkg')     
                            : $_[0]->get('itemdesc')
                        },
@@ -49,8 +47,9 @@
                    @currency,
                    'invnum',
                    '_date',
-                   #'pay_amount',
-                   #'credit_amount',
+                   '', #'pay_amount',
+                   '', #'credit_amount',
+                   FS::UI::Web::cust_sort_fields(),
                  ],
                  'links'       => [
                    @pkgnum_null,
@@ -245,7 +244,6 @@ if ( $conf->exists('enable_taxclasses') ) {
   push @post_desc, 'taxclass';
   push @post_desc_null, '';
   $post_desc_align .= 'l';
-  push @select, 'part_pkg.taxclass'; # or should this use override?
 }
 
 # valid in both the tax and non-tax cases
@@ -310,7 +308,9 @@ my $join_pkg =
   LEFT JOIN part_pkg      USING (pkgpart)';
 
 my $part_pkg = 'part_pkg';
-if ( $cgi->param('use_override') ) { #"Separate sub-packages from parents"
+# "Separate sub-packages from parents"
+my $use_override = $cgi->param('use_override') ? 1 : 0;
+if ( $use_override ) {
   # still need the real part_pkg for tax applicability, 
   # so alias this one
   $join_pkg .= " LEFT JOIN part_pkg AS override ON (
@@ -318,7 +318,8 @@ if ( $cgi->param('use_override') ) { #"Separate sub-packages from parents"
   )";
   $part_pkg = 'override';
 }
-push @select, 'part_pkg.pkgpart', 'part_pkg.pkg'; # or should this use override?
+push @select, "$part_pkg.pkgpart", "$part_pkg.pkg";
+push @select, "$part_pkg.taxclass" if $conf->exists('enable_taxclasses');
 
 # the non-tax case
 if ( $cgi->param('nottax') ) {
@@ -341,14 +342,16 @@ if ( $cgi->param('nottax') ) {
   }
 
   if ( grep { $_ eq 'report_optionnum' } $cgi->param ) {
-    my @nums = grep /^\w+$/, $cgi->param('report_optionnum');
-    my $num = join(',', @nums);
+    my $num = join(',', grep /^[\d,]+$/, $cgi->param('report_optionnum'));
+    my $not_num = join(',', grep /^[\d,]+$/, $cgi->param('not_report_optionnum'));
+    my $all = $cgi->param('all_report_options') ? 1 : 0;
     push @where, # code reuse FTW
-      FS::Report::Table->with_report_option( $num, $cgi->param('use_override'));
-  }
-
-  if ( $cgi->param('report_optionnum') =~ /^(\w+)$/ ) {
-    ;
+      FS::Report::Table->with_report_option(
+        report_optionnum      => $num,
+        not_report_optionnum  => $not_num,
+        use_override          => $use_override,
+        all_report_options    => $all,
+      );
   }
 
   # taxclass
@@ -431,12 +434,12 @@ if ( $cgi->param('nottax') ) {
 
     $join_pkg .= " LEFT JOIN ($exempt_sub) AS item_exempt
     USING (billpkgnum)";
-  }
  
-  # process tax restrictions
-  unshift @tax_where,
-    'cust_bill_pkg_tax_location.taxable_billpkgnum = cust_bill_pkg.billpkgnum',
-    'cust_main_county.tax > 0';
+    # process tax restrictions
+    unshift @tax_where,
+      'cust_bill_pkg_tax_location.taxable_billpkgnum = cust_bill_pkg.billpkgnum',
+      'cust_main_county.tax > 0';
+  }
 
   my $tax_sub = "SELECT 1
     FROM cust_bill_pkg_tax_location