summaryrefslogtreecommitdiff
path: root/httemplate/edit/cust_main/contact.html
blob: 57490b962526568b6f82f911197da2065ba5db22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<TABLE CLASS="fsinnerbox">

<TR>
  <TH ALIGN="right"><%$r%><% mt('Contact name (last, first)') |h %></TH>
  <TD COLSPAN=7>
    <INPUT TYPE="text" NAME="<%$pre%>last" VALUE="<% $cust_main->get($pre.'last') |h %>" onChange="<% $onchange %>" <%$disabled%> <%$style%>> , 
    <INPUT TYPE="text" NAME="<%$pre%>first" VALUE="<% $cust_main->get($pre.'first') |h %>" onChange="<% $onchange %>" <%$disabled%> <%$style%>>
  </TD>
% if ( $conf->exists('show_ss') && !$pre ) { 

  <TD ALIGN="right"><% mt('SS#') |h %></TD>
  <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $opt{ss} %>" SIZE=11></TD>
% } elsif ( !$pre ) { 

  <TD><INPUT TYPE="hidden" NAME="ss" VALUE="<% $opt{ss} %>"></TD>
% } 
</TR>

% if ( $conf->exists('cust-email-high-visibility') && !$pre ) {
    <TR>
      <TD ALIGN="right" WIDTH="200">
        <% $conf->exists('cust_main-require_invoicing_list_email', $agentnum) 
          ? $r : '' %>Email address(es)
      </TD>
      <TD bgcolor="#FFFF00">
        <INPUT TYPE="text" NAME="invoicing_list" VALUE="<% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) %>">
      </TD>
    </TR>
% }

% unless ( $conf->exists('cust-edit-alt-field-order') ) { #standard order

  <& company &>
  <& location &>
  <& phones &>
  <& fax &>

% } else { #alternate field order

  <& phones &>
  <& location &>
  <& fax &>
  <& company &>

% }

% if ( $conf->exists('show_stateid') && !$pre ) { 

<TR>
  <TD ALIGN="right"><% $stateid_label %></TD>
  <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $opt{stateid} %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%> <%$style%>></TD>
  <TD ALIGN="right"><% $stateid_state_label %></TD>
  <TD><& /elements/select-state.html,
                   'state'    => $cust_main->stateid_state,
                   'country'  => $cust_main->country,
                   'prefix'   => 'stateid_',
                   'onchange' => $onchange,
                   'disabled' => $disabled,
                   'style'    => \@style,
      &>
  </TD>
</TR>
% } elsif ( !$pre ) { 

  <TD><INPUT TYPE="hidden" NAME="stateid" VALUE="<% $opt{stateid} %>"></TD>
  <TD><INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $cust_main->stateid_state %>"></TD>
% } 

</TABLE>
<%$r%><% mt('required fields') |h %><BR>

<%def company>
% my $display = ($cust_main->residential_commercial eq 'Commercial')
%                 ? '' : 'none';
  <TR ID="<%$pre%>company_row" STYLE="display:<%$display%>">
    <TD ALIGN="right"><% mt('Company') |h %></TD>
    <TD COLSPAN=7>
      <INPUT TYPE="text" NAME="<%$pre%>company" ID="<%$pre%>company" VALUE="<% $cust_main->get($pre.'company') |h %>" SIZE=60 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
    </TD>
  </TR>
</%def>

<%def location>
  <& /elements/location.html,
               'prefix'       => $pre,
               'object'       => $cust_main,
               'onchange'     => $onchange,
               'disabled'     => $disabled,
               'style'        => \@style,
               'same_checked' => $opt{'same_checked'},
               'geocode'      => $opt{'geocode'},
               'censustract'  => $opt{'censustract'},
  &>
</%def>

<%def phones>
  <TR>
    <TD ALIGN="right" VALIGN="top"><% mt('Phones') %></TD>
    <TD COLSPAN=6>

      <TABLE CELLSPACING=0 CELLPADDING=0>
        <TR>
          <TD>
            <INPUT TYPE="text" NAME="<%$pre%>daytime" VALUE="<% $cust_main->get($pre.'daytime') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
            <BR><FONT SIZE=-1><% $daytime_label %></FONT>
          </TD>
          <TD>&nbsp;</TD>
          <TD>
            <INPUT TYPE="text" NAME="<%$pre%>night" VALUE="<% $cust_main->get($pre.'night') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
            <BR><FONT SIZE=-1><% $night_label %></FONT>
          </TD>
          <TD>&nbsp;</TD>
          <TD>
            <INPUT TYPE="text" NAME="<%$pre%>mobile" VALUE="<% $cust_main->get($pre.'mobile') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
            <BR><FONT SIZE=-1><% $mobile_label %></FONT>
          </TD>
        </TR>
      </TABLE>
    </TD>
  </TR>
</%def>

<%def fax>
  <TR>
    <TD ALIGN="right"><% mt('Fax') |h %></TD>
    <TD COLSPAN=5>
      <INPUT TYPE="text" NAME="<%$pre%>fax" VALUE="<% $cust_main->get($pre.'fax') %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%> <%$style%>>
    </TD>
  </TR>
</%def>

<%once>

my $r = qq!<font color="#ff0000">*</font>&nbsp;!;

</%once>
<%shared>

my( %opt, $cust_main, $pre, $onchange, $disabled, @style, $style,
    $daytime_label, $night_label, $mobile_label,
  );

</%shared>
<%init>

%opt = @_;
$cust_main = $opt{'cust_main'};
$pre       = $opt{'pre'};
$onchange  = $opt{'onchange'};
$disabled  = $opt{'disabled'};
@style     = ( $opt{'style'} ? @{ $opt{'style'} } : () );

$style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : '';

my $conf = new FS::Conf;

foreach (qw(ss stateid)) {
  $opt{$_} = $cust_main->masked($_) unless exists $opt{$_};
}

#false laziness with ship state
my $countrydefault = $conf->config('countrydefault') || 'US';
$cust_main->set($pre.'country', $countrydefault )
  unless $cust_main->get($pre.'country');

my $statedefault = $conf->config('statedefault')
                   || ($countrydefault eq 'US' ? 'CA' : '');
$cust_main->set($pre.'state', $statedefault )
  unless $cust_main->get($pre.'state')
         || $cust_main->get($pre.'country') ne $countrydefault;

$cust_main->set('stateid_state', $cust_main->state )
  unless $pre || $cust_main->get('stateid_state');

$opt{geocode} ||= $cust_main->get('geocode');

if ( $conf->exists('cust_main-require_censustract') ) {
  $opt{censustract} ||= $cust_main->censustract;
}

$daytime_label = FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/
                   ? 'Day'
                   : FS::Msgcat::_gettext('daytime');
$night_label   = FS::Msgcat::_gettext('night') =~/^(night)?$/
                   ? 'Night'
                   : FS::Msgcat::_gettext('night') || 'Night';
$mobile_label = FS::Msgcat::_gettext('mobile') =~/^(mobile)?$/
                   ? 'Mobile'
                   : FS::Msgcat::_gettext('mobile') || 'Mobile';

my $stateid_label = FS::Msgcat::_gettext('stateid') =~ /^(stateid)?$/
                  ? 'Driver&rsquo;s License'
                  : FS::Msgcat::_gettext('stateid') || 'Driver&rsquo;s License';
my $stateid_state_label = FS::Msgcat::_gettext('stateid_state') =~ /^(stateid_state)?$/
                        ? 'Driver&rsquo;s License State'
                        : FS::Msgcat::_gettext('stateid_state') || 'Driver&rsquo;s License State';

my @invoicing_list = $cust_main->invoicing_list;

my $agentnum = $cust_main->agentnum if $cust_main->custnum;

</%init>