X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_main.cgi;h=89a946b0f98b33baff20f9f13ced3b183fcae792;hb=105c166a23234dd923757a477b4efcda65fb2881;hp=2941acdf32fbda66964ca19ab00d990cabeb485a;hpb=3dddb60bd783aaf5fa1fda90a351f1e877b7e19b;p=freeside.git diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index 2941acdf3..89a946b0f 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -1,47 +1,33 @@ + <% -# - -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 CGI::Switch; -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup getotaker); -#use FS::Record qw(qsearch qsearchs fields); -use FS::Record qw(qsearch qsearchs fields dbdef); -use FS::CGI qw(header popurl itable table); -use FS::cust_main; -use FS::agent; -use FS::part_referral; -use FS::cust_main_county; #for misplaced logic below - use FS::part_pkg; + #use FS::part_pkg; - #for false laziness below - use FS::svc_acct_pop; + #for false laziness below (now more properly lazy) + #use FS::svc_acct_pop; #for (other) false laziness below - use FS::agent; - use FS::type_pkgs; + #use FS::agent; + #use FS::type_pkgs; -$conf = new FS::Conf; +my $conf = new FS::Conf; #get record +my $error = ''; +my($custnum, $username, $password, $popnum, $cust_main, $saved_pkgpart); 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,43 +37,44 @@ 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; } -$action = $custnum ? 'Edit' : 'Add'; +$cgi->delete_all(); +my $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'); +my $p1 = popurl(1); +print header("Customer $action", ''); +print qq!Error: !, $error, "" + if $error; print qq!
!, qq!!, - qq!Customer # !, ( $custnum ? $custnum : " (NEW)" ), + qq!Customer # !, ( $custnum ? "$custnum" : " (NEW)" ), ; # agent -$r = qq!*!; +my $r = qq!*!; -@agents = qsearch( 'agent', {} ); +my @agents = qsearch( 'agent', {} ); #die "No agents created!" unless @agents; die "You have not created any agents. You must create at least one agent before adding a customer. Go to ". popurl(2). "browse/agent.cgi and create one or more agents." unless @agents; -$agentnum = $cust_main->agentnum || $agents[0]->agentnum; #default to first +my $agentnum = $cust_main->agentnum || $agents[0]->agentnum; #default to first if ( scalar(@agents) == 1 ) { print qq!!; } else { @@ -105,7 +92,7 @@ if ( scalar(@agents) == 1 ) { #referral -$refnum = $cust_main->refnum || $conf->config('referraldefault') || 0; +my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0; if ( $custnum && ! $conf->exists('editreferrals') ) { print qq!!; } else { @@ -127,10 +114,28 @@ 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 -($last,$first,$ss,$company,$address1,$address2,$city,$zip)=( +my($last,$first,$ss,$company,$address1,$address2,$city,$zip)=( $cust_main->last, $cust_main->first, $cust_main->ss, @@ -148,21 +153,34 @@ END print < , + END +if ( $conf->exists('show_ss') ) { + print qq!SS#!; +} else { + print qq!!; +} + print <SS# + Company ${r}Address   ${r}City${r}State/Country${r}Zip!; -($daytime,$night,$fax)=( +my($daytime,$night,$fax)=( $cust_main->daytime, $cust_main->night, $cust_main->fax, @@ -210,11 +228,12 @@ print <Service address ', - '(ship_last ) { print ' CHECKED'; foreach ( - qw( last first company address1 address2 city state zip daytime night fax) + qw( last first company address1 address2 city county state zip country + daytime night fax ) ) { $cust_main->set("ship_$_", $cust_main->get($_) ); } @@ -248,11 +267,17 @@ END ${r}City${r}State/Countryinvoicing_list; +my @invoicing_list = $cust_main->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 ); +my $invoicing_list = join(', ', grep { $_ ne 'POST' } @invoicing_list ); print qq!Email invoice !; print "Billing type", "", &table("#cccccc"), ""; -($payinfo, $payname)=( +my($payinfo, $payname)=( $cust_main->payinfo, $cust_main->payname, ); -%payby = ( +my %payby = ( 'CARD' => qq!Credit card
${r}
${r}Exp !. expselect("CARD"). qq!
${r}Name on card
!, - 'BILL' => qq!Billing
P.O.
${r}Exp !. expselect("BILL", "12-2037"). qq!
${r}Attention
!, + 'BILL' => qq!Billing
P.O.
${r}Exp !. expselect("BILL", "12-2037"). qq!
Attention
!, 'COMP' => qq!Complimentary
${r}Approved by
${r}Exp !. expselect("COMP"), ); -%paybychecked = ( +my %paybychecked = ( 'CARD' => qq!Credit card
${r}
${r}Exp !. expselect("CARD", $cust_main->paydate). qq!
${r}Name on card
!, - 'BILL' => qq!Billing
P.O.
${r}Exp !. expselect("BILL", $cust_main->paydate). qq!
${r}Attention
!, + 'BILL' => qq!Billing
P.O.
${r}Exp !. expselect("BILL", $cust_main->paydate). qq!
Attention
!, 'COMP' => qq!Complimentary
${r}Approved by
${r}Exp !. expselect("COMP", $cust_main->paydate), ); for (qw(CARD BILL COMP)) { @@ -369,7 +395,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 { @@ -384,10 +410,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!"; #false laziness: (mostly) copied from edit/svc_acct.cgi #$ulen = $svc_acct->dbdef_table->column('username')->length; - $ulen = dbdef->table('svc_acct')->column('username')->length; - $ulen2 = $ulen+2; + my $ulen = dbdef->table('svc_acct')->column('username')->length; + my $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; +my $otaker = $cust_main->otaker; print qq!!, - qq!

!, "", ;