X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FMisc.pm;h=9a4318086fcfcf9aa22e0fc5f2751905e34ed881;hp=18cb275bf1bb2a3999baaa866811ca6a87e20352;hb=389b6f1116c3309c2ee57a6c295ed1a793503095;hpb=2b2dd969f3c18751afc583ad1e836ab8e6f73b5d 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.