1 % unless ( $opt{'js_only'} ) {
3 <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
5 <TABLE STYLE="display:inline">
7 % if ( @contact_class && ! $opt{name_only} ) {
9 <SELECT NAME="<%$name%>_classnum" <% $onchange %>>
11 % my $classnum = scalar($cgi->param($name.'_classnum'))
12 % || $contact->classnum;
13 % foreach my $contact_class (@contact_class) {
14 <OPTION VALUE="<% $contact_class->classnum %>"
15 <% ($contact_class->classnum == $classnum) ? 'SELECTED' : '' %>
16 ><% $contact_class->classname |h %>
19 <FONT SIZE="-1">Type</FONT>
22 <INPUT TYPE="hidden" NAME="<%$name%>_classnum" VALUE="">
25 % foreach my $field ( @fields ) {
28 % if ( $field =~ /^phonetypenum(\d+)$/ ) {
29 % my $contact_phone = qsearchs('contact_phone', {
30 % 'contactnum' => $curr_value,
31 % 'phonetypenum' => $1,
33 % if ( $contact_phone ) {
34 % $value = $contact_phone->phonenum_pretty;
35 % $value .= 'x'.$contact_phone->extension
36 % if $contact_phone->extension;
37 % $value = '+'. $contact_phone->countrycode. " $value"
38 % if $contact_phone->countrycode
39 % && $contact_phone->countrycode ne '1';
41 % } elsif ( $field eq 'emailaddress' ) {
42 % $value = join(', ', map $_->emailaddress, $contact->contact_email);
43 % } elsif ( $field eq 'password' ) {
44 % $value = $contact->get('_password') ? '********' : '';
46 % $value = $contact->get($field);
50 % if ( $field eq 'selfservice_access' ) {
52 <SELECT NAME = "<%$name%>_<%$field%>"
53 ID = "<%$id%>_<%$field%>"
54 STYLE = "width: 140px"
56 <OPTION VALUE="" <% !$value ? 'SELECTED' : '' %>>Disabled
57 % if ( $value || $self_base_url ) {
58 <OPTION VALUE="<% $value eq 'Y' ? 'Y' : 'E' %>" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled
59 % if ( $value eq 'Y' && $self_base_url ) {
60 <OPTION VALUE="R">Re-email
61 <OPTION VALUE="P"><% $pwd_change_label %>
66 % } elsif ( $field eq 'password') {
68 NAME = "<%$name%>_<%$field%>"
69 ID = "changepw<%$id%>_<%$field%>"
70 SIZE = "<% $size{$field} || 14 %>"
72 placeholder = "<% $value |h %>"
74 % my $contactnum = $curr_value ? $curr_value : '0';
75 <& '/elements/validate_password.html',
76 'fieldid' => "changepw".$id."_password",
78 'contactnum' => $contactnum,
79 'submitid' => "submit",
82 <SCRIPT TYPE="text/javascript">
83 var selfService = document.getElementById("<%$id%>_selfservice_access").value;
85 if (selfService !== "Y") { document.getElementById("changepw<%$id%>_password").disabled = 'true'; }
86 document.getElementById("<%$id%>_selfservice_access").onchange = function() {
87 if (this.value == "P" || this.value == "E" || this.value =="Y") {
88 document.getElementById("changepw<%$id%>_password").disabled = '';
90 else { document.getElementById("changepw<%$id%>_password").disabled = 'true'; }
94 % } elsif ( $field eq 'invoice_dest' ) {
95 % my $curr_value = $cgi->param($name . '_' . $field);
96 % $curr_value = $value if !defined($curr_value);
98 field => $name . '_' . $field,
99 curr_value => $curr_value,
100 options => [ '', 'Y' ],
101 option_labels => { '' => 'no', 'Y' => 'yes' },
102 style => 'width: 100%',
106 NAME = "<%$name%>_<%$field%>"
107 ID = "<%$id%>_<%$field%>"
108 SIZE = "<% $size{$field} || 14 %>"
109 VALUE = "<% scalar($cgi->param($name."_$field"))
115 <FONT SIZE="-1"><% $label{$field} %></FONT>
116 % if ( $field eq 'password' ) {
117 <div id="changepw<%$id%>_<%$field%>_result"></div>
129 my $conf = new FS::Conf;
131 my $self_base_url = $conf->config('selfservice_server-base_url');
133 my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum';
134 my $id = $opt{'id'} || 'contactnum';
136 my $curr_value = $opt{'curr_value'} || $opt{'value'};
139 if ( $opt{'onchange'} ) {
140 $onchange = $opt{'onchange'};
141 $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
142 $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange
143 #callbacks should act the same
144 $onchange = 'onChange="'. $onchange. '"';
147 my @contact_class = qsearch('contact_class', { 'disabled' => '' });
151 $contact = qsearchs('contact', { 'contactnum' => $curr_value } );
153 $contact = new FS::contact {};
156 my %size = ( 'title' => 12 );
158 tie my %label, 'Tie::IxHash',
159 'first' => 'First name',
160 'last' => 'Last name',
161 'title' => 'Title/Position',
162 'emailaddress' => 'Email',
163 'selfservice_access' => 'Self-service'
166 unless ($opt{'for_prospect'}) {
167 $label{'selfservice_access'} = 'Self-service';
168 $label{'password'} = 'Password';
172 foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
173 next if $phone_type->typename =~ /^(Home|Fax)$/;
174 my $f = 'phonetypenum'.$phone_type->phonetypenum;
175 $label{$f} = $phone_type->typename. ' phone';
176 $size{$f} = $first++ ? 10 : 15;
179 $label{'comment'} = 'Comment';
181 my @fields = $opt{'name_only'} ? qw( first last ) : keys %label;
183 my $pwd_change_label = 'Change Password';
184 $pwd_change_label = 'Setup Password' unless $contact->_password;