X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fbrowse%2Fcust_main_county.cgi;h=736d7fdbe19ad67a220b8bfb967736cc86a01e3e;hb=04a69f9d197efee6fa396bd35d04ae553e669978;hp=fc10226840743f5d88b37dfdd55d0b7d43527052;hpb=9eded70a59f22d7df3b645ad3636e28e0fd08bee;p=freeside.git diff --git a/httemplate/browse/cust_main_county.cgi b/httemplate/browse/cust_main_county.cgi index fc1022684..736d7fdbe 100755 --- a/httemplate/browse/cust_main_county.cgi +++ b/httemplate/browse/cust_main_county.cgi @@ -32,18 +32,6 @@ my $conf = new FS::Conf; my $money_char = $conf->config('money_char') || '$'; -my @manual_countries = ( 'US', 'CA', 'AU', 'NZ', 'GB' ); #some manual ordering -my @all_countries = ( @manual_countries, - grep { my $c = $_; ! grep { $c eq $_ } @manual_countries } - map { $_->country } - qsearch({ - 'select' => 'country', - 'table' => 'cust_main_county', - 'hashref' => {}, - 'extra_sql' => 'GROUP BY country', - }) - ); - my $exempt_sub = sub { my $cust_main_county = shift; @@ -153,16 +141,24 @@ if ( $cgi->param('country') =~ /^(\w\w)$/ ) { $cgi->delete('country'); my $state = ''; -if ( $cgi->param('state') =~ /^([\w \-\'\[\]]+)$/ ) { +if ( $country && $cgi->param('state') =~ /^([\w \-\'\[\]]+)$/ ) { $state = $1; $title = "$state, $title"; } $cgi->delete('state'); my $county = ''; -if ( $cgi->param('county') =~ /^([\w \-\'\[\]]+)$/ ) { +if ( $country && $state && + $cgi->param('county') =~ + /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]+)$/ + ) +{ $county = $1; - $title = "$county county, $title"; + if ( $county eq '__NONE__' ) { + $title = "No county, $title"; + } else { + $title = "$county county, $title"; + } } $cgi->delete('county'); @@ -181,9 +177,11 @@ if ( $country || $taxclass ) { $cgi->param('dummy', 1); -my $country_filter_change = - "window.location = '". - $cgi->self_url. ";country=' + this.options[this.selectedIndex].value;"; +my $filter_change = + "window.location = '". $cgi->self_url. + ";country=' + encodeURIComponent( document.getElementById('country').options[document.getElementById('country').selectedIndex].value ) + ". + "';state=' + encodeURIComponent( document.getElementById('state').options[document.getElementById('state').selectedIndex].value ) +". + "';county=' + encodeURIComponent( document.getElementById('county').options[document.getElementById('county').selectedIndex].value );"; #restore this so pagination works $cgi->param('country', $country) if $country; @@ -192,19 +190,61 @@ $cgi->param('county', $county ) if $county; $cgi->param('taxclass', $county ) if $taxclass; my $html_posttotal = - '(show country: '. - qq()'; + '
( show country: '. + include('/elements/select-country.html', + 'country' => $country, + 'onchange' => $filter_change, + 'empty_label' => '(all)', + 'disable_empty' => 0, + 'disable_stateupdate' => 1, + ); + +my %states_hash = $country ? states_hash($country) : (); +if ( scalar(keys(%states_hash)) > 1 ) { + $html_posttotal .= + ' show state: '. + include('/elements/select-state.html', + 'country' => $country, + 'state' => $state, + 'onchange' => $filter_change, + 'empty_label' => '(all)', + 'disable_empty' => 0, + 'disable_countyupdate' => 1, + ); +} else { + $html_posttotal .= + ''; +} + +my @counties = ( $country && $state ) ? counties($state, $country) : (); +if ( scalar(@counties) > 1 ) { + $html_posttotal .= + ' show county: '. + include('/elements/select-county.html', + 'country' => $country, + 'state' => $state, + 'county' => $county, + 'onchange' => $filter_change, + 'empty_label' => '(all)', + 'empty_data_label' => '(none)', + 'empty_data_value' => '__NONE__', + 'disable_empty' => 0, + 'disable_countyupdate' => 1, + ); +} else { + $html_posttotal .= + ''; +} + +$html_posttotal .= ' )'; my $bulk_popup_link = include( '/elements/popup_link_onclick.html', - 'action' => "${p}edit/bulk_cust_main_county.html?MAGIC_taxnum_MAGIC", + 'action' => "${p}edit/bulk-cust_main_county.html?MAGIC_taxnum_MAGIC", 'actionlabel' => 'Bulk add new tax', 'nofalse' => 1, 'height' => 420, @@ -281,11 +321,16 @@ if ( $country ) { } if ( $state ) { $hashref->{'state'} = $state; - $count_query .= ' AND state = '. dbh->quote($state); + $count_query .= ' AND state = '. dbh->quote($state); } if ( $county ) { - $hashref->{'country'} = $country; - $count_query .= ' AND county = '. dbh->quote($county); + if ( $county eq '__NONE__' ) { + $hashref->{'county'} = ''; + $count_query .= " AND ( county = '' OR county IS NULL ) "; + } else { + $hashref->{'county'} = $county; + $count_query .= ' AND county = '. dbh->quote($county); + } } if ( $taxclass ) { $hashref->{'taxclass'} = $taxclass;