Optimize "Customer has a referring customer" condition, RT#74452
[freeside.git] / httemplate / elements / change_password.html
1 <STYLE>
2 .passwordbox {
3   border: 1px solid #7e0079;
4   padding: 2px;
5   position: absolute;
6   font-size: 80%;
7   background-color: #ffffff;
8   display: none;
9 }
10 </STYLE>
11 % if (!$opt{'no_label_display'}) {
12 <A ID="<%$pre%>link" HREF="javascript:void(0)" onclick="<%$pre%>toggle(true)">(<% emt( $change_title ) %>)</A>
13 % }
14 <DIV ID="<%$pre%>form" CLASS="passwordbox">
15 % if (!$opt{'noformtag'}) {
16   <FORM METHOD="POST" ACTION="<%$fsurl%>misc/process/change-password.html" onsubmit="return checkPasswordValidation()">
17 % }
18
19     <% $change_id_input %>
20     <INPUT TYPE="text" ID="<%$pre%>password" NAME="<% $opt{'pre_pwd_field_label'} %>password" VALUE="<% $curr_value |h%>">
21     <& /elements/random_pass.html, $pre.'password', 'randomize', $change_button_id &>
22 % if (!$opt{'noformtag'}) {
23     <INPUT TYPE="submit" ID="<%$change_button_id%>" VALUE="change" disabled="disabled">
24 % } else {
25     <INPUT TYPE="button" ID="<%$change_button_id%>" VALUE="change" onclick="<%$pre%>toggle(false)" disabled="disabled">
26 %}
27     <INPUT TYPE="button" ID="<%$pre%>cancel_button" VALUE="cancel" onclick="<%$pre%>toggle(false, true)">
28
29     <DIV ID="<%$pre%>password_result" STYLE="font-size: smaller"></DIV>
30     <& '/elements/validate_password.html', 
31          'fieldid'    => $pre.'password',
32          'svcnum'     => $svcnum,
33          'contactnum' => $opt{'contact_num'},
34          'submitid'   => $change_button_id,
35     &>
36
37 % if (!$opt{'noformtag'}) {
38   </FORM>
39 % }
40
41 </DIV>
42 <SCRIPT TYPE="text/javascript">
43 function <%$pre%>toggle(toggle, clear) {
44   if (clear) {
45     document.getElementById('<%$pre%>password').value = '';
46     document.getElementById('<%$pre%>password_result').innerHTML = '';
47 % if ($opt{'contact_num'}) {
48     document.getElementById('<% $opt{'pre_pwd_field_label'} %>selfservice_access').value = 'Y';
49 % }
50 }
51   document.getElementById('<%$pre%>form').style.display =
52     toggle ? 'inline-block' : 'none';
53 % if (!$opt{'no_label_display'}) {
54   document.getElementById('<%$pre%>link').style.display =
55     toggle ? 'none' : 'inline';
56 % }
57 }
58
59 function checkPasswordValidation()  {
60   var validationResult = document.getElementById('<%$pre%>password_result').innerHTML;
61   if (validationResult.match(/Password valid!/)) {
62     return true;
63   }
64   else {
65     return false;
66   }
67 }
68 </SCRIPT>
69 <%init>
70 my %opt = @_;
71
72 my $curr_value = $opt{'curr_value'} || '';
73 my $change_title = $opt{'label'} || 'change';
74 my $svcnum;
75 my $change_id_input = '';
76 my $pre = 'changepw';
77
78 if ($opt{'svc_acct'}) {
79   my $svc_acct = $opt{'svc_acct'};
80   $change_id_input = '<INPUT TYPE="hidden" NAME="'.$opt{'pre_pwd_field_label'}.'svcnum" VALUE="' . $svc_acct->svcnum . '">';
81   $pre .= $svc_acct->svcnum . '_';
82   $svcnum = $svc_acct->svcnum;
83 }
84 elsif ($opt{'contact_num'}) {
85   $change_id_input = '
86     <INPUT TYPE="hidden" NAME="'.$opt{'pre_pwd_field_label'}.'contactnum" VALUE="' . $opt{'contact_num'} . '">
87     <INPUT TYPE="hidden" NAME="'.$opt{'pre_pwd_field_label'}.'custnum" VALUE="' . $opt{'custnum'} . '">
88   ';
89   $pre .= $opt{'pre_pwd_field_label'};
90 }
91
92 my $change_button_id = $pre.'change_button';
93
94  my $error = $cgi->param($pre.'error');
95 </%init>