4.x style
[freeside.git] / httemplate / elements / contact.html
index 85cecd0..308b846 100644 (file)
@@ -1,4 +1,6 @@
-% unless ( $opt{'js_only'} ) {
+% if ( $opt{'js_only'} ) {
+<% $js %>
+% } else {
 
   <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
 
@@ -63,7 +65,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>
                    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">
-                    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>
+              <% $js %>
             </SCRIPT>
 %         } elsif ( $field eq 'invoice_dest' || $field eq 'message_dest' ) {
 %           my $curr_value = $cgi->param($name . '_' . $field);
           <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>
 %     }
@@ -139,6 +123,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'} ) {
@@ -195,7 +180,7 @@ unless ($opt{'for_prospect'}) {
 }
 
 my $first = 0;
-foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
+foreach my $phone_type ( FS::phone_type->get_phone_types() ) {
   next if $phone_type->typename =~ /^(Home|Fax)$/;
   my $f = 'phonetypenum'.$phone_type->phonetypenum;
   $label{$f} = $phone_type->typename. ' phone';
@@ -206,7 +191,21 @@ $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;
+my $submitid = $opt{'submit_id'} ? $opt{'submit_id'} : 'submit';
+
+my $js = qq(
+    add_password_validation('changepw$id\_password', '$submitid', '', '$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;
+    }
+) unless $opt{'for_prospect'};
 
 </%init>