[freeside-commits] freeside/httemplate/search report_tax.cgi, 1.58, 1.59 cust_bill_pkg.cgi, 1.20, 1.21

Ivan,,, ivan at wavetail.420.am
Wed May 27 15:10:43 PDT 2009


Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail.420.am:/tmp/cvs-serv8938

Modified Files:
	report_tax.cgi cust_bill_pkg.cgi 
Log Message:
maybe this willf inally fix total line links on tax report when using report_group kludge? (still possibly not in all corner cases), RT#5446

Index: report_tax.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_tax.cgi,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- report_tax.cgi	27 May 2009 21:35:02 -0000	1.58
+++ report_tax.cgi	27 May 2009 22:10:41 -0000	1.59
@@ -285,6 +285,9 @@
 
   my $label = getlabel($r);
   $regions{$label}->{'label'} = $label;
+
+  $regions{$label}->{$_} = $r->$_() for (qw( county state country )); #taxname?
+
   $regions{$label}->{'url_param'} =
     join(';', map "$_=".uri_escape($r->$_()),
                   qw( county state country taxname )
@@ -532,6 +535,9 @@
 my( $total, $tot_taxable, $tot_owed ) = ( 0, 0, 0 );
 my( $exempt_cust, $exempt_pkg, $exempt_monthly ) = ( 0, 0, 0 );
 my %taxclasses = ();
+my %county = ();
+my %state = ();
+my %country = ();
 foreach (@regions) {
   $total          += $regions{$_}->{'total'};
   $tot_taxable    += $regions{$_}->{'taxable'};
@@ -541,13 +547,32 @@
   $exempt_monthly += $regions{$_}->{'exempt_monthly'};
   $taxclasses{$regions{$_}->{'taxclass'}} = 1
     if $regions{$_}->{'taxclass'};
+  $county{$regions{$_}->{'county'}} = 1;
+  $state{$regions{$_}->{'state'}} = 1;
+  $country{$regions{$_}->{'country'}} = 1;
 }
 
 my $total_url_param = '';
 if ( $group_op ) {
+
+  my @country = keys %country;
+  warn "WARNING: multiple countries on this grouped report; total links broken"
+    if scalar(@country) > 1;
+  my $country = $country[0];
+
+  my @state = keys %state;
+  warn "WARNING: multiple countries on this grouped report; total links broken"
+    if scalar(@state) > 1;
+  my $state = $state[0];
+
   $total_url_param =
     'report_group='.uri_escape("$group_op $group_value").';'.
-    join(';', map 'taxclass='.dbh->quote($_), keys %taxclasses );
+    join(';', map 'taxclass='.uri_escape($_), keys %taxclasses ).';'.
+    "country=$country;state=".uri_escape($state).';'.
+    join(';', map 'county='.uri_escape($_), keys %county )
+  ;
+
+
 }
 
 #ordering

Index: cust_bill_pkg.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_bill_pkg.cgi,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- cust_bill_pkg.cgi	27 May 2009 17:18:36 -0000	1.20
+++ cust_bill_pkg.cgi	27 May 2009 22:10:41 -0000	1.21
@@ -156,15 +156,47 @@
 
 } elsif ( $cgi->param('country') ) {
 
-  my %ph = map { $_ => dbh->quote( $cgi->param($_) ) }
-               qw( county state country );
+  my @counties = $cgi->param('county');
+   
+  if ( scalar(@counties) > 1 ) {
 
-  my ( $loc_sql, @param ) = FS::cust_pkg->location_sql;
-  while ( $loc_sql =~ /\?/ ) { #easier to do our own substitution
-    $loc_sql =~ s/\?/$ph{shift(@param)}/e;
-  }
+    #hacky, could be more efficient.  care if it is ever used for more than the
+    # tax-report_groups filtering kludge
 
-  push @where, $loc_sql;
+    my $locs_sql =
+      ' ( '. join(' OR ', map {
+
+          my %ph = ( 'county' => $_,
+                     map { $_ => dbh->quote( $cgi->param($_) ) }
+                       qw( county state country )
+                   );
+
+          my ( $loc_sql, @param ) = FS::cust_pkg->location_sql;
+          while ( $loc_sql =~ /\?/ ) { #easier to do our own substitution
+            $loc_sql =~ s/\?/$ph{shift(@param)}/e;
+          }
+
+          $loc_sql;
+
+        } @counties
+
+      ). ' ) ';
+
+    push @where, $locs_sql;
+
+  } else {
+
+    my %ph = map { $_ => dbh->quote( $cgi->param($_) ) }
+                 qw( county state country );
+
+    my ( $loc_sql, @param ) = FS::cust_pkg->location_sql;
+    while ( $loc_sql =~ /\?/ ) { #easier to do our own substitution
+      $loc_sql =~ s/\?/$ph{shift(@param)}/e;
+    }
+
+    push @where, $loc_sql;
+
+  }
    
   if ( $cgi->param('istax') ) {
     if ( $cgi->param('taxname') ) {



More information about the freeside-commits mailing list