1 <% include('/elements/header.html',
4 ' onUnload="myclose()"'
7 <% include('/elements/error.html') %>
9 <FORM NAME="topform" STYLE="margin-bottom: 0">
10 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
13 Customer #<B><% $custnum %></B> -
14 <B><FONT COLOR="#<% $cust_main->statuscolor %>">
15 <% ucfirst($cust_main->status) %>
21 <% &ntable("#cccccc") %>
25 <% include('/elements/tr-select-agent.html', $cust_main->agentnum,
26 'label' => "<B>${r}Agent</B>",
27 'empty_label' => 'Select agent',
28 'disable_empty' => ( $cust_main->agentnum ? 1 : 0 ),
32 <!-- referral (advertising source) -->
34 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
35 %if ( $custnum && ! $conf->exists('editreferrals') ) {
39 <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
43 <% include('/elements/tr-select-part_referral.html', $refnum ) %>
47 <!-- referring customer -->
49 %my $referring_cust_main = '';
50 %if ( $cust_main->referral_custnum
51 % and $referring_cust_main =
52 % qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
58 <TD ALIGN="right">Referring customer</TD>
60 <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name %></A>
63 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
64 % } elsif ( ! $conf->exists('disable_customer_referrals') ) {
68 <TD ALIGN="right">Referring customer</TD>
70 <!-- <INPUT TYPE="text" NAME="referral_custnum" VALUE=""> -->
71 <% include('/elements/search-cust_main.html',
72 'field_name' => 'referral_custnum',
80 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
88 % if ( $conf->exists('cust_main-enable_birthdate') ) {
91 <% ntable("#cccccc", 2) %>
92 <% include ('/elements/tr-input-date-field.html',
94 $cust_main->birthdate,
96 $conf->config('date_format') || "%m/%d/%Y",
104 <!-- contact info -->
106 % my $same_checked = '';
107 % my $ship_disabled = '';
108 % unless ( $cust_main->ship_last && $same ne 'Y' ) {
109 % $same_checked = 'CHECKED';
110 % $ship_disabled = 'DISABLED STYLE="background-color: #dddddd"';
112 % qw( last first company address1 address2 city county state zip country
113 % daytime night fax )
115 % $cust_main->set("ship_$_", $cust_main->get($_) );
121 <% include('cust_main/contact.html',
122 'cust_main' => $cust_main,
124 'onchange' => 'bill_changed(this)',
127 'stateid' => $stateid,
128 'same_checked' => $same_checked, #for address2 "Unit #" labeling
133 function bill_changed(what) {
134 if ( what.form.same.checked ) {
135 % for (qw( last first company address1 address2 city zip daytime night fax )) {
137 what.form.ship_<%$_%>.value = what.form.<%$_%>.value;
140 what.form.ship_country.selectedIndex = what.form.country.selectedIndex;
142 function fix_ship_county() {
143 what.form.ship_county.selectedIndex = what.form.county.selectedIndex;
146 function fix_ship_state() {
147 what.form.ship_state.selectedIndex = what.form.state.selectedIndex;
148 ship_state_changed(what.form.ship_state, fix_ship_county );
151 ship_country_changed(what.form.ship_country, fix_ship_state );
155 function samechanged(what) {
156 if ( what.checked ) {
159 % for (qw( last first company address1 address2 city county state zip country daytime night fax )) {
160 what.form.ship_<%$_%>.disabled = true;
161 what.form.ship_<%$_%>.style.backgroundColor = '#dddddd';
164 % if ( $conf->exists('cust_main-require_address2') ) {
165 document.getElementById('address2_required').style.visibility = '';
166 document.getElementById('address2_label').style.visibility = '';
167 document.getElementById('ship_address2_required').style.visibility = 'hidden';
168 document.getElementById('ship_address2_label').style.visibility = 'hidden';
173 % for (qw( last first company address1 address2 city county state zip country daytime night fax )) {
174 what.form.ship_<%$_%>.disabled = false;
175 what.form.ship_<%$_%>.style.backgroundColor = '#ffffff';
178 % if ( $conf->exists('cust_main-require_address2') ) {
179 document.getElementById('address2_required').style.visibility = 'hidden';
180 document.getElementById('address2_label').style.visibility = 'hidden';
181 document.getElementById('ship_address2_required').style.visibility = '';
182 document.getElementById('ship_address2_label').style.visibility = '';
191 (<INPUT TYPE="checkbox" NAME="same" VALUE="Y" onClick="samechanged(this)" <%$same_checked%>>same as billing address)
192 <% include('cust_main/contact.html',
193 'cust_main' => $cust_main,
196 'disabled' => $ship_disabled,
201 <!-- billing info -->
203 <% include( 'cust_main/billing.html', $cust_main,
204 'payinfo' => $payinfo,
205 'invoicing_list' => \@invoicing_list,
210 function bottomfixup(what) {
212 var topvars = new Array(
215 'custnum', 'agentnum', 'refnum', 'referral_custnum',
217 'last', 'first', 'ss', 'company',
218 'address1', 'address2', 'city',
219 'county', 'state', 'zip', 'country',
220 'daytime', 'night', 'fax',
221 'stateid', 'stateid_state',
225 'ship_last', 'ship_first', 'ship_company',
226 'ship_address1', 'ship_address2', 'ship_city',
227 'ship_county', 'ship_state', 'ship_zip', 'ship_country',
228 'ship_daytime','ship_night', 'ship_fax',
233 var layervars = new Array(
235 'payinfo', 'payinfo1', 'payinfo2', 'paytype',
236 'payname', 'paystate', 'exp_month', 'exp_year', 'paycvv',
237 'paystart_month', 'paystart_year', 'payissue',
242 var billing_bottomvars = new Array(
244 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
248 for ( f=0; f < topvars.length; f++ ) {
249 var field = topvars[f];
250 copyelement( document.topform.elements[field],
251 document.bottomform.elements[field]
255 var layerform = document.topform.select.options[document.topform.select.selectedIndex].value;
256 for ( f=0; f < layervars.length; f++ ) {
257 var field = layervars[f];
258 copyelement( document.forms[layerform].elements[field],
259 document.bottomform.elements[field]
263 for ( f=0; f < billing_bottomvars.length; f++ ) {
264 var field = billing_bottomvars[f];
265 copyelement( document.billing_bottomform.elements[field],
266 document.bottomform.elements[field]
272 function copyelement(from, to) {
273 if ( from == undefined ) {
275 } else if ( from.type == 'select-one' ) {
276 to.value = from.options[from.selectedIndex].value;
277 //alert(from + " (" + from.type + "): " + to.name + " => (" + from.selectedIndex + ") " + to.value);
278 } else if ( from.type == 'checkbox' ) {
279 if ( from.checked ) {
280 to.value = from.value;
285 if ( from.value == undefined ) {
288 to.value = from.value;
291 //alert(from + " (" + from.type + "): " + to.name + " => " + to.value);
296 <FORM ACTION="<% popurl(1) %>process/cust_main.cgi" METHOD=POST NAME="bottomform" onSubmit="document.bottomform.submit.disabled=true; bottomfixup(this.form);" STYLE="margin-top: 0; margin-bottom: 0">
297 % foreach my $hidden (
300 % 'custnum', 'agentnum', 'refnum', 'referral_custnum',
301 % 'last', 'first', 'ss', 'company',
302 % 'address1', 'address2', 'city',
303 % 'county', 'state', 'zip', 'country',
304 % 'daytime', 'night', 'fax',
305 % 'stateid', 'stateid_state',
309 % 'ship_last', 'ship_first', 'ship_company',
310 % 'ship_address1', 'ship_address2', 'ship_city',
311 % 'ship_county', 'ship_state', 'ship_zip', 'ship_country',
312 % 'ship_daytime','ship_night', 'ship_fax',
317 % 'payinfo', 'payinfo1', 'payinfo2', 'paytype',
318 % 'payname', 'paystate', 'exp_month', 'exp_year', 'paycvv',
319 % 'paystart_month', 'paystart_year', 'payissue',
324 % 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
329 <INPUT TYPE="hidden" NAME="<% $hidden %>" VALUE="">
332 % my $ro_comments = $conf->exists('cust_main-use_comments')?'':'readonly';
333 % if (!$ro_comments || $cust_main->comments) {
336 <% &ntable("#cccccc") %>
339 <TEXTAREA COLS=80 ROWS=5 WRAP="HARD" NAME="comments" <%$ro_comments%>><% $cust_main->comments %></TEXTAREA>
346 %unless ( $custnum ) {
347 % # pry the wrong place for this logic. also pretty expensive
350 % #false laziness, copied from FS::cust_pkg::order
352 % my @agents = $FS::CurrentUser::CurrentUser->agents;
353 % if ( scalar(@agents) == 1 ) {
354 % # $pkgpart->{PKGPART} is true iff $custnum may purchase PKGPART
355 % $pkgpart = $agents[0]->pkgpart_hashref;
357 % #can't know (agent not chosen), so, allow all
359 % foreach my $agent ( @agents ) {
360 % next if $typenum{$agent->typenum}++;
361 % #fixed in 5.004_05 #$pkgpart->{$_}++ foreach keys %{ $agent->pkgpart_hashref }
362 % foreach ( keys %{ $agent->pkgpart_hashref } ) { $pkgpart->{$_}++; } #5.004_04 workaround
367 % my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } }
368 % qsearch( 'part_pkg', { 'disabled' => '' }, '', 'ORDER BY pkg' ); # case?
372 % # print "<BR><BR>First package", &itable("#cccccc", "0 ALIGN=LEFT"),
373 % #apiabuse & undesirable wrapping
378 <% ntable("#cccccc") %>
382 <% include('cust_main/select-domain.html',
383 'pkgparts' => \@part_pkg,
384 'saved_pkgpart' => $saved_pkgpart,
385 'saved_domsvc' => $saved_domsvc,
391 % #false laziness: (mostly) copied from edit/svc_acct.cgi
392 % #$ulen = $svc_acct->dbdef_table->column('username')->length;
393 % my $ulen = dbdef->table('svc_acct')->column('username')->length;
394 % my $ulen2 = $ulen+2;
395 % my $passwordmax = $conf->config('passwordmax') || 8;
396 % my $pmax2 = $passwordmax + 2;
401 <TD ALIGN="right">Username</TD>
403 <INPUT TYPE="text" NAME="username" VALUE="<% $username %>" SIZE=<% $ulen2 %> MAXLENGTH=<% $ulen %>>
408 <TD ALIGN="right">Domain</TD>
410 <SELECT NAME="domsvc">
411 <OPTION>(none)</OPTION>
417 <TD ALIGN="right">Password</TD>
419 <INPUT TYPE="text" NAME="_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $passwordmax %>>
425 <TD ALIGN="right">Access number</TD>
426 <TD><% FS::svc_acct_pop::popselector($popnum) %></TD>
433 <INPUT TYPE="hidden" NAME="otaker" VALUE="<% $cust_main->otaker %>">
435 <INPUT TYPE="submit" NAME="submit" VALUE="<% $custnum ? "Apply Changes" : "Add Customer" %>">
439 <% include('/elements/footer.html') %>
444 unless $FS::CurrentUser::CurrentUser->access_right('Edit customer');
446 #for misplaced logic below
449 #for false laziness below (now more properly lazy)
450 #use FS::svc_acct_pop;
452 #for (other) false laziness below
456 my $conf = new FS::Conf;
460 my($custnum, $username, $password, $popnum, $cust_main, $saved_pkgpart, $saved_domsvc);
462 my ($ss,$stateid,$payinfo);
464 if ( $cgi->param('error') ) {
465 $cust_main = new FS::cust_main ( {
466 map { $_, scalar($cgi->param($_)) } fields('cust_main')
468 $custnum = $cust_main->custnum;
469 $saved_domsvc = $cgi->param('domsvc') || '';
470 if ( $saved_domsvc =~ /^(\d+)$/ ) {
475 $saved_pkgpart = $cgi->param('pkgpart_svcpart') || '';
476 if ( $saved_pkgpart =~ /^(\d+)_/ ) {
481 $username = $cgi->param('username');
482 $password = $cgi->param('_password');
483 $popnum = $cgi->param('popnum');
484 @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') );
485 $same = $cgi->param('same');
486 $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid');
487 $ss = $cust_main->ss; # don't mask an entered value on errors
488 $stateid = $cust_main->stateid; # don't mask an entered value on errors
489 $payinfo = $cust_main->payinfo; # don't mask an entered value on errors
490 } elsif ( $cgi->keywords ) { #editing
491 my( $query ) = $cgi->keywords;
494 $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
495 if ( $cust_main->dbdef_table->column('paycvv')
496 && length($cust_main->paycvv) ) {
497 my $paycvv = $cust_main->paycvv;
499 $cust_main->paycvv($paycvv);
506 @invoicing_list = $cust_main->invoicing_list;
507 $ss = $cust_main->masked('ss');
508 $stateid = $cust_main->masked('stateid');
509 $payinfo = $cust_main->paymask;
512 $cust_main = new FS::cust_main ( {} );
513 $cust_main->otaker( &getotaker );
514 $cust_main->referral_custnum( $cgi->param('referral_custnum') );
520 @invoicing_list = ();
521 push @invoicing_list, 'POST'
522 unless $conf->exists('disablepostalinvoicedefault');
529 my $action = $custnum ? 'Edit' : 'Add';
530 $action .= ": ". $cust_main->name if $custnum;
532 my $r = qq!<font color="#ff0000">*</font> !;