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 window.onload = function() {
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"),
132 %# referral (advertising source)
133 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
134 %if ( $custnum && ! $conf->exists('editreferrals') ) {
136 <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
140 <& /elements/tr-select-part_referral.html,
141 'curr_value' => $refnum
146 %# referring customer
147 %my $referring_cust_main = '';
148 %if ( $cust_main->referral_custnum
149 % and $referring_cust_main =
150 % qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
151 % and ! $curuser->access_right('Edit referring customer')
155 <TD ALIGN="right"><% mt('Referring customer') |h %></TD>
157 <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name |h %></A>
160 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
162 % } elsif ( ! $conf->exists('disable_customer_referrals') ) {
165 <TD ALIGN="right"><% mt('Referring customer') |h %></TD>
167 <& /elements/search-cust_main.html,
168 'field_name' => 'referral_custnum',
169 'curr_value' => $cust_main->referral_custnum,
175 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
179 % if ( $conf->exists('cust_main-edit_signupdate') ) {
180 <& /elements/tr-input-date-field.html, {
181 'name' => 'signupdate',
182 'value' => $cust_main->signupdate,
183 'label' => emt('Signup date'),
184 'format' => ( $conf->config('date_format') || "%m/%d/%Y" ),
189 % # permission to edit ticket subjects
190 % if ( $conf->exists('ticket_system-selfservice_edit_subject') ) {
193 <INPUT TYPE="checkbox" NAME="edit_subject" VALUE="Y" <%
194 $cust_main->edit_subject ? 'CHECKED' : '' %>></TD>
195 <TD ALIGN="left"><% mt('Can edit ticket subjects') |h %></TD>
198 <INPUT TYPE="hidden" NAME="edit_subject" VALUE="<% $cust_main->edit_subject %>">
201 % # permission to edit
202 % if ( $conf->exists('cust_main-edit_calling_list_exempt') ) {
205 <INPUT TYPE="checkbox" NAME="calling_list_exempt" VALUE="Y" <%
206 $cust_main->calling_list_exempt ? 'CHECKED' : '' %>></TD>
207 <TD ALIGN="left"><% mt('Calling list exempt') |h %></TD>
210 <INPUT TYPE="hidden" NAME="calling_list_exempt" VALUE="<% $cust_main->calling_list_exempt %>">
217 my( $cust_main, %opt ) = @_;
219 my $custnum = $opt{'custnum'};
221 if ( $cgi->param('error') ) {
222 $cust_main->set('residential_commercial',
223 ($cgi->param('residential_commercial') eq 'Commercial')
227 } elsif ( $custnum ) { #editing
228 $cust_main->set('residential_commercial',
229 length($cust_main->company)
233 } else { #new customer
234 #config to default to commercial and/or disable residential when someone needs
235 $cust_main->set('residential_commercial', 'Residential');
238 my $conf = new FS::Conf;
240 my $curuser = $FS::CurrentUser::CurrentUser;
242 my $r = qq!<font color="#ff0000">*</font> !;
244 # which agents lock the service address, if any
245 my %ship_locked_agents;
246 foreach (qsearch('agent',{})) {
247 my $agentnum = $_->agentnum;
248 next unless $conf->exists('agent-ship_address', $_->agentnum);
249 my $cust_main = $_->agent_cust_main or next;
250 my $agent_ship_location = $cust_main->ship_location;
251 $ship_locked_agents{$agentnum} = +{
252 map { $_ => $agent_ship_location->$_ }
253 qw(address1 city state zip country latitude longitude district)