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','address2',<% $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), 'TH') %>
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 % my $rclass = $conf->exists('cust_main-require_classnum') ? $r : '';
173 <& /elements/tr-select-cust_class.html,
174 'curr_value' => $cust_main->classnum,
175 'label' => $rclass . emt("Class"),
176 'empty_label' => $rclass ? 'Select class' : '(none)',
177 'disable_empty' => ($rclass && $cust_main->classnum) ? 1 : 0,
181 <& /elements/tr-select-tax_status.html,
182 'curr_value' => $cust_main->taxstatusnum,
183 'disable_empty' => 0,
184 'empty_label' => ' ',
188 <& /elements/tr-select-sales.html,
189 'curr_value' => $cust_main->salesnum,
193 %# referral (advertising source)
194 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
195 %if ( $custnum && ! $conf->exists('editreferrals') ) {
197 <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
201 <& /elements/tr-select-part_referral.html,
202 'curr_value' => $refnum,
203 'label' => $r. emt('Advertising source'),
208 %# referring customer
209 %my $referring_cust_main = '';
210 %if ( $cust_main->referral_custnum
211 % and $referring_cust_main =
212 % qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
213 % and ! $curuser->access_right('Edit referring customer')
217 <TH ALIGN="right"><% mt('Referring customer') |h %></TD>
219 <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name |h %></A>
222 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
224 % } elsif ( ! $conf->exists('disable_customer_referrals') ) {
227 <TH ALIGN="right"><% mt('Referring customer') |h %></TD>
229 <& /elements/search-cust_main.html,
230 'field_name' => 'referral_custnum',
231 'curr_value' => $cust_main->referral_custnum,
237 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
241 % if ( $conf->exists('cust_main-edit_signupdate') ) {
242 <& /elements/tr-input-date-field.html, {
243 'name' => 'signupdate',
244 'value' => $cust_main->signupdate,
245 'label' => emt('Signup date'),
246 'format' => ( $conf->config('date_format') || "%m/%d/%Y" ),
251 % # permission to edit ticket subjects
252 % if ( $conf->exists('ticket_system-selfservice_edit_subject') ) {
255 <INPUT TYPE="checkbox" NAME="edit_subject" VALUE="Y" <%
256 $cust_main->edit_subject ? 'CHECKED' : '' %>></TD>
257 <TD ALIGN="left"><% mt('Can edit ticket subjects') |h %></TD>
260 <INPUT TYPE="hidden" NAME="edit_subject" VALUE="<% $cust_main->edit_subject %>">
263 % # permission to edit
264 % if ( $conf->exists('cust_main-edit_calling_list_exempt') ) {
267 <INPUT TYPE="checkbox" NAME="calling_list_exempt" VALUE="Y" <%
268 $cust_main->calling_list_exempt ? 'CHECKED' : '' %>></TD>
269 <TD ALIGN="left"><% mt('Calling list exempt') |h %></TD>
272 <INPUT TYPE="hidden" NAME="calling_list_exempt" VALUE="<% $cust_main->calling_list_exempt %>">
279 my( $cust_main, %opt ) = @_;
281 my $custnum = $opt{'custnum'};
283 my $conf = new FS::Conf;
285 if ( $cgi->param('error') ) {
286 $cust_main->set('residential_commercial',
287 ($cgi->param('residential_commercial') eq 'Commercial')
291 } elsif ( $custnum ) { #editing
292 $cust_main->set('residential_commercial',
293 length($cust_main->company)
297 } else { #new customer
298 $cust_main->set('residential_commercial',
299 $conf->exists('cust_main-default_commercial')
305 my $curuser = $FS::CurrentUser::CurrentUser;
307 my $r = qq!<font color="#ff0000">*</font> !;
309 # which agents lock the service address, if any
310 my %ship_locked_agents;
311 foreach (qsearch('agent',{})) {
312 my $agentnum = $_->agentnum;
313 next unless $conf->exists('agent-ship_address', $_->agentnum);
314 my $cust_main = $_->agent_cust_main or next;
315 my $agent_ship_location = $cust_main->ship_location;
316 $ship_locked_agents{$agentnum} = +{
317 map { $_ => $agent_ship_location->$_ }
319 qw(locationname address1 state zip country latitude longitude district),
320 ($conf->exists('cust_main-no_city_in_address') ? () : 'city')