[freeside-commits] branch master updated. d0ba0fe7d87171e79f0cf38b073b9d454e868b68

Ivan ivan at 420.am
Fri Feb 6 16:53:33 PST 2015


The branch, master has been updated
       via  d0ba0fe7d87171e79f0cf38b073b9d454e868b68 (commit)
      from  085c3997c33b6aeb55eed0fee6db11b243a20081 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d0ba0fe7d87171e79f0cf38b073b9d454e868b68
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Feb 6 16:53:29 2015 -0800

    contacts can be shared among customers / "duplicate contact emails", ng_selfservice login, RT#27943

diff --git a/fs_selfservice/FS-SelfService/cgi/select_cust.html b/fs_selfservice/FS-SelfService/cgi/select_cust.html
index 7ab55db..03b35c6 100644
--- a/fs_selfservice/FS-SelfService/cgi/select_cust.html
+++ b/fs_selfservice/FS-SelfService/cgi/select_cust.html
@@ -10,7 +10,7 @@
 <FONT SIZE="+1" COLOR="#ff0000"><%= $error %></FONT>
 
 <%= $selfurl =~ s/\?.*//; ''; %>
-<FORM ACTION="<%= $selfurl %>" METHOD=POST>
+<FORM NAME="SelectCustomerForm" ACTION="<%= $selfurl %>" METHOD=POST>
 <INPUT TYPE="hidden" NAME="action" VALUE="switch_cust">
 <INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agentnum %>">
 
@@ -19,7 +19,7 @@
   <TR>
     <TH ALIGN="right">Customer </TH>
     <TD>
-      <SELECT NAME="custnum">
+      <SELECT NAME="custnum" ID="custnum" onChange="custnum_changed()">
         <OPTION VALUE="">Select a customer
 <%=     $OUT .= qq(<OPTION VALUE="$_">). encode_entities( $customers{$_} )
           foreach keys %customers;
@@ -29,10 +29,23 @@
   </TR>
 
   <TR>
-    <TD COLSPAN=2 ALIGN="center"><INPUT TYPE="submit" VALUE="Select customer"></TD>
+    <TD COLSPAN=2 ALIGN="center"><INPUT TYPE="submit" ID="submit" VALUE="Select customer" DISABLED></TD>
   </TR>
 
 </TABLE>
 </FORM>
 
+<SCRIPT TYPE="text/javascript">
+
+function custnum_changed () {
+  var form = document.SelectCustomerForm;
+  if ( form.custnum.selectedIndex > 0 ) {
+    form.submit.disabled = false;
+  } else {
+    form.submit.disabled = true;
+  }
+}
+
+</SCRIPT>
+
 <%= $body_footer %>
diff --git a/ng_selfservice/process_login.php b/ng_selfservice/process_login.php
index d2d0155..15b000b 100644
--- a/ng_selfservice/process_login.php
+++ b/ng_selfservice/process_login.php
@@ -4,6 +4,7 @@ require('freeside.class.php');
 $freeside = new FreesideSelfService();
 
 $response = $freeside->login( array( 
+  'email'    => strtolower($_POST['email']),
   'username' => strtolower($_POST['username']),
   'domain'   => strtolower($_POST['domain']),
   'password' => $_POST['password'],
@@ -16,8 +17,9 @@ $error = $response['error'];
 if ( $error ) {
 
   header('Location:index.php?username='. urlencode($username).
-                            '&domain='.   urlencode($domain).
-                            '&error='.    urlencode($error)
+                           '&domain='.   urlencode($domain).
+                           '&email='.    urlencode($email).
+                           '&error='.    urlencode($error)
         );
   die();
 
@@ -29,12 +31,69 @@ $session_id = $response['session_id'];
 
 error_log("[login] logged into freeside with session_id=$session_id, setting cookie");
 
-// now what?  for now, always redirect to the main page.
+// now what?  for now, always redirect to the main page (or the select a
+// customer diversion).
 // eventually, other options?
 
 setcookie('session_id', $session_id);
 
-header("Location:main.php")
-#die();
+if ( $response['custnum'] || $response['svcnum'] ) {
+
+  header("Location:main.php");
+  die();
+
+} elseif ( $response['customers'] ) {
+var_dump($response['customers']);
+?>
+
+  <? $title ='Select customer'; include('elements/header.php'); ?>
+  <? include('elements/error.php'); ?>
+
+  <FORM NAME="SelectCustomerForm" ACTION="process_select_cust.php" METHOD=POST>
+  <INPUT TYPE="hidden" NAME="action" VALUE="switch_cust">
+
+  <TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=2 CELLPADDING=0>
+
+    <TR>
+      <TH ALIGN="right">Customer </TH>
+      <TD>
+        <SELECT NAME="custnum" ID="custnum" onChange="custnum_changed()">
+          <OPTION VALUE="">Select a customer
+          <? foreach ( $response['customers'] AS $custnum => $customer ) { ?>
+            <OPTION VALUE="<? echo $custnum ?>"><? echo htmlspecialchars( $customer ) ?>
+          <? } ?>
+        </SELECT>
+      </TD>
+    </TR>
+
+    <TR>
+      <TD COLSPAN=2 ALIGN="center"><INPUT TYPE="submit" ID="submit" VALUE="Select customer" DISABLED></TD>
+    </TR>
+
+  </TABLE>
+  </FORM>
+
+  <SCRIPT TYPE="text/javascript">
+
+  function custnum_changed () {
+    var form = document.SelectCustomerForm;
+    if ( form.custnum.selectedIndex > 0 ) {
+      form.submit.disabled = false;
+    } else {
+      form.submit.disabled = true;
+    }
+  }
+
+  </SCRIPT>
+
+  <? include('elements/footer.php'); ?>
+
+<?
+
+// } else {
+// 
+//   die 'login successful, but unrecognized info (no custnum, svcnum or customers)';
+  
+}
 
 ?>
diff --git a/ng_selfservice/process_select_cust.php b/ng_selfservice/process_select_cust.php
new file mode 100644
index 0000000..fe36121
--- /dev/null
+++ b/ng_selfservice/process_select_cust.php
@@ -0,0 +1,32 @@
+<?
+
+require('freeside.class.php');
+$freeside = new FreesideSelfService();
+
+$response = $freeside->switch_cust( array( 
+  'session_id' => $_COOKIE['session_id'],
+  'custnum'    => $_POST['custnum'],
+) );
+
+#error_log("[switch_cust] received response from freeside: $response");
+
+$error = $response['error'];
+
+if ( $error ) {
+
+  //this isn't well handled... but the only possible error is a session timeout?
+
+  header('Location:index.php?username='. urlencode($username).
+                           '&domain='.   urlencode($domain).
+                           '&email='.    urlencode($email).
+                           '&error='.    urlencode($error)
+        );
+  die();
+
+}
+
+// sucessful customer selection
+
+header("Location:main.php");
+
+?>

-----------------------------------------------------------------------

Summary of changes:
 fs_selfservice/FS-SelfService/cgi/select_cust.html |   19 +++++-
 ng_selfservice/process_login.php                   |   69 ++++++++++++++++++--
 ng_selfservice/process_select_cust.php             |   32 +++++++++
 3 files changed, 112 insertions(+), 8 deletions(-)
 create mode 100644 ng_selfservice/process_select_cust.php




More information about the freeside-commits mailing list