diff options
author | ivan <ivan> | 2011-04-11 20:40:42 +0000 |
---|---|---|
committer | ivan <ivan> | 2011-04-11 20:40:42 +0000 |
commit | ade7fd5f694fcc47e4a0ffb606c0dc08ecb322fb (patch) | |
tree | bb8bf6b9ddaa954a989e1b5b7b52191415df682e /httemplate | |
parent | e2cdebec95ba8f2a41c1841b4501f230b01bde99 (diff) |
improve tax edit: don't offer to remove cities that have already been split into taxclasses, RT#11144
Diffstat (limited to 'httemplate')
-rwxr-xr-x | httemplate/browse/cust_main_county.cgi | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/httemplate/browse/cust_main_county.cgi b/httemplate/browse/cust_main_county.cgi index 2a21da150..c6484cacd 100755 --- a/httemplate/browse/cust_main_county.cgi +++ b/httemplate/browse/cust_main_county.cgi @@ -456,6 +456,7 @@ my @fields = ( code2country($country). " ($country)"; }, + #state sub { my $label = $seen_state{$_[0]->country}->{$_[0]->state}++ ? '' : state_label($_[0]->state, $_[0]->country); @@ -488,6 +489,7 @@ my @fields = ( $label.$countylinks.$addlink; }, + #county sub { my $label = $seen_county{$_[0]->country}->{$_[0]->state}->{$_[0]->county}++ ? '' : $_[0]->county; @@ -525,19 +527,29 @@ my @fields = ( ); }, - sub { $_[0]->city - ? $_[0]->city. ' '. + #city + sub { + my $r = shift; + if ( $r->city ) { + + if ( $r->taxclass ) { #but if it has a taxclass, can't remove + $r->city; + } else { + $r->city. ' '. remove_link( col => 'city', label=> 'remove city', - row => $_[0], + row => $r, cgi => $cgi, - ) - : '(all) '. - expand_link( desc => 'Add Cities', - row => $_[0], - label => 'add cities', - cgi => $cgi, ); + } + } else { + '(all) '. + expand_link( desc => 'Add Cities', + row => $r, + label => 'add cities', + cgi => $cgi, + ); + } }, ); @@ -551,10 +563,24 @@ my @color = ( if ( $conf->exists('enable_taxclasses') ) { push @header, qq!Tax class (<A HREF="${p}edit/part_pkg_taxclass.html">add new</A>)!; push @header2, '(per-package classification)'; - push @fields, sub { $_[0]->taxclass || '(all) '. - separate_taxclasses_link($_[0], 'Separate Taxclasses'). - 'separate taxclasses</A></FONT>' - }; + push @fields, sub { + my $r = shift; + if ( $r->taxclass ) { + $r->taxclass; + } else { + my $sql = 'SELECT COUNT(*) FROM cust_main_county + WHERE country = ? AND state = ? AND county = ? + AND city = ? AND taxclass IS NOT NULL'; + if ( FS::Record->scalar_sql($sql, map $r->$_, + qw( country state county city) ) ) { + '(none)'; + } else { + '(all) '. + separate_taxclasses_link($r, 'Separate Taxclasses'). + 'separate taxclasses</A></FONT>'; + } + } + }; push @color, sub { shift->taxclass ? '000000' : '999999' }; push @links, ''; push @link_onclicks, ''; |