From e773f2d834f6757e7a0430184d9db6939e0b632d Mon Sep 17 00:00:00 2001 From: Christopher Burger Date: Thu, 29 Jun 2017 12:51:25 -0400 Subject: [PATCH] RT# 75817 - updated set contact password to use popup window. fixes break in first contact. --- httemplate/edit/cust_main-contacts-password.html | 34 +++++++++++++++ httemplate/elements/change_password.html | 13 +++++- httemplate/elements/contact.html | 26 +++++++----- httemplate/misc/process/change-password.html | 54 ++++++++++++++---------- 4 files changed, 93 insertions(+), 34 deletions(-) create mode 100644 httemplate/edit/cust_main-contacts-password.html diff --git a/httemplate/edit/cust_main-contacts-password.html b/httemplate/edit/cust_main-contacts-password.html new file mode 100644 index 000000000..e3c1d6fa8 --- /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 %> +

+<& /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 } ); + + \ No newline at end of file diff --git a/httemplate/elements/change_password.html b/httemplate/elements/change_password.html index b3a432f95..a8cc883b9 100644 --- a/httemplate/elements/change_password.html +++ b/httemplate/elements/change_password.html @@ -15,7 +15,12 @@ <& /elements/random_pass.html, $pre.'password', 'randomize' &> - +% if ($opt{'popup'}) { + +% } +% else { + +%}

<& '/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); % } @@ -63,5 +68,9 @@ elsif ($opt{'contact_num'}) { $pre .= $opt{'contact_num'} . '_'; } +if ($opt{'popup'}) { + $change_id_input .= ''; +} + my $error = $cgi->param($pre.'error'); diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html index 8936569ce..072270ea8 100644 --- a/httemplate/elements/contact.html +++ b/httemplate/elements/contact.html @@ -85,18 +85,20 @@ <% $label{$field} %> % } -% 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) { - - <& /elements/change_password.html, - 'contact_num' => $curr_value, - 'custnum' => $opt{'custnum'}, - 'curr_value' => '', - 'label' => $pwd_change_label, - &> - + <% include('/elements/popup_link.html', + 'action' => $action, + 'width' => '763', + 'height' => '408', + 'actionlabel' => "$pwd_change_label password", + 'html_label' => "$pwd_change_label password", + + ) + %>
Password @@ -110,6 +112,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 250e8320b..be83786cd 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' &> + + <%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'); } - -% 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')) %> -% } - + \ No newline at end of file -- 2.11.0