summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorivan <ivan>2006-12-27 02:37:17 +0000
committerivan <ivan>2006-12-27 02:37:17 +0000
commit3c8870ee619416f126a65c93d5ef7a2f2e24bc96 (patch)
tree728873036ac4ae84b649923605176a875588167e /FS/FS
parent14ee9d25605ce139bad4655987575508c06f7f7e (diff)
Add a (magically appearing and disappearing) label on the county selector. confusing when labeled "state"
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/Misc.pm38
1 files changed, 30 insertions, 8 deletions
diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm
index 97ff8ed61..5d74adf23 100644
--- a/FS/FS/Misc.pm
+++ b/FS/FS/Misc.pm
@@ -7,7 +7,10 @@ use Carp;
use Data::Dumper;
@ISA = qw( Exporter );
-@EXPORT_OK = qw( send_email send_fax states_hash state_label card_types );
+@EXPORT_OK = qw( send_email send_fax
+ states_hash counties state_label
+ card_types
+ );
$DEBUG = 0;
@@ -359,13 +362,12 @@ sub states_hash {
# sort
map { s/[\n\r]//g; $_; }
map { $_->state; }
- qsearch({
- 'select' => 'state',
- 'table' => 'cust_main_county',
- 'hashref' => { 'country' => $country },
- 'extra_sql' => 'GROUP BY state',
- })
- ;
+ qsearch({
+ 'select' => 'state',
+ 'table' => 'cust_main_county',
+ 'hashref' => { 'country' => $country },
+ 'extra_sql' => 'GROUP BY state',
+ });
#it could throw a fatal "Invalid country code" error (for example "AX")
my $subcountry = eval { new Locale::SubCountry($country) }
@@ -378,6 +380,26 @@ sub states_hash {
@states;
}
+=item counties STATE COUNTRY
+
+Returns a list of counties for this state and country.
+
+=cut
+
+sub counties {
+ my( $state, $country ) = @_;
+
+ sort map { s/[\n\r]//g; $_; }
+ map { $_->county }
+ qsearch({
+ 'select' => 'DISTINCT county',
+ 'table' => 'cust_main_county',
+ 'hashref' => { 'state' => $state,
+ 'country' => $country,
+ },
+ });
+}
+
=item state_label STATE COUNTRY_OR_LOCALE_SUBCOUNRY_OBJECT
=cut