[freeside-commits] freeside/httemplate/edit/cust_main
select-country.html, 1.4, 1.5 select-county.html, 1.3,
1.4 select-state.html, 1.3, 1.4
Ivan,,,
ivan at wavetail.420.am
Fri Aug 25 12:30:54 PDT 2006
Update of /home/cvs/cvsroot/freeside/httemplate/edit/cust_main
In directory wavetail:/tmp/cvs-serv26929/httemplate/edit/cust_main
Modified Files:
select-country.html select-county.html select-state.html
Log Message:
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
Index: select-country.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/cust_main/select-country.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- select-country.html 23 Aug 2006 22:25:37 -0000 1.4
+++ select-country.html 25 Aug 2006 19:30:52 -0000 1.5
@@ -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 @@
</SCRIPT>
<SELECT NAME="<% $opt{'prefix'} %>country" onChange="<% $opt{'prefix'} %>country_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
+
% foreach my $country (
% sort { ($b eq $countrydefault) <=> ($a eq $countrydefault)
% or code2country($a) cmp code2country($b) }
% map { $_->country }
-% qsearch( 'cust_main_county',{}, 'DISTINCT ON ( country ) *', )
-% ) {
-%
-
+% qsearch({
+% 'select' => 'country',
+% 'table' => 'cust_main_county',
+% 'hashref' => {},
+% 'extra_sql' => 'GROUP BY country',
+% })
+% ) {
<OPTION VALUE="<% $country %>"<% $country eq $opt{'country'} ? ' SELECTED' : '' %>><% code2country($country). " ($country)" %>
-% }
+% }
</SELECT>
+<%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';
+</%init>
+
Index: select-state.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/cust_main/select-state.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- select-state.html 23 Aug 2006 22:25:37 -0000 1.3
+++ select-state.html 25 Aug 2006 19:30:52 -0000 1.4
@@ -1,21 +1,20 @@
-%
-%
-% my %opt = @_;
-% foreach my $opt (qw( county state country prefix onchange disabled )) {
-% $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_});
-% }
-%
-%
-
-
<SELECT NAME="<% $opt{'prefix'} %>state" onChange="<% $opt{'prefix'} %>state_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
-% tie my %states, 'Tie::IxHash', states_hash( $opt{'country'} );
-% foreach my $state ( keys %states ) {
+% foreach my $state ( keys %states ) {
<OPTION VALUE="<% $state %>"<% $state eq $opt{'state'} ? ' SELECTED' : '' %>><% $states{$state} || '(n/a)' %>
+
% }
</SELECT>
+<%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'} );
+</%init>
+
Index: select-county.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/cust_main/select-county.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- select-county.html 23 Aug 2006 22:25:37 -0000 1.3
+++ select-county.html 25 Aug 2006 19:30:52 -0000 1.4
@@ -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' ],
)
-%>
+ %>
<SCRIPT TYPE="text/javascript">
@@ -69,15 +54,14 @@
% 'country' => $opt{'country'},
% }
% )
-% ) {
-%
-
+% ) {
<OPTION VALUE="<% $county %>"<% $county eq $opt{'county'} ? ' SELECTED' : '' %>><% $county %>
-% }
+% }
</SELECT>
+
% } else {
@@ -87,5 +71,18 @@
</SCRIPT>
<INPUT TYPE="hidden" NAME="<% $opt{'prefix'} %>county" VALUE="<% $opt{'county'} %>">
+
% }
+<%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];
+</%init>
More information about the freeside-commits
mailing list