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);
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_pkgpart = $cgi->param('pkgpart_svcpart') || '';
29 % if ( $saved_pkgpart =~ /^(\d+)_/ ) {
30 % $saved_pkgpart = $1;
32 % $saved_pkgpart = '';
34 % $username = $cgi->param('username');
35 % $password = $cgi->param('_password');
36 % $popnum = $cgi->param('popnum');
37 % @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') );
38 % $same = $cgi->param('same');
39 % $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid');
40 % $payinfo = $cust_main->payinfo; # don't mask an entered value on errors
41 %} elsif ( $cgi->keywords ) { #editing
42 % my( $query ) = $cgi->keywords;
43 % $query =~ /^(\d+)$/;
45 % $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
46 % if ( $cust_main->dbdef_table->column('paycvv')
47 % && length($cust_main->paycvv) ) {
48 % my $paycvv = $cust_main->paycvv;
50 % $cust_main->paycvv($paycvv);
56 % @invoicing_list = $cust_main->invoicing_list;
57 % $payinfo = $cust_main->paymask;
60 % $cust_main = new FS::cust_main ( {} );
61 % $cust_main->otaker( &getotaker );
62 % $cust_main->referral_custnum( $cgi->param('referral_custnum') );
67 % @invoicing_list = ();
68 % push @invoicing_list, 'POST'
69 % unless $conf->exists('disablepostalinvoicedefault');
74 %my $action = $custnum ? 'Edit' : 'Add';
75 %$action .= ": ". $cust_main->name if $custnum;
77 %my $r = qq!<font color="#ff0000">*</font> !;
84 <% include('/elements/header.html',
87 ' onUnload="myclose()"'
91 <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT><BR><BR>
95 <FORM NAME="topform" STYLE="margin-bottom: 0">
96 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
99 Customer #<B><% $custnum %></B> -
100 <B><FONT COLOR="<% $cust_main->statuscolor %>">
101 <% ucfirst($cust_main->status) %>
107 <% &ntable("#cccccc") %>
111 <% include('/elements/tr-select-agent.html', $cust_main->agentnum,
112 'label' => "<B>${r}Agent</B>",
113 'empty_label' => 'Select agent',
117 <!-- referral (advertising source) -->
119 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
120 %if ( $custnum && ! $conf->exists('editreferrals') ) {
124 <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
128 <% include('/elements/tr-select-part_referral.html', $refnum ) %>
132 <!-- referring customer -->
134 %my $referring_cust_main = '';
135 %if ( $cust_main->referral_custnum
136 % and $referring_cust_main =
137 % qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
143 <TD ALIGN="right">Referring customer</TD>
145 <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name %></A>
148 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
149 % } elsif ( ! $conf->exists('disable_customer_referrals') ) {
153 <TD ALIGN="right">Referring customer</TD>
155 <!-- <INPUT TYPE="text" NAME="referral_custnum" VALUE=""> -->
156 <% include('/elements/search-cust_main.html',
157 'field_name' => 'referral_custnum',
165 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
173 % if ( $conf->exists('cust_main-enable_birthdate') ) {
176 <% ntable("#cccccc", 2) %>
177 <% include ('/elements/tr-input-date-field.html',
179 $cust_main->birthdate,
181 $conf->config('date_format') || "%m/%d/%Y",
189 <!-- contact info -->
193 <% include('cust_main/contact.html', $cust_main, '', 'bill_changed(this)', '' ) %>
195 <!-- service address -->
196 % if ( defined $cust_main->dbdef_table->column('ship_last') ) {
200 function bill_changed(what) {
201 if ( what.form.same.checked ) {
202 % for (qw( last first company address1 address2 city zip daytime night fax )) {
204 what.form.ship_<%$_%>.value = what.form.<%$_%>.value;
208 what.form.ship_country.selectedIndex = what.form.country.selectedIndex;
209 function fix_ship_state() {
210 what.form.ship_state.selectedIndex = what.form.state.selectedIndex;
212 ship_country_changed(what.form.ship_country, fix_ship_state );
214 function fix_ship_county() {
215 what.form.ship_county.selectedIndex = what.form.county.selectedIndex;
217 ship_state_changed(what.form.ship_state, fix_ship_county );
220 function samechanged(what) {
221 if ( what.checked ) {
223 % for (qw( last first company address1 address2 city county state zip country daytime night fax )) {
225 what.form.ship_<%$_%>.disabled = true;
226 what.form.ship_<%$_%>.style.backgroundColor = '#dddddd';
230 % for (qw( last first company address1 address2 city county state zip country daytime night fax )) {
232 what.form.ship_<%$_%>.disabled = false;
233 what.form.ship_<%$_%>.style.backgroundColor = '#ffffff';
242 % my $disabledselect = '';
243 % unless ( $cust_main->ship_last && $same ne 'Y' ) {
244 % $checked = 'CHECKED';
245 % $disabled = 'DISABLED style="background-color: #dddddd"';
247 % qw( last first company address1 address2 city county state zip country
248 % daytime night fax )
250 % $cust_main->set("ship_$_", $cust_main->get($_) );
258 (<INPUT TYPE="checkbox" NAME="same" VALUE="Y" onClick="samechanged(this)" <%$checked%>>same as billing address)
259 <% include('cust_main/contact.html', $cust_main, 'ship_', '', $disabled ) %>
263 <!-- billing info -->
265 <% include( 'cust_main/billing.html', $cust_main,
266 'payinfo' => $payinfo,
267 'invoicing_list' => \@invoicing_list,
272 function bottomfixup(what) {
274 var topvars = new Array(
277 'custnum', 'agentnum', 'refnum', 'referral_custnum',
279 'last', 'first', 'ss', 'company',
280 'address1', 'address2', 'city',
281 'county', 'state', 'zip', 'country',
282 'daytime', 'night', 'fax',
286 'ship_last', 'ship_first', 'ship_company',
287 'ship_address1', 'ship_address2', 'ship_city',
288 'ship_county', 'ship_state', 'ship_zip', 'ship_country',
289 'ship_daytime','ship_night', 'ship_fax',
294 var layervars = new Array(
296 'payinfo', 'payinfo1', 'payinfo2',
297 'payname', 'exp_month', 'exp_year', 'paycvv',
298 'paystart_month', 'paystart_year', 'payissue',
303 var billing_bottomvars = new Array(
305 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
309 for ( f=0; f < topvars.length; f++ ) {
310 var field = topvars[f];
311 copyelement( document.topform.elements[field],
312 document.bottomform.elements[field]
316 var layerform = document.topform.select.options[document.topform.select.selectedIndex].value;
317 for ( f=0; f < layervars.length; f++ ) {
318 var field = layervars[f];
319 copyelement( document.forms[layerform].elements[field],
320 document.bottomform.elements[field]
324 for ( f=0; f < billing_bottomvars.length; f++ ) {
325 var field = billing_bottomvars[f];
326 copyelement( document.billing_bottomform.elements[field],
327 document.bottomform.elements[field]
333 function copyelement(from, to) {
334 if ( from == undefined ) {
336 } else if ( from.type == 'select-one' ) {
337 to.value = from.options[from.selectedIndex].value;
338 //alert(from + " (" + from.type + "): " + to.name + " => (" + from.selectedIndex + ") " + to.value);
339 } else if ( from.type == 'checkbox' ) {
340 if ( from.checked ) {
341 to.value = from.value;
346 if ( from.value == undefined ) {
349 to.value = from.value;
352 //alert(from + " (" + from.type + "): " + to.name + " => " + to.value);
357 <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">
358 % foreach my $hidden (
361 % 'custnum', 'agentnum', 'refnum', 'referral_custnum',
362 % 'last', 'first', 'ss', 'company',
363 % 'address1', 'address2', 'city',
364 % 'county', 'state', 'zip', 'country',
365 % 'daytime', 'night', 'fax',
369 % 'ship_last', 'ship_first', 'ship_company',
370 % 'ship_address1', 'ship_address2', 'ship_city',
371 % 'ship_county', 'ship_state', 'ship_zip', 'ship_country',
372 % 'ship_daytime','ship_night', 'ship_fax',
377 % 'payinfo', 'payinfo1', 'payinfo2',
378 % 'payname', 'exp_month', 'exp_year', 'paycvv',
379 % 'paystart_month', 'paystart_year', 'payissue',
384 % 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
389 <INPUT TYPE="hidden" NAME="<% $hidden %>" VALUE="">
392 % my $ro_comments = $conf->exists('cust_main-use_comments')?'':'readonly';
393 % if (!$ro_comments || $cust_main->comments) {
396 <% &ntable("#cccccc") %>
399 <TEXTAREA COLS=80 ROWS=5 WRAP="HARD" NAME="comments" <%$ro_comments%>><% $cust_main->comments %></TEXTAREA>
406 %unless ( $custnum ) {
407 % # pry the wrong place for this logic. also pretty expensive
410 % #false laziness, copied from FS::cust_pkg::order
412 % my @agents = $FS::CurrentUser::CurrentUser->agents;
413 % if ( scalar(@agents) == 1 ) {
414 % # $pkgpart->{PKGPART} is true iff $custnum may purchase PKGPART
415 % $pkgpart = $agents[0]->pkgpart_hashref;
417 % #can't know (agent not chosen), so, allow all
419 % foreach my $agent ( @agents ) {
420 % next if $typenum{$agent->typenum}++;
421 % #fixed in 5.004_05 #$pkgpart->{$_}++ foreach keys %{ $agent->pkgpart_hashref }
422 % foreach ( keys %{ $agent->pkgpart_hashref } ) { $pkgpart->{$_}++; } #5.004_04 workaround
427 % my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } }
428 % qsearch( 'part_pkg', { 'disabled' => '' } );
432 % # print "<BR><BR>First package", &itable("#cccccc", "0 ALIGN=LEFT"),
433 % #apiabuse & undesirable wrapping
438 <% ntable("#cccccc") %>
442 <SELECT NAME="pkgpart_svcpart">
443 <OPTION VALUE="">(none)
444 % foreach my $part_pkg ( @part_pkg ) {
447 <OPTION VALUE="<% $part_pkg->pkgpart. "_". $part_pkg->svcpart('svc_acct') %>"<% ( $saved_pkgpart && $part_pkg->pkgpart == $saved_pkgpart ) ? ' SELECTED' : '' %>><% $part_pkg->pkg. " - ". $part_pkg->comment %>
454 % #false laziness: (mostly) copied from edit/svc_acct.cgi
455 % #$ulen = $svc_acct->dbdef_table->column('username')->length;
456 % my $ulen = dbdef->table('svc_acct')->column('username')->length;
457 % my $ulen2 = $ulen+2;
458 % my $passwordmax = $conf->config('passwordmax') || 8;
459 % my $pmax2 = $passwordmax + 2;
464 <TD ALIGN="right">Username</TD>
466 <INPUT TYPE="text" NAME="username" VALUE="<% $username %>" SIZE=<% $ulen2 %> MAXLENGTH=<% $ulen %>>
471 <TD ALIGN="right">Password</TD>
473 <INPUT TYPE="text" NAME="_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $passwordmax %>>
479 <TD ALIGN="right">Access number</TD>
480 <TD><% FS::svc_acct_pop::popselector($popnum) %></TD>
487 <INPUT TYPE="hidden" NAME="otaker" VALUE="<% $cust_main->otaker %>">
489 <INPUT TYPE="submit" NAME="submit" VALUE="<% $custnum ? "Apply Changes" : "Add Customer" %>">
493 <% include('/elements/footer.html') %>