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 % || $X_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 'selfservice_access'
44 % or $field eq 'comment'
45 % or $field eq 'invoice_dest' ) {
46 % $value = $X_contact->get($field);
48 % $value = $contact->get($field);
52 % if ( $field eq 'selfservice_access' ) {
53 <SELECT NAME = "<%$name%>_<%$field%>"
54 ID = "<%$id%>_<%$field%>"
56 <OPTION VALUE="">Disabled
57 % if ( $value || $self_base_url ) {
58 <OPTION VALUE="Y" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled
59 % if ( $value eq 'Y' && $self_base_url ) {
60 <OPTION VALUE="R">Re-email
64 % } elsif ( $field eq 'invoice_dest' ) {
65 % my $curr_value = $cgi->param($name . '_' . $field);
66 % $curr_value = $value if !defined($curr_value);
68 field => $name . '_' . $field,
69 curr_value => $curr_value,
70 options => [ '', 'Y' ],
71 option_labels => { '' => 'no', 'Y' => 'yes' },
72 style => 'width: 100%',
76 NAME = "<%$name%>_<%$field%>"
77 ID = "<%$id%>_<%$field%>"
78 SIZE = "<% $size{$field} || 14 %>"
79 VALUE = "<% scalar($cgi->param($name . '_' . $field))
85 <FONT SIZE="-1"><% $label{$field} %></FONT>
88 % my $pwd_change_label = 'change password';
89 % $pwd_change_label = 'setup password' unless $contact->_password;
92 <span STYLE="white-space: nowrap">
93 <& /elements/change_password.html,
94 'contact_num' => $curr_value,
95 'custnum' => $opt{'custnum'},
97 'label' => $pwd_change_label,
101 <FONT SIZE="-1">Password</FONT>
112 my $conf = new FS::Conf;
113 my $self_base_url = $conf->config('selfservice_server-base_url');
115 my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum';
116 my $id = $opt{'id'} || 'contactnum';
118 my $curr_value = $opt{'curr_value'} || $opt{'value'};
121 if ( $opt{'onchange'} ) {
122 $onchange = $opt{'onchange'};
123 $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
124 $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange
125 #callbacks should act the same
126 $onchange = 'onChange="'. $onchange. '"';
129 my @contact_class = qsearch('contact_class', { 'disabled' => '' });
134 $contact = qsearchs('contact', { 'contactnum' => $curr_value } );
135 if ( $opt{'custnum'} ) {
136 $X_contact = qsearchs('cust_contact', {
137 'contactnum' => $curr_value,
138 'custnum' => $opt{'custnum'},
140 } elsif ( $opt{'prospectnum'} ) {
141 $X_contact = qsearchs('prospect_contact', {
142 'contactnum' => $curr_value,
143 'prospectnum' => $opt{'prospectnum'},
145 $opt{'for_prospect'} = 1;
147 die 'neither custnum nor prospectnum specified';
150 $contact = new FS::contact {};
151 if ($opt{'for_prospect'}) {
152 $X_contact = new FS::prospect_contact;
154 $X_contact = new FS::cust_contact;
158 my %size = ( 'title' => 12 );
160 tie my %label, 'Tie::IxHash',
161 'first' => 'First name',
162 'last' => 'Last name',
163 'title' => 'Title/Position',
164 'emailaddress' => 'Email'
167 unless ($opt{'for_prospect'}) {
168 $label{'invoice_dest'} = 'Send invoices';
169 $label{'selfservice_access'} = 'Self-service';
173 foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
174 next if $phone_type->typename =~ /^(Home|Fax)$/;
175 my $f = 'phonetypenum'.$phone_type->phonetypenum;
176 $label{$f} = $phone_type->typename. ' phone';
177 $size{$f} = $first++ ? 10 : 15;
180 $label{'comment'} = 'Comment';
182 my @fields = $opt{'name_only'} ? qw( first last ) : keys %label;