summaryrefslogtreecommitdiff
path: root/httemplate/edit/cust_main
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/edit/cust_main')
-rw-r--r--httemplate/edit/cust_main/billing.html621
-rw-r--r--httemplate/edit/cust_main/contact.html155
-rw-r--r--httemplate/edit/cust_main/select-country.html64
-rw-r--r--httemplate/edit/cust_main/select-county.html106
-rw-r--r--httemplate/edit/cust_main/select-domain.html66
-rw-r--r--httemplate/edit/cust_main/select-state.html31
6 files changed, 568 insertions, 475 deletions
diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html
index 96f777baa..ba10929ed 100644
--- a/httemplate/edit/cust_main/billing.html
+++ b/httemplate/edit/cust_main/billing.html
@@ -1,70 +1,54 @@
-<%
+%if ( $payby_default eq 'HIDE' ) {
+%
+% $cust_main->payby('BILL') unless $cust_main->payby;
-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 %>">
+ <INPUT TYPE="hidden" NAME="select" VALUE="<% $cust_main->payby %>">
</FORM>
- <FORM NAME="<%= $cust_main->payby %>" STYLE="margin-top: 0; margin-bottom: 0"> <% # XXX key %>
+ <FORM NAME="<% $cust_main->payby %>" STYLE="margin-top: 0; margin-bottom: 0">
- <% foreach my $field (qw( payinfo payname paycvv paystart_month paystart_year payissue payip )) { %>
+ <INPUT TYPE="hidden" NAME="payinfo" VALUE="<% $cust_main->paymask %>">
- <INPUT TYPE="hidden" NAME="<%= $field %>" VALUE="<%= $cust_main->getfield($field) %>">
+% foreach my $field (qw( 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";
- }
- %>
+% }
+
+% #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 %>">
+ <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="tax" VALUE="<% $cust_main->tax %>">
- <INPUT TYPE="hidden" NAME="invoicing_list" VALUE="<%= join(', ', @invoicing_list) %>">
+ <INPUT TYPE="hidden" NAME="invoicing_list" VALUE="<% join(', ', @invoicing_list) %>">
</FORM>
-<% } else {
-
- my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
-
-%>
+% } else {
+%
+% my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
<BR>Billing information
- <%= &ntable("#cccccc") %>
+ <% &ntable("#cccccc") %>
<TR>
- <TD ALIGN="right" WIDTH="200"><%=$r%>Billing type</TD>
+ <TD ALIGN="right" WIDTH="200"><%$r%>Billing type</TD>
<SCRIPT>
@@ -134,279 +118,271 @@ if ( $payby_default eq 'HIDE' ) {
}
</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&nbsp;!.
-
- 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>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</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>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</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>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</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>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</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>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</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>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</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>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</TD></TR>'.
- '<TR><TD>&nbsp;</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 %>
+% my $payby = $cust_main->payby;
+% 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&nbsp;!.
+%
+% 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->is_encrypted($cust_main->paycvv) ? $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=12 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>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</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>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</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>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</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>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</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>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</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>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</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>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+% '<TR><TD>&nbsp;</TD></TR>'.
+%
+% '</TABLE>',
+%
+% );
+%
+% #this should use FS::payby
+% 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") %>
+ <% &ntable("#cccccc") %>
<TR><TD>&nbsp;</TD></TR>
<TR>
- <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="tax" VALUE="Y" <%= $cust_main->tax eq "Y" ? 'CHECKED' : '' %>> Tax Exempt</TD>
+ <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" <%=
+ <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 )
+ ( grep { $_ eq 'POST' } @invoicing_list )
? 'CHECKED'
: ''
@@ -417,7 +393,7 @@ if ( $payby_default eq 'HIDE' ) {
</TR>
<TR>
- <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_FAX" VALUE="FAX" <%=
+ <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_FAX" VALUE="FAX" <%
( grep { $_ eq 'FAX' } @invoicing_list )
? 'CHECKED'
@@ -430,14 +406,37 @@ if ( $payby_default eq 'HIDE' ) {
<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>
+ <TD WIDTH="408"><INPUT TYPE="text" NAME="invoicing_list" VALUE="<% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) %>"></TD>
</TR>
+% if ( $conf->exists('voip-cust_cdr_spools') ) {
+
+ <TR>
+ <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="spool_cdr" VALUE="Y" <% $cust_main->spool_cdr eq "Y" ? 'CHECKED' : '' %>> Spool CDRs</TD>
+ </TR>
+% } else {
+
+ <INPUT TYPE="hidden" NAME="spool_cdr" VALUE="<% $cust_main->spool_cdr %>">
+% }
+
</TABLE>
</FORM>
- <%= $r %> required fields
+ <% $r %> required fields
+% }
+
+<%init>
+
+my( $cust_main, %options ) = @_;
+my @invoicing_list = @{ $options{'invoicing_list'} };
+my $payinfo = $options{'payinfo'};
+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;
+</%init>
diff --git a/httemplate/edit/cust_main/contact.html b/httemplate/edit/cust_main/contact.html
index e0cd06f56..e813986cd 100644
--- a/httemplate/edit/cust_main/contact.html
+++ b/httemplate/edit/cust_main/contact.html
@@ -1,125 +1,134 @@
-<%
-
-my( $cust_main, $pre, $onchange, $disabled ) = @_;
-my $conf = new FS::Conf;
-
-#false laziness with ship state
-my $countrydefault = $conf->config('countrydefault') || 'US';
-$cust_main->set($pre.'country', $countrydefault )
- unless $cust_main->get($pre.'country');
-
-my $statedefault = $conf->config('statedefault')
- || ($countrydefault eq 'US' ? 'CA' : '');
-$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 $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone';
-my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone';
-
-my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
-
-%>
-
-<%= &ntable("#cccccc") %>
+<% &ntable("#cccccc") %>
<TR>
- <TH ALIGN="right"><%=$r%>Contact&nbsp;name<BR>(last,&nbsp;first)</TH>
- <TD COLSPAN=3>
- <INPUT TYPE="text" NAME="<%=$pre%>last" VALUE="<%= $cust_main->get($pre.'last') %>" onChange="<%= $onchange %>" <%=$disabled%>> ,
- <INPUT TYPE="text" NAME="<%=$pre%>first" VALUE="<%= $cust_main->get($pre.'first') %>" onChange="<%= $onchange %>" <%=$disabled%>>
+ <TH ALIGN="right"><%$r%>Contact&nbsp;name<BR>(last,&nbsp;first)</TH>
+ <TD COLSPAN=5>
+ <INPUT TYPE="text" NAME="<%$pre%>last" VALUE="<% $cust_main->get($pre.'last') %>" onChange="<% $onchange %>" <%$disabled%>> ,
+ <INPUT TYPE="text" NAME="<%$pre%>first" VALUE="<% $cust_main->get($pre.'first') %>" onChange="<% $onchange %>" <%$disabled%>>
</TD>
+% if ( $conf->exists('show_ss') && !$pre ) {
-<% 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 ) { %>
- <TD><INPUT TYPE="hidden" NAME="ss" VALUE="<%= $cust_main->ss %>"></TD>
-<% } %>
+ <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $cust_main->ss %>" SIZE=11></TD>
+% } elsif ( !$pre ) {
+
+ <TD><INPUT TYPE="hidden" NAME="ss" VALUE="<% $cust_main->ss %>"></TD>
+% }
+
</TR>
<TR>
<TD ALIGN="right">Company</TD>
- <TD COLSPAN=5>
- <INPUT TYPE="text" NAME="<%=$pre%>company" VALUE="<%= $cust_main->get($pre.'company') %>" SIZE=70 onChange="<%= $onchange %>" <%=$disabled%>>
+ <TD COLSPAN=7>
+ <INPUT TYPE="text" NAME="<%$pre%>company" VALUE="<% $cust_main->get($pre.'company') %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%>>
</TD>
</TR>
<TR>
- <TH ALIGN="right"><%=$r%>Address</TH>
- <TD COLSPAN=5>
- <INPUT TYPE="text" NAME="<%=$pre%>address1" VALUE="<%= $cust_main->get($pre.'address1') %>" SIZE=70 onChange="<%= $onchange %>" <%=$disabled%>>
+ <TH ALIGN="right"><%$r%>Address</TH>
+ <TD COLSPAN=7>
+ <INPUT TYPE="text" NAME="<%$pre%>address1" VALUE="<% $cust_main->get($pre.'address1') %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%>>
</TD>
</TR>
<TR>
<TD ALIGN="right">&nbsp;</TD>
- <TD COLSPAN=5>
- <INPUT TYPE="text" NAME="<%=$pre%>address2" VALUE="<%= $cust_main->get($pre.'address2') %>" SIZE=70 onChange="<%= $onchange %>" <%=$disabled%>>
+ <TD COLSPAN=7>
+ <INPUT TYPE="text" NAME="<%$pre%>address2" VALUE="<% $cust_main->get($pre.'address2') %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%>>
</TD>
</TR>
<TR>
- <TH ALIGN="right"><%=$r%>City</TH>
+ <TH ALIGN="right"><%$r%>City</TH>
+ <TD>
+ <INPUT TYPE="text" NAME="<%$pre%>city" VALUE="<% $cust_main->get($pre.'city') %>" onChange="<% $onchange %>" <%$disabled%>>
+ </TD>
+ <TH ALIGN="right" ID="<%$pre%>countylabel" <%$county_style%>><%$r%>County</TH>
<TD>
- <INPUT TYPE="text" NAME="<%=$pre%>city" VALUE="<%= $cust_main->get($pre.'city') %>" onChange="<%= $onchange %>" <%=$disabled%>>
+ <% include('select-county.html', %select_hash ) %>
</TD>
- <TH ALIGN="right"><%=$r%>State</TH>
+ <TH ALIGN="right"><%$r%>State</TH>
<TD>
- <%= include('select-county.html', %select_hash ) %>
- <%= include('select-state.html', %select_hash ) %>
+ <% include('select-state.html', %select_hash ) %>
</TD>
- <TH><%=$r%>Zip</TH>
+ <TH><%$r%>Zip</TH>
<TD>
- <INPUT TYPE="text" NAME="<%=$pre%>zip" VALUE="<%= $cust_main->get($pre.'zip') %>" SIZE=10 onChange="<%= $onchange %>" <%=$disabled%>>
+ <INPUT TYPE="text" NAME="<%$pre%>zip" VALUE="<% $cust_main->get($pre.'zip') %>" SIZE=10 onChange="<% $onchange %>" <%$disabled%>>
</TD>
</TR>
<TR>
- <TH ALIGN="right"><%=$r%>Country</TH>
- <TD><%= include('select-country.html', %select_hash ) %></TD>
+ <TH ALIGN="right"><%$r%>Country</TH>
+ <TD COLSPAN=5><% include('select-country.html', %select_hash ) %></TD>
</TR>
<TR>
- <TD ALIGN="right"><%= $daytime_label %></TD>
+ <TD ALIGN="right"><% $daytime_label %></TD>
<TD COLSPAN=5>
- <INPUT TYPE="text" NAME="<%=$pre%>daytime" VALUE="<%= $cust_main->get($pre.'daytime') %>" SIZE=18 onChange="<%= $onchange %>" <%=$disabled%>>
+ <INPUT TYPE="text" NAME="<%$pre%>daytime" VALUE="<% $cust_main->get($pre.'daytime') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%>>
</TD>
</TR>
<TR>
- <TD ALIGN="right"><%= $night_label %></TD>
+ <TD ALIGN="right"><% $night_label %></TD>
<TD COLSPAN=5>
- <INPUT TYPE="text" NAME="<%=$pre%>night" VALUE="<%= $cust_main->get($pre.'night') %>" SIZE=18 onChange="<%= $onchange %>" <%=$disabled%>>
+ <INPUT TYPE="text" NAME="<%$pre%>night" VALUE="<% $cust_main->get($pre.'night') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%>>
</TD>
</TR>
<TR>
<TD ALIGN="right">Fax</TD>
<TD COLSPAN=5>
- <INPUT TYPE="text" NAME="<%=$pre%>fax" VALUE="<%= $cust_main->get($pre.'fax') %>" SIZE=12 onChange="<%= $onchange %>" <%=$disabled%>>
+ <INPUT TYPE="text" NAME="<%$pre%>fax" VALUE="<% $cust_main->get($pre.'fax') %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%>>
</TD>
</TR>
</TABLE>
-<%=$r%>required fields<BR>
+<%$r%>required fields<BR>
+
+<%init>
+
+my( $cust_main, $pre, $onchange, $disabled ) = @_;
+my $conf = new FS::Conf;
+
+#false laziness with ship state
+my $countrydefault = $conf->config('countrydefault') || 'US';
+$cust_main->set($pre.'country', $countrydefault )
+ unless $cust_main->get($pre.'country');
+
+my $statedefault = $conf->config('statedefault')
+ || ($countrydefault eq 'US' ? 'CA' : '');
+$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 @counties = counties( $cust_main->get($pre.'state'),
+ $cust_main->get($pre.'country'),
+ );
+my $county_style = scalar(@counties) > 1 ? '' : 'STYLE="visibility:hidden"';
+
+my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone';
+my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone';
+
+my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
+</%init>
diff --git a/httemplate/edit/cust_main/select-country.html b/httemplate/edit/cust_main/select-country.html
index 014effd66..137f61975 100644
--- a/httemplate/edit/cust_main/select-country.html
+++ b/httemplate/edit/cust_main/select-country.html
@@ -1,16 +1,5 @@
-<%
- 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',
+<% include('/elements/xmlhttp.html',
'url' => $p.'misc/states.cgi',
'subs' => [ $opt{'prefix'}. 'get_states' ],
)
@@ -24,23 +13,23 @@
what.options[length] = optionName;
}
- function <%= $opt{'prefix'} %>country_changed(what, callback) {
+ function <% $opt{'prefix'} %>country_changed(what, callback) {
- country = what.options[what.selectedIndex].text;
+ country = what.options[what.selectedIndex].value;
- function <%= $opt{'prefix'} %>update_states(states) {
+ 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;
+ 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];
+ for ( var s = 0; s < statesArray.length; s=s+2 ) {
+ var stateLabel = statesArray[s+1];
if ( stateLabel == "" )
stateLabel = '(n/a)';
- opt(what.form.<%= $opt{'prefix'} %>state, statesArray[s], stateLabel);
+ opt(what.form.<% $opt{'prefix'} %>state, statesArray[s], stateLabel);
}
//run the callback
@@ -49,24 +38,39 @@
}
// go get the new states
- <%= $opt{'prefix'} %>get_states( country, <%= $opt{'prefix'} %>update_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'} %>>
+<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 ) *', )
- ) {
-%>
+% foreach my $country (
+% sort { ($b eq $countrydefault) <=> ($a eq $countrydefault)
+% or code2country($a) cmp code2country($b) }
+% map { $_->country }
+% qsearch({
+% 'select' => 'country',
+% 'table' => 'cust_main_county',
+% 'hashref' => {},
+% 'extra_sql' => 'GROUP BY country',
+% })
+% ) {
- <OPTION VALUE="<%= $country %>"<%= $country eq $opt{'country'} ? ' SELECTED' : '' %>><%= $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>
+
diff --git a/httemplate/edit/cust_main/select-county.html b/httemplate/edit/cust_main/select-county.html
index 3de380b31..0dc826896 100644
--- a/httemplate/edit/cust_main/select-county.html
+++ b/httemplate/edit/cust_main/select-county.html
@@ -1,25 +1,10 @@
-<%
+% if ( $countyflag ) {
- 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',
+ <% include('/elements/xmlhttp.html',
'url' => $p.'misc/counties.cgi',
'subs' => [ $opt{'prefix'}. 'get_counties' ],
)
-%>
+ %>
<SCRIPT TYPE="text/javascript">
@@ -29,16 +14,16 @@
what.options[length] = optionName;
}
- function <%= $opt{'prefix'} %>state_changed(what, callback) {
+ 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;
+ state = what.options[what.selectedIndex].value;
+ country = what.form.<% $opt{'prefix'} %>country.options[what.form.<% $opt{'prefix'} %>country.selectedIndex].value;
- function <%= $opt{'prefix'} %>update_counties(counties) {
+ 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;
+ 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 + ')' );
@@ -46,7 +31,17 @@
var countyLabel = countiesArray[s];
if ( countyLabel == "" )
countyLabel = '(n/a)';
- opt(what.form.<%= $opt{'prefix'} %>county, countiesArray[s], countyLabel);
+ opt(what.form.<% $opt{'prefix'} %>county, countiesArray[s], countyLabel);
+ }
+
+ var countyFormLabel = document.getElementById('<% $opt{'prefix'} %>countylabel');
+
+ if ( countiesArray.length > 1 ) {
+ what.form.<% $opt{'prefix'} %>county.style.display = '';
+ countyFormLabel.style.visibility = 'visible';
+ } else {
+ what.form.<% $opt{'prefix'} %>county.style.display = 'none';
+ countyFormLabel.style.visibility = 'hidden';
}
//run the callback
@@ -55,37 +50,64 @@
}
// go get the new counties
- <%= $opt{'prefix'} %>get_counties( state, country, <%= $opt{'prefix'} %>update_counties );
+ <% $opt{'prefix'} %>get_counties( state, country, <% $opt{'prefix'} %>update_counties );
}
</SCRIPT>
- <SELECT NAME="<%= $opt{'prefix'} %>county" onChange="<%= $opt{'onchange'} %>" <%= $opt{'disabled'} %>>
+ <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'},
- }
- )
- ) {
- %>
+% foreach my $county ( @counties ) {
- <OPTION VALUE="<%= $county %>"<%= $county eq $opt{'county'} ? ' SELECTED' : '' %>><%= $county %>
+ <OPTION VALUE="<% $county %>"<% $county eq $opt{'county'} ? ' SELECTED' : '' %>><% $county %>
- <% } %>
+% }
</SELECT>
-<% } else { %>
+% } else {
+
<SCRIPT TYPE="text/javascript">
- function <%= $opt{'prefix'} %>state_changed(what) {
+ function <% $opt{'prefix'} %>state_changed(what) {
}
</SCRIPT>
- <INPUT TYPE="hidden" NAME="<%= $opt{'prefix'} %>county" VALUE="<%= $opt{'county'} %>">
+ <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 @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>
diff --git a/httemplate/edit/cust_main/select-domain.html b/httemplate/edit/cust_main/select-domain.html
new file mode 100644
index 000000000..3d42eb8b1
--- /dev/null
+++ b/httemplate/edit/cust_main/select-domain.html
@@ -0,0 +1,66 @@
+
+<% include('/elements/xmlhttp.html',
+ 'url' => $p.'misc/svc_acct-domains.cgi',
+ 'subs' => [ $opt{'prefix'}. 'get_domains' ],
+ )
+%>
+
+<SCRIPT TYPE="text/javascript">
+
+ function selopt(what,value,text,selected) {
+ var optionName = new Option(text, value, false, selected);
+ var length = what.length;
+ what.options[length] = optionName;
+ }
+
+ function <% $opt{'prefix'} %>pkgpart_svcpart_changed(what,selected) {
+
+ pkgpart_svcpart = what.options[what.selectedIndex].value;
+
+ function <% $opt{'prefix'} %>update_domains(domains) {
+
+ // blank the current domain list
+ for ( var i = what.form.<% $opt{'prefix'} %>domsvc.length; i >= 0; i-- )
+ what.form.<% $opt{'prefix'} %>domsvc.options[i] = null;
+
+ // add the new domains
+ var domainArray = eval('(' + domains + ')' );
+ for ( var s = 0; s < domainArray.length; s=s+2 ) {
+ var domainLabel = domainArray[s+1];
+ if ( domainLabel == "" )
+ domainLabel = '(n/a)';
+ selopt(what.form.<% $opt{'prefix'} %>domsvc, domainArray[s], domainLabel, (domainArray[s] == selected) ? true : false);
+ }
+
+ }
+
+ // go get the new domains
+ <% $opt{'prefix'} %>get_domains( pkgpart_svcpart, <% $opt{'prefix'} %>update_domains );
+
+ }
+
+</SCRIPT>
+
+<SELECT NAME="<% $opt{'prefix'} %>pkgpart_svcpart" onchange="<% $opt{'prefix'} %>pkgpart_svcpart_changed(this,0);" >
+
+% foreach my $part_pkg ( @part_pkg ) {
+
+ <OPTION VALUE="<% $part_pkg->pkgpart. "_". $part_pkg->svcpart('svc_acct') %>"<% ( $opt{saved_pkgpart} && $part_pkg->pkgpart == $opt{saved_pkgpart} ) ? ' SELECTED' : '' %>><% $part_pkg->pkg. " - ". $part_pkg->comment %>
+
+% }
+
+</SELECT>
+<SCRIPT>
+ pkgpart_svcpart_changed(document.bottomform.pkgpart_svcpart, <% $opt{saved_domsvc} %>);
+</SCRIPT>
+
+<%init>
+my %opt = @_;
+foreach my $opt (qw( svc_part pkgparts saved_pkgpart saved_domsvc prefix)) {
+ $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_});
+}
+$opt{saved_domsvc} = 0 unless $opt{saved_domsvc};
+my @part_pkg = @{$opt{'pkgparts'}};
+
+</%init>
+
diff --git a/httemplate/edit/cust_main/select-state.html b/httemplate/edit/cust_main/select-state.html
index 98e685ab8..87546e5e3 100644
--- a/httemplate/edit/cust_main/select-state.html
+++ b/httemplate/edit/cust_main/select-state.html
@@ -1,27 +1,20 @@
-<%
+<SELECT NAME="<% $opt{'prefix'} %>state" onChange="<% $opt{'prefix'} %>state_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
- my %opt = @_;
- foreach my $opt (qw( county state country prefix onchange disabled )) {
- $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_});
- }
+% foreach my $state ( keys %states ) {
-%>
+ <OPTION VALUE="<% $state %>"<% $state eq $opt{'state'} ? ' SELECTED' : '' %>><% $states{$state} || '(n/a)' %>
-<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>
-<% } %>
+<%init>
+my %opt = @_;
+foreach my $opt (qw( county state country prefix onchange disabled )) {
+ $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_});
+}
-</SELECT>
+tie my %states, 'Tie::IxHash', states_hash( $opt{'country'} );
+</%init>