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' : '' %>
23 <SCRIPT TYPE="text/javascript">
24 function rescom_changed(what) {
25 if ( what.checked == (what.value == 'Commercial' ) ) {
26 document.getElementById('company_row').style.display = '';
27 document.getElementById('contacts_div').style.display = '';
29 if ( document.getElementById('company').value.length == 0 ) {
30 document.getElementById('company_row').style.display = 'none';
32 document.getElementById('contacts_div').style.display = 'none';
36 var ship_locked_agents = <% encode_json(\%ship_locked_agents) %>;
37 var ship_fields = ['address1', 'city', 'state', 'zip', 'country',
38 'latitude', 'longitude', 'district'];
39 function agent_changed(what) {
40 var agentnum = what.value;
42 if ( ship_locked_agents[agentnum] ) {
43 % # For this agent, the service location (except address2)
44 % # should be locked to the agent's location.
45 % # Set the ship_ fields to those values (just for display) and
46 % # then disable them.
47 for(var x in ship_locked_agents[agentnum]) {
48 f['ship_'+x].value = ship_locked_agents[agentnum][x];
49 f['ship_'+x].disabled = true;
51 f['same'].checked = false;
52 f['same'].disabled = true;
54 % # Unlock the ship_ location fields. If they were previously
55 % # disabled, then they contain some agent's address, which is
56 % # no longer meaningful. So set them back to the customer's
58 for(var i=0; i<ship_fields.length; i++) {
60 if ( f['ship_'+x].disabled ) {
61 f['ship_'+x].value = f['old_ship_'+x].value;
63 f['ship_'+x].disabled = false;
65 f['same'].disabled = false;
67 samechanged(f['same']);
69 <&| /elements/onload.js &>
70 agent_changed(document.getElementById('agentnum'))
75 % foreach my $field ($cust_main->virtual_fields) {
76 <% $cust_main->pvf($field)->widget('HTML', 'edit',$cust_main->getfield($field)) %>
80 <& /elements/tr-select-cust_tag.html,
81 'custnum' => $custnum,
86 % if ( $cgi->param('lock_agentnum') =~ /^(\d+)$/ && $curuser->agentnum($1) ) {
89 % $cust_main->agentnum($agentnum);
91 <INPUT TYPE="hidden" NAME="lock_agentnum" VALUE="<% $agentnum %>">
92 <INPUT TYPE="hidden" NAME="agentnum" ID="agentnum"
93 VALUE="<% $agentnum %>">
95 <TD ALIGN="right"><% mt('Agent') |h %></TD>
96 <TD CLASS="fsdisabled"><% $cust_main->agent->agent |h %></TD>
101 <& /elements/tr-select-agent.html,
102 'curr_value' => $cust_main->agentnum,
103 'label' => "<B>${r}".emt('Agent')."</B>",
104 'empty_label' => emt('Select agent'),
105 'disable_empty' => ( $cust_main->agentnum ? 1 : 0 ),
106 'viewall_right' => emt('None'),
107 'onchange' => 'agent_changed(this)',
113 % if ( $conf->exists('cust_main-edit_agent_custid') ) {
116 <TD ALIGN="right"><% mt('Customer identifier') |h %></TD>
117 <TD><INPUT TYPE="text" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>"></TD>
122 <INPUT TYPE="hidden" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>">
127 <& /elements/tr-select-cust_class.html,
128 'curr_value' => $cust_main->classnum,
129 'label' => emt("Class"),
133 <& /elements/tr-select-sales.html,
134 'curr_value' => $cust_main->salesnum,
137 %# referral (advertising source)
138 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
139 %if ( $custnum && ! $conf->exists('editreferrals') ) {
141 <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
145 <& /elements/tr-select-part_referral.html,
146 'curr_value' => $refnum
151 %# referring customer
152 %my $referring_cust_main = '';
153 %if ( $cust_main->referral_custnum
154 % and $referring_cust_main =
155 % qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
156 % and ! $curuser->access_right('Edit referring customer')
160 <TD ALIGN="right"><% mt('Referring customer') |h %></TD>
162 <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name |h %></A>
165 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
167 % } elsif ( ! $conf->exists('disable_customer_referrals') ) {
170 <TD ALIGN="right"><% mt('Referring customer') |h %></TD>
172 <& /elements/search-cust_main.html,
173 'field_name' => 'referral_custnum',
174 'curr_value' => $cust_main->referral_custnum,
180 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
184 % if ( $conf->exists('cust_main-edit_signupdate') ) {
185 <& /elements/tr-input-date-field.html, {
186 'name' => 'signupdate',
187 'value' => $cust_main->signupdate,
188 'label' => emt('Signup date'),
189 'format' => ( $conf->config('date_format') || "%m/%d/%Y" ),
194 % # permission to edit ticket subjects
195 % if ( $conf->exists('ticket_system-selfservice_edit_subject') ) {
198 <INPUT TYPE="checkbox" NAME="edit_subject" VALUE="Y" <%
199 $cust_main->edit_subject ? 'CHECKED' : '' %>></TD>
200 <TD ALIGN="left"><% mt('Can edit ticket subjects') |h %></TD>
203 <INPUT TYPE="hidden" NAME="edit_subject" VALUE="<% $cust_main->edit_subject %>">
206 % # permission to edit
207 % if ( $conf->exists('cust_main-edit_calling_list_exempt') ) {
210 <INPUT TYPE="checkbox" NAME="calling_list_exempt" VALUE="Y" <%
211 $cust_main->calling_list_exempt ? 'CHECKED' : '' %>></TD>
212 <TD ALIGN="left"><% mt('Calling list exempt') |h %></TD>
215 <INPUT TYPE="hidden" NAME="calling_list_exempt" VALUE="<% $cust_main->calling_list_exempt %>">
222 my( $cust_main, %opt ) = @_;
224 my $custnum = $opt{'custnum'};
226 if ( $cgi->param('error') ) {
227 $cust_main->set('residential_commercial',
228 ($cgi->param('residential_commercial') eq 'Commercial')
232 } elsif ( $custnum ) { #editing
233 $cust_main->set('residential_commercial',
234 length($cust_main->company)
238 } else { #new customer
239 #config to default to commercial and/or disable residential when someone needs
240 $cust_main->set('residential_commercial', 'Residential');
243 my $conf = new FS::Conf;
245 my $curuser = $FS::CurrentUser::CurrentUser;
247 my $r = qq!<font color="#ff0000">*</font> !;
249 # which agents lock the service address, if any
250 my %ship_locked_agents;
251 foreach (qsearch('agent',{})) {
252 my $agentnum = $_->agentnum;
253 next unless $conf->exists('agent-ship_address', $_->agentnum);
254 my $cust_main = $_->agent_cust_main or next;
255 my $agent_ship_location = $cust_main->ship_location;
256 $ship_locked_agents{$agentnum} = +{
257 map { $_ => $agent_ship_location->$_ }
258 qw(address1 city state zip country latitude longitude district)