[freeside-commits] branch FREESIDE_3_BRANCH updated. 7bc4ecaaa2989870e2200f193815a1815aff7fcd

Christopher Burger burgerc at 420.am
Fri Aug 18 13:36:11 PDT 2017


The branch, FREESIDE_3_BRANCH has been updated
       via  7bc4ecaaa2989870e2200f193815a1815aff7fcd (commit)
       via  64f8904fc5f6d1d4314d76e61a3b250c2fc18805 (commit)
       via  ec8a6d7d6c309c1d452f690cc0f3f70b8da2e3be (commit)
       via  a08453e81bddef781785954516d4ca176bf7a6d8 (commit)
       via  ec479b83db152b2658e99901e03d29d2a458acb9 (commit)
       via  e1c33eb543954d13ca0984c2a768fe3d98bbb75a (commit)
      from  96ae0e14d1e0113858ace78ea4586bc3ad11c844 (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 7bc4ecaaa2989870e2200f193815a1815aff7fcd
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Fri Aug 18 16:35:24 2017 -0400

    RT# 75817 - Some small updates to be able to backport to V3 because of no cust_contact table in V3

diff --git a/FS/FS/contact.pm b/FS/FS/contact.pm
index 76ebe98..8a381a5 100644
--- a/FS/FS/contact.pm
+++ b/FS/FS/contact.pm
@@ -465,7 +465,7 @@ and replace methods.
 sub check {
   my $self = shift;
 
-  if ( $self->selfservice_access eq 'R' || $self->selfservice_access eq 'P' ) {
+  if ( $self->selfservice_access eq 'R' || $self->selfservice_access eq 'E' || $self->selfservice_access eq 'P' ) {
     $self->selfservice_access('Y');
     $self->_resend('Y');
   }
diff --git a/FS/FS/cust_contact.pm b/FS/FS/cust_contact.pm
deleted file mode 100644
index 118a9e0..0000000
--- a/FS/FS/cust_contact.pm
+++ /dev/null
@@ -1,151 +0,0 @@
-package FS::cust_contact;
-use base qw( FS::Record );
-
-use strict;
-use FS::Record qw( qsearch qsearchs );
-
-=head1 NAME
-
-FS::cust_contact - Object methods for cust_contact records
-
-=head1 SYNOPSIS
-
-  use FS::cust_contact;
-
-  $record = new FS::cust_contact \%hash;
-  $record = new FS::cust_contact { 'column' => 'value' };
-
-  $error = $record->insert;
-
-  $error = $new_record->replace($old_record);
-
-  $error = $record->delete;
-
-  $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::cust_contact object represents a contact's attachment to a specific
-customer.  FS::cust_contact inherits from FS::Record.  The following fields are
-currently supported:
-
-=over 4
-
-=item custcontactnum
-
-primary key
-
-=item custnum
-
-custnum
-
-=item contactnum
-
-contactnum
-
-=item classnum
-
-classnum
-
-=item comment
-
-comment
-
-=item selfservice_access
-
-empty or Y
-
-=item invoice_dest
-
-'Y' if the customer should get invoices sent to this address, null if not
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new record.  To add the record to the database, see L<"insert">.
-
-Note that this stores the hash reference, not a distinct copy of the hash it
-points to.  You can ask the object for a copy with the I<hash> method.
-
-=cut
-
-# the new method can be inherited from FS::Record, if a table method is defined
-
-sub table { 'cust_contact'; }
-
-=item insert
-
-Adds this record to the database.  If there is an error, returns the error,
-otherwise returns false.
-
-=item delete
-
-Delete this record from the database.
-
-=item replace OLD_RECORD
-
-Replaces the OLD_RECORD with this one in the database.  If there is an error,
-returns the error, otherwise returns false.
-
-=item check
-
-Checks all fields to make sure this is a valid record.  If there is
-an error, returns the error, otherwise returns false.  Called by the insert
-and replace methods.
-
-=cut
-
-# the check method should currently be supplied - FS::Record contains some
-# data checking routines
-
-sub check {
-  my $self = shift;
-
-  if ( $self->selfservice_access eq 'R' || $self->selfservice_access eq 'E' || $self->selfservice_access eq 'P') {
-    $self->selfservice_access('Y');
-    $self->_resend('Y');
-  }
-
-  my $error = 
-    $self->ut_numbern('custcontactnum')
-    || $self->ut_number('custnum')
-    || $self->ut_number('contactnum')
-    || $self->ut_numbern('classnum')
-    || $self->ut_textn('comment')
-    || $self->ut_enum('selfservice_access', [ '', 'Y' ])
-    || $self->ut_flag('invoice_dest')
-  ;
-  return $error if $error;
-
-  $self->SUPER::check;
-}
-
-=item contact_classname
-
-Returns the name of this contact's class (see L<FS::contact_class>).
-
-=cut
-
-sub contact_classname {
-  my $self = shift;
-  my $contact_class = $self->contact_class or return '';
-  $contact_class->classname;
-}
-
-=back
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::contact>, L<FS::cust_main>, L<FS::Record>
-
-=cut
-
-1;
-
diff --git a/httemplate/elements/validate_password.html b/httemplate/elements/validate_password.html
index 3ca311d..1b0688e 100644
--- a/httemplate/elements/validate_password.html
+++ b/httemplate/elements/validate_password.html
@@ -28,7 +28,7 @@ function add_password_validation (fieldid, submitid) {
     var resultfield = document.getElementById(fieldid);
     if (this.value) {
       resultfield.innerHTML = '<SPAN STYLE="color: blue;">Validating password...</SPAN>';
-      validate_password('fieldid',fieldid,'svcnum','<% $opt{'svcnum'} |js_string %>','pkgnum','<% $opt{'pkgnum'} |js_string %>','contactnum','<% $opt{'contactnum'} |js_string %>','password',this.value,
+      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);

commit 64f8904fc5f6d1d4314d76e61a3b250c2fc18805
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue Aug 1 17:36:05 2017 -0400

    RT# 75817 - fixed bug to only send email out to contact that is being enabled not to all enabled contacts

diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html
index 905d3d8..6781935 100644
--- a/httemplate/elements/contact.html
+++ b/httemplate/elements/contact.html
@@ -53,7 +53,7 @@
             >
               <OPTION VALUE="">Disabled
 %             if ( $value || $self_base_url ) {
-                <OPTION VALUE="E" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled
+                <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 %>

commit ec8a6d7d6c309c1d452f690cc0f3f70b8da2e3be
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue Aug 1 15:08:57 2017 -0400

    RT# 75817 - fixed enable selection to send password reset and to allow you to set password in one step

diff --git a/FS/FS/cust_contact.pm b/FS/FS/cust_contact.pm
index 6820ac4..118a9e0 100644
--- a/FS/FS/cust_contact.pm
+++ b/FS/FS/cust_contact.pm
@@ -106,7 +106,7 @@ and replace methods.
 sub check {
   my $self = shift;
 
-  if ( $self->selfservice_access eq 'R' || $self->selfservice_access eq 'P') {
+  if ( $self->selfservice_access eq 'R' || $self->selfservice_access eq 'E' || $self->selfservice_access eq 'P') {
     $self->selfservice_access('Y');
     $self->_resend('Y');
   }
diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html
index df2107a..905d3d8 100644
--- a/httemplate/elements/contact.html
+++ b/httemplate/elements/contact.html
@@ -53,7 +53,7 @@
             >
               <OPTION VALUE="">Disabled
 %             if ( $value || $self_base_url ) {
-                <OPTION VALUE="Y" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled
+                <OPTION VALUE="E" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled
 %               if ( $value eq 'Y' && $self_base_url ) {
                   <OPTION VALUE="R">Re-email
                   <OPTION VALUE="P"><% $pwd_change_label %>
@@ -70,7 +70,7 @@
                   &>
             <SCRIPT TYPE="text/javascript">
                     document.getElementById("<%$id%>_<%$field%>").onchange = function() {
-                      if (this.value == "P") { changepw<%$id%>_toggle(true); }
+                      if (this.value == "P" || this.value == "E") { changepw<%$id%>_toggle(true); }
                       return false
                     }
             </SCRIPT>

commit a08453e81bddef781785954516d4ca176bf7a6d8
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Thu Jul 6 11:52:22 2017 -0400

    RT# 75817 - fixed contact password page to be more consistant with svc password page, updated javascript to check password as you type rather than when you leave the field.
    
    Conflicts:
    	FS/FS/contact.pm
    	FS/FS/cust_contact.pm
    	httemplate/elements/contact.html

diff --git a/FS/FS/contact.pm b/FS/FS/contact.pm
index ad0de6e..76ebe98 100644
--- a/FS/FS/contact.pm
+++ b/FS/FS/contact.pm
@@ -370,6 +370,15 @@ sub replace {
     }
   }
 
+  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;
 
   '';
@@ -456,7 +465,7 @@ and replace methods.
 sub check {
   my $self = shift;
 
-  if ( $self->selfservice_access eq 'R' ) {
+  if ( $self->selfservice_access eq 'R' || $self->selfservice_access eq 'P' ) {
     $self->selfservice_access('Y');
     $self->_resend('Y');
   }
@@ -742,6 +751,7 @@ sub cgi_contact_fields {
 
   my @contact_fields = qw(
     classnum first last title comment emailaddress selfservice_access
+    invoice_dest password
   );
 
   push @contact_fields, 'phonetypenum'. $_->phonetypenum
diff --git a/FS/FS/cust_contact.pm b/FS/FS/cust_contact.pm
new file mode 100644
index 0000000..6820ac4
--- /dev/null
+++ b/FS/FS/cust_contact.pm
@@ -0,0 +1,151 @@
+package FS::cust_contact;
+use base qw( FS::Record );
+
+use strict;
+use FS::Record qw( qsearch qsearchs );
+
+=head1 NAME
+
+FS::cust_contact - Object methods for cust_contact records
+
+=head1 SYNOPSIS
+
+  use FS::cust_contact;
+
+  $record = new FS::cust_contact \%hash;
+  $record = new FS::cust_contact { 'column' => 'value' };
+
+  $error = $record->insert;
+
+  $error = $new_record->replace($old_record);
+
+  $error = $record->delete;
+
+  $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::cust_contact object represents a contact's attachment to a specific
+customer.  FS::cust_contact inherits from FS::Record.  The following fields are
+currently supported:
+
+=over 4
+
+=item custcontactnum
+
+primary key
+
+=item custnum
+
+custnum
+
+=item contactnum
+
+contactnum
+
+=item classnum
+
+classnum
+
+=item comment
+
+comment
+
+=item selfservice_access
+
+empty or Y
+
+=item invoice_dest
+
+'Y' if the customer should get invoices sent to this address, null if not
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new record.  To add the record to the database, see L<"insert">.
+
+Note that this stores the hash reference, not a distinct copy of the hash it
+points to.  You can ask the object for a copy with the I<hash> method.
+
+=cut
+
+# the new method can be inherited from FS::Record, if a table method is defined
+
+sub table { 'cust_contact'; }
+
+=item insert
+
+Adds this record to the database.  If there is an error, returns the error,
+otherwise returns false.
+
+=item delete
+
+Delete this record from the database.
+
+=item replace OLD_RECORD
+
+Replaces the OLD_RECORD with this one in the database.  If there is an error,
+returns the error, otherwise returns false.
+
+=item check
+
+Checks all fields to make sure this is a valid record.  If there is
+an error, returns the error, otherwise returns false.  Called by the insert
+and replace methods.
+
+=cut
+
+# the check method should currently be supplied - FS::Record contains some
+# data checking routines
+
+sub check {
+  my $self = shift;
+
+  if ( $self->selfservice_access eq 'R' || $self->selfservice_access eq 'P') {
+    $self->selfservice_access('Y');
+    $self->_resend('Y');
+  }
+
+  my $error = 
+    $self->ut_numbern('custcontactnum')
+    || $self->ut_number('custnum')
+    || $self->ut_number('contactnum')
+    || $self->ut_numbern('classnum')
+    || $self->ut_textn('comment')
+    || $self->ut_enum('selfservice_access', [ '', 'Y' ])
+    || $self->ut_flag('invoice_dest')
+  ;
+  return $error if $error;
+
+  $self->SUPER::check;
+}
+
+=item contact_classname
+
+Returns the name of this contact's class (see L<FS::contact_class>).
+
+=cut
+
+sub contact_classname {
+  my $self = shift;
+  my $contact_class = $self->contact_class or return '';
+  $contact_class->classname;
+}
+
+=back
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::contact>, L<FS::cust_main>, L<FS::Record>
+
+=cut
+
+1;
+
diff --git a/httemplate/elements/change_password.html b/httemplate/elements/change_password.html
index a8cc883..463384f 100644
--- a/httemplate/elements/change_password.html
+++ b/httemplate/elements/change_password.html
@@ -8,69 +8,81 @@
   display: none;
 }
 </STYLE>
+% 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">
+% if (!$opt{'noformtag'}) {
   <FORM METHOD="POST" ACTION="<%$fsurl%>misc/process/change-password.html">
-    <% $change_id_input %>
-    <INPUT TYPE="text" ID="<%$pre%>password" NAME="password" VALUE="<% $curr_value |h%>">
-    <& /elements/random_pass.html, $pre.'password', 'randomize' &>
-    <INPUT TYPE="submit" VALUE="change">
-% if ($opt{'popup'}) {
-    <INPUT TYPE="button" VALUE="cancel" onclick="parent.cClick();">
 % }
-% else {
-    <INPUT TYPE="button" VALUE="cancel" onclick="<%$pre%>toggle(false)">  
+
+    <% $change_id_input %>
+    <INPUT TYPE="text" ID="<%$pre%>password" NAME="<% $opt{'pre_pwd_field_label'} %>password" VALUE="<% $curr_value |h%>">
+    <& /elements/random_pass.html, $pre.'password', 'randomize', $change_button_id &>
+% if (!$opt{'noformtag'}) {
+    <INPUT TYPE="submit" ID="<%$change_button_id%>" VALUE="change" disabled="disabled">
+% } else {
+    <INPUT TYPE="button" ID="<%$change_button_id%>" VALUE="change" onclick="<%$pre%>toggle(false)" disabled="disabled">
 %}
+    <INPUT TYPE="button" ID="<%$pre%>cancel_button" VALUE="cancel" onclick="<%$pre%>toggle(false, true)">
+
     <DIV ID="<%$pre%>password_result" STYLE="font-size: smaller"></DIV>
     <& '/elements/validate_password.html', 
          'fieldid'    => $pre.'password',
          'svcnum'     => $svcnum,
-         'contactnum' => $contactnum,
+         'contactnum' => $opt{'contact_num'},
+         'submitid'   => $change_button_id,
     &>
 % if ( $error ) {
     <BR><SPAN STYLE="color: #ff0000"><% $error |h %></SPAN>
 % }
+
+% if (!$opt{'noformtag'}) {
   </FORM>
+% }
+
 </DIV>
 <SCRIPT TYPE="text/javascript">
-function <%$pre%>toggle(val) {
+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 =
-    val ? 'inline-block' : 'none';
+    toggle ? 'inline-block' : 'none';
+% if (!$opt{'no_label_display'}) {
   document.getElementById('<%$pre%>link').style.display =
-    val ? 'none' : 'inline';
-}
-% if ( $error || $opt{'popup'} ) {
-<%$pre%>toggle(true);
+    toggle ? 'none' : 'inline';
 % }
+}
 </SCRIPT>
 <%init>
 my %opt = @_;
 
-my $contactnum = $opt{'contact_num'};
 my $curr_value = $opt{'curr_value'} || '';
 my $change_title = $opt{'label'} || 'change';
-
 my $svcnum;
 my $change_id_input = '';
 my $pre = 'changepw';
 
 if ($opt{'svc_acct'}) {
   my $svc_acct = $opt{'svc_acct'};
-  $change_id_input = '<INPUT TYPE="hidden" NAME="svcnum" VALUE="' . $svc_acct->svcnum . '">';
+  $change_id_input = '<INPUT TYPE="hidden" NAME="'.$opt{'pre_pwd_field_label'}.'svcnum" VALUE="' . $svc_acct->svcnum . '">';
   $pre .= $svc_acct->svcnum . '_';
   $svcnum = $svc_acct->svcnum;
 }
 elsif ($opt{'contact_num'}) {
   $change_id_input = '
-    <INPUT TYPE="hidden" NAME="contactnum" VALUE="' . $opt{'contact_num'} . '">
-    <INPUT TYPE="hidden" NAME="custnum" VALUE="' . $opt{'custnum'} . '">
+    <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'} . '">
   ';
-  $pre .= $opt{'contact_num'} . '_';
+  $pre .= $opt{'pre_pwd_field_label'};
 }
 
-if ($opt{'popup'}) {
-  $change_id_input .= '<INPUT TYPE="hidden" NAME="popup" VALUE="' . $opt{'popup'} . '">';
-}
+my $change_button_id = $pre.'change_button';
 
  my $error = $cgi->param($pre.'error');
 </%init>
diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html
index 755daed..df2107a 100644
--- a/httemplate/elements/contact.html
+++ b/httemplate/elements/contact.html
@@ -46,18 +46,44 @@
 
         <TD>
 %         if ( $field eq 'selfservice_access' ) {
+
             <SELECT NAME = "<%$name%>_<%$field%>"
                     ID   = "<%$id%>_<%$field%>"
+                    STYLE = "width: 140px"
             >
               <OPTION VALUE="">Disabled
 %             if ( $value || $self_base_url ) {
                 <OPTION VALUE="Y" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled
 %               if ( $value eq 'Y' && $self_base_url ) {
                   <OPTION VALUE="R">Re-email
+                  <OPTION VALUE="P"><% $pwd_change_label %>
 %               }
 %             }
             </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.'_',
+                  &>
+            <SCRIPT TYPE="text/javascript">
+                    document.getElementById("<%$id%>_<%$field%>").onchange = function() {
+                      if (this.value == "P") { changepw<%$id%>_toggle(true); }
+                      return false
+                    }
+            </SCRIPT>
+%         } elsif ( $field eq 'invoice_dest' ) {
+%           my $curr_value = $cgi->param($name . '_' . $field);
+%           $curr_value = $value if !defined($curr_value);
+            <& select.html,
+                field         => $name . '_' . $field,
+                curr_value    => $curr_value,
+                options       => [ '', 'Y' ],
+                option_labels => { '' => 'no', 'Y' => 'yes' },
+                style         => 'width: 100%',
+            &>
 %         } else {
             <INPUT TYPE  = "text"
                    NAME  = "<%$name%>_<%$field%>"
@@ -72,24 +98,6 @@
           <FONT SIZE="-1"><% $label{$field} %></FONT>
         </TD>
 %     }
-%     my $pwd_change_label = 'change';
-%     $pwd_change_label = 'setup' unless $contact->_password;
-%     my $action = $fsurl . "edit/cust_main-contacts-password.html?custnum=" . $opt{'custnum'} . "&contactnum=" . $curr_value . "&label=" . $pwd_change_label . "&popup=1";
-%     if ($curr_value) {
-        <TD>
-          <% include('/elements/popup_link.html',
-                         'action'      => $action,
-                         'width'       => '763',
-                         'height'      => '408',
-                         'actionlabel' => "$pwd_change_label password",
-                         'html_label'  => "$pwd_change_label password",
-
-                    )
-          %>
-          <br>
-          <FONT SIZE="-1">Password</FONT>
-        </TD>
-%     }
     </TR>
   </TABLE>
 
@@ -100,9 +108,6 @@ my( %opt ) = @_;
 
 my $conf = new FS::Conf;
 
-use Data::Dumper;
-print Dumper($conf->config);
-
 my $self_base_url = $conf->config('selfservice_server-base_url');
 
 my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum';
@@ -150,4 +155,7 @@ $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>
diff --git a/httemplate/elements/random_pass.html b/httemplate/elements/random_pass.html
index 1517a55..778aa20 100644
--- a/httemplate/elements/random_pass.html
+++ b/httemplate/elements/random_pass.html
@@ -1,6 +1,6 @@
-<INPUT TYPE="button" VALUE="<% emt($label) %>" onclick="randomPass()">
+<INPUT TYPE="button" VALUE="<% emt($label) %>" onclick="<% $id %>randomPass()">
 <SCRIPT TYPE="text/javascript">
-function randomPass() {
+function <% $id %>randomPass() {
   var pw_set = <% $pw_set |js_string %>;
   var lower = <% $lower |js_string %>;
   var upper = <% $upper |js_string %>;
@@ -19,11 +19,15 @@ function randomPass() {
   for(var j, x, i = pass.length; i; j = Math.floor(Math.random() * i), x = pass[--i], pass[i] = pass[j], pass[j] = x);
   pass = pass.join('');
   document.getElementById('<% $id %>').value = pass;
+% if ($submitid) {
+    document.getElementById('<% $submitid %>').disabled = false;
+% }
 }
 </SCRIPT>
 <%init>
 my $id = shift;
 my $label = shift || 'Generate';
+my $submitid = shift;
 my $pw_set = join('', FS::Password_Mixin->pw_set);
 my $lower = join('', $pw_set =~ /[[:lower:]]/g);
 my $upper = join('', $pw_set =~ /[[:upper:]]/g);
diff --git a/httemplate/elements/validate_password.html b/httemplate/elements/validate_password.html
index cb15029..3ca311d 100644
--- a/httemplate/elements/validate_password.html
+++ b/httemplate/elements/validate_password.html
@@ -21,9 +21,9 @@ should be the input id plus '_result'.
     'method' => 'POST', # important not to put passwords in url
 &>
 <SCRIPT>
-function add_password_validation (fieldid) {
+function add_password_validation (fieldid, submitid) {
   var inputfield = document.getElementById(fieldid);
-  inputfield.onchange = function () {
+  inputfield.onkeyup = function () {
     var fieldid = this.id+'_result';
     var resultfield = document.getElementById(fieldid);
     if (this.value) {
@@ -37,11 +37,14 @@ function add_password_validation (fieldid) {
             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; }
             }
           }
         }
@@ -51,7 +54,8 @@ function add_password_validation (fieldid) {
     }
   };
 }
-add_password_validation('<% $opt{'fieldid'} %>');
+
+add_password_validation('<% $opt{'fieldid'} %>', '<% $opt{'submitid'} %>');
 </SCRIPT>
 
 <%init>

commit ec479b83db152b2658e99901e03d29d2a458acb9
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Thu Jun 29 12:51:25 2017 -0400

    RT# 75817 - updated set contact password to use popup window. fixes break in first contact.

diff --git a/httemplate/edit/cust_main-contacts-password.html b/httemplate/edit/cust_main-contacts-password.html
new file mode 100644
index 0000000..e3c1d6f
--- /dev/null
+++ b/httemplate/edit/cust_main-contacts-password.html
@@ -0,0 +1,34 @@
+<% include("/elements/header-popup.html", $title) %>
+For Contact <% $contact->first %> <% $contact->last %>
+<P>
+<& /elements/change_password.html,
+              'contact_num' => $contactnum,
+              'custnum'     => $custnum,
+              'curr_value'  => '',
+              'label'       => $label,
+              'popup'       => $popup,
+&>
+
+<%init>
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+$cgi->param('contactnum') =~ /^(\d+)$/ or die "illegal contactnum" if $cgi->param('contactnum');
+my $contactnum = $1;
+
+$cgi->param('custnum') =~ /^(\d+)$/ or die "illegal customernum" if $cgi->param('custnum');
+my $custnum = $1;
+
+my $label = "change password";
+$label = "set password" unless ($cgi->param('label') eq "change");
+my $title = $label;
+$title =~ s/\b(\w)/\U$1/g;
+
+my $popup = $cgi->param('popup');
+
+die "access denied"
+    unless $curuser->access_right(($custnum ? 'Edit' : 'New'). ' customer'); #password?
+
+my $contact = qsearchs('contact', { 'contactnum' => $contactnum } );
+
+</%init>
\ No newline at end of file
diff --git a/httemplate/elements/change_password.html b/httemplate/elements/change_password.html
index b3a432f..a8cc883 100644
--- a/httemplate/elements/change_password.html
+++ b/httemplate/elements/change_password.html
@@ -15,7 +15,12 @@
     <INPUT TYPE="text" ID="<%$pre%>password" NAME="password" VALUE="<% $curr_value |h%>">
     <& /elements/random_pass.html, $pre.'password', 'randomize' &>
     <INPUT TYPE="submit" VALUE="change">
-    <INPUT TYPE="button" VALUE="cancel" onclick="<%$pre%>toggle(false)">
+% if ($opt{'popup'}) {
+    <INPUT TYPE="button" VALUE="cancel" onclick="parent.cClick();">
+% }
+% else {
+    <INPUT TYPE="button" VALUE="cancel" onclick="<%$pre%>toggle(false)">  
+%}
     <DIV ID="<%$pre%>password_result" STYLE="font-size: smaller"></DIV>
     <& '/elements/validate_password.html', 
          'fieldid'    => $pre.'password',
@@ -34,7 +39,7 @@ function <%$pre%>toggle(val) {
   document.getElementById('<%$pre%>link').style.display =
     val ? 'none' : 'inline';
 }
-% if ( $error ) {
+% if ( $error || $opt{'popup'} ) {
 <%$pre%>toggle(true);
 % }
 </SCRIPT>
@@ -63,5 +68,9 @@ elsif ($opt{'contact_num'}) {
   $pre .= $opt{'contact_num'} . '_';
 }
 
+if ($opt{'popup'}) {
+  $change_id_input .= '<INPUT TYPE="hidden" NAME="popup" VALUE="' . $opt{'popup'} . '">';
+}
+
  my $error = $cgi->param($pre.'error');
 </%init>
diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html
index 7799052..755daed 100644
--- a/httemplate/elements/contact.html
+++ b/httemplate/elements/contact.html
@@ -72,18 +72,20 @@
           <FONT SIZE="-1"><% $label{$field} %></FONT>
         </TD>
 %     }
-%     my $pwd_change_label = 'change password';
-%     $pwd_change_label = 'setup password' unless $contact->_password;
+%     my $pwd_change_label = 'change';
+%     $pwd_change_label = 'setup' unless $contact->_password;
+%     my $action = $fsurl . "edit/cust_main-contacts-password.html?custnum=" . $opt{'custnum'} . "&contactnum=" . $curr_value . "&label=" . $pwd_change_label . "&popup=1";
 %     if ($curr_value) {
         <TD>
-          <span STYLE="white-space: nowrap">
-            <& /elements/change_password.html,
-              'contact_num' => $curr_value,
-              'custnum'     => $opt{'custnum'},
-              'curr_value'  => '',
-              'label'       => $pwd_change_label,
-            &>
-          </span>
+          <% include('/elements/popup_link.html',
+                         'action'      => $action,
+                         'width'       => '763',
+                         'height'      => '408',
+                         'actionlabel' => "$pwd_change_label password",
+                         'html_label'  => "$pwd_change_label password",
+
+                    )
+          %>
           <br>
           <FONT SIZE="-1">Password</FONT>
         </TD>
@@ -97,6 +99,10 @@
 my( %opt ) = @_;
 
 my $conf = new FS::Conf;
+
+use Data::Dumper;
+print Dumper($conf->config);
+
 my $self_base_url = $conf->config('selfservice_server-base_url');
 
 my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum';
diff --git a/httemplate/misc/process/change-password.html b/httemplate/misc/process/change-password.html
index 250e832..be83786 100644
--- a/httemplate/misc/process/change-password.html
+++ b/httemplate/misc/process/change-password.html
@@ -1,3 +1,32 @@
+% if ( $error ) {
+%	if ($svcnum) {
+%   		$cgi->param('svcnum', $svcnum);
+%   		$cgi->param("changepw${svcnum}_error", $error);
+%	}
+%	elsif ($contactnum) {
+%   		$cgi->param('contactnum', $contactnum);
+%   		$cgi->param("changepw${contactnum}_error", $error);
+%	}
+% } else {
+%	if ($svcnum) { $cgi->query_string($svcnum); }
+%	elsif ($contactnum) { $cgi->query_string($contactnum); }
+% }
+
+% if (!$popup) {
+%   if ($svcnum) { 
+	 <% $cgi->redirect($fsurl.'view/svc_acct.cgi?'.$cgi->query_string) %>
+%   }
+%   elsif ($contactnum) { 
+	 <% $cgi->redirect($fsurl.'edit/cust_main-contacts.html?'.$cgi->param('custnum')) %>
+%   }
+% }
+
+<& /elements/header-popup.html, 'Password Set' &>
+<SCRIPT TYPE="text/javascript">
+  topreload();
+  parent.cClick();
+</SCRIPT>
+
 <%init>
 my $curuser = $FS::CurrentUser::CurrentUser;
 
@@ -7,6 +36,8 @@ my $svcnum = $1;
 $cgi->param('contactnum') =~ /^(\d+)$/ or die "illegal contactnum" if $cgi->param('contactnum');
 my $contactnum = $1;
 
+my $popup = $cgi->param('popup');
+
 my $newpass = $cgi->param('password');
 
 my $error;
@@ -39,25 +70,4 @@ elsif ($contactnum) {
 	#$cgi->delete('password');
 }
 
-</%init>
-% if ( $error ) {
-%	if ($svcnum) {
-%   		$cgi->param('svcnum', $svcnum);
-%   		$cgi->param("changepw${svcnum}_error", $error);
-%	}
-%	elsif ($contactnum) {
-%   		$cgi->param('contactnum', $contactnum);
-%   		$cgi->param("changepw${contactnum}_error", $error);
-%	}
-% } else {
-%	if ($svcnum) { $cgi->query_string($svcnum); }
-%	elsif ($contactnum) { $cgi->query_string($contactnum); }
-% }
-%warn('my pwd error is ' . $error . ' end');
-% if ($svcnum) { 
-	<% $cgi->redirect($fsurl.'view/svc_acct.cgi?'.$cgi->query_string) %>
-% }
-% elsif ($contactnum) { 
-	<% $cgi->redirect($fsurl.'edit/cust_main-contacts.html?'.$cgi->param('custnum')) %>
-% }
-
+</%init>
\ No newline at end of file

commit e1c33eb543954d13ca0984c2a768fe3d98bbb75a
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue Jun 20 09:04:14 2017 -0400

    RT# 75817 - Added the ability to set contacts password on the backend
    
    Conflicts:
    	httemplate/elements/validate_password.html
    	httemplate/misc/xmlhttp-validate_password.html

diff --git a/httemplate/elements/validate_password.html b/httemplate/elements/validate_password.html
index 01e8b94..cb15029 100644
--- a/httemplate/elements/validate_password.html
+++ b/httemplate/elements/validate_password.html
@@ -28,11 +28,7 @@ function add_password_validation (fieldid) {
     var resultfield = document.getElementById(fieldid);
     if (this.value) {
       resultfield.innerHTML = '<SPAN STYLE="color: blue;">Validating password...</SPAN>';
-      validate_password('fieldid',fieldid,
-                        'svcnum',<% $opt{'svcnum'} |js_string %>,
-                        'pkgnum',<% $opt{'pkgnum'} |js_string %>,
-                        'contactnum',<% $opt{'contactnum'} |js_string %>,
-                        'password',this.value,
+      validate_password('fieldid',fieldid,'svcnum','<% $opt{'svcnum'} |js_string %>','pkgnum','<% $opt{'pkgnum'} |js_string %>','contactnum','<% $opt{'contactnum'} |js_string %>','password',this.value,
         function (result) {
           result = JSON.parse(result);
           var resultfield = document.getElementById(result.fieldid);

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

Summary of changes:
 FS/FS/contact.pm                                 |   12 ++++-
 httemplate/edit/cust_main-contacts-password.html |   34 +++++++++++++
 httemplate/elements/change_password.html         |   55 +++++++++++++++-------
 httemplate/elements/contact.html                 |   50 +++++++++++++-------
 httemplate/elements/random_pass.html             |    8 +++-
 httemplate/elements/validate_password.html       |   16 +++----
 httemplate/misc/process/change-password.html     |   54 ++++++++++++---------
 7 files changed, 161 insertions(+), 68 deletions(-)
 create mode 100644 httemplate/edit/cust_main-contacts-password.html




More information about the freeside-commits mailing list