change service, billing, and payment info in selfservice
authorjeff <jeff>
Wed, 23 Jan 2008 19:18:39 +0000 (19:18 +0000)
committerjeff <jeff>
Wed, 23 Jan 2008 19:18:39 +0000 (19:18 +0000)
15 files changed:
FS/FS/ClientAPI/MyAccount.pm
fs_selfservice/FS-SelfService/cgi/bill.html [new file with mode: 0644]
fs_selfservice/FS-SelfService/cgi/card.html [new file with mode: 0644]
fs_selfservice/FS-SelfService/cgi/change_bill.html [new file with mode: 0755]
fs_selfservice/FS-SelfService/cgi/change_pay.html [new file with mode: 0644]
fs_selfservice/FS-SelfService/cgi/change_ship.html [new file with mode: 0755]
fs_selfservice/FS-SelfService/cgi/check.html [new file with mode: 0644]
fs_selfservice/FS-SelfService/cgi/contact.html [new file with mode: 0644]
fs_selfservice/FS-SelfService/cgi/make_ach_payment.html
fs_selfservice/FS-SelfService/cgi/make_payment.html
fs_selfservice/FS-SelfService/cgi/myaccount_menu.html
fs_selfservice/FS-SelfService/cgi/process_change_bill.html [new file with mode: 0644]
fs_selfservice/FS-SelfService/cgi/process_change_pay.html [new file with mode: 0644]
fs_selfservice/FS-SelfService/cgi/process_change_ship.html [new file with mode: 0644]
fs_selfservice/FS-SelfService/cgi/selfservice.cgi

index 61078a9..2d39510 100644 (file)
@@ -42,6 +42,7 @@ use vars qw( @cust_main_editable_fields );
   ship_first ship_last ship_company ship_address1 ship_address2 ship_city
     ship_state ship_zip ship_country ship_daytime ship_night ship_fax
   payby payinfo payname paystart_month paystart_year payissue payip
+  ss paytype paystate stateid stateid_state
 );
 
 use subs qw(_provision);
@@ -113,6 +114,14 @@ sub customer_info {
   return { 'error' => $session } if $context eq 'error';
 
   my %return;
+
+  my $conf = new FS::Conf;
+  if ($conf->exists('cust_main-require_address2')) {
+    $return{'require_address2'} = '1';
+  }else{
+    $return{'require_address2'} = '';
+  }
+  
   if ( $custnum ) { #customer record
 
     my $search = { 'custnum' => $custnum };
@@ -133,7 +142,6 @@ sub customer_info {
                    } $cust_main->open_cust_bill;
     $return{open_invoices} = \@open;
 
-    my $conf = new FS::Conf;
     $return{small_custview} =
       small_custview( $cust_main, $conf->config('countrydefault') );
 
@@ -208,13 +216,46 @@ sub edit_info {
   $new->set( $_ => $p->{$_} )
     foreach grep { exists $p->{$_} } @cust_main_editable_fields;
 
-  if ( $p->{'payby'} =~ /^(CARD|DCRD)$/ ) {
+  my $payby = '';
+  if (exists($p->{'payby'})) {
+    $p->{'payby'} =~ /^([A-Z]{4})$/
+      or return { 'error' => "illegal_payby " . $p->{'payby'} };
+    $payby = $1;
+  }
+
+  if ( $payby =~ /^(CARD|DCRD)$/ ) {
+
     $new->paydate($p->{'year'}. '-'. $p->{'month'}. '-01');
+
     if ( $new->payinfo eq $cust_main->paymask ) {
       $new->payinfo($cust_main->payinfo);
     } else {
-      $new->paycvv($p->{'paycvv'});
+      $new->payinfo($p->{'payinfo'});
     }
+
+    $new->set( 'payby' => $p->{'auto'} ? 'CARD' : 'DCRD' );
+
+  }elsif ( $payby =~ /^(CHEK|DCHK)$/ ) {
+    my $payinfo;
+    $p->{'payinfo1'} =~ /^([\dx]+)$/
+      or return { 'error' => "illegal account number ". $p->{'payinfo1'} };
+    my $payinfo1 = $1;
+     $p->{'payinfo2'} =~ /^([\dx]+)$/
+      or return { 'error' => "illegal ABA/routing number ". $p->{'payinfo2'} };
+    my $payinfo2 = $1;
+    $payinfo = $payinfo1. '@'. $payinfo2;
+
+    if ( $payinfo eq $cust_main->paymask ) {
+      $new->payinfo($cust_main->payinfo);
+    } else {
+      $new->payinfo($payinfo);
+    }
+
+    $new->set( 'payby' => $p->{'auto'} ? 'CHEK' : 'DCHK' );
+
+  }elsif ( $payby =~ /^(BILL)$/ ) {
+  } elsif ( $payby ) {  #notyet ready
+    return { 'error' => "unknown payby $payby" };
   }
 
   my @invoicing_list;
@@ -265,6 +306,8 @@ sub payment_info {
 
       'paytypes' => [ @FS::cust_main::paytypes ],
 
+      'paybys' => [ $conf->config('signup_server-payby') ],
+
       'stateid_label' => FS::Msgcat::_gettext('stateid'),
       'stateid_state_label' => FS::Msgcat::_gettext('stateid_state'),
 
diff --git a/fs_selfservice/FS-SelfService/cgi/bill.html b/fs_selfservice/FS-SelfService/cgi/bill.html
new file mode 100644 (file)
index 0000000..bbdf1f2
--- /dev/null
@@ -0,0 +1,7 @@
+<TR>
+  <TD ALIGN="right">P.O.&nbsp;number</TD>
+  <TD><INPUT TYPE="text" NAME="payinfo" SIZE=10 MAXLENGTH=20 VALUE="<%=$payinfo%>"></TD>
+</TR><TR>
+  <TD ALIGN="right">Attention</TD>
+  <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%=$payname%>"></TD>
+</TR>
diff --git a/fs_selfservice/FS-SelfService/cgi/card.html b/fs_selfservice/FS-SelfService/cgi/card.html
new file mode 100644 (file)
index 0000000..cf6d20d
--- /dev/null
@@ -0,0 +1,73 @@
+<TR>
+  <TD ALIGN="right">Card&nbsp;number</TD>
+  <TD>
+    <TABLE>
+      <TR>
+        <TD>
+          <INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<%=$payinfo%>"> </TD>
+        <TD>Exp.</TD>
+        <TD>
+          <SELECT NAME="month">
+            <%= for ( ( map "0$_", 1 .. 9 ), 10 .. 12 ) {
+                  $OUT .= '<OPTION'. ($_ == $month ? ' SELECTED' : ''). ">$_\n";
+            } %>
+          </SELECT>
+        </TD>
+        <TD> / </TD>
+        <TD>
+          <SELECT NAME="year">
+            <%= my @a = localtime; for ( $a[5]+1900 .. $a[5]+1915 ) {
+                  $OUT .= '<OPTION'. ($_ == $year ? ' SELECTED' : ''). ">$_\n";
+            } %>
+          </SELECT>
+        </TD>
+      </TR>
+    </TABLE>
+  </TD>
+</TR>
+<%= 
+  if ( $withcvv ) {
+    $OUT .= qq!<TR>!;
+    $OUT .= qq!<TD ALIGN="right">CVV2&nbsp;(<A HREF="javascript:myopen('cvv2.html','cvv2','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=480,height=288')">help</A>)</TD>!;
+    $OUT .= qq!<TD><INPUT TYPE="text" NAME="paycvv" VALUE="" SIZE=4 MAXLENGTH=4></TD>!;
+    $OUT .= qq!</TR>!;
+  }
+  '';
+%>
+<TR>
+  <TD ALIGN="right">Exact&nbsp;name&nbsp;on&nbsp;card</TD>
+  <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%=$payname%>"></TD>
+</TR><TR>
+  <TD ALIGN="right">Card&nbsp;billing&nbsp;address</TD>
+  <TD>
+    <INPUT TYPE="text" SIZE=40 MAXLENGTH=80 NAME="address1" VALUE="<%=$address1%>">
+  </TD>
+</TR><TR>
+  <TD ALIGN="right">Address&nbsp;line&nbsp;2</TD>
+  <TD>
+    <INPUT TYPE="text" SIZE=40 MAXLENGTH=80 NAME="address2" VALUE="<%=$address2%>">
+  </TD>
+</TR><TR>
+  <TD ALIGN="right">City</TD>
+  <TD>
+    <TABLE>
+      <TR>
+        <TD>
+          <INPUT TYPE="text" NAME="city" SIZE="12" MAXLENGTH=80 VALUE="<%=$city%>">
+        </TD>
+        <TD>State</TD>
+        <TD>
+          <SELECT NAME="state">
+            <%= for ( @states ) {
+              $OUT .= '<OPTION'. ($_ eq $state ? ' SELECTED' : '' ). ">$_\n";
+            } %>
+          </SELECT>
+        </TD>
+        <TD>Zip</TD>
+        <TD>
+          <INPUT TYPE="text" NAME="zip" SIZE=11 MAXLENGTH=10 VALUE="<%=$zip%>">
+        </TD>
+      </TR>
+    </TABLE>
+  </TD>
+</TR>
diff --git a/fs_selfservice/FS-SelfService/cgi/change_bill.html b/fs_selfservice/FS-SelfService/cgi/change_bill.html
new file mode 100755 (executable)
index 0000000..0bc47d0
--- /dev/null
@@ -0,0 +1,25 @@
+<HTML><HEAD><TITLE>MyAccount</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee">
+<FONT SIZE=5>MyAccount</FONT><BR><BR>
+<%= $url = "$selfurl?session=$session_id;action="; ''; %>
+<%= include('myaccount_menu') %>
+<TD VALIGN="top">
+<FONT SIZE=4>Edit billing address</FONT><BR><BR>
+<%= if ( $error ) { 
+  $OUT .= qq!<FONT SIZE="+1" COLOR="#ff0000">Error: $error</FONT><BR><BR>!;
+}  ''; %>
+
+<FORM NAME="ChangeBillForm" ACTION="<%= $selfurl %>" METHOD=POST onSubmit="document.bottomform.submit.disabled=true;">
+<INPUT TYPE="hidden" NAME="session" VALUE="<%= $session_id %>">
+<INPUT TYPE="hidden" NAME="action" VALUE="process_change_bill">
+<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
+
+<%= $r=qq!<font color="#ff0000">*</font>&nbsp;!; include('contact') %>
+
+<INPUT TYPE="submit" NAME="submit" VALUE="<%= $custnum ?  "Apply Changes" : "Add Customer" %>">
+<BR>
+</FORM>
+</TD></TR></TABLE>
+<HR>
+<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
+</BODY></HTML>
diff --git a/fs_selfservice/FS-SelfService/cgi/change_pay.html b/fs_selfservice/FS-SelfService/cgi/change_pay.html
new file mode 100644 (file)
index 0000000..d26abfa
--- /dev/null
@@ -0,0 +1,75 @@
+<HTML><HEAD><TITLE>MyAccount</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee">
+<script language="JavaScript"><!--
+  var mywindow = -1;
+  function myopen(filename,windowname,properties) {
+    myclose();
+    mywindow = window.open(filename,windowname,properties);
+  }
+  function myclose() {
+    if ( mywindow != -1 )
+      mywindow.close();
+    mywindow = -1
+  }
+//--></script>
+<FONT SIZE=5>MyAccount</FONT><BR><BR>
+<%= $url = "$selfurl?session=$session_id;action="; ''; %>
+<%= include('myaccount_menu') %>
+<TD VALIGN="top">
+<FONT SIZE=4>Change payment information</FONT><BR><BR>
+<%= if ( $error ) { 
+  $OUT .= qq!<FONT SIZE="+1" COLOR="#ff0000">Error: $error</FONT><BR><BR>!;
+  }  ''; %>
+
+<FORM NAME="OneTrueForm" METHOD="POST" ACTION="<%=$selfurl%>" onSubmit="document.OneTrueForm.process.disabled=true">
+<%=
+  use Tie::IxHash;
+  use HTML::Widgets::SelectLayers;
+
+  my $preauto = '<TR><TD COLSPAN=3><INPUT TYPE="checkbox" NAME="auto" VALUE="1"';
+  my $postauto = '>Charge future payments to this card automatically</TD></TR>';
+
+  my $tail = qq(</TABLE><INPUT TYPE="hidden" NAME="session" VALUE="$session_id">). 
+             qq(<INPUT TYPE="hidden" NAME="action" VALUE="process_change_pay">).
+             qq(<BR>).
+             qq(<INPUT TYPE="submit" NAME="process" ).
+             qq(VALUE="Save payment information"> ).
+             qq(<!-- onClick="this.disabled=true"> -->);
+
+
+  my %paybychecked = (
+    'BILL' => include('bill'),
+    'CARD' => include('card')."$preauto CHECKED $postauto",
+    'DCRD' => include('card')."$preauto $postauto",
+    'CHEK' => include('check')."$preauto CHECKED $postauto",
+    'DCHK' => include('check')."$preauto $postauto",
+  );
+  my %payby_index = ( 'CARD'   => qq/Credit Card/,
+                      'DCRD'   => qq/Credit Card/,
+                      'CHEK'   => qq/Check/,
+                      'DCHK'   => qq/Check/,
+                      'LECB'   => qq/Phone Bill Billing/,
+                      'BILL'   => qq/Billing/,
+                      'COMP'   => qq/Complimentary/,
+                      'PREPAY' => qq/Prepaid Card/,
+                    );
+  tie my %options, 'Tie::IxHash', ();
+  foreach my $payby_option ( @paybys ) {
+    $options{$payby_option} = $payby_index{$payby_option};
+  }
+  $options{$payby} = $payby_index{$payby}
+    unless exists($options{$payby});
+
+  HTML::Widgets::SelectLayers->new(
+    options => \%options,
+    selected_layer => $payby,
+#    form_name => 'dummy',
+#    form_action => 'dummy.cgi',
+    layer_callback => sub { my $layer = shift; return '<TABLE BGCOLOR="#cccccc">'.$paybychecked{$layer}.qq!<INPUT TYPE="hidden" NAME="payby" VALUE="$layer">$tail!; },
+  )->html;
+
+%>
+</TD></TR></TABLE>
+<HR>
+<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
+</BODY></HTML>
diff --git a/fs_selfservice/FS-SelfService/cgi/change_ship.html b/fs_selfservice/FS-SelfService/cgi/change_ship.html
new file mode 100755 (executable)
index 0000000..1a3b85d
--- /dev/null
@@ -0,0 +1,104 @@
+<HTML><HEAD><TITLE>MyAccount</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee">
+<FONT SIZE=5>MyAccount</FONT><BR><BR>
+<%= $url = "$selfurl?session=$session_id;action="; ''; %>
+<%= include('myaccount_menu') %>
+<TD VALIGN="top">
+<FONT SIZE=4>Edit service address</FONT><BR><BR>
+<%= if ( $error ) { 
+  $OUT .= qq!<FONT SIZE="+1" COLOR="#ff0000">Error: $error</FONT><BR><BR>!;
+}  ''; %>
+
+<FORM NAME="OneTrueForm" ACTION="<%= $selfurl %>" METHOD=POST onSubmit="document.bottomform.submit.disabled=true;">
+<INPUT TYPE="hidden" NAME="session" VALUE="<%= $session_id %>">
+<INPUT TYPE="hidden" NAME="action" VALUE="process_change_ship">
+<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
+
+<%=
+  foreach (
+    qw( last first company address1 address2 city county state zip country
+        daytime night fax )
+  ) {
+    $OUT .= qq!<INPUT TYPE="hidden" NAME="$_" VALUE="${$_}">!;
+  };
+  '';
+%>
+<SCRIPT>
+function bill_changed(what) {
+  if ( what.form.same.checked ) {
+<%=
+  for (qw( last first company address1 address2 city zip daytime night fax )) { 
+    $OUT .= "what.form.ship_$_.value = what.form.$_.value;";
+  } 
+  '';
+%>
+    what.form.ship_country.selectedIndex = what.form.country.selectedIndex;
+
+    function fix_ship_county() {
+      what.form.ship_county.selectedIndex = what.form.county.selectedIndex;
+    }
+
+    function fix_ship_state() {
+      what.form.ship_state.selectedIndex = what.form.state.selectedIndex;
+      ship_state_changed(what.form.ship_state, fix_ship_county );
+    }
+
+    ship_country_changed(what.form.ship_country, fix_ship_state );
+
+  }
+}
+function samechanged(what) {
+  if ( what.checked ) {
+    bill_changed(what);
+
+<%=
+  for (qw( last first company address1 address2 city county state zip country daytime night fax )) { 
+    $OUT .= "what.form.ship_$_.disabled = true;";
+    $OUT .= "what.form.ship_$_.style.backgroundColor = '#dddddd';";
+  } 
+  if ( $require_address2 ) {
+    $OUT .= "document.getElementById('ship_address2_required').style.visibility = 'hidden';";
+    $OUT .= "document.getElementById('ship_address2_label').style.visibility = 'hidden';";
+  }
+%> 
+
+  } else {
+
+<%=
+  for (qw( last first company address1 address2 city county state zip country daytime night fax )) { 
+    $OUT .= "what.form.ship_$_.disabled = false;";
+    $OUT .= "what.form.ship_$_.style.backgroundColor = '#ffffff';";
+  } 
+  if ( $require_address2 ) {
+    $OUT .= "document.getElementById('ship_address2_required').style.visibility = '';";
+    $OUT .= "document.getElementById('ship_address2_label').style.visibility = '';";
+  }
+%>
+  }
+}
+</SCRIPT>
+(<INPUT TYPE="checkbox" NAME="same" VALUE="Y" onClick="samechanged(this)"
+  <%= (!$ship_last || $cgi->param('same') eq 'Y') ? 'CHECKED' : '' %>
+ >same as billing address)
+<%= $r=qq!<font color="#ff0000">*</font>&nbsp;!;
+    if (!$ship_last || $cgi->param('same') eq 'Y') {
+      $disabled = 'DISABLED STYLE="background-color: #dddddd"';
+      foreach ( qw( last first company address1 address2 city county state
+                    zip country daytime night fax )
+      ) {
+        ${"ship_$_"} = ${$_};
+      }
+    }else{
+      $disabled = '';
+    }
+    $pre = 'ship_';
+    include('contact');
+%>
+
+<INPUT TYPE="submit" NAME="submit" VALUE="<%= $custnum ?  "Apply Changes" : "Add Customer" %>">
+<BR>
+</FORM>
+</TD></TR></TABLE>
+<HR>
+<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
+</BODY></HTML>
diff --git a/fs_selfservice/FS-SelfService/cgi/check.html b/fs_selfservice/FS-SelfService/cgi/check.html
new file mode 100644 (file)
index 0000000..68753fe
--- /dev/null
@@ -0,0 +1,54 @@
+<TR>
+  <TD ALIGN="right">Account&nbsp;type</TD>
+  <TD>
+    <SELECT NAME="paytype">
+      <%= foreach ( @paytypes ) {
+            $selected = $paytype eq $_ ? ' SELECTED' : '';
+            $OUT .= qq(<OPTION$selected VALUE="$_">$_\n);
+      } %>
+    </SELECT>
+  </TD>
+</TD><TR>
+  <TD ALIGN="right">Account&nbsp;number</TD>
+  <TD><INPUT TYPE="text" NAME="payinfo1" SIZE=10 MAXLENGTH=20 VALUE="<%=$payinfo1%>"></TD>
+</TD><TR>
+  <TD ALIGN="right">ABA/Routing&nbsp;number</TD>
+  <TD><INPUT TYPE="text" NAME="payinfo2" SIZE=10 MAXLENGTH=9 VALUE="<%=$payinfo2%>"></TD>
+</TR><TR>
+  <TD ALIGN="right">Bank&nbsp;name</TD>
+  <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%=$payname%>"></TD>
+</TR><TR>
+  <%=
+    $OUT = '';
+    if ($show_paystate) {
+      $OUT .= qq!<TD ALIGN="right">Bank state</TD><TD><SELECT NAME="paystate">!;
+      for ( @states ) {
+        $OUT .= '<OPTION'. ($_ eq $paystate ? ' SELECTED' : '' ). ">$_\n";
+      }
+      $OUT .= '</SELECT></TD></TR><TR>';
+    }
+  %>
+  <%=
+    $OUT = '';
+    if ($show_ss) {
+      $OUT .= '<TD ALIGN="right">Account&nbsp;holder<BR>Social&nbsp;';
+      $OUT .= 'security&nbsp;or&nbsp;tax&nbsp;ID&nbsp;#</TD><TD>';
+      $OUT .= qq!<INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="ss" VALUE="$ss">!;
+      $OUT .= '</TD></TR><TR>';
+    }
+  %>
+  <%=
+    $OUT = '';
+    if ($show_stateid) {
+      $OUT .= '<TD ALIGN="right">';
+      $OUT .= qq!Account&nbsp;holder<BR>$stateid_label</TD><TD>!;
+      $OUT .= qq!<INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="stateid" VALUE="$stateid"></TD>!;
+      $OUT .= qq!<TD ALIGN="right">$stateid_state_label</TD>!;
+      $OUT .= '<TD><SELECT NAME="stateid_state">';
+      for ( @states ) {
+        $OUT .= '<OPTION'. ($_ eq $stateid_state ? ' SELECTED' : '' ). ">$_\n";
+      }
+      $OUT .='</SELECT></TD></TR><TR>';
+    }
+  %>
+</TR>
diff --git a/fs_selfservice/FS-SelfService/cgi/contact.html b/fs_selfservice/FS-SelfService/cgi/contact.html
new file mode 100644 (file)
index 0000000..20c15df
--- /dev/null
@@ -0,0 +1,135 @@
+<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
+
+<TR>
+  <TH ALIGN="right"><%=$r%>Contact&nbsp;name<BR>(last,&nbsp;first)</TH>
+  <TD COLSPAN=5>
+    <INPUT TYPE="text" NAME="<%=$pre%>last" VALUE="<%= ${$pre.'last'} %>" onChange="<%= $onchange %>" <%=$disabled%>> , 
+    <INPUT TYPE="text" NAME="<%=$pre%>first" VALUE="<%= ${$pre.'first'} %>" onChange="<%= $onchange %>" <%=$disabled%>>
+  </TD>
+</TR>
+
+<TR>
+  <TD ALIGN="right">Company</TD>
+  <TD COLSPAN=7>
+    <INPUT TYPE="text" NAME="<%=$pre%>company" VALUE="<%= ${$pre.'company'} %>" SIZE=70 onChange="<%= $onchange %>" <%=$disabled%>>
+  </TD>
+</TR>
+
+<TR>
+  <TH ALIGN="right"><%=$r%>Address</TH>
+  <TD COLSPAN=7>
+    <INPUT TYPE="text" NAME="<%=$pre%>address1" VALUE="<%= ${$pre.'address1'} %>" SIZE=70 onChange="<%= $onchange %>" <%=$disabled%>>
+  </TD>
+</TR>
+
+<TR>
+  <TD ALIGN="right">
+    <%= 
+      my $style =
+        ( $disabled
+          || !$require_address2 
+          || ( !$pre && $ship_last )
+        )
+          ? 'visibility:hidden'
+          : '';
+
+      $OUT .= qq!<FONT ID="${pre}address2_required" color="#ff0000" STYLE="$style">*</FONT>&nbsp;<FONT ID="${pre}address2_label" STYLE="$style"><B>Unit&nbsp;#</B></FONT>!;
+    %>
+  </TD>
+  <TD COLSPAN=7>
+    <INPUT TYPE="text" NAME="<%=$pre%>address2" VALUE="<%= ${$pre.'address2'} %>" SIZE=70 onChange="<%= $onchange %>" <%=$disabled%>>
+  </TD>
+</TR>
+
+<TR>
+  <TH ALIGN="right"><%=$r%>City</TH>
+  <TD>
+    <INPUT TYPE="text" ID="<%=$pre%>city" NAME="<%=$pre%>city" VALUE="<%= ${$pre.'city'} %>" onChange="<%= $onchange %>" <%=$disabled%>>
+  </TD>
+  <%= 
+    ($county_html, $state_html, $country_html) = 
+      FS::SelfService::regionselector( {
+        prefix           => $pre,
+        selected_county  => ${$pre.'county'},
+        selected_state   => ${$pre.'state'},
+        selected_country => ${$pre.'country'},
+        default_state    => $statedefault,
+        default_country  => $countrydefault,
+        locales          => \@cust_main_county,
+      } );
+
+  $OUT .= qq!<TH ALIGN="right">${r}State/County</TH>!;
+  $OUT .= qq!<TD>$county_html $state_html</TD>!;
+  $OUT .= qq!<TH>${r}Zip</TH>!;
+  $OUT .= qq!<TD><INPUT TYPE="text" NAME="${pre}zip" VALUE="${$pre.'zip'}" SIZE=10 onChange="$onchange" $disabled></TD>!;
+  $OUT .= qq!</TR>!;
+  $OUT .= qq!<TR>!;
+  $OUT .= qq!<TH ALIGN="right">${r}Country</TH>!;
+  $OUT .= qq!<TD COLSPAN=5>$country_html</TD>!;
+  %>
+</TR>
+
+<SCRIPT>
+  <%=
+    if ( $disabled ) {
+      $OUT .= qq!var what = document.getElementById("${pre}city");!;
+      for (qw( county state country ) ) {
+        $OUT .= "what.form.$pre$_.disabled = true;";
+        $OUT .= "what.form.$pre$_.style.backgroundColor = '#dddddd';";
+      }
+    }else{
+      '';
+    }
+  %>
+</SCRIPT>
+
+<TR>
+  <TD ALIGN="right">Day Phone</TD>
+  <TD COLSPAN=5>
+    <INPUT TYPE="text" NAME="<%=$pre%>daytime" VALUE="<%= ${$pre.'daytime'} %>" SIZE=18 onChange="<%= $onchange %>" <%=$disabled%>>
+  </TD>
+</TR>
+
+<TR>
+  <TD ALIGN="right">Night Phone</TD>
+  <TD COLSPAN=5>
+    <INPUT TYPE="text" NAME="<%=$pre%>night" VALUE="<%= ${$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="<%= ${$pre.'fax'} %>" SIZE=12 onChange="<%= $onchange %>" <%=$disabled%>>
+  </TD>
+</TR>
+
+</TABLE>
+<%=$r%>required fields<BR>
+
+<!--
+#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'   => ${$pre.'county'},
+  'state'    => ${$pre.'state'},
+  'country'  => ${$pre.'country'},
+  'prefix'   => $pre,
+  'onchange' => $onchange,
+  'disabled' => $disabled,
+);
+
+my @counties = counties( ${$pre.'state'},
+                         ${$pre.'country'},
+                       );
+my $county_style = scalar(@counties) > 1 ? '' : 'STYLE="visibility:hidden"';
+
+my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
+-->
index 83d36b9..f801423 100644 (file)
       $<INPUT TYPE="text" NAME="amount" SIZE=8 VALUE="<%=sprintf("%.2f",$balance)%>">
     </TD></TR></TABLE>
   </TD>
-</TR><TR>
-  <TD ALIGN="right">Account&nbsp;type</TD>
-  <TD>
-    <SELECT NAME="paytype"><OPTION></OPTION>
-      <%= foreach ( @paytypes ) {
-            $selected = $paytype eq $_ ? ' SELECTED' : '';
-            $OUT .= qq(<OPTION$selected VALUE="$_">$_\n);
-      } %>
-    </SELECT>
-  </TD>
-</TD><TR>
-  <TD ALIGN="right">Account&nbsp;number</TD>
-  <TD><INPUT TYPE="text" NAME="payinfo1" SIZE=10 MAXLENGTH=20 VALUE="<%=$payinfo1%>"></TD>
-</TD><TR>
-  <TD ALIGN="right">ABA/Routing&nbsp;number</TD>
-  <TD><INPUT TYPE="text" NAME="payinfo2" SIZE=10 MAXLENGTH=9 VALUE="<%=$payinfo2%>"></TD>
-</TR><TR>
-  <TD ALIGN="right">Bank&nbsp;name</TD>
-  <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%=$payname%>"></TD>
-</TR><TR>
-  <%=
-    $OUT = '';
-    if ($show_paystate) {
-      $OUT .= qq!<TD ALIGN="right">Bank state</TD><TD><SELECT NAME="paystate">!;
-      for ( @states ) {
-        $OUT .= '<OPTION'. ($_ eq $paystate ? ' SELECTED' : '' ). ">$_\n";
-      }
-      $OUT .= '</SELECT></TD></TR><TR>';
-    }
-  %>
-  <%=
-    $OUT = '';
-    if ($show_ss) {
-      $OUT .= '<TD ALIGN="right">Account&nbsp;holder<BR>Social&nbsp;';
-      $OUT .= 'security&nbsp;or&nbsp;tax&nbsp;ID&nbsp;#</TD><TD>';
-      $OUT .= qq!<INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="ss" VALUE="$ss">!;
-      $OUT .= '</TD></TR><TR>';
-    }
-  %>
-  <%=
-    $OUT = '';
-    if ($show_stateid) {
-      $OUT .= '<TD ALIGN="right">';
-      $OUT .= qq!Account&nbsp;holder<BR>$stateid_label</TD><TD>!;
-      $OUT .= qq!<INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="stateid" VALUE="$stateid"></TD>!;
-      $OUT .= qq!<TD ALIGN="right">$stateid_state_label</TD>!;
-      $OUT .= '<TD><SELECT NAME="stateid_state">';
-      for ( @states ) {
-        $OUT .= '<OPTION'. ($_ eq $stateid_state ? ' SELECTED' : '' ). ">$_\n";
-      }
-      $OUT .='</SELECT></TD></TR><TR>';
-    }
-  %>
+</TR>
+<%= include('check') %>
+<TR>
   <TD COLSPAN=2>
     <INPUT TYPE="checkbox" CHECKED NAME="save" VALUE="1">
     Remember this information
index 64b1e00..89239c0 100644 (file)
       } %>
     </SELECT>
   </TD>
-</TD><TR>
-  <TD ALIGN="right">Card&nbsp;number</TD>
-  <TD>
-    <TABLE>
-      <TR>
-        <TD>
-          <INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<%=$payinfo%>"> </TD>
-        <TD>Exp.</TD>
-        <TD>
-          <SELECT NAME="month">
-            <%= for ( ( map "0$_", 1 .. 9 ), 10 .. 12 ) {
-                  $OUT .= '<OPTION'. ($_ == $month ? ' SELECTED' : ''). ">$_\n";
-            } %>
-          </SELECT>
-        </TD>
-        <TD> / </TD>
-        <TD>
-          <SELECT NAME="year">
-            <%= my @a = localtime; for ( $a[5]+1900 .. $a[5]+1915 ) {
-                  $OUT .= '<OPTION'. ($_ == $year ? ' SELECTED' : ''). ">$_\n";
-            } %>
-          </SELECT>
-        </TD>
-      </TR>
-    </TABLE>
-  </TD>
-</TR><TR>
-  <TD ALIGN="right">CVV2&nbsp;(<A HREF="javascript:myopen('cvv2.html','cvv2','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=480,height=288')">help</A>)</TD>
-  <TD><INPUT TYPE="text" NAME="paycvv" VALUE="" SIZE=4 MAXLENGTH=4></TD></TR>
-</TR><TR>
-  <TD ALIGN="right">Exact&nbsp;name&nbsp;on&nbsp;card</TD>
-  <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%=$payname%>"></TD>
-</TR><TR>
-  <TD ALIGN="right">Card&nbsp;billing&nbsp;address</TD>
-  <TD>
-    <INPUT TYPE="text" SIZE=40 MAXLENGTH=80 NAME="address1" VALUE="<%=$address1%>">
-  </TD>
-</TR><TR>
-  <TD ALIGN="right">Address&nbsp;line&nbsp;2</TD>
-  <TD>
-    <INPUT TYPE="text" SIZE=40 MAXLENGTH=80 NAME="address2" VALUE="<%=$address2%>">
-  </TD>
-</TR><TR>
-  <TD ALIGN="right">City</TD>
-  <TD>
-    <TABLE>
-      <TR>
-        <TD>
-          <INPUT TYPE="text" NAME="city" SIZE="12" MAXLENGTH=80 VALUE="<%=$city%>">
-        </TD>
-        <TD>State</TD>
-        <TD>
-          <SELECT NAME="state">
-            <%= for ( @states ) {
-              $OUT .= '<OPTION'. ($_ eq $state ? ' SELECTED' : '' ). ">$_\n";
-            } %>
-          </SELECT>
-        </TD>
-        <TD>Zip</TD>
-        <TD>
-          <INPUT TYPE="text" NAME="zip" SIZE=11 MAXLENGTH=10 VALUE="<%=$zip%>">
-        </TD>
-      </TR>
-    </TABLE>
-  </TD>
-</TR><TR>
+</TR>
+<%= include('card') %>
+<TR>
   <TD COLSPAN=2>
     <INPUT TYPE="checkbox" CHECKED NAME="save" VALUE="1">
     Remember this information
index defd817..ec5a8fa 100644 (file)
@@ -39,8 +39,9 @@ push @menu, (
 { title=>' ' },
 
 { title=>'Change my information', size=>'+1', },
-#  { title=>'Change payment information*', url=>'change_bill',     indent=>2 },
-#  { title=>'Change service address*',     url=>'change_ship',     indent=>2 },
+  { title=>'Change billing address',      url=>'change_bill',     indent=>2 },
+  { title=>'Change service address',      url=>'change_ship',     indent=>2 },
+  { title=>'Change payment information',  url=>'change_pay',      indent=>2 },
   { title=>'Change password(s)',          url=>'change_password', indent=>2 },
 
 { title=>' ' },
diff --git a/fs_selfservice/FS-SelfService/cgi/process_change_bill.html b/fs_selfservice/FS-SelfService/cgi/process_change_bill.html
new file mode 100644 (file)
index 0000000..66a71e6
--- /dev/null
@@ -0,0 +1,13 @@
+<HTML><HEAD><TITLE>MyAccount</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>MyAccount</FONT><BR><BR>
+<%= $url = "$selfurl?session=$session_id;action="; ''; %>
+<%= include('myaccount_menu') %>
+<TD VALIGN="top">
+
+<FONT SIZE=4>Information updated successfully.</FONT>
+
+</TD></TR></TABLE>
+<HR>
+<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
+</BODY></HTML>
+
diff --git a/fs_selfservice/FS-SelfService/cgi/process_change_pay.html b/fs_selfservice/FS-SelfService/cgi/process_change_pay.html
new file mode 100644 (file)
index 0000000..66a71e6
--- /dev/null
@@ -0,0 +1,13 @@
+<HTML><HEAD><TITLE>MyAccount</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>MyAccount</FONT><BR><BR>
+<%= $url = "$selfurl?session=$session_id;action="; ''; %>
+<%= include('myaccount_menu') %>
+<TD VALIGN="top">
+
+<FONT SIZE=4>Information updated successfully.</FONT>
+
+</TD></TR></TABLE>
+<HR>
+<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
+</BODY></HTML>
+
diff --git a/fs_selfservice/FS-SelfService/cgi/process_change_ship.html b/fs_selfservice/FS-SelfService/cgi/process_change_ship.html
new file mode 100644 (file)
index 0000000..66a71e6
--- /dev/null
@@ -0,0 +1,13 @@
+<HTML><HEAD><TITLE>MyAccount</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>MyAccount</FONT><BR><BR>
+<%= $url = "$selfurl?session=$session_id;action="; ''; %>
+<%= include('myaccount_menu') %>
+<TD VALIGN="top">
+
+<FONT SIZE=4>Information updated successfully.</FONT>
+
+</TD></TR></TABLE>
+<HR>
+<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
+</BODY></HTML>
+
index b5a6720..36557b6 100644 (file)
@@ -9,7 +9,7 @@ use Text::Template;
 use HTML::Entities;
 use Date::Format;
 use Number::Format 1.50;
-use FS::SelfService qw( login customer_info invoice
+use FS::SelfService qw( login customer_info edit_info invoice
                         payment_info process_payment 
                         process_prepay
                         list_pkgs order_pkg signup_info order_recharge
@@ -68,7 +68,7 @@ $session_id = $cgi->param('session');
 
 #order|pw_list XXX ???
 $cgi->param('action') =~
-    /^(myaccount|view_invoice|make_payment|make_ach_payment|payment_results|ach_payment_results|recharge_prepay|recharge_results|logout|change_bill|change_ship|customer_order_pkg|process_order_pkg|customer_change_pkg|process_change_pkg|process_order_recharge|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|view_usage|view_usage_details|view_support_details|change_password|process_change_password)$/
+    /^(myaccount|view_invoice|make_payment|make_ach_payment|payment_results|ach_payment_results|recharge_prepay|recharge_results|logout|change_bill|change_ship|change_pay|process_change_bill|process_change_ship|process_change_pay|customer_order_pkg|process_order_pkg|customer_change_pkg|process_change_pkg|process_order_recharge|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|view_usage|view_usage_details|view_support_details|change_password|process_change_password)$/
   or die "unknown action ". $cgi->param('action');
 my $action = $1;
 
@@ -100,6 +100,70 @@ do_template($action, {
 
 sub myaccount { customer_info( 'session_id' => $session_id ); }
 
+sub change_bill { my $payment_info =
+                    payment_info( 'session_id' => $session_id );
+                  return $payment_info if ( $payment_info->{'error'} );
+                  my $customer_info =
+                    customer_info( 'session_id' => $session_id );
+                  return { 
+                    %$payment_info,
+                    %$customer_info,
+                  };
+                }
+sub change_ship { change_bill(@_); }
+sub change_pay { change_bill(@_); }
+
+sub _process_change_info { 
+  my ($erroraction, @fields) = @_;
+
+  my $results = '';
+
+  $results ||= edit_info (
+    'session_id' => $session_id,
+    map { ($_ => $cgi->param($_)) } grep { defined($cgi->param($_)) } @fields,
+  );
+
+
+  if ( $results->{'error'} ) {
+    no strict 'refs';
+    $action = $erroraction;
+    return {
+      $cgi->Vars,
+      %{&$action()},
+      'error' => '<FONT COLOR="#FF0000">'. $results->{'error'}. '</FONT>',
+    };
+  } else {
+    return $results;
+  }
+}
+
+sub process_change_bill {
+        _process_change_info( 'change_bill', 
+          qw( first last company address1 address2 city state
+              county state zip country daytime night fax )
+        );
+}
+
+sub process_change_ship {
+        my @list = map { "ship_$_" }
+                     qw( first last company address1 address2 city state
+                         county zip country daytime night fax 
+                       );
+        if ($cgi->param('same') eq 'Y') {
+          foreach (@list) { $cgi->param($_, '') }
+        }
+
+        _process_change_info( 'change_ship', @list );
+}
+
+sub process_change_pay {
+        _process_change_info( 'change_pay', 
+          qw( payby payinfo payinfo1 payinfo2 month year payname
+              address1 address2 city county state zip country auto paytype
+              paystate ss stateid stateid_state )
+        );
+}
+
 sub view_invoice {
 
   $cgi->param('invnum') =~ /^(\d+)$/ or die "illegal invnum";
@@ -563,7 +627,7 @@ package FS::SelfService::_selfservicecgi;
 
 #use FS::SelfService qw(regionselector expselect popselector);
 use HTML::Entities;
-use FS::SelfService qw(popselector domainselector);
+use FS::SelfService qw(regionselector popselector domainselector);
 
 #false laziness w/agent.cgi
 sub include {