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,
126 'default' => { map { $_=>1 } FS::part_tag->default_tags },
131 % if ( $cgi->param('lock_agentnum') =~ /^(\d+)$/ && $curuser->agentnum($1) ) {
134 % $cust_main->agentnum($agentnum);
136 <INPUT TYPE="hidden" NAME="lock_agentnum" VALUE="<% $agentnum %>">
137 <INPUT TYPE="hidden" NAME="agentnum" ID="agentnum"
138 VALUE="<% $agentnum %>">
140 <TH ALIGN="right"><% mt('Agent') |h %></TD>
141 <TD CLASS="fsdisabled"><% $cust_main->agent->agent |h %></TD>
146 <& /elements/tr-select-agent.html,
147 'curr_value' => $cust_main->agentnum,
148 'label' => $r. emt('Agent'),
149 'empty_label' => emt('Select agent'),
150 'disable_empty' => ( $cust_main->agentnum ? 1 : 0 ),
151 'viewall_right' => emt('None'),
152 'onchange' => 'agent_changed(this)',
158 % if ( $conf->exists('cust_main-edit_agent_custid') ) {
161 <TH ALIGN="right"><% mt('Customer identifier') |h %></TD>
162 <TD><INPUT TYPE="text" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>"></TD>
167 <INPUT TYPE="hidden" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>">
172 <& /elements/tr-select-cust_class.html,
173 'curr_value' => $cust_main->classnum,
174 'label' => emt("Class"),
178 <& /elements/tr-select-tax_status.html,
179 'curr_value' => $cust_main->taxstatusnum,
180 'disable_empty' => 0,
181 'empty_label' => ' ',
185 <& /elements/tr-select-sales.html,
186 'curr_value' => $cust_main->salesnum,
190 %# referral (advertising source)
191 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
192 %if ( $custnum && ! $conf->exists('editreferrals') ) {
194 <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
198 <& /elements/tr-select-part_referral.html,
199 'curr_value' => $refnum,
200 'label' => $r. emt('Advertising source'),
205 %# referring customer
206 %my $referring_cust_main = '';
207 %if ( $cust_main->referral_custnum
208 % and $referring_cust_main =
209 % qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
210 % and ! $curuser->access_right('Edit referring customer')
214 <TH ALIGN="right"><% mt('Referring customer') |h %></TD>
216 <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name |h %></A>
219 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
221 % } elsif ( ! $conf->exists('disable_customer_referrals') ) {
224 <TH ALIGN="right"><% mt('Referring customer') |h %></TD>
226 <& /elements/search-cust_main.html,
227 'field_name' => 'referral_custnum',
228 'curr_value' => $cust_main->referral_custnum,
234 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
238 % if ( $conf->exists('cust_main-edit_signupdate') ) {
239 <& /elements/tr-input-date-field.html, {
240 'name' => 'signupdate',
241 'value' => $cust_main->signupdate,
242 'label' => emt('Signup date'),
243 'format' => ( $conf->config('date_format') || "%m/%d/%Y" ),
248 % # permission to edit ticket subjects
249 % if ( $conf->exists('ticket_system-selfservice_edit_subject') ) {
252 <INPUT TYPE="checkbox" NAME="edit_subject" VALUE="Y" <%
253 $cust_main->edit_subject ? 'CHECKED' : '' %>></TD>
254 <TD ALIGN="left"><% mt('Can edit ticket subjects') |h %></TD>
257 <INPUT TYPE="hidden" NAME="edit_subject" VALUE="<% $cust_main->edit_subject %>">
260 % # permission to edit
261 % if ( $conf->exists('cust_main-edit_calling_list_exempt') ) {
264 <INPUT TYPE="checkbox" NAME="calling_list_exempt" VALUE="Y" <%
265 $cust_main->calling_list_exempt ? 'CHECKED' : '' %>></TD>
266 <TD ALIGN="left"><% mt('Calling list exempt') |h %></TD>
269 <INPUT TYPE="hidden" NAME="calling_list_exempt" VALUE="<% $cust_main->calling_list_exempt %>">
276 my( $cust_main, %opt ) = @_;
278 my $custnum = $opt{'custnum'};
280 my $conf = new FS::Conf;
282 if ( $cgi->param('error') ) {
283 $cust_main->set('residential_commercial',
284 ($cgi->param('residential_commercial') eq 'Commercial')
288 } elsif ( $custnum ) { #editing
289 $cust_main->set('residential_commercial',
290 length($cust_main->company)
294 } else { #new customer
295 $cust_main->set('residential_commercial',
296 $conf->exists('cust_main-default_commercial')
302 my $curuser = $FS::CurrentUser::CurrentUser;
304 my $r = qq!<font color="#ff0000">*</font> !;
306 # which agents lock the service address, if any
307 my %ship_locked_agents;
308 foreach (qsearch('agent',{})) {
309 my $agentnum = $_->agentnum;
310 next unless $conf->exists('agent-ship_address', $_->agentnum);
311 my $cust_main = $_->agent_cust_main or next;
312 my $agent_ship_location = $cust_main->ship_location;
313 $ship_locked_agents{$agentnum} = +{
314 map { $_ => $agent_ship_location->$_ }
316 qw(locationname address1 state zip country latitude longitude district),
317 ($conf->exists('cust_main-no_city_in_address') ? () : 'city')