diff options
Diffstat (limited to 'FS/FS/Misc.pm')
-rw-r--r-- | FS/FS/Misc.pm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm index 18cb275..9a43180 100644 --- a/FS/FS/Misc.pm +++ b/FS/FS/Misc.pm @@ -510,6 +510,9 @@ use Locale::SubCountry; sub states_hash { my($country) = @_; + #a hash? not expecting an explosion of business from unrecognized countries.. + return states_hash_nosubcountry($country) if $country eq 'XC'; + my @states = # sort map { s/[\n\r]//g; $_; } @@ -532,6 +535,27 @@ sub states_hash { @states; } +sub states_hash_nosubcountry { + my($country) = @_; + + my @states = +# sort + map { s/[\n\r]//g; $_; } + map { $_->state; } + qsearch({ + 'select' => 'state', + 'table' => 'cust_main_county', + 'hashref' => { 'country' => $country }, + 'extra_sql' => 'GROUP BY state', + }); + + #"i see your schwartz is as big as mine!" + map { ( $_->[0] => $_->[1] ) } + sort { $a->[1] cmp $b->[1] } + map { [ $_ => $_ ] } + @states; +} + =item counties STATE COUNTRY Returns a list of counties for this state and country. |