1 <% include('/elements/header.html',
4 ' onUnload="myclose()"' #hmm, in billing.html
7 <% include('/elements/error.html') %>
9 <FORM NAME = "CustomerForm"
11 ACTION = "<% popurl(1) %>process/cust_main.cgi"
12 %# STYLE = "margin-bottom: 0"
13 %# STYLE="margin-top: 0; margin-bottom: 0">
16 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
19 Customer #<B><% $cust_main->display_custnum %></B> -
20 <B><FONT COLOR="#<% $cust_main->statuscolor %>">
21 <% ucfirst($cust_main->status) %>
26 %# agent, agent_custid, refnum (advertising source), referral_custnum
27 <% include('cust_main/top_misc.html', $cust_main, 'custnum' => $custnum ) %>
30 % if ( $conf->exists('cust_main-enable_birthdate') ) {
32 <% include('cust_main/birthdate.html', $cust_main) %>
35 %# latitude and longitude
36 % if ( $conf->exists('cust_main-require_censustract') ) {
37 % my ($latitude, $longitude) = $cust_main->service_coordinates;
38 % $latitude ||= $conf->config('company_latitude') || '';
39 % $longitude ||= $conf->config('company_longitude') || '';
40 <INPUT NAME="latitude" TYPE="hidden" VALUE="<% $latitude |h %>">
41 <INPUT NAME="longitude" TYPE="hidden" VALUE="<% $longitude |h %>">
46 % my $same_checked = '';
47 % my $ship_disabled = '';
48 % my @ship_style = ();
49 % unless ( $cust_main->ship_last && $same ne 'Y' ) {
50 % $same_checked = 'CHECKED';
51 % $ship_disabled = 'DISABLED';
52 % push @ship_style, 'background-color:#dddddd';
54 % qw( last first company address1 address2 city county state zip country
57 % $cust_main->set("ship_$_", $cust_main->get($_) );
62 <FONT SIZE="+1"><B>Billing address</B></FONT>
64 <% include('cust_main/contact.html',
65 'cust_main' => $cust_main,
67 'onchange' => 'bill_changed(this)',
70 'stateid' => $stateid,
71 'same_checked' => $same_checked, #for address2 "Unit #" labeling
76 function bill_changed(what) {
77 if ( what.form.same.checked ) {
78 % for (qw( last first company address1 address2 city zip daytime night fax )) {
79 what.form.ship_<%$_%>.value = what.form.<%$_%>.value;
82 what.form.ship_country.selectedIndex = what.form.country.selectedIndex;
84 function fix_ship_city() {
85 what.form.ship_city_select.selectedIndex = what.form.city_select.selectedIndex;
86 what.form.ship_city.style.display = what.form.city.style.display;
87 what.form.ship_city_select.style.display = what.form.city_select.style.display;
90 function fix_ship_county() {
91 what.form.ship_county.selectedIndex = what.form.county.selectedIndex;
92 ship_county_changed(what.form.ship_county, fix_ship_city );
95 function fix_ship_state() {
96 what.form.ship_state.selectedIndex = what.form.state.selectedIndex;
97 ship_state_changed(what.form.ship_state, fix_ship_county );
100 ship_country_changed(what.form.ship_country, fix_ship_state );
104 function samechanged(what) {
105 if ( what.checked ) {
108 % my @fields = qw( last first company address1 address2 city city_select county state zip country daytime night fax );
110 what.form.ship_<%$_%>.disabled = true;
111 what.form.ship_<%$_%>.style.backgroundColor = '#dddddd';
114 % if ( $conf->exists('cust_main-require_address2') ) {
115 document.getElementById('address2_required').style.visibility = '';
116 document.getElementById('address2_label').style.visibility = '';
117 document.getElementById('ship_address2_required').style.visibility = 'hidden';
118 document.getElementById('ship_address2_label').style.visibility = 'hidden';
124 what.form.ship_<%$_%>.disabled = false;
125 what.form.ship_<%$_%>.style.backgroundColor = '#ffffff';
128 % if ( $conf->exists('cust_main-require_address2') ) {
129 document.getElementById('address2_required').style.visibility = 'hidden';
130 document.getElementById('address2_label').style.visibility = 'hidden';
131 document.getElementById('ship_address2_required').style.visibility = '';
132 document.getElementById('ship_address2_label').style.visibility = '';
140 <FONT SIZE="+1"><B>Service address</B></FONT>
142 (<INPUT TYPE="checkbox" NAME="same" VALUE="Y" onClick="samechanged(this)" <%$same_checked%>>same as billing address)
143 <% include('cust_main/contact.html',
144 'cust_main' => $cust_main,
147 'disabled' => $ship_disabled,
148 'style' => \@ship_style
153 <% include( 'cust_main/billing.html', $cust_main,
154 'payinfo' => $payinfo,
155 'invoicing_list' => \@invoicing_list,
159 % my $ro_comments = $conf->exists('cust_main-use_comments')?'':'readonly';
160 % if (!$ro_comments || $cust_main->comments) {
163 <% &ntable("#cccccc") %>
166 <TEXTAREA NAME = "comments"
171 ><% $cust_main->comments %></TEXTAREA>
178 % unless ( $custnum ) {
180 <% include('cust_main/first_pkg.html', $cust_main,
181 'pkgpart_svcpart' => $pkgpart_svcpart,
183 'username' => $username,
184 'password' => $password,
186 'saved_domsvc' => $saved_domsvc,
193 <INPUT TYPE="hidden" NAME="usernum" VALUE="<% $cust_main->usernum %>">
195 %# cust_main/bottomfixup.js
196 % foreach my $hidden (
198 % 'payinfo', 'payinfo1', 'payinfo2', 'paytype',
199 % 'payname', 'paystate', 'exp_month', 'exp_year', 'paycvv',
200 % 'paystart_month', 'paystart_year', 'payissue',
204 <INPUT TYPE="hidden" NAME="<% $hidden %>" VALUE="">
207 <% include('cust_main/bottomfixup.html') %>
210 <INPUT TYPE = "button"
211 NAME = "submitButton"
213 VALUE = "<% $custnum ? "Apply Changes" : "Add Customer" %>"
214 onClick = "this.disabled=true; bottomfixup(this.form);"
218 <% include('/elements/footer.html') %>
222 my $curuser = $FS::CurrentUser::CurrentUser;
224 #probably redundant given the checks below...
226 unless $curuser->access_right('New customer')
227 || $curuser->access_right('Edit customer');
229 my $conf = new FS::Conf;
233 my($custnum, $cust_main, $ss, $stateid, $payinfo, @invoicing_list);
235 my $pkgpart_svcpart = ''; #first_pkg
236 my($username, $password, $popnum, $saved_domsvc) = ( '', '', 0, 0 ); #svc_acct
239 if ( $cgi->param('error') ) {
241 $cust_main = new FS::cust_main ( {
242 map { $_, scalar($cgi->param($_)) } fields('cust_main')
245 $custnum = $cust_main->custnum;
248 unless $curuser->access_right($custnum ? 'Edit customer' : 'New customer');
250 @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') );
251 $same = $cgi->param('same');
252 $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid');
253 $ss = $cust_main->ss; # don't mask an entered value on errors
254 $stateid = $cust_main->stateid; # don't mask an entered value on errors
255 $payinfo = $cust_main->payinfo; # don't mask an entered value on errors
257 $pkgpart_svcpart = $cgi->param('pkgpart_svcpart') || '';
260 $username = $cgi->param('username');
261 $password = $cgi->param('_password');
262 $popnum = $cgi->param('popnum');
263 $saved_domsvc = $cgi->param('domsvc') || '';
264 if ( $saved_domsvc =~ /^(\d+)$/ ) {
271 $svc_phone{$_} = $cgi->param($_)
272 foreach qw( countrycode phonenum sip_password pin phone_name );
274 } elsif ( $cgi->keywords ) { #editing
277 unless $curuser->access_right('Edit customer');
279 my( $query ) = $cgi->keywords;
282 $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
283 if ( $cust_main->dbdef_table->column('paycvv')
284 && length($cust_main->paycvv) ) {
285 my $paycvv = $cust_main->paycvv;
287 $cust_main->paycvv($paycvv);
289 @invoicing_list = $cust_main->invoicing_list;
290 $ss = $cust_main->masked('ss');
291 $stateid = $cust_main->masked('stateid');
292 $payinfo = $cust_main->paymask;
294 } else { #new customer
297 unless $curuser->access_right('New customer');
300 $cust_main = new FS::cust_main ( {} );
301 $cust_main->otaker( &getotaker );
302 $cust_main->referral_custnum( $cgi->param('referral_custnum') );
303 @invoicing_list = ();
304 push @invoicing_list, 'POST'
305 unless $conf->exists('disablepostalinvoicedefault');
312 my $error = $cgi->param('error');
314 $cgi->param('error', $error);
316 my $title = $custnum ? 'Edit Customer' : 'Add Customer';
317 $title .= ": ". $cust_main->name if $custnum;
319 my $r = qq!<font color="#ff0000">*</font> !;