From d8cb6cd67cc574c90dbbfbd8db2da6711c516d65 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 28 Dec 2008 18:48:51 +0000 Subject: fix browse results for selecting counties (resulting from separating tax classes), also add dropdowns to browse by state and county, RT#4496 --- httemplate/elements/select-country.html | 120 ++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 httemplate/elements/select-country.html (limited to 'httemplate/elements/select-country.html') diff --git a/httemplate/elements/select-country.html b/httemplate/elements/select-country.html new file mode 100644 index 000000000..c4368c271 --- /dev/null +++ b/httemplate/elements/select-country.html @@ -0,0 +1,120 @@ +<%doc> + +Example: + + include( '/elements/select-country.html', + #recommended + country => $current_country, + + #optional + prefix => $optional_unique_prefix, + onchange => $javascript, + disabled => 0, #bool + disable_empty => 1, #defaults to 1, disable the empty option + empty_label => 'all', #label for empty option + disable_stateupdate => 0, #bool - disabled update of the select-state.html + + ); + + +% unless ( $opt{'disable_stateupdate'} ) { + + <% include('/elements/xmlhttp.html', + 'url' => $p.'misc/states.cgi', + 'subs' => [ $pre. 'get_states' ], + ) + %> + + + +% } + + + +<%init> + +my %opt = @_; +foreach my $opt (qw( country prefix onchange disabled disable_stateupdate )) { + $opt{$opt} = '' unless exists($opt{$opt}) && defined($opt{$opt}); +} + +$opt{'disable_empty'} = 1 unless exists($opt{'disable_empty'}); + +my $pre = $opt{'prefix'}; + +my $onchange = + ( $opt{'disable_stateupdate'} ? '' : $pre.'country_changed(this); ' ). + $opt{'onchange'}; + +my $conf = new FS::Conf; +my $default = $conf->config('countrydefault') || 'US'; + +my @all_countries = ( + sort { ($b eq $default) <=> ($a eq $default) + or code2country($a) cmp code2country($b) + } + map { $_->country } + qsearch({ + 'select' => 'country', + 'table' => 'cust_main_county', + 'hashref' => {}, + 'extra_sql' => 'GROUP BY country', + }) + ); + + -- cgit v1.2.1