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();
34 $('#invoice_email_label').slideUp();
35 $('#invoice_email_input').slideUp();
37 if ( document.getElementById('company').value.length == 0 ) {
38 $('#company_label').slideUp();
39 $('#company_input').slideUp();
41 $('#contacts_div').slideUp();
42 $('#spouse_label').slideDown();
43 $('#spouse_last_input').slideDown();
44 $('#spouse_first_input').slideDown();
45 $('#invoice_email_label').slideDown();
46 $('#invoice_email_input').slideDown();
51 var ship_locked_agents = <% encode_json(\%ship_locked_agents) %>;
53 'locationname', 'address1',<% $conf->exists('cust_main-no_city_in_address') ? '' : q( 'city',) %> 'state', 'zip', 'country',
54 'latitude', 'longitude', 'district'
57 function agent_changed(what) {
58 var agentnum = what.value;
60 % # unlock/lock service location
63 var was_same = f['same'].checked;
64 if ( ship_locked_agents[agentnum] ) {
65 % # For this agent, the service location (except address2)
66 % # should be locked to the agent's location.
67 % # Set the ship_ fields to those values (just for display) and
68 % # then disable them.
69 for(var x in ship_locked_agents[agentnum]) {
70 f['ship_'+x].value = ship_locked_agents[agentnum][x];
71 f['ship_'+x].disabled = true;
73 f['same'].checked = false;
74 f['same'].disabled = true;
76 % # Unlock the ship_ location fields. If they were previously
77 % # disabled, then they contain some agent's address, which is
78 % # no longer meaningful. So set them back to the customer's
81 for(var i=0; i<ship_fields.length; i++) {
83 if ( f['ship_'+x].disabled ) {
84 f['ship_'+x].value = f['old_ship_'+x].value;
86 f['ship_'+x].disabled = false;
87 if ( f['bill_'+x].value != f['ship_'+x].value ) {
91 % # if the customer's current location has the same bill and ship
92 % # address, then check the box
93 f['same'].checked = is_same;
94 f['same'].disabled = false;
96 if (f['same'].checked != was_same) {
97 samechanged(f['same']);
100 % # update sales dropdown
101 salesnum_agentnum_changed(what);
105 <&| /elements/onload.js &>
106 rescom_changed(document.getElementById('residential_commercial_Residential'));
107 agent_changed(document.getElementById('agentnum'));
109 if ( $('#same').prop('checked') ) {
110 $('#div_ship_location').hide();
112 $('#div_ship_location').show();
119 % foreach my $field ($cust_main->virtual_fields) {
120 <% $cust_main->pvf($field)->widget('HTML', 'edit',$cust_main->getfield($field)) %>
124 <& /elements/tr-select-cust_tag.html,
125 'custnum' => $custnum,
130 % if ( $cgi->param('lock_agentnum') =~ /^(\d+)$/ && $curuser->agentnum($1) ) {
133 % $cust_main->agentnum($agentnum);
135 <INPUT TYPE="hidden" NAME="lock_agentnum" VALUE="<% $agentnum %>">
136 <INPUT TYPE="hidden" NAME="agentnum" ID="agentnum"
137 VALUE="<% $agentnum %>">
139 <TH ALIGN="right"><% mt('Agent') |h %></TD>
140 <TD CLASS="fsdisabled"><% $cust_main->agent->agent |h %></TD>
145 <& /elements/tr-select-agent.html,
146 'curr_value' => $cust_main->agentnum,
147 'label' => $r. emt('Agent'),
148 'empty_label' => emt('Select agent'),
149 'disable_empty' => ( $cust_main->agentnum ? 1 : 0 ),
150 'viewall_right' => emt('None'),
151 'onchange' => 'agent_changed(this)',
157 % if ( $conf->exists('cust_main-edit_agent_custid') ) {
160 <TH ALIGN="right"><% mt('Customer identifier') |h %></TD>
161 <TD><INPUT TYPE="text" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>"></TD>
166 <INPUT TYPE="hidden" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>">
171 <& /elements/tr-select-cust_class.html,
172 'curr_value' => $cust_main->classnum,
173 'label' => emt("Class"),
177 <& /elements/tr-select-tax_status.html,
178 'curr_value' => $cust_main->taxstatusnum,
179 'disable_empty' => 0,
180 'empty_label' => ' ',
184 <& /elements/tr-select-sales.html,
185 'curr_value' => $cust_main->salesnum,
189 %# referral (advertising source)
190 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
191 %if ( $custnum && ! $conf->exists('editreferrals') ) {
193 <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
197 <& /elements/tr-select-part_referral.html,
198 'curr_value' => $refnum,
199 'label' => $r. emt('Advertising source'),
204 %# referring customer
205 %my $referring_cust_main = '';
206 %if ( $cust_main->referral_custnum
207 % and $referring_cust_main =
208 % qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
209 % and ! $curuser->access_right('Edit referring customer')
213 <TH ALIGN="right"><% mt('Referring customer') |h %></TD>
215 <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name |h %></A>
218 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
220 % } elsif ( ! $conf->exists('disable_customer_referrals') ) {
223 <TH ALIGN="right"><% mt('Referring customer') |h %></TD>
225 <& /elements/search-cust_main.html,
226 'field_name' => 'referral_custnum',
227 'curr_value' => $cust_main->referral_custnum,
233 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
237 % if ( $conf->exists('cust_main-edit_signupdate') ) {
238 <& /elements/tr-input-date-field.html, {
239 'name' => 'signupdate',
240 'value' => $cust_main->signupdate,
241 'label' => emt('Signup date'),
242 'format' => ( $conf->config('date_format') || "%m/%d/%Y" ),
247 % # permission to edit ticket subjects
248 % if ( $conf->exists('ticket_system-selfservice_edit_subject') ) {
251 <INPUT TYPE="checkbox" NAME="edit_subject" VALUE="Y" <%
252 $cust_main->edit_subject ? 'CHECKED' : '' %>></TD>
253 <TD ALIGN="left"><% mt('Can edit ticket subjects') |h %></TD>
256 <INPUT TYPE="hidden" NAME="edit_subject" VALUE="<% $cust_main->edit_subject %>">
259 % # permission to edit
260 % if ( $conf->exists('cust_main-edit_calling_list_exempt') ) {
263 <INPUT TYPE="checkbox" NAME="calling_list_exempt" VALUE="Y" <%
264 $cust_main->calling_list_exempt ? 'CHECKED' : '' %>></TD>
265 <TD ALIGN="left"><% mt('Calling list exempt') |h %></TD>
268 <INPUT TYPE="hidden" NAME="calling_list_exempt" VALUE="<% $cust_main->calling_list_exempt %>">
275 my( $cust_main, %opt ) = @_;
277 my $custnum = $opt{'custnum'};
279 my $conf = new FS::Conf;
281 if ( $cgi->param('error') ) {
282 $cust_main->set('residential_commercial',
283 ($cgi->param('residential_commercial') eq 'Commercial')
287 } elsif ( $custnum ) { #editing
288 $cust_main->set('residential_commercial',
289 length($cust_main->company)
293 } else { #new customer
294 $cust_main->set('residential_commercial',
295 $conf->exists('cust_main-default_commercial')
301 my $curuser = $FS::CurrentUser::CurrentUser;
303 my $r = qq!<font color="#ff0000">*</font> !;
305 # which agents lock the service address, if any
306 my %ship_locked_agents;
307 foreach (qsearch('agent',{})) {
308 my $agentnum = $_->agentnum;
309 next unless $conf->exists('agent-ship_address', $_->agentnum);
310 my $cust_main = $_->agent_cust_main or next;
311 my $agent_ship_location = $cust_main->ship_location;
312 $ship_locked_agents{$agentnum} = +{
313 map { $_ => $agent_ship_location->$_ }
315 qw(locationname address1 state zip country latitude longitude district),
316 ($conf->exists('cust_main-no_city_in_address') ? () : 'city')