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);
20 %my ($ss,$stateid,$payinfo);
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 % $ss = $cust_main->ss; # don't mask an entered value on errors
47 % $stateid = $cust_main->stateid; # don't mask an entered value on errors
48 % $payinfo = $cust_main->payinfo; # don't mask an entered value on errors
49 %} elsif ( $cgi->keywords ) { #editing
50 % my( $query ) = $cgi->keywords;
51 % $query =~ /^(\d+)$/;
53 % $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
54 % if ( $cust_main->dbdef_table->column('paycvv')
55 % && length($cust_main->paycvv) ) {
56 % my $paycvv = $cust_main->paycvv;
58 % $cust_main->paycvv($paycvv);
65 % @invoicing_list = $cust_main->invoicing_list;
66 % $ss = $cust_main->masked('ss');
67 % $stateid = $cust_main->masked('stateid');
68 % $payinfo = $cust_main->paymask;
71 % $cust_main = new FS::cust_main ( {} );
72 % $cust_main->otaker( &getotaker );
73 % $cust_main->referral_custnum( $cgi->param('referral_custnum') );
79 % @invoicing_list = ();
80 % push @invoicing_list, 'POST'
81 % unless $conf->exists('disablepostalinvoicedefault');
88 %my $action = $custnum ? 'Edit' : 'Add';
89 %$action .= ": ". $cust_main->name if $custnum;
91 %my $r = qq!<font color="#ff0000">*</font> !;
98 <% include('/elements/header.html',
101 ' onUnload="myclose()"'
105 <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT><BR><BR>
109 <FORM NAME="topform" STYLE="margin-bottom: 0">
110 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
113 Customer #<B><% $custnum %></B> -
114 <B><FONT COLOR="#<% $cust_main->statuscolor %>">
115 <% ucfirst($cust_main->status) %>
121 <% &ntable("#cccccc") %>
125 <% include('/elements/tr-select-agent.html',
126 'curr_value' => $cust_main->agentnum,
127 'label' => "<B>${r}Agent</B>",
128 'empty_label' => 'Select agent',
129 'disable_empty' => ( $cust_main->agentnum ? 1 : 0 ),
133 <!-- referral (advertising source) -->
135 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
136 %if ( $custnum && ! $conf->exists('editreferrals') ) {
140 <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
144 <% include('/elements/tr-select-part_referral.html',
145 'curr_value' => $refnum
151 <!-- referring customer -->
153 %my $referring_cust_main = '';
154 %if ( $cust_main->referral_custnum
155 % and $referring_cust_main =
156 % qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
162 <TD ALIGN="right">Referring customer</TD>
164 <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name %></A>
167 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
168 % } elsif ( ! $conf->exists('disable_customer_referrals') ) {
172 <TD ALIGN="right">Referring customer</TD>
174 <!-- <INPUT TYPE="text" NAME="referral_custnum" VALUE=""> -->
175 <% include('/elements/search-cust_main.html',
176 'field_name' => 'referral_custnum',
184 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
192 % if ( $conf->exists('cust_main-enable_birthdate') ) {
195 <% ntable("#cccccc", 2) %>
196 <% include ('/elements/tr-input-date-field.html',
198 $cust_main->birthdate,
200 $conf->config('date_format') || "%m/%d/%Y",
208 <!-- contact info -->
212 <% include('cust_main/contact.html', $cust_main, '', 'bill_changed(this)', '', 'ss' => $ss, 'stateid' => $stateid ) %>
214 <!-- service address -->
215 % if ( defined $cust_main->dbdef_table->column('ship_last') ) {
219 function bill_changed(what) {
220 if ( what.form.same.checked ) {
221 % for (qw( last first company address1 address2 city zip daytime night fax )) {
223 what.form.ship_<%$_%>.value = what.form.<%$_%>.value;
226 what.form.ship_country.selectedIndex = what.form.country.selectedIndex;
228 function fix_ship_county() {
229 what.form.ship_county.selectedIndex = what.form.county.selectedIndex;
232 function fix_ship_state() {
233 what.form.ship_state.selectedIndex = what.form.state.selectedIndex;
234 ship_state_changed(what.form.ship_state, fix_ship_county );
237 ship_country_changed(what.form.ship_country, fix_ship_state );
241 function samechanged(what) {
242 if ( what.checked ) {
244 % for (qw( last first company address1 address2 city county state zip country daytime night fax )) {
246 what.form.ship_<%$_%>.disabled = true;
247 what.form.ship_<%$_%>.style.backgroundColor = '#dddddd';
251 % for (qw( last first company address1 address2 city county state zip country daytime night fax )) {
253 what.form.ship_<%$_%>.disabled = false;
254 what.form.ship_<%$_%>.style.backgroundColor = '#ffffff';
263 % my $disabledselect = '';
264 % unless ( $cust_main->ship_last && $same ne 'Y' ) {
265 % $checked = 'CHECKED';
266 % $disabled = 'DISABLED STYLE="background-color: #dddddd"';
268 % qw( last first company address1 address2 city county state zip country
269 % daytime night fax )
271 % $cust_main->set("ship_$_", $cust_main->get($_) );
279 (<INPUT TYPE="checkbox" NAME="same" VALUE="Y" onClick="samechanged(this)" <%$checked%>>same as billing address)
280 <% include('cust_main/contact.html', $cust_main, 'ship_', '', $disabled ) %>
284 <!-- billing info -->
286 <% include( 'cust_main/billing.html', $cust_main,
287 'payinfo' => $payinfo,
288 'invoicing_list' => \@invoicing_list,
293 function bottomfixup(what) {
295 var topvars = new Array(
298 'custnum', 'agentnum', 'refnum', 'referral_custnum',
300 'last', 'first', 'ss', 'company',
301 'address1', 'address2', 'city',
302 'county', 'state', 'zip', 'country',
303 'daytime', 'night', 'fax',
304 'stateid', 'stateid_state',
308 'ship_last', 'ship_first', 'ship_company',
309 'ship_address1', 'ship_address2', 'ship_city',
310 'ship_county', 'ship_state', 'ship_zip', 'ship_country',
311 'ship_daytime','ship_night', 'ship_fax',
316 var layervars = new Array(
318 'payinfo', 'payinfo1', 'payinfo2', 'paytype',
319 'payname', 'paystate', 'exp_month', 'exp_year', 'paycvv',
320 'paystart_month', 'paystart_year', 'payissue',
325 var billing_bottomvars = new Array(
327 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
332 for ( f=0; f < topvars.length; f++ ) {
333 var field = topvars[f];
334 copyelement( document.topform.elements[field],
335 document.bottomform.elements[field]
339 var layerform = document.topform.select.options[document.topform.select.selectedIndex].value;
340 for ( f=0; f < layervars.length; f++ ) {
341 var field = layervars[f];
342 copyelement( document.forms[layerform].elements[field],
343 document.bottomform.elements[field]
347 for ( f=0; f < billing_bottomvars.length; f++ ) {
348 var field = billing_bottomvars[f];
349 copyelement( document.billing_bottomform.elements[field],
350 document.bottomform.elements[field]
356 function copyelement(from, to) {
357 if ( from == undefined ) {
359 } else if ( from.type == 'select-one' ) {
360 to.value = from.options[from.selectedIndex].value;
361 //alert(from + " (" + from.type + "): " + to.name + " => (" + from.selectedIndex + ") " + to.value);
362 } else if ( from.type == 'checkbox' ) {
363 if ( from.checked ) {
364 to.value = from.value;
369 if ( from.value == undefined ) {
372 to.value = from.value;
375 //alert(from + " (" + from.type + "): " + to.name + " => " + to.value);
380 <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">
381 % foreach my $hidden (
384 % 'custnum', 'agentnum', 'refnum', 'referral_custnum',
385 % 'last', 'first', 'ss', 'company',
386 % 'address1', 'address2', 'city',
387 % 'county', 'state', 'zip', 'country',
388 % 'daytime', 'night', 'fax',
389 % 'stateid', 'stateid_state',
393 % 'ship_last', 'ship_first', 'ship_company',
394 % 'ship_address1', 'ship_address2', 'ship_city',
395 % 'ship_county', 'ship_state', 'ship_zip', 'ship_country',
396 % 'ship_daytime','ship_night', 'ship_fax',
401 % 'payinfo', 'payinfo1', 'payinfo2', 'paytype',
402 % 'payname', 'paystate', 'exp_month', 'exp_year', 'paycvv',
403 % 'paystart_month', 'paystart_year', 'payissue',
408 % 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
414 <INPUT TYPE="hidden" NAME="<% $hidden %>" VALUE="">
417 % my $ro_comments = $conf->exists('cust_main-use_comments')?'':'readonly';
418 % if (!$ro_comments || $cust_main->comments) {
421 <% &ntable("#cccccc") %>
424 <TEXTAREA COLS=80 ROWS=5 WRAP="HARD" NAME="comments" <%$ro_comments%>><% $cust_main->comments %></TEXTAREA>
431 %unless ( $custnum ) {
432 % # pry the wrong place for this logic. also pretty expensive
435 % #false laziness, copied from FS::cust_pkg::order
437 % my @agents = $FS::CurrentUser::CurrentUser->agents;
438 % if ( scalar(@agents) == 1 ) {
439 % # $pkgpart->{PKGPART} is true iff $custnum may purchase PKGPART
440 % $pkgpart = $agents[0]->pkgpart_hashref;
442 % #can't know (agent not chosen), so, allow all
444 % foreach my $agent ( @agents ) {
445 % next if $typenum{$agent->typenum}++;
446 % #fixed in 5.004_05 #$pkgpart->{$_}++ foreach keys %{ $agent->pkgpart_hashref }
447 % foreach ( keys %{ $agent->pkgpart_hashref } ) { $pkgpart->{$_}++; } #5.004_04 workaround
452 % my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } }
453 % qsearch( 'part_pkg', { 'disabled' => '' }, '', 'ORDER BY pkg' ); # case?
457 % # print "<BR><BR>First package", &itable("#cccccc", "0 ALIGN=LEFT"),
458 % #apiabuse & undesirable wrapping
463 <% ntable("#cccccc") %>
467 <% include('cust_main/select-domain.html',
468 'pkgparts' => \@part_pkg,
469 'saved_pkgpart' => $saved_pkgpart,
470 'saved_domsvc' => $saved_domsvc,
476 % #false laziness: (mostly) copied from edit/svc_acct.cgi
477 % #$ulen = $svc_acct->dbdef_table->column('username')->length;
478 % my $ulen = dbdef->table('svc_acct')->column('username')->length;
479 % my $ulen2 = $ulen+2;
480 % my $passwordmax = $conf->config('passwordmax') || 8;
481 % my $pmax2 = $passwordmax + 2;
486 <TD ALIGN="right">Username</TD>
488 <INPUT TYPE="text" NAME="username" VALUE="<% $username %>" SIZE=<% $ulen2 %> MAXLENGTH=<% $ulen %>>
493 <TD ALIGN="right">Domain</TD>
495 <SELECT NAME="domsvc">
496 <OPTION>(none)</OPTION>
502 <TD ALIGN="right">Password</TD>
504 <INPUT TYPE="text" NAME="_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $passwordmax %>>
510 <TD ALIGN="right">Access number</TD>
511 <TD><% FS::svc_acct_pop::popselector($popnum) %></TD>
518 <INPUT TYPE="hidden" NAME="otaker" VALUE="<% $cust_main->otaker %>">
520 <INPUT TYPE="submit" NAME="submit" VALUE="<% $custnum ? "Apply Changes" : "Add Customer" %>">
524 <% include('/elements/footer.html') %>