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);
44 % $value = $contact->get($field);
48 % if ( $field eq 'selfservice_access' ) {
49 <SELECT NAME = "<%$name%>_<%$field%>"
50 ID = "<%$id%>_<%$field%>"
52 <OPTION VALUE="">Disabled
53 % if ( $value || $self_base_url ) {
54 <OPTION VALUE="Y" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled
55 % if ( $value eq 'Y' && $self_base_url ) {
56 <OPTION VALUE="R">Re-email
63 NAME = "<%$name%>_<%$field%>"
64 ID = "<%$id%>_<%$field%>"
65 SIZE = "<% $size{$field} || 14 %>"
66 VALUE = "<% scalar($cgi->param($name."_$field"))
72 <FONT SIZE="-1"><% $label{$field} %></FONT>
75 % my $pwd_change_label = 'change';
76 % $pwd_change_label = 'setup' unless $contact->_password;
77 % my $action = $fsurl . "edit/cust_main-contacts-password.html?custnum=" . $opt{'custnum'} . "&contactnum=" . $curr_value . "&label=" . $pwd_change_label . "&popup=1";
80 <% include('/elements/popup_link.html',
84 'actionlabel' => "$pwd_change_label password",
85 'html_label' => "$pwd_change_label password",
90 <FONT SIZE="-1">Password</FONT>
101 my $conf = new FS::Conf;
104 print Dumper($conf->config);
106 my $self_base_url = $conf->config('selfservice_server-base_url');
108 my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum';
109 my $id = $opt{'id'} || 'contactnum';
111 my $curr_value = $opt{'curr_value'} || $opt{'value'};
114 if ( $opt{'onchange'} ) {
115 $onchange = $opt{'onchange'};
116 $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
117 $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange
118 #callbacks should act the same
119 $onchange = 'onChange="'. $onchange. '"';
122 my @contact_class = qsearch('contact_class', { 'disabled' => '' });
126 $contact = qsearchs('contact', { 'contactnum' => $curr_value } );
128 $contact = new FS::contact {};
131 my %size = ( 'title' => 12 );
133 tie my %label, 'Tie::IxHash',
134 'first' => 'First name',
135 'last' => 'Last name',
136 'title' => 'Title/Position',
137 'emailaddress' => 'Email',
138 'selfservice_access' => 'Self-service'
142 foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
143 next if $phone_type->typename =~ /^(Home|Fax)$/;
144 my $f = 'phonetypenum'.$phone_type->phonetypenum;
145 $label{$f} = $phone_type->typename. ' phone';
146 $size{$f} = $first++ ? 10 : 15;
149 $label{'comment'} = 'Comment';
151 my @fields = $opt{'name_only'} ? qw( first last ) : keys %label;