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) %>
37 % my $same_checked = '';
38 % my $ship_disabled = '';
39 % unless ( $cust_main->ship_last && $same ne 'Y' ) {
40 % $same_checked = 'CHECKED';
41 % $ship_disabled = 'DISABLED STYLE="background-color: #dddddd"';
43 % qw( last first company address1 address2 city county state zip country
46 % $cust_main->set("ship_$_", $cust_main->get($_) );
51 <FONT SIZE="+1"><B>Billing address</B></FONT>
53 <% include('cust_main/contact.html',
54 'cust_main' => $cust_main,
56 'onchange' => 'bill_changed(this)',
59 'stateid' => $stateid,
60 'same_checked' => $same_checked, #for address2 "Unit #" labeling
65 function bill_changed(what) {
66 if ( what.form.same.checked ) {
67 % for (qw( last first company address1 address2 city zip daytime night fax )) {
69 what.form.ship_<%$_%>.value = what.form.<%$_%>.value;
72 what.form.ship_country.selectedIndex = what.form.country.selectedIndex;
74 function fix_ship_county() {
75 what.form.ship_county.selectedIndex = what.form.county.selectedIndex;
78 function fix_ship_state() {
79 what.form.ship_state.selectedIndex = what.form.state.selectedIndex;
80 ship_state_changed(what.form.ship_state, fix_ship_county );
83 ship_country_changed(what.form.ship_country, fix_ship_state );
87 function samechanged(what) {
91 % for (qw( last first company address1 address2 city county state zip country daytime night fax )) {
92 what.form.ship_<%$_%>.disabled = true;
93 what.form.ship_<%$_%>.style.backgroundColor = '#dddddd';
96 % if ( $conf->exists('cust_main-require_address2') ) {
97 document.getElementById('address2_required').style.visibility = '';
98 document.getElementById('address2_label').style.visibility = '';
99 document.getElementById('ship_address2_required').style.visibility = 'hidden';
100 document.getElementById('ship_address2_label').style.visibility = 'hidden';
105 % for (qw( last first company address1 address2 city county state zip country daytime night fax )) {
106 what.form.ship_<%$_%>.disabled = false;
107 what.form.ship_<%$_%>.style.backgroundColor = '#ffffff';
110 % if ( $conf->exists('cust_main-require_address2') ) {
111 document.getElementById('address2_required').style.visibility = 'hidden';
112 document.getElementById('address2_label').style.visibility = 'hidden';
113 document.getElementById('ship_address2_required').style.visibility = '';
114 document.getElementById('ship_address2_label').style.visibility = '';
122 <FONT SIZE="+1"><B>Service address</B></FONT>
124 (<INPUT TYPE="checkbox" NAME="same" VALUE="Y" onClick="samechanged(this)" <%$same_checked%>>same as billing address)
125 <% include('cust_main/contact.html',
126 'cust_main' => $cust_main,
129 'disabled' => $ship_disabled,
134 <% include( 'cust_main/billing.html', $cust_main,
135 'payinfo' => $payinfo,
136 'invoicing_list' => \@invoicing_list,
140 % my $ro_comments = $conf->exists('cust_main-use_comments')?'':'readonly';
141 % if (!$ro_comments || $cust_main->comments) {
144 <% &ntable("#cccccc") %>
147 <TEXTAREA NAME = "comments"
152 ><% $cust_main->comments %></TEXTAREA>
159 % unless ( $custnum ) {
161 <% include('cust_main/first_pkg.html', $cust_main,
162 'pkgpart_svcpart' => $pkgpart_svcpart,
164 'username' => $username,
165 'password' => $password,
167 'saved_domsvc' => $saved_domsvc,
174 <INPUT TYPE="hidden" NAME="otaker" VALUE="<% $cust_main->otaker %>">
176 % foreach my $hidden (
178 % 'payinfo', 'payinfo1', 'payinfo2', 'paytype',
179 % 'payname', 'paystate', 'exp_month', 'exp_year', 'paycvv',
180 % 'paystart_month', 'paystart_year', 'payissue',
184 <INPUT TYPE="hidden" NAME="<% $hidden %>" VALUE="">
187 <% include('cust_main/bottomfixup.html') %>
190 <INPUT TYPE = "button"
191 NAME = "submitButton"
193 VALUE = "<% $custnum ? "Apply Changes" : "Add Customer" %>"
194 onClick = "this.disabled=true; bottomfixup(this.form);"
198 <% include('/elements/footer.html') %>
202 my $curuser = $FS::CurrentUser::CurrentUser;
204 #probably redundant given the checks below...
206 unless $curuser->access_right('New customer')
207 || $curuser->access_right('Edit customer');
209 my $conf = new FS::Conf;
213 my($custnum, $cust_main, $ss, $stateid, $payinfo, @invoicing_list);
215 my $pkgpart_svcpart = ''; #first_pkg
216 my($username, $password, $popnum, $saved_domsvc) = ( '', '', 0, 0 ); #svc_acct
219 if ( $cgi->param('error') ) {
221 $cust_main = new FS::cust_main ( {
222 map { $_, scalar($cgi->param($_)) } fields('cust_main')
225 $custnum = $cust_main->custnum;
228 unless $curuser->access_right($custnum ? 'Edit customer' : 'New customer');
230 @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') );
231 $same = $cgi->param('same');
232 $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid');
233 $ss = $cust_main->ss; # don't mask an entered value on errors
234 $stateid = $cust_main->stateid; # don't mask an entered value on errors
235 $payinfo = $cust_main->payinfo; # don't mask an entered value on errors
237 $pkgpart_svcpart = $cgi->param('pkgpart_svcpart') || '';
240 $username = $cgi->param('username');
241 $password = $cgi->param('_password');
242 $popnum = $cgi->param('popnum');
243 $saved_domsvc = $cgi->param('domsvc') || '';
244 if ( $saved_domsvc =~ /^(\d+)$/ ) {
251 $svc_phone{$_} = $cgi->param($_)
252 foreach qw( countrycode phonenum sip_password pin phone_name );
254 } elsif ( $cgi->keywords ) { #editing
257 unless $curuser->access_right('Edit customer');
259 my( $query ) = $cgi->keywords;
262 $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
263 if ( $cust_main->dbdef_table->column('paycvv')
264 && length($cust_main->paycvv) ) {
265 my $paycvv = $cust_main->paycvv;
267 $cust_main->paycvv($paycvv);
269 @invoicing_list = $cust_main->invoicing_list;
270 $ss = $cust_main->masked('ss');
271 $stateid = $cust_main->masked('stateid');
272 $payinfo = $cust_main->paymask;
274 } else { #new customer
277 unless $curuser->access_right('New customer');
280 $cust_main = new FS::cust_main ( {} );
281 $cust_main->otaker( &getotaker );
282 $cust_main->referral_custnum( $cgi->param('referral_custnum') );
283 @invoicing_list = ();
284 push @invoicing_list, 'POST'
285 unless $conf->exists('disablepostalinvoicedefault');
292 my $error = $cgi->param('error');
294 $cgi->param('error', $error);
296 my $action = $custnum ? 'Edit' : 'Add';
297 $action .= ": ". $cust_main->name if $custnum;
299 my $r = qq!<font color="#ff0000">*</font> !;