3 % #for misplaced logic below
6 % #for false laziness below (now more properly lazy)
7 % #use FS::svc_acct_pop;
9 % #for (other) false laziness below
13 %my $conf = new FS::Conf;
18 %my($custnum, $username, $password, $popnum, $cust_main, $saved_pkgpart, $saved_domsvc);
22 %if ( $cgi->param('error') ) {
23 % $error = $cgi->param('error');
24 % $cust_main = new FS::cust_main ( {
25 % map { $_, scalar($cgi->param($_)) } fields('cust_main')
27 % $custnum = $cust_main->custnum;
28 % $saved_domsvc = $cgi->param('domsvc') || '';
29 % if ( $saved_domsvc =~ /^(\d+)$/ ) {
34 % $saved_pkgpart = $cgi->param('pkgpart_svcpart') || '';
35 % if ( $saved_pkgpart =~ /^(\d+)_/ ) {
36 % $saved_pkgpart = $1;
38 % $saved_pkgpart = '';
40 % $username = $cgi->param('username');
41 % $password = $cgi->param('_password');
42 % $popnum = $cgi->param('popnum');
43 % @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') );
44 % $same = $cgi->param('same');
45 % $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid');
46 % $payinfo = $cust_main->payinfo; # don't mask an entered value on errors
47 %} elsif ( $cgi->keywords ) { #editing
48 % my( $query ) = $cgi->keywords;
49 % $query =~ /^(\d+)$/;
51 % $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
52 % if ( $cust_main->dbdef_table->column('paycvv')
53 % && length($cust_main->paycvv) ) {
54 % my $paycvv = $cust_main->paycvv;
56 % $cust_main->paycvv($paycvv);
63 % @invoicing_list = $cust_main->invoicing_list;
64 % $payinfo = $cust_main->paymask;
67 % $cust_main = new FS::cust_main ( {} );
68 % $cust_main->otaker( &getotaker );
69 % $cust_main->referral_custnum( $cgi->param('referral_custnum') );
75 % @invoicing_list = ();
76 % push @invoicing_list, 'POST'
77 % unless $conf->exists('disablepostalinvoicedefault');
82 %my $action = $custnum ? 'Edit' : 'Add';
83 %$action .= ": ". $cust_main->name if $custnum;
85 %my $r = qq!<font color="#ff0000">*</font> !;
92 <% include('/elements/header.html',
95 ' onUnload="myclose()"'
99 <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT><BR><BR>
103 <FORM NAME="topform" STYLE="margin-bottom: 0">
104 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
107 Customer #<B><% $custnum %></B> -
108 <B><FONT COLOR="<% $cust_main->statuscolor %>">
109 <% ucfirst($cust_main->status) %>
115 <% &ntable("#cccccc") %>
119 <% include('/elements/tr-select-agent.html', $cust_main->agentnum,
120 'label' => "<B>${r}Agent</B>",
121 'empty_label' => 'Select agent',
125 <!-- referral (advertising source) -->
127 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
128 %if ( $custnum && ! $conf->exists('editreferrals') ) {
132 <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
136 <% include('/elements/tr-select-part_referral.html', $refnum ) %>
140 <!-- referring customer -->
142 %my $referring_cust_main = '';
143 %if ( $cust_main->referral_custnum
144 % and $referring_cust_main =
145 % qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
151 <TD ALIGN="right">Referring customer</TD>
153 <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name %></A>
156 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
157 % } elsif ( ! $conf->exists('disable_customer_referrals') ) {
161 <TD ALIGN="right">Referring customer</TD>
163 <!-- <INPUT TYPE="text" NAME="referral_custnum" VALUE=""> -->
164 <% include('/elements/search-cust_main.html',
165 'field_name' => 'referral_custnum',
173 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
181 % if ( $conf->exists('cust_main-enable_birthdate') ) {
184 <% ntable("#cccccc", 2) %>
185 <% include ('/elements/tr-input-date-field.html',
187 $cust_main->birthdate,
189 $conf->config('date_format') || "%m/%d/%Y",
197 <!-- contact info -->
201 <% include('cust_main/contact.html', $cust_main, '', 'bill_changed(this)', '' ) %>
203 <!-- service address -->
204 % if ( defined $cust_main->dbdef_table->column('ship_last') ) {
208 function bill_changed(what) {
209 if ( what.form.same.checked ) {
210 % for (qw( last first company address1 address2 city zip daytime night fax )) {
212 what.form.ship_<%$_%>.value = what.form.<%$_%>.value;
215 what.form.ship_country.selectedIndex = what.form.country.selectedIndex;
217 function fix_ship_county() {
218 what.form.ship_county.selectedIndex = what.form.county.selectedIndex;
221 function fix_ship_state() {
222 what.form.ship_state.selectedIndex = what.form.state.selectedIndex;
223 ship_state_changed(what.form.ship_state, fix_ship_county );
226 ship_country_changed(what.form.ship_country, fix_ship_state );
230 function samechanged(what) {
231 if ( what.checked ) {
233 % for (qw( last first company address1 address2 city county state zip country daytime night fax )) {
235 what.form.ship_<%$_%>.disabled = true;
236 what.form.ship_<%$_%>.style.backgroundColor = '#dddddd';
240 % for (qw( last first company address1 address2 city county state zip country daytime night fax )) {
242 what.form.ship_<%$_%>.disabled = false;
243 what.form.ship_<%$_%>.style.backgroundColor = '#ffffff';
252 % my $disabledselect = '';
253 % unless ( $cust_main->ship_last && $same ne 'Y' ) {
254 % $checked = 'CHECKED';
255 % $disabled = 'DISABLED STYLE="background-color: #dddddd"';
257 % qw( last first company address1 address2 city county state zip country
258 % daytime night fax )
260 % $cust_main->set("ship_$_", $cust_main->get($_) );
268 (<INPUT TYPE="checkbox" NAME="same" VALUE="Y" onClick="samechanged(this)" <%$checked%>>same as billing address)
269 <% include('cust_main/contact.html', $cust_main, 'ship_', '', $disabled ) %>
273 <!-- billing info -->
275 <% include( 'cust_main/billing.html', $cust_main,
276 'payinfo' => $payinfo,
277 'invoicing_list' => \@invoicing_list,
282 function bottomfixup(what) {
284 var topvars = new Array(
287 'custnum', 'agentnum', 'refnum', 'referral_custnum',
289 'last', 'first', 'ss', 'company',
290 'address1', 'address2', 'city',
291 'county', 'state', 'zip', 'country',
292 'daytime', 'night', 'fax',
296 'ship_last', 'ship_first', 'ship_company',
297 'ship_address1', 'ship_address2', 'ship_city',
298 'ship_county', 'ship_state', 'ship_zip', 'ship_country',
299 'ship_daytime','ship_night', 'ship_fax',
304 var layervars = new Array(
306 'payinfo', 'payinfo1', 'payinfo2',
307 'payname', 'exp_month', 'exp_year', 'paycvv',
308 'paystart_month', 'paystart_year', 'payissue',
313 var billing_bottomvars = new Array(
315 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
320 for ( f=0; f < topvars.length; f++ ) {
321 var field = topvars[f];
322 copyelement( document.topform.elements[field],
323 document.bottomform.elements[field]
327 var layerform = document.topform.select.options[document.topform.select.selectedIndex].value;
328 for ( f=0; f < layervars.length; f++ ) {
329 var field = layervars[f];
330 copyelement( document.forms[layerform].elements[field],
331 document.bottomform.elements[field]
335 for ( f=0; f < billing_bottomvars.length; f++ ) {
336 var field = billing_bottomvars[f];
337 copyelement( document.billing_bottomform.elements[field],
338 document.bottomform.elements[field]
344 function copyelement(from, to) {
345 if ( from == undefined ) {
347 } else if ( from.type == 'select-one' ) {
348 to.value = from.options[from.selectedIndex].value;
349 //alert(from + " (" + from.type + "): " + to.name + " => (" + from.selectedIndex + ") " + to.value);
350 } else if ( from.type == 'checkbox' ) {
351 if ( from.checked ) {
352 to.value = from.value;
357 if ( from.value == undefined ) {
360 to.value = from.value;
363 //alert(from + " (" + from.type + "): " + to.name + " => " + to.value);
368 <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">
369 % foreach my $hidden (
372 % 'custnum', 'agentnum', 'refnum', 'referral_custnum',
373 % 'last', 'first', 'ss', 'company',
374 % 'address1', 'address2', 'city',
375 % 'county', 'state', 'zip', 'country',
376 % 'daytime', 'night', 'fax',
380 % 'ship_last', 'ship_first', 'ship_company',
381 % 'ship_address1', 'ship_address2', 'ship_city',
382 % 'ship_county', 'ship_state', 'ship_zip', 'ship_country',
383 % 'ship_daytime','ship_night', 'ship_fax',
388 % 'payinfo', 'payinfo1', 'payinfo2',
389 % 'payname', 'exp_month', 'exp_year', 'paycvv',
390 % 'paystart_month', 'paystart_year', 'payissue',
395 % 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
401 <INPUT TYPE="hidden" NAME="<% $hidden %>" VALUE="">
404 % my $ro_comments = $conf->exists('cust_main-use_comments')?'':'readonly';
405 % if (!$ro_comments || $cust_main->comments) {
408 <% &ntable("#cccccc") %>
411 <TEXTAREA COLS=80 ROWS=5 WRAP="HARD" NAME="comments" <%$ro_comments%>><% $cust_main->comments %></TEXTAREA>
418 %unless ( $custnum ) {
419 % # pry the wrong place for this logic. also pretty expensive
422 % #false laziness, copied from FS::cust_pkg::order
424 % my @agents = $FS::CurrentUser::CurrentUser->agents;
425 % if ( scalar(@agents) == 1 ) {
426 % # $pkgpart->{PKGPART} is true iff $custnum may purchase PKGPART
427 % $pkgpart = $agents[0]->pkgpart_hashref;
429 % #can't know (agent not chosen), so, allow all
431 % foreach my $agent ( @agents ) {
432 % next if $typenum{$agent->typenum}++;
433 % #fixed in 5.004_05 #$pkgpart->{$_}++ foreach keys %{ $agent->pkgpart_hashref }
434 % foreach ( keys %{ $agent->pkgpart_hashref } ) { $pkgpart->{$_}++; } #5.004_04 workaround
439 % my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } }
440 % qsearch( 'part_pkg', { 'disabled' => '' }, '', 'ORDER BY pkg' ); # case?
444 % # print "<BR><BR>First package", &itable("#cccccc", "0 ALIGN=LEFT"),
445 % #apiabuse & undesirable wrapping
450 <% ntable("#cccccc") %>
454 <% include('cust_main/select-domain.html',
455 'pkgparts' => \@part_pkg,
456 'saved_pkgpart' => $saved_pkgpart,
457 'saved_domsvc' => $saved_domsvc,
463 % #false laziness: (mostly) copied from edit/svc_acct.cgi
464 % #$ulen = $svc_acct->dbdef_table->column('username')->length;
465 % my $ulen = dbdef->table('svc_acct')->column('username')->length;
466 % my $ulen2 = $ulen+2;
467 % my $passwordmax = $conf->config('passwordmax') || 8;
468 % my $pmax2 = $passwordmax + 2;
473 <TD ALIGN="right">Username</TD>
475 <INPUT TYPE="text" NAME="username" VALUE="<% $username %>" SIZE=<% $ulen2 %> MAXLENGTH=<% $ulen %>>
480 <TD ALIGN="right">Domain</TD>
482 <SELECT NAME="domsvc">
483 <OPTION>(none)</OPTION>
489 <TD ALIGN="right">Password</TD>
491 <INPUT TYPE="text" NAME="_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $passwordmax %>>
497 <TD ALIGN="right">Access number</TD>
498 <TD><% FS::svc_acct_pop::popselector($popnum) %></TD>
505 <INPUT TYPE="hidden" NAME="otaker" VALUE="<% $cust_main->otaker %>">
507 <INPUT TYPE="submit" NAME="submit" VALUE="<% $custnum ? "Apply Changes" : "Add Customer" %>">
511 <% include('/elements/footer.html') %>