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);
21 %if ( $cgi->param('error') ) {
22 % $error = $cgi->param('error');
23 % $cust_main = new FS::cust_main ( {
24 % map { $_, scalar($cgi->param($_)) } fields('cust_main')
26 % $custnum = $cust_main->custnum;
27 % $saved_pkgpart = $cgi->param('pkgpart_svcpart') || '';
28 % if ( $saved_pkgpart =~ /^(\d+)_/ ) {
29 % $saved_pkgpart = $1;
31 % $saved_pkgpart = '';
33 % $username = $cgi->param('username');
34 % $password = $cgi->param('_password');
35 % $popnum = $cgi->param('popnum');
36 % @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') );
37 % $same = $cgi->param('same');
38 % $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid');
39 %} elsif ( $cgi->keywords ) { #editing
40 % my( $query ) = $cgi->keywords;
41 % $query =~ /^(\d+)$/;
43 % $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
44 % if ( $cust_main->dbdef_table->column('paycvv')
45 % && length($cust_main->paycvv) ) {
46 % my $paycvv = $cust_main->paycvv;
48 % $cust_main->paycvv($paycvv);
54 % @invoicing_list = $cust_main->invoicing_list;
57 % $cust_main = new FS::cust_main ( {} );
58 % $cust_main->otaker( &getotaker );
59 % $cust_main->referral_custnum( $cgi->param('referral_custnum') );
64 % @invoicing_list = ();
68 %my $action = $custnum ? 'Edit' : 'Add';
69 %$action .= ": ". $cust_main->name if $custnum;
71 %my $r = qq!<font color="#ff0000">*</font> !;
78 <% include('/elements/header.html',
81 ' onUnload="myclose()"'
85 <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT><BR><BR>
89 <FORM NAME="topform" STYLE="margin-bottom: 0">
90 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
93 Customer #<B><% $custnum %></B> -
94 <B><FONT COLOR="<% $cust_main->statuscolor %>">
95 <% ucfirst($cust_main->status) %>
101 <% &ntable("#cccccc") %>
105 <% include('/elements/tr-select-agent.html', $cust_main->agentnum,
106 'label' => "<B>${r}Agent</B>",
107 'empty_label' => 'Select agent',
111 <!-- referral (advertising source) -->
113 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
114 %if ( $custnum && ! $conf->exists('editreferrals') ) {
118 <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
122 <% include('/elements/tr-select-part_referral.html', $refnum ) %>
126 <!-- referring customer -->
128 %my $referring_cust_main = '';
129 %if ( $cust_main->referral_custnum
130 % and $referring_cust_main =
131 % qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
137 <TD ALIGN="right">Referring customer</TD>
139 <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name %></A>
142 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
143 % } elsif ( ! $conf->exists('disable_customer_referrals') ) {
147 <TD ALIGN="right">Referring customer</TD>
149 <!-- <INPUT TYPE="text" NAME="referral_custnum" VALUE=""> -->
150 <% include('/elements/search-cust_main.html',
151 'field_name' => 'referral_custnum',
159 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
167 % if ( $conf->exists('cust_main-enable_birthdate') ) {
170 <% ntable("#cccccc", 2) %>
171 <% include ('/elements/tr-input-date-field.html',
173 $cust_main->birthdate,
175 $conf->config('date_format') || "%m/%d/%Y",
183 <!-- contact info -->
187 <% include('cust_main/contact.html', $cust_main, '', 'bill_changed(this)', '' ) %>
189 <!-- service address -->
190 % if ( defined $cust_main->dbdef_table->column('ship_last') ) {
194 function bill_changed(what) {
195 if ( what.form.same.checked ) {
196 % for (qw( last first company address1 address2 city zip daytime night fax )) {
198 what.form.ship_<%$_%>.value = what.form.<%$_%>.value;
202 what.form.ship_country.selectedIndex = what.form.country.selectedIndex;
203 function fix_ship_state() {
204 what.form.ship_state.selectedIndex = what.form.state.selectedIndex;
206 ship_country_changed(what.form.ship_country, fix_ship_state );
208 function fix_ship_county() {
209 what.form.ship_county.selectedIndex = what.form.county.selectedIndex;
211 ship_state_changed(what.form.ship_state, fix_ship_county );
214 function samechanged(what) {
215 if ( what.checked ) {
217 % for (qw( last first company address1 address2 city county state zip country daytime night fax )) {
219 what.form.ship_<%$_%>.disabled = true;
220 what.form.ship_<%$_%>.style.backgroundColor = '#dddddd';
224 % for (qw( last first company address1 address2 city county state zip country daytime night fax )) {
226 what.form.ship_<%$_%>.disabled = false;
227 what.form.ship_<%$_%>.style.backgroundColor = '#ffffff';
236 % my $disabledselect = '';
237 % unless ( $cust_main->ship_last && $same ne 'Y' ) {
238 % $checked = 'CHECKED';
239 % $disabled = 'DISABLED style="background-color: #dddddd"';
241 % qw( last first company address1 address2 city county state zip country
242 % daytime night fax )
244 % $cust_main->set("ship_$_", $cust_main->get($_) );
252 (<INPUT TYPE="checkbox" NAME="same" VALUE="Y" onClick="samechanged(this)" <%$checked%>>same as billing address)
253 <% include('cust_main/contact.html', $cust_main, 'ship_', '', $disabled ) %>
257 <!-- billing info -->
259 <% include( 'cust_main/billing.html', $cust_main,
260 'invoicing_list' => \@invoicing_list,
265 function bottomfixup(what) {
267 var topvars = new Array(
270 'custnum', 'agentnum', 'refnum', 'referral_custnum',
272 'last', 'first', 'ss', 'company',
273 'address1', 'address2', 'city',
274 'county', 'state', 'zip', 'country',
275 'daytime', 'night', 'fax',
279 'ship_last', 'ship_first', 'ship_company',
280 'ship_address1', 'ship_address2', 'ship_city',
281 'ship_county', 'ship_state', 'ship_zip', 'ship_country',
282 'ship_daytime','ship_night', 'ship_fax',
287 var layervars = new Array(
289 'payinfo', 'payinfo1', 'payinfo2',
290 'payname', 'exp_month', 'exp_year', 'paycvv',
291 'paystart_month', 'paystart_year', 'payissue',
296 var billing_bottomvars = new Array(
298 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
302 for ( f=0; f < topvars.length; f++ ) {
303 var field = topvars[f];
304 copyelement( document.topform.elements[field],
305 document.bottomform.elements[field]
309 var layerform = document.topform.select.options[document.topform.select.selectedIndex].value;
310 for ( f=0; f < layervars.length; f++ ) {
311 var field = layervars[f];
312 copyelement( document.forms[layerform].elements[field],
313 document.bottomform.elements[field]
317 for ( f=0; f < billing_bottomvars.length; f++ ) {
318 var field = billing_bottomvars[f];
319 copyelement( document.billing_bottomform.elements[field],
320 document.bottomform.elements[field]
326 function copyelement(from, to) {
327 if ( from == undefined ) {
329 } else if ( from.type == 'select-one' ) {
330 to.value = from.options[from.selectedIndex].value;
331 //alert(from + " (" + from.type + "): " + to.name + " => (" + from.selectedIndex + ") " + to.value);
332 } else if ( from.type == 'checkbox' ) {
333 if ( from.checked ) {
334 to.value = from.value;
339 if ( from.value == undefined ) {
342 to.value = from.value;
345 //alert(from + " (" + from.type + "): " + to.name + " => " + to.value);
350 <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">
351 % foreach my $hidden (
354 % 'custnum', 'agentnum', 'refnum', 'referral_custnum',
355 % 'last', 'first', 'ss', 'company',
356 % 'address1', 'address2', 'city',
357 % 'county', 'state', 'zip', 'country',
358 % 'daytime', 'night', 'fax',
362 % 'ship_last', 'ship_first', 'ship_company',
363 % 'ship_address1', 'ship_address2', 'ship_city',
364 % 'ship_county', 'ship_state', 'ship_zip', 'ship_country',
365 % 'ship_daytime','ship_night', 'ship_fax',
370 % 'payinfo', 'payinfo1', 'payinfo2',
371 % 'payname', 'exp_month', 'exp_year', 'paycvv',
372 % 'paystart_month', 'paystart_year', 'payissue',
377 % 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
382 <INPUT TYPE="hidden" NAME="<% $hidden %>" VALUE="">
385 % my $ro_comments = $conf->exists('cust_main-use_comments')?'':'readonly';
386 % if (!$ro_comments || $cust_main->comments) {
389 <% &ntable("#cccccc") %>
392 <TEXTAREA COLS=80 ROWS=5 WRAP="HARD" NAME="comments" <%$ro_comments%>><% $cust_main->comments %></TEXTAREA>
399 %unless ( $custnum ) {
400 % # pry the wrong place for this logic. also pretty expensive
403 % #false laziness, copied from FS::cust_pkg::order
405 % my @agents = $FS::CurrentUser::CurrentUser->agents;
406 % if ( scalar(@agents) == 1 ) {
407 % # $pkgpart->{PKGPART} is true iff $custnum may purchase PKGPART
408 % $pkgpart = $agents[0]->pkgpart_hashref;
410 % #can't know (agent not chosen), so, allow all
412 % foreach my $agent ( @agents ) {
413 % next if $typenum{$agent->typenum}++;
414 % #fixed in 5.004_05 #$pkgpart->{$_}++ foreach keys %{ $agent->pkgpart_hashref }
415 % foreach ( keys %{ $agent->pkgpart_hashref } ) { $pkgpart->{$_}++; } #5.004_04 workaround
420 % my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } }
421 % qsearch( 'part_pkg', { 'disabled' => '' } );
425 % # print "<BR><BR>First package", &itable("#cccccc", "0 ALIGN=LEFT"),
426 % #apiabuse & undesirable wrapping
431 <% ntable("#cccccc") %>
435 <SELECT NAME="pkgpart_svcpart">
436 <OPTION VALUE="">(none)
437 % foreach my $part_pkg ( @part_pkg ) {
440 <OPTION VALUE="<% $part_pkg->pkgpart. "_". $part_pkg->svcpart('svc_acct') %>"<% ( $saved_pkgpart && $part_pkg->pkgpart == $saved_pkgpart ) ? ' SELECTED' : '' %>><% $part_pkg->pkg. " - ". $part_pkg->comment %>
447 % #false laziness: (mostly) copied from edit/svc_acct.cgi
448 % #$ulen = $svc_acct->dbdef_table->column('username')->length;
449 % my $ulen = dbdef->table('svc_acct')->column('username')->length;
450 % my $ulen2 = $ulen+2;
451 % my $passwordmax = $conf->config('passwordmax') || 8;
452 % my $pmax2 = $passwordmax + 2;
457 <TD ALIGN="right">Username</TD>
459 <INPUT TYPE="text" NAME="username" VALUE="<% $username %>" SIZE=<% $ulen2 %> MAXLENGTH=<% $ulen %>>
464 <TD ALIGN="right">Password</TD>
466 <INPUT TYPE="text" NAME="_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $passwordmax %>>
472 <TD ALIGN="right">Access number</TD>
473 <TD><% FS::svc_acct_pop::popselector($popnum) %></TD>
480 <INPUT TYPE="hidden" NAME="otaker" VALUE="<% $cust_main->otaker %>">
482 <INPUT TYPE="submit" NAME="submit" VALUE="<% $custnum ? "Apply Changes" : "Add Customer" %>">
486 <% include('/elements/footer.html') %>