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 document.getElementById('company_row').style.display = '';
29 document.getElementById('contacts_div').style.display = '';
30 document.getElementById('spouse_row').style.display = 'none';
32 if ( document.getElementById('company').value.length == 0 ) {
33 document.getElementById('company_row').style.display = 'none';
35 document.getElementById('contacts_div').style.display = 'none';
36 document.getElementById('spouse_row').style.display = '';
41 var ship_locked_agents = <% encode_json(\%ship_locked_agents) %>;
43 'locationname', 'address1',<% $conf->exists('cust_main-no_city_in_address') ? '' : q( 'city',) %> 'state', 'zip', 'country',
44 'latitude', 'longitude', 'district'
47 function agent_changed(what) {
48 var agentnum = what.value;
50 % # unlock/lock service location
53 if ( ship_locked_agents[agentnum] ) {
54 % # For this agent, the service location (except address2)
55 % # should be locked to the agent's location.
56 % # Set the ship_ fields to those values (just for display) and
57 % # then disable them.
58 for(var x in ship_locked_agents[agentnum]) {
59 f['ship_'+x].value = ship_locked_agents[agentnum][x];
60 f['ship_'+x].disabled = true;
62 f['same'].checked = false;
63 f['same'].disabled = true;
65 % # Unlock the ship_ location fields. If they were previously
66 % # disabled, then they contain some agent's address, which is
67 % # no longer meaningful. So set them back to the customer's
69 for(var i=0; i<ship_fields.length; i++) {
71 if ( f['ship_'+x].disabled ) {
72 f['ship_'+x].value = f['old_ship_'+x].value;
74 f['ship_'+x].disabled = false;
76 f['same'].disabled = false;
78 samechanged(f['same']);
80 % # update sales dropdown
81 salesnum_agentnum_changed(what);
85 <&| /elements/onload.js &>
86 rescom_changed(document.getElementById('residential_commercial_Residential'));
87 agent_changed(document.getElementById('agentnum'))
92 % foreach my $field ($cust_main->virtual_fields) {
93 <% $cust_main->pvf($field)->widget('HTML', 'edit',$cust_main->getfield($field)) %>
97 <& /elements/tr-select-cust_tag.html,
98 'custnum' => $custnum,
103 % if ( $cgi->param('lock_agentnum') =~ /^(\d+)$/ && $curuser->agentnum($1) ) {
106 % $cust_main->agentnum($agentnum);
108 <INPUT TYPE="hidden" NAME="lock_agentnum" VALUE="<% $agentnum %>">
109 <INPUT TYPE="hidden" NAME="agentnum" ID="agentnum"
110 VALUE="<% $agentnum %>">
112 <TD ALIGN="right"><% mt('Agent') |h %></TD>
113 <TD CLASS="fsdisabled"><% $cust_main->agent->agent |h %></TD>
118 <& /elements/tr-select-agent.html,
119 'curr_value' => $cust_main->agentnum,
120 'label' => "<B>${r}".emt('Agent')."</B>",
121 'empty_label' => emt('Select agent'),
122 'disable_empty' => ( $cust_main->agentnum ? 1 : 0 ),
123 'viewall_right' => emt('None'),
124 'onchange' => 'agent_changed(this)',
130 % if ( $conf->exists('cust_main-edit_agent_custid') ) {
133 <TD ALIGN="right"><% mt('Customer identifier') |h %></TD>
134 <TD><INPUT TYPE="text" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>"></TD>
139 <INPUT TYPE="hidden" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>">
144 % my $rclass = $conf->exists('cust_main-require_classnum') ? $r : '';
145 <& /elements/tr-select-cust_class.html,
146 'curr_value' => $cust_main->classnum,
147 'label' => $rclass . emt("Class"),
148 'empty_label' => $rclass ? 'Select class' : '(none)',
149 'disable_empty' => ($rclass && $cust_main->classnum) ? 1 : 0,
153 <& /elements/tr-select-sales.html,
154 'curr_value' => $cust_main->salesnum,
157 %# referral (advertising source)
158 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
159 %if ( $custnum && ! $conf->exists('editreferrals') ) {
161 <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
165 <& /elements/tr-select-part_referral.html,
166 'curr_value' => $refnum,
167 'label' => "<B>${r}".emt('Advertising source')."</B>"
172 %# referring customer
173 %my $referring_cust_main = '';
174 %if ( $cust_main->referral_custnum
175 % and $referring_cust_main =
176 % qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
177 % and ! $curuser->access_right('Edit referring customer')
181 <TD ALIGN="right"><% mt('Referring customer') |h %></TD>
183 <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name |h %></A>
186 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
188 % } elsif ( ! $conf->exists('disable_customer_referrals') ) {
191 <TD ALIGN="right"><% mt('Referring customer') |h %></TD>
193 <& /elements/search-cust_main.html,
194 'field_name' => 'referral_custnum',
195 'curr_value' => $cust_main->referral_custnum,
201 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
205 % if ( $conf->exists('cust_main-edit_signupdate') ) {
206 <& /elements/tr-input-date-field.html, {
207 'name' => 'signupdate',
208 'value' => $cust_main->signupdate,
209 'label' => emt('Signup date'),
210 'format' => ( $conf->config('date_format') || "%m/%d/%Y" ),
215 % # permission to edit ticket subjects
216 % if ( $conf->exists('ticket_system-selfservice_edit_subject') ) {
219 <INPUT TYPE="checkbox" NAME="edit_subject" VALUE="Y" <%
220 $cust_main->edit_subject ? 'CHECKED' : '' %>></TD>
221 <TD ALIGN="left"><% mt('Can edit ticket subjects') |h %></TD>
224 <INPUT TYPE="hidden" NAME="edit_subject" VALUE="<% $cust_main->edit_subject %>">
227 % # permission to edit
228 % if ( $conf->exists('cust_main-edit_calling_list_exempt') ) {
231 <INPUT TYPE="checkbox" NAME="calling_list_exempt" VALUE="Y" <%
232 $cust_main->calling_list_exempt ? 'CHECKED' : '' %>></TD>
233 <TD ALIGN="left"><% mt('Calling list exempt') |h %></TD>
236 <INPUT TYPE="hidden" NAME="calling_list_exempt" VALUE="<% $cust_main->calling_list_exempt %>">
243 my( $cust_main, %opt ) = @_;
245 my $custnum = $opt{'custnum'};
247 my $conf = new FS::Conf;
249 if ( $cgi->param('error') ) {
250 $cust_main->set('residential_commercial',
251 ($cgi->param('residential_commercial') eq 'Commercial')
255 } elsif ( $custnum ) { #editing
256 $cust_main->set('residential_commercial',
257 length($cust_main->company)
261 } else { #new customer
262 $cust_main->set('residential_commercial',
263 $conf->exists('cust_main-default_commercial')
269 my $curuser = $FS::CurrentUser::CurrentUser;
271 my $r = qq!<font color="#ff0000">*</font> !;
273 # which agents lock the service address, if any
274 my %ship_locked_agents;
275 foreach (qsearch('agent',{})) {
276 my $agentnum = $_->agentnum;
277 next unless $conf->exists('agent-ship_address', $_->agentnum);
278 my $cust_main = $_->agent_cust_main or next;
279 my $agent_ship_location = $cust_main->ship_location;
280 $ship_locked_agents{$agentnum} = +{
281 map { $_ => $agent_ship_location->$_ }
283 qw(locationname address1 state zip country latitude longitude district),
284 ($conf->exists('cust_main-no_city_in_address') ? () : 'city')