-<% include('elements/edit.html',
- 'name_singular' => 'customer contacts', #yes, we're editing all of them
- 'table' => 'cust_main',
- 'post_url' => popurl(1). 'process/cust_main-contacts.html',
- 'labels' => { 'custnum' => ' ', #XXX supress this line entirely, its being redundant
- 'contactnum' => ' ', #'Contact',
- #'locationnum' => ' ',
- },
- 'fields' => [
+<SCRIPT>
+function checkPasswordValidation(fieldid) {
+ var validationResult = document.getElementById(fieldid+'_result').innerHTML;
+ if (validationResult.match(/Password valid!/)) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+</SCRIPT>
+
+<& elements/edit.html,
+ 'name_singular' => 'customer contacts', #yes, we're editing all of them
+ 'table' => 'cust_main',
+ 'post_url' => popurl(1). 'process/cust_main-contacts.html',
+ 'no_pkey_display' => 1,
+ 'labels' => { 'custnum' => ' ', #XXX supress this line entirely, its being redundant
+ 'contactnum' => ' ', #'Contact',
+ #'locationnum' => ' ',
+ },
+ 'fields' => [
{ 'field' => 'contactnum',
'type' => 'contact',
'colspan' => 6,
$conf->config('countrydefault') || 'US',
1, #no balance
),
- )
-%>
+&>
<%init>
my $curuser = $FS::CurrentUser::CurrentUser;
% }
% } elsif ( $field eq 'emailaddress' ) {
% $value = join(', ', map $_->emailaddress, $contact->contact_email);
+% } elsif ( $field eq 'password' ) {
+% $value = $contact->get('_password') ? '********' : '';
% } else {
% $value = $contact->get($field);
% }
ID = "<%$id%>_<%$field%>"
STYLE = "width: 140px"
>
- <OPTION VALUE="">Disabled
+ <OPTION VALUE="" <% !$value ? 'SELECTED' : '' %>>Disabled
% if ( $value || $self_base_url ) {
<OPTION VALUE="<% $value eq 'Y' ? 'Y' : 'E' %>" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled
% if ( $value eq 'Y' && $self_base_url ) {
% }
% }
</SELECT>
- <& /elements/change_password.html,
- 'contact_num' => $curr_value,
- 'custnum' => $opt{'custnum'},
- 'curr_value' => '',
- 'no_label_display' => '1',
- 'noformtag' => '1',
- 'pre_pwd_field_label' => $id.'_',
- &>
+% #password form
+% } elsif ( $field eq 'password') {
+ <INPUT TYPE = "text"
+ NAME = "<%$name%>_<%$field%>"
+ ID = "changepw<%$id%>_<%$field%>"
+ SIZE = "<% $size{$field} || 14 %>"
+ 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">
- document.getElementById("<%$id%>_<%$field%>").onchange = function() {
- if (this.value == "P" || this.value == "E") { changepw<%$id%>_toggle(true); }
- return false
+ 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>
% } elsif ( $field eq 'invoice_dest' ) {
% }
<BR>
<FONT SIZE="-1"><% $label{$field} %></FONT>
+% if ( $field eq 'password' ) {
+ <div id="changepw<%$id%>_<%$field%>_result"></div>
+% }
</TD>
% }
</TR>
'selfservice_access' => 'Self-service'
;
+unless ($opt{'for_prospect'}) {
+ $label{'selfservice_access'} = 'Self-service';
+ $label{'password'} = 'Password';
+}
+
my $first = 0;
foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
next if $phone_type->typename =~ /^(Home|Fax)$/;
$result{'syserror'} = 'Invoked without password' unless $password;
return \%result if $result{'syserror'};
- if ($arg{'contactnum'}) {
+ if ($arg{'contactnum'} =~ /^\d+$/) {
my $contactnum = $arg{'contactnum'};
$result{'syserror'} = 'Invalid contactnum' unless $contactnum =~ /^\d*$/;
return \%result if $result{'syserror'};
my $contact = $contactnum
? qsearchs('contact',{'contactnum' => $contactnum})
- : '';
+ : (new FS::contact {});
$result{'error'} = $contact->is_password_allowed($password);
}