From 7517eaa583bcb213b62dfd0c11288aa50a350e8a Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 25 Aug 2006 19:30:52 +0000 Subject: use GROUP BY instead of DISTINCT ON in the state and country queries for better cross-database compatibility, based on a preliminary patch from Jason Thomas --- httemplate/edit/cust_main/select-country.html | 36 ++++++++++++++------------ httemplate/edit/cust_main/select-county.html | 37 ++++++++++++--------------- httemplate/edit/cust_main/select-state.html | 23 ++++++++--------- 3 files changed, 47 insertions(+), 49 deletions(-) (limited to 'httemplate/edit/cust_main') diff --git a/httemplate/edit/cust_main/select-country.html b/httemplate/edit/cust_main/select-country.html index 5467f26e9..137f61975 100644 --- a/httemplate/edit/cust_main/select-country.html +++ b/httemplate/edit/cust_main/select-country.html @@ -1,15 +1,3 @@ -% -% -% my %opt = @_; -% foreach my $opt (qw( county state country prefix onchange disabled )) { -% $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); -% } -% -% my $conf = new FS::Conf; -% my $countrydefault = $conf->config('countrydefault') || 'US'; -% -% - <% include('/elements/xmlhttp.html', 'url' => $p.'misc/states.cgi', @@ -57,18 +45,32 @@ +<%init> +my %opt = @_; +foreach my $opt (qw( county state country prefix onchange disabled )) { + $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); +} + +my $conf = new FS::Conf; +my $countrydefault = $conf->config('countrydefault') || 'US'; + + diff --git a/httemplate/edit/cust_main/select-county.html b/httemplate/edit/cust_main/select-county.html index 70939fca5..c9b64bf4f 100644 --- a/httemplate/edit/cust_main/select-county.html +++ b/httemplate/edit/cust_main/select-county.html @@ -1,25 +1,10 @@ -% -% -% my %opt = @_; -% foreach my $opt (qw( county state country prefix onchange disabled )) { -% $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); -% } -% -% my $sql = "SELECT COUNT(*) FROM cust_main_county". -% " WHERE county IS NOT NULL AND county != ''"; -% my $sth = dbh->prepare($sql) or die dbh->errstr; -% $sth->execute or die $sth->errstr; -% my $countyflag = $sth->fetchrow_arrayref->[0]; -% -% % if ( $countyflag ) { - <% include('/elements/xmlhttp.html', 'url' => $p.'misc/counties.cgi', 'subs' => [ $opt{'prefix'}. 'get_counties' ], ) -%> + %> + % } +<%init> +my %opt = @_; +foreach my $opt (qw( county state country prefix onchange disabled )) { + $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); +} + +my $sql = "SELECT COUNT(*) FROM cust_main_county". + " WHERE county IS NOT NULL AND county != ''"; +my $sth = dbh->prepare($sql) or die dbh->errstr; +$sth->execute or die $sth->errstr; +my $countyflag = $sth->fetchrow_arrayref->[0]; + diff --git a/httemplate/edit/cust_main/select-state.html b/httemplate/edit/cust_main/select-state.html index a7e56e78f..87546e5e3 100644 --- a/httemplate/edit/cust_main/select-state.html +++ b/httemplate/edit/cust_main/select-state.html @@ -1,21 +1,20 @@ -% -% -% my %opt = @_; -% foreach my $opt (qw( county state country prefix onchange disabled )) { -% $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); -% } -% -% - - +<%init> +my %opt = @_; +foreach my $opt (qw( county state country prefix onchange disabled )) { + $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); +} + +tie my %states, 'Tie::IxHash', states_hash( $opt{'country'} ); + + -- cgit v1.2.1