X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_main.cgi;h=9588dcb3aa53fe12da8a867b45ebfc6f5843b609;hp=8902e3dcea09328ccfb9bddc1720e45316ac975f;hb=cf16b23820da69e3c8d0156ae27e21c635bf1ec5;hpb=51984ac3d3da3006809c6866fdecd4ad83610731 diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index 8902e3dce..9588dcb3a 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -1,11 +1,12 @@ <% -# +# use vars qw( $cgi $custnum $action $cust_main $p1 @agents $agentnum $last $first $ss $company $address1 $address2 $city $zip $daytime $night $fax @invoicing_list $invoicing_list $payinfo $payname %payby %paybychecked $refnum $otaker $r ); -use vars qw ( $conf $pkgpart $username $password $popnum $ulen $ulen2 ); +use vars qw ( $conf $saved_pkgpart $username $password $popnum $ulen $ulen2 ); +use vars qw ( $error ); #use CGI::Switch; use CGI; use CGI::Carp qw(fatalsToBrowser); @@ -21,7 +22,7 @@ use FS::cust_main_county; #for misplaced logic below use FS::part_pkg; - #for false laziness below + #for false laziness below (now more properly lazy) use FS::svc_acct_pop; #for (other) false laziness below @@ -32,16 +33,18 @@ $conf = new FS::Conf; #get record +$error = ''; if ( $cgi->param('error') ) { + $error = $cgi->param('error'); $cust_main = new FS::cust_main ( { map { $_, scalar($cgi->param($_)) } fields('cust_main') } ); $custnum = $cust_main->custnum; - $pkgpart = $cgi->param('pkgpart_svcpart') || ''; - if ( $pkgpart =~ /^(\d+)_/ ) { - $pkgpart = $1; + $saved_pkgpart = $cgi->param('pkgpart_svcpart') || ''; + if ( $saved_pkgpart =~ /^(\d+)_/ ) { + $saved_pkgpart = $1; } else { - $pkgpart = ''; + $saved_pkgpart = ''; } $username = $cgi->param('username'); $password = $cgi->param('_password'); @@ -51,32 +54,33 @@ if ( $cgi->param('error') ) { $query =~ /^(\d+)$/; $custnum=$1; $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); - $pkgpart = 0; + $saved_pkgpart = 0; $username = ''; $password = ''; $popnum = 0; } else { $custnum=''; $cust_main = new FS::cust_main ( {} ); - $cust_main->setfield('otaker',&getotaker); - $pkgpart = 0; + $cust_main->otaker( &getotaker ); + $cust_main->referral_custnum( $cgi->param('referral_custnum') ); + $saved_pkgpart = 0; $username = ''; $password = ''; $popnum = 0; } +$cgi->delete_all(); $action = $custnum ? 'Edit' : 'Add'; # top $p1 = popurl(1); -print $cgi->header( '-expires' => 'now' ), header("Customer $action", ''); -print qq!Error: !, $cgi->param('error'), - "" - if $cgi->param('error'); +print header("Customer $action", ''); +print qq!Error: !, $error, "" + if $error; print qq!
!, qq!!, - qq!Customer # !, ( $custnum ? $custnum : " (NEW)" ), + qq!Customer # !, ( $custnum ? "$custnum" : " (NEW)" ), ; @@ -127,6 +131,24 @@ if ( $custnum && ! $conf->exists('editreferrals') ) { } } +#referring customer + +#print qq!

Referring Customer: !; +if ( $cust_main->referral_custnum ) { + my $referring_cust_main = + qsearchs('cust_main', { custnum => $cust_main->referral_custnum } ); + print '

Referring Customer: '. + $cust_main->referral_custnum. ': '. + ( $referring_cust_main->company + || $referring_cust_main->last. ', '. $referring_cust_main->first ). + ''; +} elsif ( ! $conf->exists('disable_customer_referrals') ) { + print '

Referring customer number: '; +} else { + print ''; +} # contact info @@ -158,11 +180,16 @@ print <${r}City${r}State/Countryship_last ) { print ' CHECKED'; foreach ( @@ -320,7 +347,8 @@ print qq!>Tax Exempt!; print qq!invoicing_list; print qq! CHECKED! - if ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list; + if ( ! @invoicing_list && ! $conf->exists('disablepostalinvoicedefault') ) + || grep { $_ eq 'POST' } @invoicing_list; print qq!>Postal mail invoice!; $invoicing_list = join(', ', grep { $_ ne 'POST' } @invoicing_list ); print qq!Email invoice !; @@ -355,6 +383,13 @@ for (qw(CARD BILL COMP)) { print "$r required fields for each billing type"; +if ( defined $cust_main->dbdef_table->column('comments') ) { + print "

Comments", &itable("#cccccc"), + qq!", + ""; +} + unless ( $custnum ) { # pry the wrong place for this logic. also pretty expensive #use FS::part_pkg; @@ -362,7 +397,7 @@ unless ( $custnum ) { #false laziness, copied from FS::cust_pkg::order my $pkgpart; if ( scalar(@agents) == 1 ) { - # $pkgpart->{PKGPART} is true iff $custnum may purchase $pkgpart + # $pkgpart->{PKGPART} is true iff $custnum may purchase PKGPART my($agent)=qsearchs('agent',{'agentnum'=> $agentnum }); $pkgpart = $agent->pkgpart_hashref; } else { @@ -377,10 +412,12 @@ unless ( $custnum ) { #eslaf my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } } - qsearch( 'part_pkg', {} ); + qsearch( 'part_pkg', { 'disabled' => '' } ); if ( @part_pkg ) { +# print "

First package", &itable("#cccccc", "0 ALIGN=LEFT"), +#apiabuse & undesirable wrapping print "

First package", &itable("#cccccc"), qq!"; @@ -399,32 +436,27 @@ unless ( $custnum ) { #$ulen = $svc_acct->dbdef_table->column('username')->length; $ulen = dbdef->table('svc_acct')->column('username')->length; $ulen2 = $ulen+2; + my $passwordmax = $conf->config('passwordmax') || 8; + my $pmax2 = $passwordmax + 2; print <Username Password - + (blank to generate) END - print qq!POP"; + + print 'Access number' + . + &FS::svc_acct_pop::popselector($popnum). + '' + ; } } $otaker = $cust_main->otaker; print qq!!, - qq!

!, "", ;