RT# 75817 - updated set contact password to use popup window. fixes break in first...
authorChristopher Burger <burgerc@freeside.biz>
Thu, 29 Jun 2017 16:51:25 +0000 (12:51 -0400)
committerChristopher Burger <burgerc@freeside.biz>
Thu, 29 Jun 2017 16:51:25 +0000 (12:51 -0400)
httemplate/edit/cust_main-contacts-password.html [new file with mode: 0644]
httemplate/elements/change_password.html
httemplate/elements/contact.html
httemplate/misc/process/change-password.html

diff --git a/httemplate/edit/cust_main-contacts-password.html b/httemplate/edit/cust_main-contacts-password.html
new file mode 100644 (file)
index 0000000..e3c1d6f
--- /dev/null
@@ -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
index b3a432f..a8cc883 100644 (file)
     <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>
index 8936569..072270e 100644 (file)
           <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>
 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';
index 250e832..be83786 100644 (file)
@@ -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