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',
319 for ( f=0; f < topvars.length; f++ ) {
320 var field = topvars[f];
321 copyelement( document.topform.elements[field],
322 document.bottomform.elements[field]
326 var layerform = document.topform.select.options[document.topform.select.selectedIndex].value;
327 for ( f=0; f < layervars.length; f++ ) {
328 var field = layervars[f];
329 copyelement( document.forms[layerform].elements[field],
330 document.bottomform.elements[field]
334 for ( f=0; f < billing_bottomvars.length; f++ ) {
335 var field = billing_bottomvars[f];
336 copyelement( document.billing_bottomform.elements[field],
337 document.bottomform.elements[field]
343 function copyelement(from, to) {
344 if ( from == undefined ) {
346 } else if ( from.type == 'select-one' ) {
347 to.value = from.options[from.selectedIndex].value;
348 //alert(from + " (" + from.type + "): " + to.name + " => (" + from.selectedIndex + ") " + to.value);
349 } else if ( from.type == 'checkbox' ) {
350 if ( from.checked ) {
351 to.value = from.value;
356 if ( from.value == undefined ) {
359 to.value = from.value;
362 //alert(from + " (" + from.type + "): " + to.name + " => " + to.value);
367 <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">
368 % foreach my $hidden (
371 % 'custnum', 'agentnum', 'refnum', 'referral_custnum',
372 % 'last', 'first', 'ss', 'company',
373 % 'address1', 'address2', 'city',
374 % 'county', 'state', 'zip', 'country',
375 % 'daytime', 'night', 'fax',
379 % 'ship_last', 'ship_first', 'ship_company',
380 % 'ship_address1', 'ship_address2', 'ship_city',
381 % 'ship_county', 'ship_state', 'ship_zip', 'ship_country',
382 % 'ship_daytime','ship_night', 'ship_fax',
387 % 'payinfo', 'payinfo1', 'payinfo2',
388 % 'payname', 'exp_month', 'exp_year', 'paycvv',
389 % 'paystart_month', 'paystart_year', 'payissue',
394 % 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
399 <INPUT TYPE="hidden" NAME="<% $hidden %>" VALUE="">
402 % my $ro_comments = $conf->exists('cust_main-use_comments')?'':'readonly';
403 % if (!$ro_comments || $cust_main->comments) {
406 <% &ntable("#cccccc") %>
409 <TEXTAREA COLS=80 ROWS=5 WRAP="HARD" NAME="comments" <%$ro_comments%>><% $cust_main->comments %></TEXTAREA>
416 %unless ( $custnum ) {
417 % # pry the wrong place for this logic. also pretty expensive
420 % #false laziness, copied from FS::cust_pkg::order
422 % my @agents = $FS::CurrentUser::CurrentUser->agents;
423 % if ( scalar(@agents) == 1 ) {
424 % # $pkgpart->{PKGPART} is true iff $custnum may purchase PKGPART
425 % $pkgpart = $agents[0]->pkgpart_hashref;
427 % #can't know (agent not chosen), so, allow all
429 % foreach my $agent ( @agents ) {
430 % next if $typenum{$agent->typenum}++;
431 % #fixed in 5.004_05 #$pkgpart->{$_}++ foreach keys %{ $agent->pkgpart_hashref }
432 % foreach ( keys %{ $agent->pkgpart_hashref } ) { $pkgpart->{$_}++; } #5.004_04 workaround
437 % my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } }
438 % qsearch( 'part_pkg', { 'disabled' => '' }, '', 'ORDER BY pkg' ); # case?
442 % # print "<BR><BR>First package", &itable("#cccccc", "0 ALIGN=LEFT"),
443 % #apiabuse & undesirable wrapping
448 <% ntable("#cccccc") %>
452 <% include('cust_main/select-domain.html',
453 'pkgparts' => \@part_pkg,
454 'saved_pkgpart' => $saved_pkgpart,
455 'saved_domsvc' => $saved_domsvc,
461 % #false laziness: (mostly) copied from edit/svc_acct.cgi
462 % #$ulen = $svc_acct->dbdef_table->column('username')->length;
463 % my $ulen = dbdef->table('svc_acct')->column('username')->length;
464 % my $ulen2 = $ulen+2;
465 % my $passwordmax = $conf->config('passwordmax') || 8;
466 % my $pmax2 = $passwordmax + 2;
471 <TD ALIGN="right">Username</TD>
473 <INPUT TYPE="text" NAME="username" VALUE="<% $username %>" SIZE=<% $ulen2 %> MAXLENGTH=<% $ulen %>>
478 <TD ALIGN="right">Domain</TD>
480 <SELECT NAME="domsvc">
481 <OPTION>(none)</OPTION>
487 <TD ALIGN="right">Password</TD>
489 <INPUT TYPE="text" NAME="_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $passwordmax %>>
495 <TD ALIGN="right">Access number</TD>
496 <TD><% FS::svc_acct_pop::popselector($popnum) %></TD>
503 <INPUT TYPE="hidden" NAME="otaker" VALUE="<% $cust_main->otaker %>">
505 <INPUT TYPE="submit" NAME="submit" VALUE="<% $custnum ? "Apply Changes" : "Add Customer" %>">
509 <% include('/elements/footer.html') %>