X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FMisc.pm;h=9a4318086fcfcf9aa22e0fc5f2751905e34ed881;hp=18cb275bf1bb2a3999baaa866811ca6a87e20352;hb=11a4787e386291574aca2357421b586e365252d9;hpb=7fe341f7e83648feecf0b221e7a370a5818be753 diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm index 18cb275bf..9a4318086 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.