RT# 75817 - Added the ability to set contacts password on the backend
[freeside.git] / httemplate / elements / contact.html
index 8abce05..7799052 100644 (file)
 %       }
 
         <TD>
-          <INPUT TYPE  = "text"
-                 NAME  = "<%$name%>_<%$field%>"
-                 ID    = "<%$id%>_<%$field%>"
-                 SIZE  = "<% $size{$field} || 15 %>"
-                 VALUE = "<% scalar($cgi->param($name."_$field"))
-                             || $value |h %>"
-                 <% $onchange %>
-          ><BR>
+%         if ( $field eq 'selfservice_access' ) {
+            <SELECT NAME = "<%$name%>_<%$field%>"
+                    ID   = "<%$id%>_<%$field%>"
+            >
+              <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
+%               }
+%             }
+            </SELECT>
+
+%         } else {
+            <INPUT TYPE  = "text"
+                   NAME  = "<%$name%>_<%$field%>"
+                   ID    = "<%$id%>_<%$field%>"
+                   SIZE  = "<% $size{$field} || 14 %>"
+                   VALUE = "<% scalar($cgi->param($name."_$field"))
+                               || $value |h %>"
+                   <% $onchange %>
+            >
+%         }
+          <BR>
           <FONT SIZE="-1"><% $label{$field} %></FONT>
         </TD>
 %     }
+%     my $pwd_change_label = 'change password';
+%     $pwd_change_label = 'setup password' unless $contact->_password;
+%     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>
+          <br>
+          <FONT SIZE="-1">Password</FONT>
+        </TD>
+%     }
     </TR>
   </TABLE>
 
@@ -64,6 +96,9 @@
 
 my( %opt ) = @_;
 
+my $conf = new FS::Conf;
+my $self_base_url = $conf->config('selfservice_server-base_url');
+
 my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum';
 my $id = $opt{'id'} || 'contactnum';
 
@@ -90,15 +125,16 @@ if ( $curr_value ) {
 my %size = ( 'title' => 12 );
 
 tie my %label, 'Tie::IxHash',
-  'first'        => 'First name',
-  'last'         => 'Last name',
-  'title'        => 'Title/Position',
-  'emailaddress' => 'Email',
+  'first'              => 'First name',
+  'last'               => 'Last name',
+  'title'              => 'Title/Position',
+  'emailaddress'       => 'Email',
+  'selfservice_access' => 'Self-service'
 ;
 
 my $first = 0;
 foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
-  next if $phone_type->typename eq 'Home';
+  next if $phone_type->typename =~ /^(Home|Fax)$/;
   my $f = 'phonetypenum'.$phone_type->phonetypenum;
   $label{$f} = $phone_type->typename. ' phone';
   $size{$f} = $first++ ? 10 : 15;