X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_main%2Fselect-county.html;h=0dc8268969334a06f32b48f3b3c799a7330899b4;hb=a96ddd777a87c2f74a9cf408b44d0f6e7347b5f3;hp=70939fca531682c01a0657dd9b4fe11f05e2b1a5;hpb=3ce7691203a7737406bf2d4442f7fd84b81f847e;p=freeside.git
diff --git a/httemplate/edit/cust_main/select-county.html b/httemplate/edit/cust_main/select-county.html
index 70939fca5..0dc826896 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' ],
)
-%>
+ %>
+
% } else {
@@ -87,5 +75,39 @@
+
% }
+<%init>
+
+my %opt = @_;
+foreach my $opt (qw( county state country prefix onchange disabled )) {
+ $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_});
+}
+
+my @counties = ();
+if ( $countyflag ) {
+
+ @counties = counties( $opt{'state'}, $opt{'country'} );
+
+ # this is very hacky
+ unless ( scalar(@counties) > 1 ) {
+ if ( $opt{'disabled'} =~ /STYLE=/i ) {
+ $opt{'disabled'} =~ s/STYLE="([^"]+)"/STYLE="$1; display:none"/i;
+ } else {
+ $opt{'disabled'} .= ' STYLE="display:none"';
+ }
+ }
+
+}
+
+%init>
+<%once>
+
+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];
+
+%once>