1 % if ( $opt{'js_only'} ) {
5 <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
7 <TABLE STYLE="display:inline">
9 % if ( @contact_class && ! $opt{name_only} ) {
11 <SELECT NAME="<%$name%>_classnum" <% $onchange %>>
13 % my $classnum = scalar($cgi->param($name.'_classnum'))
14 % || $X_contact->classnum;
15 % foreach my $contact_class (@contact_class) {
16 <OPTION VALUE="<% $contact_class->classnum %>"
17 <% ($contact_class->classnum == $classnum) ? 'SELECTED' : '' %>
18 ><% $contact_class->classname |h %>
21 <FONT SIZE="-1">Type</FONT>
24 <INPUT TYPE="hidden" NAME="<%$name%>_classnum" VALUE="">
27 % foreach my $field ( @fields ) {
30 % if ( $field =~ /^phonetypenum(\d+)$/ ) {
31 % my $contact_phone = qsearchs('contact_phone', {
32 % 'contactnum' => $curr_value,
33 % 'phonetypenum' => $1,
35 % if ( $contact_phone ) {
36 % $value = $contact_phone->phonenum_pretty;
37 % $value .= 'x'.$contact_phone->extension
38 % if $contact_phone->extension;
39 % $value = '+'. $contact_phone->countrycode. " $value"
40 % if $contact_phone->countrycode
41 % && $contact_phone->countrycode ne '1';
43 % } elsif ( $field eq 'emailaddress' ) {
44 % $value = join(', ', map $_->emailaddress, $contact->contact_email);
45 % } elsif ( $field eq 'password' ) {
46 % $value = $contact->get('_password') ? '********' : '';
47 % } elsif ( $field eq 'selfservice_access'
48 % or $field eq 'comment'
49 % or $field eq 'invoice_dest' ) {
50 % $value = $X_contact->get($field);
52 % $value = $contact->get($field);
56 % if ( $field eq 'selfservice_access' ) {
58 <SELECT NAME = "<%$name%>_<%$field%>"
59 ID = "<%$id%>_<%$field%>"
60 STYLE = "width: 140px"
62 <OPTION VALUE="" <% !$value ? 'SELECTED' : '' %>>Disabled
63 % if ( $value || $self_base_url ) {
64 <OPTION VALUE="<% $value eq 'Y' ? 'Y' : 'E' %>" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled
65 % if ( $value eq 'Y' && $self_base_url ) {
66 <OPTION VALUE="R">Re-email
71 % } elsif ( $field eq 'password') {
73 NAME = "<%$name%>_<%$field%>"
74 ID = "changepw<%$id%>_<%$field%>"
75 SIZE = "<% $size{$field} || 14 %>"
77 placeholder = "<% $value |h %>"
82 % } elsif ( $field eq 'invoice_dest' ) {
83 % my $curr_value = $cgi->param($name . '_' . $field);
84 % $curr_value = $value if !defined($curr_value);
86 field => $name . '_' . $field,
87 curr_value => $curr_value,
88 options => [ '', 'Y' ],
89 option_labels => { '' => 'no', 'Y' => 'yes' },
90 style => 'width: 100%',
94 NAME = "<%$name%>_<%$field%>"
95 ID = "<%$id%>_<%$field%>"
96 SIZE = "<% $size{$field} || 14 %>"
97 VALUE = "<% scalar($cgi->param($name . '_' . $field))
103 <FONT SIZE="-1"><% $label{$field} %></FONT>
104 % if ( $field eq 'password' ) {
105 <div id="changepw<%$id%>_<%$field%>_result"></div>
117 my $conf = new FS::Conf;
119 my $self_base_url = $conf->config('selfservice_server-base_url');
121 my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum';
122 my $id = $opt{'id'} || 'contactnum';
124 my $curr_value = $opt{'curr_value'} || $opt{'value'};
125 my $contactnum = $curr_value ? $curr_value : '0';
128 if ( $opt{'onchange'} ) {
129 $onchange = $opt{'onchange'};
130 $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
131 $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange
132 #callbacks should act the same
133 $onchange = 'onChange="'. $onchange. '"';
136 my @contact_class = qsearch('contact_class', { 'disabled' => '' });
141 $contact = qsearchs('contact', { 'contactnum' => $curr_value } );
142 if ( $opt{'custnum'} ) {
143 $X_contact = qsearchs('cust_contact', {
144 'contactnum' => $curr_value,
145 'custnum' => $opt{'custnum'},
147 } elsif ( $opt{'prospectnum'} ) {
148 $X_contact = qsearchs('prospect_contact', {
149 'contactnum' => $curr_value,
150 'prospectnum' => $opt{'prospectnum'},
152 $opt{'for_prospect'} = 1;
154 die 'neither custnum nor prospectnum specified';
157 $contact = new FS::contact {};
158 if ($opt{'for_prospect'}) {
159 $X_contact = new FS::prospect_contact;
161 $X_contact = new FS::cust_contact;
165 my %size = ( 'title' => 12 );
167 tie my %label, 'Tie::IxHash',
168 'first' => 'First name',
169 'last' => 'Last name',
170 'title' => 'Title/Position',
171 'emailaddress' => 'Email'
174 unless ($opt{'for_prospect'}) {
175 $label{'invoice_dest'} = 'Send invoices';
176 $label{'selfservice_access'} = 'Self-service';
177 $label{'password'} = 'Password';
181 foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
182 next if $phone_type->typename =~ /^(Home|Fax)$/;
183 my $f = 'phonetypenum'.$phone_type->phonetypenum;
184 $label{$f} = $phone_type->typename. ' phone';
185 $size{$f} = $first++ ? 10 : 15;
188 $label{'comment'} = 'Comment';
190 my @fields = $opt{'name_only'} ? qw( first last ) : keys %label;
193 add_password_validation('changepw$id\_password', 'submit', '', '$contactnum');
195 var selfService = document.getElementById("$id\_selfservice_access").value;
197 if (selfService !== "Y") { document.getElementById("changepw$id\_password").disabled = 'true'; }
198 document.getElementById("$id\_selfservice_access").onchange = function() {
199 if (this.value == "P" || this.value == "E" || this.value =="Y") {
200 document.getElementById("changepw$id\_password").disabled = '';
202 else { document.getElementById("changepw$id\_password").disabled = 'true'; }