[freeside-commits] branch FREESIDE_3_BRANCH updated. ebdbeb65e5b391376dabda2893acb4609d84769f

Christopher Burger burgerc at freeside.biz
Sun Sep 9 18:23:56 PDT 2018


The branch, FREESIDE_3_BRANCH has been updated
       via  ebdbeb65e5b391376dabda2893acb4609d84769f (commit)
       via  1cf3ef2e9e1d08f40eb48d77f9496919f9fb9c16 (commit)
       via  247cb7749403d7cda14e1bcc3afc430c8fec02b1 (commit)
       via  367ff2ec9a5d8e6bf73c67d02834460c069c7ede (commit)
       via  2d317a3ea606b980ebffe85c6ad3cf0e2f94dd4e (commit)
       via  405f925e2578705780332900eb5df031bfa7c272 (commit)
       via  741c37dc7259c25f4229fbeeeb28231b4a99ecbc (commit)
       via  985adebbccf51c25ebeb049675c78830b98246aa (commit)
      from  9639c805abfdd2858a29576b767461c667bd5417 (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 ebdbeb65e5b391376dabda2893acb4609d84769f
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Sun Sep 9 21:22:59 2018 -0400

    RT# 75817 - V3 css fix for table display

diff --git a/httemplate/elements/freeside.css b/httemplate/elements/freeside.css
index 8ad724a4f..1e5d1e87f 100644
--- a/httemplate/elements/freeside.css
+++ b/httemplate/elements/freeside.css
@@ -291,6 +291,10 @@ tr.row1 {
   font-style: italic;
 }
 
+th, td {
+  vertical-align: top;
+}
+
 /* border at the top of the footer, but not between footer rows */
 .grid tfoot tr:first-child td {
   border-top: 1px dashed black;

commit 1cf3ef2e9e1d08f40eb48d77f9496919f9fb9c16
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Sun Sep 9 17:34:35 2018 -0400

    RT# 75817 - fixed redirect error

diff --git a/httemplate/edit/process/cust_main-contacts.html b/httemplate/edit/process/cust_main-contacts.html
index 10ec3638f..f51c796b4 100644
--- a/httemplate/edit/process/cust_main-contacts.html
+++ b/httemplate/edit/process/cust_main-contacts.html
@@ -1,6 +1,6 @@
 <% include('elements/process.html',
      'table'          => 'cust_main',
-     'error_redirect' => popurl(3). 'edit/cust_main-contacts.html?',
+     'error_redirect' => popurl(3). 'edit/cust_main-contacts.html',
      'agent_virt'     => 1,
      'skip_process'   => 1, #we don't want to make any changes to cust_main
      'process_o2m' => {
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index 5b9ed6b52..11757237a 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -123,7 +123,7 @@ Example:
 %          " attempting to set redirect$session to ". $cgi->query_string."\n";
 %    }
 %
-<% $cgi->redirect("$error_redirect"."redirect=$session") %>
+<% $cgi->redirect("$error_redirect?redirect=$session") %>
 %
 %  } else {
 %

commit 247cb7749403d7cda14e1bcc3afc430c8fec02b1
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Sun Sep 9 16:12:23 2018 -0400

    RT# 75817 - cleaned up password validation error message

diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html
index ccbb431ab..fef189e0c 100644
--- a/httemplate/elements/contact.html
+++ b/httemplate/elements/contact.html
@@ -98,7 +98,7 @@
           <BR>
           <FONT SIZE="-1"><% $label{$field} %></FONT>
 %       if ( $field eq 'password' ) {
-          <div id="changepw<%$id%>_<%$field%>_result"></div>
+          <DIV ID="changepw<%$id%>_<%$field%>_result" STYLE="font-size: smaller"></DIV>
 %       }
         </TD>
 %     }

commit 367ff2ec9a5d8e6bf73c67d02834460c069c7ede
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Fri Sep 7 10:55:19 2018 -0400

    RT# 75817 - fixed saving of password for new contacts, and password validation on dynamicly created rows
    
    Conflicts:
            FS/FS/contact.pm
            httemplate/edit/elements/edit.html

diff --git a/FS/FS/contact.pm b/FS/FS/contact.pm
index 4db3cdfd1..8f6b6a3b5 100644
--- a/FS/FS/contact.pm
+++ b/FS/FS/contact.pm
@@ -131,7 +131,6 @@ sub insert {
   my $dbh = dbh;
 
   my $error = $self->SUPER::insert;
-  $error ||= $self->insert_password_history;
 
   if ( $error ) {
     $dbh->rollback if $oldAutoCommit;
@@ -191,6 +190,15 @@ sub insert {
     }
   }
 
+  if ( $self->get('password') ) {
+    my $error = $self->is_password_allowed($self->get('password'))
+          ||  $self->change_password($self->get('password'));
+    if ( $error ) {
+      $dbh->rollback if $oldAutoCommit;
+      return $error;
+    }
+  }
+
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
 
   '';
@@ -614,7 +622,7 @@ sub authenticate_password {
 
     $hash eq $check_hash;
 
-  } else { 
+  } else {
 
     return 0 if $self->_password eq '';
 
diff --git a/httemplate/edit/cust_main-contacts.html b/httemplate/edit/cust_main-contacts.html
index b3f67726b..b046c5b18 100644
--- a/httemplate/edit/cust_main-contacts.html
+++ b/httemplate/edit/cust_main-contacts.html
@@ -51,6 +51,13 @@
 my $curuser = $FS::CurrentUser::CurrentUser;
 my $conf = new FS::Conf;
 
+if ( $cgi->param('redirect') ) {
+  my $session = $cgi->param('redirect');
+  my $pref = $curuser->option("redirect$session");
+  die "unknown redirect session $session\n" unless length($pref);
+  $cgi = new CGI($pref);
+}
+
 my $custnum;
 if ( $cgi->param('error') ) {
   $custnum = scalar($cgi->param('custnum'));
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 3826f9752..ff1da4945 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -633,7 +633,7 @@ Example:
           var newrow =  <% include(@layer_opt, html_only=>1) |js_string %>;
 
 %         #until the rest have html/js_only
-%         if ( $type eq 'selectlayers' || $type =~ /^select-cgp_rule_/ ) {
+%         if ( $type eq 'selectlayers' || $type =~ /^select-cgp_rule_/ || $type eq 'contact') {
             var newfunc = <% include(@layer_opt, js_only=>1) |js_string %>;
 %         } else {
             var newfunc = '';
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index 11757237a..5b9ed6b52 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -123,7 +123,7 @@ Example:
 %          " attempting to set redirect$session to ". $cgi->query_string."\n";
 %    }
 %
-<% $cgi->redirect("$error_redirect?redirect=$session") %>
+<% $cgi->redirect("$error_redirect"."redirect=$session") %>
 %
 %  } else {
 %
diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html
index e330e1fea..ccbb431ab 100644
--- a/httemplate/elements/contact.html
+++ b/httemplate/elements/contact.html
@@ -1,4 +1,6 @@
-% unless ( $opt{'js_only'} ) {
+% if ( $opt{'js_only'} ) {
+<% $js %>
+% } else {
 
   <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
 
@@ -70,23 +72,8 @@
                    VALUE = ""
                    placeholder = "<% $value |h %>"
             >
-%           my $contactnum = $curr_value ? $curr_value : '0';
-
             <SCRIPT>
-              add_password_validation('<% "changepw".$id."_password" %>', 'submit', '', '<% $contactnum %>');
-            </SCRIPT>
-
-            <SCRIPT TYPE="text/javascript">
-                    var selfService = document.getElementById("<%$id%>_selfservice_access").value;
-
-                    if (selfService !== "Y") { document.getElementById("changepw<%$id%>_password").disabled = 'true'; }
-                    document.getElementById("<%$id%>_selfservice_access").onchange = function() {
-                      if (this.value == "P" || this.value == "E" || this.value =="Y") {
-                        document.getElementById("changepw<%$id%>_password").disabled = '';
-                      }
-                      else { document.getElementById("changepw<%$id%>_password").disabled = 'true'; }
-                      return false;
-                    }
+              <% $js %>
             </SCRIPT>
 %         } elsif ( $field eq 'invoice_dest' ) {
 %           my $curr_value = $cgi->param($name . '_' . $field);
@@ -131,6 +118,7 @@ my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum';
 my $id = $opt{'id'} || 'contactnum';
 
 my $curr_value = $opt{'curr_value'} || $opt{'value'};
+my $contactnum = $curr_value ? $curr_value : '0';
 
 my $onchange = '';
 if ( $opt{'onchange'} ) {
@@ -177,4 +165,19 @@ $label{'comment'} = 'Comment';
 
 my @fields = $opt{'name_only'} ? qw( first last ) : keys %label;
 
+my $js = qq(
+    add_password_validation('changepw$id\_password', 'submit', '', '$contactnum');
+
+    var selfService = document.getElementById("$id\_selfservice_access").value;
+
+    if (selfService !== "Y") { document.getElementById("changepw$id\_password").disabled = 'true'; }
+    document.getElementById("$id\_selfservice_access").onchange = function() {
+      if (this.value == "P" || this.value == "E" || this.value =="Y") {
+        document.getElementById("changepw$id\_password").disabled = '';
+      }
+      else { document.getElementById("changepw$id\_password").disabled = 'true'; }
+      return false;
+    }
+);
+
 </%init>

commit 2d317a3ea606b980ebffe85c6ad3cf0e2f94dd4e
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue Sep 4 08:32:21 2018 -0400

    RT# 75817 - added new file to hold javascript for password validation

diff --git a/httemplate/elements/validate_password_js.html b/httemplate/elements/validate_password_js.html
new file mode 100644
index 000000000..64db0a97b
--- /dev/null
+++ b/httemplate/elements/validate_password_js.html
@@ -0,0 +1,71 @@
+<%doc>
+
+JavaScript to perform password validation
+
+  <& '/elements/validate_password_js.html', 
+     contactnum  => $contactnum,
+     svcnum      => $svcnum
+  &>
+
+The ID of the input field can be anything;  the ID of the DIV in which to display results
+should be the input id plus '_result'.
+
+</%doc>
+
+<& '/elements/xmlhttp.html',
+    'url'  => $p.'misc/xmlhttp-validate_password.html',
+    'subs' => [ 'validate_password' ],
+    'method' => 'POST', # important not to put passwords in url
+&>
+<SCRIPT>
+function add_password_validation (fieldid, submitid, svcnum, contactnum) {
+  var inputfield = document.getElementById(fieldid);
+  inputfield.onkeydown = function(e) {
+    var key;
+    if (window.event) { key = window.event.keyCode; }
+    else { key = e.which; } // for ff browsers
+    // some browsers allow the enter key to submit a form even if the submit button is disabled
+    // below prevents enter key from submiting form if password has not been validated.
+    if (key == '13') {
+      var check = checkPasswordValidation(fieldid);
+      return check;
+    }
+  }
+  inputfield.onkeyup = function () {
+    var fieldid = this.id+'_result';
+    var resultfield = document.getElementById(fieldid);
+    if (this.value) {
+      resultfield.innerHTML = '<SPAN STYLE="color: blue;">Validating password...</SPAN>';
+      validate_password('fieldid',fieldid,'svcnum','<% $opt{'svcnum'} %>','contactnum', contactnum,'password',this.value,
+        function (result) {
+          result = JSON.parse(result);
+          var resultfield = document.getElementById(result.fieldid);
+          if (resultfield) {
+            var errorimg = '<IMG SRC="<% $p %>images/error.png" style="width: 1em; display: inline-block; padding-right: .5em">';
+            var validimg = '<IMG SRC="<% $p %>images/tick.png" style="width: 1em; display: inline-block; padding-right: .5em">';
+            if (result.valid) {
+              resultfield.innerHTML = validimg+'<SPAN STYLE="color: green;">Password valid!</SPAN>';
+              if (submitid){ document.getElementById(submitid).disabled = false; }
+            } else if (result.error) {
+              resultfield.innerHTML = errorimg+'<SPAN STYLE="color: red;">'+result.error+'</SPAN>';
+              if (submitid){ document.getElementById(submitid).disabled = true; }
+            } else {
+              result.syserror = result.syserror || 'Server error';
+              resultfield.innerHTML = errorimg+'<SPAN STYLE="color: red;">'+result.syserror+'</SPAN>';
+              if (submitid){ document.getElementById(submitid).disabled = true; }
+            }
+          }
+        }
+      );
+    } else {
+      resultfield.innerHTML = '';
+      if (submitid){ document.getElementById(submitid).disabled = false; }
+    }
+  };
+}
+
+</SCRIPT>
+
+<%init>
+my %opt = @_;
+</%init>
\ No newline at end of file

commit 405f925e2578705780332900eb5df031bfa7c272
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue Sep 4 08:30:35 2018 -0400

    RT# 75817 - Added password change link to cust main page
    
    Conflicts:
            httemplate/edit/cust_main-contacts.html
            httemplate/elements/validate_password.html
            httemplate/view/cust_main/contacts_new.html

diff --git a/httemplate/edit/cust_main-contacts.html b/httemplate/edit/cust_main-contacts.html
index aeedd78e5..b3f67726b 100644
--- a/httemplate/edit/cust_main-contacts.html
+++ b/httemplate/edit/cust_main-contacts.html
@@ -1,15 +1,17 @@
 <SCRIPT>
-function checkPasswordValidation(fieldid)  {
-  var validationResult = document.getElementById(fieldid+'_result').innerHTML;
-  if (validationResult.match(/Password valid!/)) {
-    return true;
+  function checkPasswordValidation(fieldid)  {
+    var validationResult = document.getElementById(fieldid+'_result').innerHTML;
+    if (validationResult.match(/Password valid!/)) {
+      return true;
+    }
+    else {
+      return false;
+    }
   }
-  else {
-    return false;
-  }
-}
 </SCRIPT>
 
+<& '/elements/validate_password_js.html', &>
+
 <& elements/edit.html,
      'name_singular'    => 'customer contacts', #yes, we're editing all of them
      'table'            => 'cust_main',
diff --git a/httemplate/elements/change_password.html b/httemplate/elements/change_password.html
index 7d95e19dc..65b7d8502 100644
--- a/httemplate/elements/change_password.html
+++ b/httemplate/elements/change_password.html
@@ -11,9 +11,9 @@
 % if (!$opt{'no_label_display'}) {
 <A ID="<%$pre%>link" HREF="javascript:void(0)" onclick="<%$pre%>toggle(true)">(<% emt( $change_title ) %>)</A>
 % }
-<DIV ID="<%$pre%>form" CLASS="passwordbox">
+<DIV ID="<%$pre%>div" CLASS="passwordbox">
 % if (!$opt{'noformtag'}) {
-  <FORM METHOD="POST" ACTION="<%$fsurl%>misc/process/change-password.html" onsubmit="return checkPasswordValidation()">
+  <FORM ID="<%$pre%>form" METHOD="POST" ACTION="<%$fsurl%>misc/process/change-password.html" onsubmit="return <%$pre%>checkPasswordValidation()">
 % }
 
     <% $change_id_input %>
@@ -44,11 +44,8 @@ function <%$pre%>toggle(toggle, clear) {
   if (clear) {
     document.getElementById('<%$pre%>password').value = '';
     document.getElementById('<%$pre%>password_result').innerHTML = '';
-% if ($opt{'contact_num'}) {
-    document.getElementById('<% $opt{'pre_pwd_field_label'} %>selfservice_access').value = 'Y';
-% }
 }
-  document.getElementById('<%$pre%>form').style.display =
+  document.getElementById('<%$pre%>div').style.display =
     toggle ? 'inline-block' : 'none';
 % if (!$opt{'no_label_display'}) {
   document.getElementById('<%$pre%>link').style.display =
@@ -56,7 +53,7 @@ function <%$pre%>toggle(toggle, clear) {
 % }
 }
 
-function checkPasswordValidation()  {
+function <%$pre%>checkPasswordValidation(resultId)  {
   var validationResult = document.getElementById('<%$pre%>password_result').innerHTML;
   if (validationResult.match(/Password valid!/)) {
     return true;
@@ -83,8 +80,8 @@ if ($opt{'svc_acct'}) {
 }
 elsif ($opt{'contact_num'}) {
   $change_id_input = '
-    <INPUT TYPE="hidden" NAME="'.$opt{'pre_pwd_field_label'}.'contactnum" VALUE="' . $opt{'contact_num'} . '">
-    <INPUT TYPE="hidden" NAME="'.$opt{'pre_pwd_field_label'}.'custnum" VALUE="' . $opt{'custnum'} . '">
+    <INPUT TYPE="hidden" NAME="contactnum" VALUE="' . $opt{'contact_num'} . '">
+    <INPUT TYPE="hidden" NAME="custnum" VALUE="' . $opt{'custnum'} . '">
   ';
   $pre .= $opt{'pre_pwd_field_label'};
 }
diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html
index a915a5876..e330e1fea 100644
--- a/httemplate/elements/contact.html
+++ b/httemplate/elements/contact.html
@@ -71,12 +71,10 @@
                    placeholder = "<% $value |h %>"
             >
 %           my $contactnum = $curr_value ? $curr_value : '0';
-            <& '/elements/validate_password.html',
-             'fieldid'    => "changepw".$id."_password",
-             'svcnum'     => '',
-             'contactnum' => $contactnum,
-             'submitid'   => "submit",
-           &>
+
+            <SCRIPT>
+              add_password_validation('<% "changepw".$id."_password" %>', 'submit', '', '<% $contactnum %>');
+            </SCRIPT>
 
             <SCRIPT TYPE="text/javascript">
                     var selfService = document.getElementById("<%$id%>_selfservice_access").value;
diff --git a/httemplate/elements/validate_password.html b/httemplate/elements/validate_password.html
index 9ecbba52d..10471d974 100644
--- a/httemplate/elements/validate_password.html
+++ b/httemplate/elements/validate_password.html
@@ -15,59 +15,10 @@ should be the input id plus '_result'.
 
 </%doc>
 
-<& '/elements/xmlhttp.html',
-    'url'  => $p.'misc/xmlhttp-validate_password.html',
-    'subs' => [ 'validate_password' ],
-    'method' => 'POST', # important not to put passwords in url
-&>
-<SCRIPT>
-function add_password_validation (fieldid, submitid) {
-  var inputfield = document.getElementById(fieldid);
-  inputfield.onkeydown = function(e) {
-    var key;
-    if (window.event) { key = window.event.keyCode; }
-    else { key = e.which; } // for ff browsers
-    // some browsers allow the enter key to submit a form even if the submit button is disabled
-    // below prevents enter key from submiting form if password has not been validated.
-    if (key == '13') {
-      var check = checkPasswordValidation(fieldid);
-      return check;
-    }
-  }
-  inputfield.onkeyup = function () {
-    var fieldid = this.id+'_result';
-    var resultfield = document.getElementById(fieldid);
-    if (this.value) {
-      resultfield.innerHTML = '<SPAN STYLE="color: blue;">Validating password...</SPAN>';
-      validate_password('fieldid',fieldid,'svcnum','<% $opt{'svcnum'} %>','pkgnum','<% $opt{'pkgnum'} %>','contactnum','<% $opt{'contactnum'} %>','password',this.value,
-        function (result) {
-          result = JSON.parse(result);
-          var resultfield = document.getElementById(result.fieldid);
-          if (resultfield) {
-            var errorimg = '<IMG SRC="<% $p %>images/error.png" style="width: 1em; display: inline-block; padding-right: .5em">';
-            var validimg = '<IMG SRC="<% $p %>images/tick.png" style="width: 1em; display: inline-block; padding-right: .5em">';
-            if (result.valid) {
-              resultfield.innerHTML = validimg+'<SPAN STYLE="color: green;">Password valid!</SPAN>';
-              if (submitid){ document.getElementById(submitid).disabled = false; }
-            } else if (result.error) {
-              resultfield.innerHTML = errorimg+'<SPAN STYLE="color: red;">'+result.error+'</SPAN>';
-              if (submitid){ document.getElementById(submitid).disabled = true; }
-            } else {
-              result.syserror = result.syserror || 'Server error';
-              resultfield.innerHTML = errorimg+'<SPAN STYLE="color: red;">'+result.syserror+'</SPAN>';
-              if (submitid){ document.getElementById(submitid).disabled = true; }
-            }
-          }
-        }
-      );
-    } else {
-      resultfield.innerHTML = '';
-      if (submitid){ document.getElementById(submitid).disabled = false; }
-    }
-  };
-}
+<& '/elements/validate_password_js.html', %opt &>
 
-add_password_validation('<% $opt{'fieldid'} %>', '<% $opt{'submitid'} %>');
+<SCRIPT>
+  add_password_validation('<% $opt{'fieldid'} %>', '<% $opt{'submitid'} %>', '<% $opt{'svcnum'} %>', '<% $opt{'contactnum'} %>');
 </SCRIPT>
 
 <%init>
diff --git a/httemplate/misc/process/change-password.html b/httemplate/misc/process/change-password.html
index a3e060168..37ad6d915 100644
--- a/httemplate/misc/process/change-password.html
+++ b/httemplate/misc/process/change-password.html
@@ -18,7 +18,7 @@
 	 <% $cgi->redirect($fsurl.'view/svc_acct.cgi?'.$cgi->query_string) %>
 %   }
 %   elsif ($contactnum) { 
-	 <% $cgi->redirect($fsurl.'edit/cust_main-contacts.html?'.$cgi->param('custnum')) %>
+	 <% $cgi->redirect($fsurl.'view/cust_main.cgi?'.$cgi->param('custnum')) %>
 %   }
 % }
 
@@ -34,6 +34,10 @@ my $curuser = $FS::CurrentUser::CurrentUser;
 $cgi->param('svcnum') =~ /^(\d+)$/ or die "illegal svcnum" if $cgi->param('svcnum');
 my $svcnum = $1;
 
+foreach my $prefix (grep /^(.*)(password)$/, $cgi->param) {
+     $cgi->param('password' => $cgi->param($prefix));
+}
+
 $cgi->param('contactnum') =~ /^(\d+)$/ or die "illegal contactnum" if $cgi->param('contactnum');
 my $contactnum = $1;
 
diff --git a/httemplate/view/cust_main/contacts_new.html b/httemplate/view/cust_main/contacts_new.html
index f73483ae1..19118ea27 100644
--- a/httemplate/view/cust_main/contacts_new.html
+++ b/httemplate/view/cust_main/contacts_new.html
@@ -6,6 +6,7 @@
 % my $bgcolor1 = '#eeeeee';
 %     my $bgcolor2 = '#ffffff';
 %     my $bgcolor = $bgcolor2;
+%     my $count = 0;
 <TR>
   <TH CLASS="grid" ALIGN="left" BGCOLOR="#cccccc">Type</TH>
   <TH CLASS="grid" ALIGN="left" BGCOLOR="#cccccc">Contact</TH>
@@ -29,6 +30,16 @@
             Enabled
 %#            <FONT SIZE="-1"><A HREF="XXX">disable</A>
 %#                            <A HREF="XXX">re-email</A></FONT>
+            <FONT SIZE="-1">
+              <& /elements/change_password.html,
+                'contact_num'      => $contact->contactnum,
+                'custnum'          => $contact->custnum,
+                'no_label_display' => '',
+                'label'            => 'change password',
+                'curr_value'       => '',
+                'pre_pwd_field_label' => 'contact'.$count.'_',
+              &>
+            </FONT>
 %         } else {
             Disabled
 %#            <FONT SIZE="-1"><A HREF="XXX">enable</A></FONT>
@@ -51,6 +62,7 @@
 %      } else {
 %        $bgcolor = $bgcolor1;
 %      }
+%     $count++;
 %   }
 </TABLE>
 <%once>
@@ -64,5 +76,6 @@ my( $cust_main ) = @_;
 #my $conf = new FS::Conf;
 
 my @contacts = $cust_main->cust_contact;
+my $display = scalar(@contacts) > 0;
 
 </%init>

commit 741c37dc7259c25f4229fbeeeb28231b4a99ecbc
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Wed Aug 29 14:24:47 2018 -0400

    RT# 75817 - removed change password link as it is not needed anymore

diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html
index a298a1b15..a915a5876 100644
--- a/httemplate/elements/contact.html
+++ b/httemplate/elements/contact.html
@@ -58,7 +58,6 @@
                 <OPTION VALUE="<% $value eq 'Y' ? 'Y' : 'E' %>" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled
 %               if ( $value eq 'Y' && $self_base_url ) {
                   <OPTION VALUE="R">Re-email
-                  <OPTION VALUE="P"><% $pwd_change_label %>
 %               }
 %             }
             </SELECT>
@@ -180,7 +179,4 @@ $label{'comment'} = 'Comment';
 
 my @fields = $opt{'name_only'} ? qw( first last ) : keys %label;
 
-my $pwd_change_label = 'Change Password';
-$pwd_change_label = 'Setup Password' unless $contact->_password;
-
 </%init>

commit 985adebbccf51c25ebeb049675c78830b98246aa
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Wed Aug 29 14:09:58 2018 -0400

    RT# 75817 - updated UI to be more intuitive
    
    Conflicts:
            httemplate/edit/cust_main-contacts.html
            httemplate/elements/contact.html

diff --git a/httemplate/edit/cust_main-contacts.html b/httemplate/edit/cust_main-contacts.html
index 7dedfe04d..aeedd78e5 100644
--- a/httemplate/edit/cust_main-contacts.html
+++ b/httemplate/edit/cust_main-contacts.html
@@ -1,12 +1,25 @@
-<% include('elements/edit.html',
-     'name_singular'   => 'customer contacts', #yes, we're editing all of them
-     'table'           => 'cust_main',
-     'post_url'       => popurl(1). 'process/cust_main-contacts.html',
-     'labels'          => { 'custnum'     => ' ', #XXX supress this line entirely, its being redundant
-                            'contactnum'  => ' ', #'Contact',
-                            #'locationnum' => ' ',
-                          },
-     'fields'          => [
+<SCRIPT>
+function checkPasswordValidation(fieldid)  {
+  var validationResult = document.getElementById(fieldid+'_result').innerHTML;
+  if (validationResult.match(/Password valid!/)) {
+    return true;
+  }
+  else {
+    return false;
+  }
+}
+</SCRIPT>
+
+<& elements/edit.html,
+     'name_singular'    => 'customer contacts', #yes, we're editing all of them
+     'table'            => 'cust_main',
+     'post_url'         => popurl(1). 'process/cust_main-contacts.html',
+     'no_pkey_display'  => 1,
+     'labels'           => { 'custnum'     => ' ', #XXX supress this line entirely, its being redundant
+                             'contactnum'  => ' ', #'Contact',
+                             #'locationnum' => ' ',
+                           },
+     'fields'           => [
        { 'field'             => 'contactnum',
          'type'              => 'contact',
          'colspan'           => 6,
@@ -30,8 +43,7 @@
                                      $conf->config('countrydefault') || 'US',
                                      1, #no balance
                                   ),
-   )
-%>
+&>
 <%init>
 
 my $curuser = $FS::CurrentUser::CurrentUser;
diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html
index 678193516..a298a1b15 100644
--- a/httemplate/elements/contact.html
+++ b/httemplate/elements/contact.html
@@ -40,6 +40,8 @@
 %         }
 %       } elsif ( $field eq 'emailaddress' ) {
 %         $value = join(', ', map $_->emailaddress, $contact->contact_email);
+%       } elsif ( $field eq 'password' ) {
+%          $value = $contact->get('_password') ? '********' : '';
 %       } else {
 %         $value = $contact->get($field);
 %       }
@@ -51,7 +53,7 @@
                     ID   = "<%$id%>_<%$field%>"
                     STYLE = "width: 140px"
             >
-              <OPTION VALUE="">Disabled
+              <OPTION VALUE="" <% !$value ? 'SELECTED' : '' %>>Disabled
 %             if ( $value || $self_base_url ) {
                 <OPTION VALUE="<% $value eq 'Y' ? 'Y' : 'E' %>" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled
 %               if ( $value eq 'Y' && $self_base_url ) {
@@ -60,18 +62,33 @@
 %               }
 %             }
             </SELECT>
-                  <& /elements/change_password.html,
-                   'contact_num'         => $curr_value,
-                   'custnum'             => $opt{'custnum'},
-                   'curr_value'          => '',
-                   'no_label_display'    => '1',
-                   'noformtag'           => '1',
-                   'pre_pwd_field_label' => $id.'_',
-                  &>
+% #password form
+%         } elsif ( $field eq 'password') {
+            <INPUT TYPE  = "text"
+                   NAME  = "<%$name%>_<%$field%>"
+                   ID    = "changepw<%$id%>_<%$field%>"
+                   SIZE  = "<% $size{$field} || 14 %>"
+                   VALUE = ""
+                   placeholder = "<% $value |h %>"
+            >
+%           my $contactnum = $curr_value ? $curr_value : '0';
+            <& '/elements/validate_password.html',
+             'fieldid'    => "changepw".$id."_password",
+             'svcnum'     => '',
+             'contactnum' => $contactnum,
+             'submitid'   => "submit",
+           &>
+
             <SCRIPT TYPE="text/javascript">
-                    document.getElementById("<%$id%>_<%$field%>").onchange = function() {
-                      if (this.value == "P" || this.value == "E") { changepw<%$id%>_toggle(true); }
-                      return false
+                    var selfService = document.getElementById("<%$id%>_selfservice_access").value;
+
+                    if (selfService !== "Y") { document.getElementById("changepw<%$id%>_password").disabled = 'true'; }
+                    document.getElementById("<%$id%>_selfservice_access").onchange = function() {
+                      if (this.value == "P" || this.value == "E" || this.value =="Y") {
+                        document.getElementById("changepw<%$id%>_password").disabled = '';
+                      }
+                      else { document.getElementById("changepw<%$id%>_password").disabled = 'true'; }
+                      return false;
                     }
             </SCRIPT>
 %         } elsif ( $field eq 'invoice_dest' ) {
@@ -96,6 +113,9 @@
 %         }
           <BR>
           <FONT SIZE="-1"><% $label{$field} %></FONT>
+%       if ( $field eq 'password' ) {
+          <div id="changepw<%$id%>_<%$field%>_result"></div>
+%       }
         </TD>
 %     }
     </TR>
@@ -143,6 +163,11 @@ tie my %label, 'Tie::IxHash',
   'selfservice_access' => 'Self-service'
 ;
 
+unless ($opt{'for_prospect'}) {
+  $label{'selfservice_access'} = 'Self-service';
+  $label{'password'} = 'Password';
+}
+
 my $first = 0;
 foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
   next if $phone_type->typename =~ /^(Home|Fax)$/;
diff --git a/httemplate/elements/validate_password.html b/httemplate/elements/validate_password.html
index a8c06774e..9ecbba52d 100644
--- a/httemplate/elements/validate_password.html
+++ b/httemplate/elements/validate_password.html
@@ -30,7 +30,7 @@ function add_password_validation (fieldid, submitid) {
     // some browsers allow the enter key to submit a form even if the submit button is disabled
     // below prevents enter key from submiting form if password has not been validated.
     if (key == '13') {
-      var check = checkPasswordValidation();
+      var check = checkPasswordValidation(fieldid);
       return check;
     }
   }
@@ -62,6 +62,7 @@ function add_password_validation (fieldid, submitid) {
       );
     } else {
       resultfield.innerHTML = '';
+      if (submitid){ document.getElementById(submitid).disabled = false; }
     }
   };
 }
diff --git a/httemplate/misc/xmlhttp-validate_password.html b/httemplate/misc/xmlhttp-validate_password.html
index b340170f8..95f1fd33c 100644
--- a/httemplate/misc/xmlhttp-validate_password.html
+++ b/httemplate/misc/xmlhttp-validate_password.html
@@ -29,14 +29,14 @@ my $validate_password = sub {
   $result{'syserror'} = 'Invoked without password' unless $password;
   return \%result if $result{'syserror'};
 
-  if ($arg{'contactnum'}) {
+  if ($arg{'contactnum'} =~ /^\d+$/) {
     my $contactnum = $arg{'contactnum'};
     $result{'syserror'} = 'Invalid contactnum' unless $contactnum =~ /^\d*$/;
     return \%result if $result{'syserror'};
 
     my $contact = $contactnum 
       ? qsearchs('contact',{'contactnum' => $contactnum})
-      : '';
+      : (new FS::contact {});
 
     $result{'error'} = $contact->is_password_allowed($password);
   }

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

Summary of changes:
 FS/FS/contact.pm                                   | 12 ++++-
 httemplate/edit/cust_main-contacts.html            | 43 ++++++++++++----
 httemplate/edit/elements/edit.html                 |  2 +-
 httemplate/edit/process/cust_main-contacts.html    |  2 +-
 httemplate/elements/change_password.html           | 15 +++---
 httemplate/elements/contact.html                   | 58 +++++++++++++++-------
 httemplate/elements/freeside.css                   |  4 ++
 httemplate/elements/validate_password.html         | 54 ++------------------
 ...ate_password.html => validate_password_js.html} | 23 ++++-----
 httemplate/misc/process/change-password.html       |  6 ++-
 httemplate/misc/xmlhttp-validate_password.html     |  4 +-
 httemplate/view/cust_main/contacts_new.html        | 13 +++++
 12 files changed, 126 insertions(+), 110 deletions(-)
 copy httemplate/elements/{validate_password.html => validate_password_js.html} (80%)




More information about the freeside-commits mailing list