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 % unless ( $cust_main->ship_last && $same ne 'Y' ) {
49 % $same_checked = 'CHECKED';
50 % $ship_disabled = 'DISABLED STYLE="background-color: #dddddd"';
52 % qw( last first company address1 address2 city county state zip country
55 % $cust_main->set("ship_$_", $cust_main->get($_) );
60 <FONT SIZE="+1"><B>Billing address</B></FONT>
62 <% include('cust_main/contact.html',
63 'cust_main' => $cust_main,
65 'onchange' => 'bill_changed(this)',
68 'stateid' => $stateid,
69 'same_checked' => $same_checked, #for address2 "Unit #" labeling
74 function bill_changed(what) {
75 if ( what.form.same.checked ) {
76 % for (qw( last first company address1 address2 city zip daytime night fax )) {
78 what.form.ship_<%$_%>.value = what.form.<%$_%>.value;
81 what.form.ship_country.selectedIndex = what.form.country.selectedIndex;
83 function fix_ship_county() {
84 what.form.ship_county.selectedIndex = what.form.county.selectedIndex;
87 function fix_ship_state() {
88 what.form.ship_state.selectedIndex = what.form.state.selectedIndex;
89 ship_state_changed(what.form.ship_state, fix_ship_county );
92 ship_country_changed(what.form.ship_country, fix_ship_state );
96 function samechanged(what) {
100 % for (qw( last first company address1 address2 city county state zip country daytime night fax )) {
101 what.form.ship_<%$_%>.disabled = true;
102 what.form.ship_<%$_%>.style.backgroundColor = '#dddddd';
105 % if ( $conf->exists('cust_main-require_address2') ) {
106 document.getElementById('address2_required').style.visibility = '';
107 document.getElementById('address2_label').style.visibility = '';
108 document.getElementById('ship_address2_required').style.visibility = 'hidden';
109 document.getElementById('ship_address2_label').style.visibility = 'hidden';
114 % for (qw( last first company address1 address2 city county state zip country daytime night fax )) {
115 what.form.ship_<%$_%>.disabled = false;
116 what.form.ship_<%$_%>.style.backgroundColor = '#ffffff';
119 % if ( $conf->exists('cust_main-require_address2') ) {
120 document.getElementById('address2_required').style.visibility = 'hidden';
121 document.getElementById('address2_label').style.visibility = 'hidden';
122 document.getElementById('ship_address2_required').style.visibility = '';
123 document.getElementById('ship_address2_label').style.visibility = '';
131 <FONT SIZE="+1"><B>Service address</B></FONT>
133 (<INPUT TYPE="checkbox" NAME="same" VALUE="Y" onClick="samechanged(this)" <%$same_checked%>>same as billing address)
134 <% include('cust_main/contact.html',
135 'cust_main' => $cust_main,
138 'disabled' => $ship_disabled,
143 <% include( 'cust_main/billing.html', $cust_main,
144 'payinfo' => $payinfo,
145 'invoicing_list' => \@invoicing_list,
149 % my $ro_comments = $conf->exists('cust_main-use_comments')?'':'readonly';
150 % if (!$ro_comments || $cust_main->comments) {
153 <% &ntable("#cccccc") %>
156 <TEXTAREA NAME = "comments"
161 ><% $cust_main->comments %></TEXTAREA>
168 % unless ( $custnum ) {
170 <% include('cust_main/first_pkg.html', $cust_main,
171 'pkgpart_svcpart' => $pkgpart_svcpart,
173 'username' => $username,
174 'password' => $password,
176 'saved_domsvc' => $saved_domsvc,
183 <INPUT TYPE="hidden" NAME="otaker" VALUE="<% $cust_main->otaker %>">
185 %# cust_main/bottomfixup.js
186 % foreach my $hidden (
188 % 'payinfo', 'payinfo1', 'payinfo2', 'paytype',
189 % 'payname', 'paystate', 'exp_month', 'exp_year', 'paycvv',
190 % 'paystart_month', 'paystart_year', 'payissue',
194 <INPUT TYPE="hidden" NAME="<% $hidden %>" VALUE="">
197 <% include('cust_main/bottomfixup.html') %>
200 <INPUT TYPE = "button"
201 NAME = "submitButton"
203 VALUE = "<% $custnum ? "Apply Changes" : "Add Customer" %>"
204 onClick = "this.disabled=true; bottomfixup(this.form);"
208 <% include('/elements/footer.html') %>
212 my $curuser = $FS::CurrentUser::CurrentUser;
214 #probably redundant given the checks below...
216 unless $curuser->access_right('New customer')
217 || $curuser->access_right('Edit customer');
219 my $conf = new FS::Conf;
223 my($custnum, $cust_main, $ss, $stateid, $payinfo, @invoicing_list);
225 my $pkgpart_svcpart = ''; #first_pkg
226 my($username, $password, $popnum, $saved_domsvc) = ( '', '', 0, 0 ); #svc_acct
229 if ( $cgi->param('error') ) {
231 $cust_main = new FS::cust_main ( {
232 map { $_, scalar($cgi->param($_)) } fields('cust_main')
235 $custnum = $cust_main->custnum;
238 unless $curuser->access_right($custnum ? 'Edit customer' : 'New customer');
240 @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') );
241 $same = $cgi->param('same');
242 $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid');
243 $ss = $cust_main->ss; # don't mask an entered value on errors
244 $stateid = $cust_main->stateid; # don't mask an entered value on errors
245 $payinfo = $cust_main->payinfo; # don't mask an entered value on errors
247 $pkgpart_svcpart = $cgi->param('pkgpart_svcpart') || '';
250 $username = $cgi->param('username');
251 $password = $cgi->param('_password');
252 $popnum = $cgi->param('popnum');
253 $saved_domsvc = $cgi->param('domsvc') || '';
254 if ( $saved_domsvc =~ /^(\d+)$/ ) {
261 $svc_phone{$_} = $cgi->param($_)
262 foreach qw( countrycode phonenum sip_password pin phone_name );
264 } elsif ( $cgi->keywords ) { #editing
267 unless $curuser->access_right('Edit customer');
269 my( $query ) = $cgi->keywords;
272 $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
273 if ( $cust_main->dbdef_table->column('paycvv')
274 && length($cust_main->paycvv) ) {
275 my $paycvv = $cust_main->paycvv;
277 $cust_main->paycvv($paycvv);
279 @invoicing_list = $cust_main->invoicing_list;
280 $ss = $cust_main->masked('ss');
281 $stateid = $cust_main->masked('stateid');
282 $payinfo = $cust_main->paymask;
284 } else { #new customer
287 unless $curuser->access_right('New customer');
290 $cust_main = new FS::cust_main ( {} );
291 $cust_main->otaker( &getotaker );
292 $cust_main->referral_custnum( $cgi->param('referral_custnum') );
293 @invoicing_list = ();
294 push @invoicing_list, 'POST'
295 unless $conf->exists('disablepostalinvoicedefault');
302 my $error = $cgi->param('error');
304 $cgi->param('error', $error);
306 my $action = $custnum ? 'Edit' : 'Add';
307 $action .= ": ". $cust_main->name if $custnum;
309 my $r = qq!<font color="#ff0000">*</font> !;