diff options
Diffstat (limited to 'httemplate/edit/cust_main')
-rw-r--r-- | httemplate/edit/cust_main/billing.html | 443 | ||||
-rw-r--r-- | httemplate/edit/cust_main/contact.html | 36 | ||||
-rw-r--r-- | httemplate/edit/cust_main/select-country.html | 72 | ||||
-rw-r--r-- | httemplate/edit/cust_main/select-county.html | 91 | ||||
-rw-r--r-- | httemplate/edit/cust_main/select-state.html | 27 |
5 files changed, 12 insertions, 657 deletions
diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html deleted file mode 100644 index 96f777baa..000000000 --- a/httemplate/edit/cust_main/billing.html +++ /dev/null @@ -1,443 +0,0 @@ -<% - -my( $cust_main, %options ) = @_; -my @invoicing_list = @{ $options{'invoicing_list'} }; -my $conf = new FS::Conf; -my $payby_default = $conf->config('payby-default'); - -my @payby = grep /\w/, $conf->config('payby'); -#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) -@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) - unless @payby; - -if ( $payby_default eq 'HIDE' ) { - - $cust_main->payby('BILL') unless $cust_main->payby; - -%> - - <INPUT TYPE="hidden" NAME="select" VALUE="<%= $cust_main->payby %>"> - - </FORM> - - <FORM NAME="<%= $cust_main->payby %>" STYLE="margin-top: 0; margin-bottom: 0"> <% # XXX key %> - - <% foreach my $field (qw( payinfo payname paycvv paystart_month paystart_year payissue payip )) { %> - - <INPUT TYPE="hidden" NAME="<%= $field %>" VALUE="<%= $cust_main->getfield($field) %>"> - - <% } %> - - <% - #false laziness w/elements/select-month_year.html & view/cust_main/billing.html - my( $mon, $year ); - my $date = $cust_main->paydate || '12-2037'; - if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format - ( $mon, $year ) = ( $2, $1 ); - } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { - ( $mon, $year ) = ( $1, $3 ); - } else { - die "unrecognized expiration date format: $date"; - } - %> - - <INPUT TYPE="hidden" NAME="exp_month" VALUE="<%= $mon %>"> - <INPUT TYPE="hidden" NAME="exp_year" VALUE="<%= $year %>"> - - </FORM> - - <FORM NAME="billing_bottomform" STYLE="margin-top: 0; margin-bottom: 0"> - - <INPUT TYPE="hidden" NAME="tax" VALUE="<%= $cust_main->tax %>"> - - <INPUT TYPE="hidden" NAME="invoicing_list" VALUE="<%= join(', ', @invoicing_list) %>"> - - </FORM> - -<% } else { - - my $r = qq!<font color="#ff0000">*</font> !; - -%> - - <BR>Billing information - <%= &ntable("#cccccc") %> - - <TR> - <TD ALIGN="right" WIDTH="200"><%=$r%>Billing type</TD> - - <SCRIPT> - - var mywindow = -1; - function myopen(filename,windowname,properties) { - myclose(); - mywindow = window.open(filename,windowname,properties); - } - function myclose() { - if ( mywindow != -1 ) - mywindow.close(); - mywindow = -1; - } - - var achwindow = -1; - function achopen(filename,windowname,properties) { - achclose(); - achwindow = window.open(filename,windowname,properties); - } - function achclose() { - if ( achwindow != -1 ) - achwindow.close(); - achwindow = -1; - } - - function card_changed(what) { - if ( - what.form.payinfo.value.substring(0, 4) == '4093' - || what.form.payinfo.value.substring(0, 4) == '4911' - || what.form.payinfo.value.substring(0, 4) == '4936' - || what.form.payinfo.value.substring(0, 6) == '564132' - || what.form.payinfo.value.substring(0, 2) == '63' - || what.form.payinfo.value.substring(0, 2) == '67' - ) - { - what.form.paystart_month.disabled = false; - what.form.paystart_year.disabled = false; - what.form.payissue.disabled = false; - what.form.paystart_month.style.backgroundColor = '#ffffff'; - what.form.paystart_year.style.backgroundColor = '#ffffff'; - what.form.payissue.style.backgroundColor = '#ffffff'; - document.getElementById('paystart_label').style.color = '#000000'; - document.getElementById('payissue_label').style.color = '#000000'; - } else { - what.form.paystart_month.disabled = true; - what.form.paystart_year.disabled = true; - what.form.payissue.disabled = true; - what.form.paystart_month.style.backgroundColor = '#dddddd'; - what.form.paystart_year.style.backgroundColor = '#dddddd'; - what.form.payissue.style.backgroundColor = '#dddddd'; - document.getElementById('paystart_label').style.color = '#999999'; - document.getElementById('payissue_label').style.color = '#999999'; - } - return true; - } - - </SCRIPT> - - <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws.js"></SCRIPT> - <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_iframe.js"></SCRIPT> - <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_draggable.js"></SCRIPT> - <SCRIPT TYPE="text/javascript"> - function OLiframeContent(src, width, height, name) { - return ('<iframe src="'+src+'" width="'+width+'" height="'+height+'"' - +(name?' name="'+name+'" id="'+name+'"':'')+' scrolling="auto">' - +'<div>[iframe not supported]</div></iframe>'); - } - </SCRIPT> - - <% - - my($payby, $payinfo, $payname)=( - $cust_main->payby, - $cust_main->payinfo, - $cust_main->payname, - ); - my( $account, $aba ) = split('@', $payinfo); - - my $disabled = 'DISABLED style="background-color: #dddddd"'; - my $text_disabled = 'style="color: #999999"'; - if ( $payby =~ /^(CARD|DCRD)$/ && cardtype($payinfo) =~ /^(Switch|Solo)$/ ) { - $disabled = 'style="background-color: #ffffff"'; - $text_disabled = 'style="color: #000000";' - } - - my %payby = ( - - 'CARD' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Card number </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby =~ /^(CARD|DCRD)$/ ? $payinfo : '' ). qq!" MAXLENGTH=19 onChange="card_changed(this)" onKeyUp="card_changed(this)"></TD></TR>!. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Expiration </TD>!. - '<TD WIDTH="408">'. - - include('/elements/select-month_year.html', - 'prefix' => 'exp', - 'selected_date' => - ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->paydate : '' ), - ). - - '</TD></TR>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">CVV2 !. - - qq!(<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/cvv2.html', 480, 352, 'cvv2_popup' ), CAPTION, 'CVV2 Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)!. - qq!</TD>!. - '<TD WIDTH="408"><INPUT TYPE="text" NAME="paycvv" VALUE="'. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->paycvv : '' ). '" SIZE=4 MAXLENGTH=4>'. - - - qq!<TR><TD ALIGN="right" WIDTH="200"><SPAN ID="paystart_label" $text_disabled>Start date </SPAN></TD>!. - '<TD WIDTH="408">'. - - include('/elements/select-month_year.html', - 'prefix' => 'paystart', - 'disabled' => $disabled, - 'empty_option' => 1, - 'start_year' => 2000, - 'end_year' => (localtime())[5] + 1900, - 'selected_date' => ( - ( $payby =~ /^(CARD|DCRD)$/ - && cardtype($payinfo) =~ /^(Switch|Solo)$/ ) - ? $cust_main->paystart_month. '-'. - $cust_main->paystart_year - : '' - ) - ). - - qq!<SPAN ID="payissue_label" $text_disabled> or Issue number </SPAN>!. - '<INPUT TYPE="text" NAME="payissue" VALUE="'. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->payissue : '' ). qq!" SIZE=3 MAXLENGTH=2 $disabled></TD></TR>!. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Exact name on card </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!. - - qq!<TR><TD COLSPAN=2 WIDTH="608"><INPUT TYPE="checkbox" NAME="payauto" !. ( $payby eq 'DCRD' ? '' : 'CHECKED' ). '> Charge future payments to this card automatically</TD></TR>'. - - '</TABLE>', - - 'CHEK' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Account number </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $account : '' ). '"></TD></TR>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}ABA/Routing number </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" SIZE=10 MAXLENGTH=9 NAME="payinfo2" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $aba : '' ). qq!" SIZE=10 MAXLENGTH=9> !. - qq!(<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/ach.html', 380, 240, 'ach_popup' ), CAPTION, 'ACH Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)!. - qq!</TD></TR>!. - - qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!. - qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Bank name </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!. - - qq!<TR><TD COLSPAN=2 WIDTH="608"><INPUT TYPE="checkbox" NAME="payauto" !. ( $payby eq 'DCHK' ? '' : 'CHECKED' ). '> Charge future payments to this electronic check automatically</TD></TR>'. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'LECB' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Phone number </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby eq 'LECB' ? $cust_main->payinfo : '' ). qq!" MAXLENGTH=15 SIZE=16></TD></TR>!. - - qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!. - qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!. - qq!<INPUT TYPE="hidden" NAME="payname" VALUE="">!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'BILL' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">P.O. </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby eq 'BILL' ? $cust_main->payinfo : '' ). qq!"></TD></TR>!. - - qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!. - qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!. - - qq!<TR><TD ALIGN="right" WIDTH="200">Attention </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $payby eq 'BILL' ? $cust_main->payname : '' ). qq!"></TD></TR>!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'COMP' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Approved by </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE=""></TD></TR>!. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Expiration </TD>!. - '<TD WIDTH="408">'. - - include('/elements/select-month_year.html', - 'prefix' => 'exp', - 'selected_date' => - ( $payby eq 'COMP' ? $cust_main->paydate : '' ), - ). - - '</TD></TR>'. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'CASH' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="paid" VALUE="!. ( $payby eq 'CASH' ? $cust_main->paid : '' ). qq!"></TD></TR>!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'WEST' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="paid" VALUE="!. ( $payby eq 'WEST' ? $cust_main->paid : '' ). qq!"></TD></TR>!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'MCRD' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="paid" VALUE="!. ( $payby eq 'MCRD' ? $cust_main->paid : '' ). qq!"></TD></TR>!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - ); - - - my %allopt = ( - 'CARD' => 'Credit card', - 'CHEK' => 'Electronic check', - 'LECB' => 'Phone bill billing', - 'BILL' => 'Billing', - 'CASH' => 'Cash', # initial payment, then billing', - 'WEST' => 'Western Union', # initial payment, then billing', - 'MCRD' => 'Manual credit card', # initial payment, then billing', - 'COMP' => 'Complimentary', - ); - if ( $cust_main->custnum ) { #don't offer CASH/WEST/MCRD initial payment types - # when editing customer - delete $allopt{$_} for qw(CASH WEST MCRD); - } - - tie my %options, 'Tie::IxHash', - map { $_ => $allopt{$_} } - grep { exists $allopt{$_} } - @payby; - - my %payby2option = ( - ( map { $_ => $_ } keys %options ), - 'DCRD' => 'CARD', - 'DCHK' => 'CHEK', - ); - - my $widget = new HTML::Widgets::SelectLayers( - 'options' => \%options, - #'form_name' => 'dummy', - #'form_action' => 'nothingyet', - #chops bottom of page in IE# 'under_position' => 'absolute', - 'html_between' => '</TD></TR></TABLE>', - 'selected_layer' => $payby2option{$payby || $payby_default || $payby[0] }, - 'layer_callback' => sub { my $layer = shift; $payby{$layer}; }, - ); - - %> - - <TD WIDTH="408"><%= $widget->html %> - - <FORM NAME="billing_bottomform" STYLE="margin-top: 0; margin-bottom: 0"> - - <%= &ntable("#cccccc") %> - - <TR><TD> </TD></TR> - - <TR> - <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="tax" VALUE="Y" <%= $cust_main->tax eq "Y" ? 'CHECKED' : '' %>> Tax Exempt</TD> - </TR> - - <TR> - <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST" <%= - - ( ( ! @invoicing_list - && ! $conf->exists('disablepostalinvoicedefault') - && ! $cust_main->custnum - ) - || grep { $_ eq 'POST' } @invoicing_list ) - - ? 'CHECKED' - : '' - - %>> Postal mail invoice - - </TD> - </TR> - - <TR> - <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_FAX" VALUE="FAX" <%= - - ( grep { $_ eq 'FAX' } @invoicing_list ) - ? 'CHECKED' - : '' - - %>> Fax invoice - - </TD> - </TR> - - <TR> - <TD ALIGN="right" WIDTH="200">Email invoice </TD> - <TD WIDTH="408"><INPUT TYPE="text" NAME="invoicing_list" VALUE="<%= join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) %>"></TD> - </TR> - - </TABLE> - - </FORM> - - <%= $r %> required fields - -<% } %> - diff --git a/httemplate/edit/cust_main/contact.html b/httemplate/edit/cust_main/contact.html index e0cd06f56..7b88ccbcb 100644 --- a/httemplate/edit/cust_main/contact.html +++ b/httemplate/edit/cust_main/contact.html @@ -14,23 +14,14 @@ $cust_main->set($pre.'state', $statedefault ) unless $cust_main->get($pre.'state') || $cust_main->get($pre.'country') ne $countrydefault; -#my($county_html, $state_html, $country_html) = -# FS::cust_main_county::regionselector( $cust_main->get($pre.'county'), -# $cust_main->get($pre.'state'), -# $cust_main->get($pre.'country'), -# $pre, -# $onchange, -# $disabled, -# ); - -my %select_hash = ( - 'county' => $cust_main->get($pre.'county'), - 'state' => $cust_main->get($pre.'state'), - 'country' => $cust_main->get($pre.'country'), - 'prefix' => $pre, - 'onchange' => $onchange, - 'disabled' => $disabled, -); +my($county_html, $state_html, $country_html) = + FS::cust_main_county::regionselector( $cust_main->get($pre.'county'), + $cust_main->get($pre.'state'), + $cust_main->get($pre.'country'), + $pre, + $onchange, + $disabled, + ); my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone'; my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone'; @@ -39,7 +30,7 @@ my $r = qq!<font color="#ff0000">*</font> !; %> -<%= &ntable("#cccccc") %> +<%= &itable("#cccccc") %> <TR> <TH ALIGN="right"><%=$r%>Contact name<BR>(last, first)</TH> @@ -51,7 +42,7 @@ my $r = qq!<font color="#ff0000">*</font> !; <% if ( $conf->exists('show_ss') && !$pre ) { %> <TD ALIGN="right">SS#</TD> <TD><INPUT TYPE="text" NAME="ss" VALUE="<%= $cust_main->ss %>" SIZE=11></TD> -<% } elsif ( !$pre ) { %> +<% } else { %> <TD><INPUT TYPE="hidden" NAME="ss" VALUE="<%= $cust_main->ss %>"></TD> <% } %> @@ -84,10 +75,7 @@ my $r = qq!<font color="#ff0000">*</font> !; <INPUT TYPE="text" NAME="<%=$pre%>city" VALUE="<%= $cust_main->get($pre.'city') %>" onChange="<%= $onchange %>" <%=$disabled%>> </TD> <TH ALIGN="right"><%=$r%>State</TH> - <TD> - <%= include('select-county.html', %select_hash ) %> - <%= include('select-state.html', %select_hash ) %> - </TD> + <TD><%= $county_html. $state_html %></TD> <TH><%=$r%>Zip</TH> <TD> <INPUT TYPE="text" NAME="<%=$pre%>zip" VALUE="<%= $cust_main->get($pre.'zip') %>" SIZE=10 onChange="<%= $onchange %>" <%=$disabled%>> @@ -96,7 +84,7 @@ my $r = qq!<font color="#ff0000">*</font> !; <TR> <TH ALIGN="right"><%=$r%>Country</TH> - <TD><%= include('select-country.html', %select_hash ) %></TD> + <TD><%= $country_html %></TD> </TR> <TR> diff --git a/httemplate/edit/cust_main/select-country.html b/httemplate/edit/cust_main/select-country.html deleted file mode 100644 index 014effd66..000000000 --- a/httemplate/edit/cust_main/select-country.html +++ /dev/null @@ -1,72 +0,0 @@ -<% - - 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', - 'subs' => [ $opt{'prefix'}. 'get_states' ], - ) -%> - -<SCRIPT TYPE="text/javascript"> - - function opt(what,value,text) { - var optionName = new Option(text, value, false, false); - var length = what.length; - what.options[length] = optionName; - } - - function <%= $opt{'prefix'} %>country_changed(what, callback) { - - country = what.options[what.selectedIndex].text; - - function <%= $opt{'prefix'} %>update_states(states) { - - // blank the current state list - for ( var i = what.form.<%= $opt{'prefix'} %>state.length; i >= 0; i-- ) - what.form.<%= $opt{'prefix'} %>state.options[i] = null; - - // add the new states - var statesArray = eval('(' + states + ')' ); - for ( var s = 0; s < statesArray.length; s++ ) { - var stateLabel = statesArray[s]; - if ( stateLabel == "" ) - stateLabel = '(n/a)'; - opt(what.form.<%= $opt{'prefix'} %>state, statesArray[s], stateLabel); - } - - //run the callback - if ( callback != null ) - callback(); - } - - // go get the new states - <%= $opt{'prefix'} %>get_states( country, <%= $opt{'prefix'} %>update_states ); - - } - -</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 $a cmp $b } - map { $_->country } - qsearch( 'cust_main_county',{}, 'DISTINCT ON ( country ) *', ) - ) { -%> - - <OPTION VALUE="<%= $country %>"<%= $country eq $opt{'country'} ? ' SELECTED' : '' %>><%= $country %> - -<% } %> - -</SELECT> - diff --git a/httemplate/edit/cust_main/select-county.html b/httemplate/edit/cust_main/select-county.html deleted file mode 100644 index 3de380b31..000000000 --- a/httemplate/edit/cust_main/select-county.html +++ /dev/null @@ -1,91 +0,0 @@ -<% - - 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"> - - function opt(what,value,text) { - var optionName = new Option(text, value, false, false); - var length = what.length; - what.options[length] = optionName; - } - - function <%= $opt{'prefix'} %>state_changed(what, callback) { - - state = what.options[what.selectedIndex].text; - country = what.form.<%= $opt{'prefix'} %>country.options[what.form.<%= $opt{'prefix'} %>country.selectedIndex].text; - - function <%= $opt{'prefix'} %>update_counties(counties) { - - // blank the current county list - for ( var i = what.form.<%= $opt{'prefix'} %>county.length; i >= 0; i-- ) - what.form.<%= $opt{'prefix'} %>county.options[i] = null; - - // add the new counties - var countiesArray = eval('(' + counties + ')' ); - for ( var s = 0; s < countiesArray.length; s++ ) { - var countyLabel = countiesArray[s]; - if ( countyLabel == "" ) - countyLabel = '(n/a)'; - opt(what.form.<%= $opt{'prefix'} %>county, countiesArray[s], countyLabel); - } - - //run the callback - if ( callback != null ) - callback(); - } - - // go get the new counties - <%= $opt{'prefix'} %>get_counties( state, country, <%= $opt{'prefix'} %>update_counties ); - - } - - </SCRIPT> - - <SELECT NAME="<%= $opt{'prefix'} %>county" onChange="<%= $opt{'onchange'} %>" <%= $opt{'disabled'} %>> - - <% foreach my $county ( - sort - map { $_->county } - qsearch('cust_main_county', { 'state' => $opt{'state'}, - 'country' => $opt{'country'}, - } - ) - ) { - %> - - <OPTION VALUE="<%= $county %>"<%= $county eq $opt{'county'} ? ' SELECTED' : '' %>><%= $county %> - - <% } %> - - </SELECT> - -<% } else { %> - - <SCRIPT TYPE="text/javascript"> - function <%= $opt{'prefix'} %>state_changed(what) { - } - </SCRIPT> - - <INPUT TYPE="hidden" NAME="<%= $opt{'prefix'} %>county" VALUE="<%= $opt{'county'} %>"> - -<% } %> diff --git a/httemplate/edit/cust_main/select-state.html b/httemplate/edit/cust_main/select-state.html deleted file mode 100644 index 98e685ab8..000000000 --- a/httemplate/edit/cust_main/select-state.html +++ /dev/null @@ -1,27 +0,0 @@ -<% - - 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'} %>> - -<% foreach my $state ( - sort - map { $_->state } - qsearch( 'cust_main_county', - { 'country' => $opt{'country'} }, - 'DISTINCT ON ( state ) *', - ) - ) { -%> - - <OPTION VALUE="<%= $state %>"<%= $state eq $opt{'state'} ? ' SELECTED' : '' %>><%= $state || '(n/a)' %> - -<% } %> - -</SELECT> - |