1 <TABLE CLASS="fsinnerbox">
4 <TD ALIGN="right">Residential</TD>
5 <TD><INPUT TYPE = "radio"
6 NAME = "residential_commercial"
7 ID = "residential_commercial_Residential"
9 onChange = "rescom_changed(this)"
10 <% $cust_main->residential_commercial eq 'Commercial' ? '' : 'CHECKED' %>
14 <TD ALIGN="right">Commercial</TD>
15 <TD><INPUT TYPE = "radio"
16 NAME = "residential_commercial"
17 ID = "residential_commercial_Commercial"
19 onChange = "rescom_changed(this)"
20 <% $cust_main->residential_commercial eq 'Commercial' ? 'CHECKED' : '' %>
24 <SCRIPT TYPE="text/javascript">
26 function rescom_changed(what) {
27 if ( what.checked == (what.value == 'Commercial' ) ) {
28 $('#company_label').slideDown();
29 $('#company_input').slideDown();
30 $('#contacts_div').slideDown();
31 $('#spouse_label').slideUp();
32 $('#spouse_last_input').slideUp();
33 $('#spouse_first_input').slideUp();
35 if ( document.getElementById('company').value.length == 0 ) {
36 $('#company_label').slideUp();
37 $('#company_input').slideUp();
39 $('#contacts_div').slideUp();
40 $('#spouse_label').slideDown();
41 $('#spouse_last_input').slideDown();
42 $('#spouse_first_input').slideDown();
47 var ship_locked_agents = <% encode_json(\%ship_locked_agents) %>;
49 'locationname', 'address1',<% $conf->exists('cust_main-no_city_in_address') ? '' : q( 'city',) %> 'state', 'zip', 'country',
50 'latitude', 'longitude', 'district'
53 function agent_changed(what) {
54 var agentnum = what.value;
56 % # unlock/lock service location
59 var was_same = f['same'].checked;
60 if ( ship_locked_agents[agentnum] ) {
61 % # For this agent, the service location (except address2)
62 % # should be locked to the agent's location.
63 % # Set the ship_ fields to those values (just for display) and
64 % # then disable them.
65 for(var x in ship_locked_agents[agentnum]) {
66 f['ship_'+x].value = ship_locked_agents[agentnum][x];
67 f['ship_'+x].disabled = true;
69 f['same'].checked = false;
70 f['same'].disabled = true;
72 % # Unlock the ship_ location fields. If they were previously
73 % # disabled, then they contain some agent's address, which is
74 % # no longer meaningful. So set them back to the customer's
77 for(var i=0; i<ship_fields.length; i++) {
79 if ( f['ship_'+x].disabled ) {
80 f['ship_'+x].value = f['old_ship_'+x].value;
82 f['ship_'+x].disabled = false;
83 if ( f['bill_'+x].value != f['ship_'+x].value ) {
87 % # if the customer's current location has the same bill and ship
88 % # address, then check the box
89 f['same'].checked = is_same;
90 f['same'].disabled = false;
92 if (f['same'].checked != was_same) {
93 samechanged(f['same']);
96 % # update sales dropdown
97 salesnum_agentnum_changed(what);
101 <&| /elements/onload.js &>
102 rescom_changed(document.getElementById('residential_commercial_Residential'));
103 agent_changed(document.getElementById('agentnum'));
105 if ( $('#same').prop('checked') ) {
106 $('#div_ship_location').hide();
108 $('#div_ship_location').show();
115 % foreach my $field ($cust_main->virtual_fields) {
116 <% $cust_main->pvf($field)->widget('HTML', 'edit',$cust_main->getfield($field)) %>
120 <& /elements/tr-select-cust_tag.html,
121 'custnum' => $custnum,
126 % if ( $cgi->param('lock_agentnum') =~ /^(\d+)$/ && $curuser->agentnum($1) ) {
129 % $cust_main->agentnum($agentnum);
131 <INPUT TYPE="hidden" NAME="lock_agentnum" VALUE="<% $agentnum %>">
132 <INPUT TYPE="hidden" NAME="agentnum" ID="agentnum"
133 VALUE="<% $agentnum %>">
135 <TH ALIGN="right"><% mt('Agent') |h %></TD>
136 <TD CLASS="fsdisabled"><% $cust_main->agent->agent |h %></TD>
141 <& /elements/tr-select-agent.html,
142 'curr_value' => $cust_main->agentnum,
143 'label' => $r. emt('Agent'),
144 'empty_label' => emt('Select agent'),
145 'disable_empty' => ( $cust_main->agentnum ? 1 : 0 ),
146 'viewall_right' => emt('None'),
147 'onchange' => 'agent_changed(this)',
153 % if ( $conf->exists('cust_main-edit_agent_custid') ) {
156 <TH ALIGN="right"><% mt('Customer identifier') |h %></TD>
157 <TD><INPUT TYPE="text" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>"></TD>
162 <INPUT TYPE="hidden" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>">
167 <& /elements/tr-select-cust_class.html,
168 'curr_value' => $cust_main->classnum,
169 'label' => emt("Class"),
173 <& /elements/tr-select-tax_status.html,
174 'curr_value' => $cust_main->taxstatusnum,
175 'disable_empty' => 0,
176 'empty_label' => ' ',
180 <& /elements/tr-select-sales.html,
181 'curr_value' => $cust_main->salesnum,
185 %# referral (advertising source)
186 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
187 %if ( $custnum && ! $conf->exists('editreferrals') ) {
189 <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
193 <& /elements/tr-select-part_referral.html,
194 'curr_value' => $refnum,
195 'label' => $r. emt('Advertising source'),
200 %# referring customer
201 %my $referring_cust_main = '';
202 %if ( $cust_main->referral_custnum
203 % and $referring_cust_main =
204 % qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
205 % and ! $curuser->access_right('Edit referring customer')
209 <TH ALIGN="right"><% mt('Referring customer') |h %></TD>
211 <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name |h %></A>
214 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
216 % } elsif ( ! $conf->exists('disable_customer_referrals') ) {
219 <TH ALIGN="right"><% mt('Referring customer') |h %></TD>
221 <& /elements/search-cust_main.html,
222 'field_name' => 'referral_custnum',
223 'curr_value' => $cust_main->referral_custnum,
229 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
233 % if ( $conf->exists('cust_main-edit_signupdate') ) {
234 <& /elements/tr-input-date-field.html, {
235 'name' => 'signupdate',
236 'value' => $cust_main->signupdate,
237 'label' => emt('Signup date'),
238 'format' => ( $conf->config('date_format') || "%m/%d/%Y" ),
243 % # permission to edit ticket subjects
244 % if ( $conf->exists('ticket_system-selfservice_edit_subject') ) {
247 <INPUT TYPE="checkbox" NAME="edit_subject" VALUE="Y" <%
248 $cust_main->edit_subject ? 'CHECKED' : '' %>></TD>
249 <TD ALIGN="left"><% mt('Can edit ticket subjects') |h %></TD>
252 <INPUT TYPE="hidden" NAME="edit_subject" VALUE="<% $cust_main->edit_subject %>">
255 % # permission to edit
256 % if ( $conf->exists('cust_main-edit_calling_list_exempt') ) {
259 <INPUT TYPE="checkbox" NAME="calling_list_exempt" VALUE="Y" <%
260 $cust_main->calling_list_exempt ? 'CHECKED' : '' %>></TD>
261 <TD ALIGN="left"><% mt('Calling list exempt') |h %></TD>
264 <INPUT TYPE="hidden" NAME="calling_list_exempt" VALUE="<% $cust_main->calling_list_exempt %>">
271 my( $cust_main, %opt ) = @_;
273 my $custnum = $opt{'custnum'};
275 my $conf = new FS::Conf;
277 if ( $cgi->param('error') ) {
278 $cust_main->set('residential_commercial',
279 ($cgi->param('residential_commercial') eq 'Commercial')
283 } elsif ( $custnum ) { #editing
284 $cust_main->set('residential_commercial',
285 length($cust_main->company)
289 } else { #new customer
290 $cust_main->set('residential_commercial',
291 $conf->exists('cust_main-default_commercial')
297 my $curuser = $FS::CurrentUser::CurrentUser;
299 my $r = qq!<font color="#ff0000">*</font> !;
301 # which agents lock the service address, if any
302 my %ship_locked_agents;
303 foreach (qsearch('agent',{})) {
304 my $agentnum = $_->agentnum;
305 next unless $conf->exists('agent-ship_address', $_->agentnum);
306 my $cust_main = $_->agent_cust_main or next;
307 my $agent_ship_location = $cust_main->ship_location;
308 $ship_locked_agents{$agentnum} = +{
309 map { $_ => $agent_ship_location->$_ }
311 qw(locationname address1 state zip country latitude longitude district),
312 ($conf->exists('cust_main-no_city_in_address') ? () : 'city')