X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_main.cgi;h=39b6ca594556a94b043dcad4a307117dafa86dc2;hb=415150fe1997eb2688dfd492710f644574e29daf;hp=d3251c2b9a8797f9abd04b1afe491f0d95e07e23;hpb=5e25b996982d42eb2587ec54db0d5b39508aa730;p=freeside.git diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index d3251c2b9..39b6ca594 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -1,39 +1,22 @@ + <% -# - -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 $saved_pkgpart $username $password $popnum $ulen $ulen2 ); -use vars qw ( $error ); -#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 (now more properly lazy) - use FS::svc_acct_pop; + #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 -$error = ''; +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 ( { @@ -69,11 +52,11 @@ if ( $cgi->param('error') ) { $popnum = 0; } $cgi->delete_all(); -$action = $custnum ? 'Edit' : 'Add'; +my $action = $custnum ? 'Edit' : 'Add'; # top -$p1 = popurl(1); +my $p1 = popurl(1); print header("Customer $action", ''); print qq!Error: !, $error, "" if $error; @@ -86,12 +69,12 @@ print qq!
!, # 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 { @@ -109,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 { @@ -152,7 +135,7 @@ if ( $cust_main->referral_custnum ) { # 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, @@ -164,56 +147,59 @@ if ( $cust_main->referral_custnum ) { ); print "

Billing address", &itable("#cccccc"), <${r}Contact name
(last, first) +${r}Contact name
(last, first) 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}State END +#false laziness with ship state my $countrydefault = $conf->config('countrydefault') || 'US'; $cust_main->country( $countrydefault ) unless $cust_main->country; + $cust_main->state( $conf->config('statedefault') || 'CA' ) unless $cust_main->state || $cust_main->country ne 'US'; -foreach ( sort { - ( $b->country eq $countrydefault ) <=> ( $a->country eq $countrydefault ) - or $a->country cmp $b->country - or $a->state cmp $b->state - or $a->county cmp $b->county -} qsearch('cust_main_county',{}) ) { - print "state eq $_->state - && $cust_main->county eq $_->county - && $cust_main->country eq $_->country - ); - print ">",$_->state; - print " (",$_->county,")" if $_->county; - print " / ", $_->country; -} -print qq!${r}Zip!; -($daytime,$night,$fax)=( +my($county_html, $state_html, $country_html) = + FS::cust_main_county::regionselector( $cust_main->county, + $cust_main->state, + $cust_main->country ); + +print "$county_html $state_html"; + +print qq!${r}Zip!; + +my($daytime,$night,$fax)=( $cust_main->daytime, $cust_main->night, $cust_main->fax, ); print <${r}Country$country_html Day Phone Night Phone Fax END -print "$r required fields
"; +print "${r}required fields
"; # service address @@ -230,7 +216,11 @@ END print " what.form.ship_$_.value = what.form.$_.value;\n" for (qw( last first company address1 address2 city zip daytime night fax )); print < @@ -241,7 +231,8 @@ END unless ( $cust_main->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($_) ); } @@ -259,7 +250,7 @@ END ); print &itable("#cccccc"), <${r}Contact name
(last, first) + ${r}Contact name
(last, first) END print <Company ${r}Address   - ${r}City${r}State/Country${r}State END - $cust_main->ship_country( $conf->config('countrydefault') || 'US' ) - unless $cust_main->ship_country; + #false laziness with regular state + $cust_main->ship_country( $countrydefault ) unless $cust_main->ship_country; + $cust_main->ship_state( $conf->config('statedefault') || 'CA' ) unless $cust_main->ship_state || $cust_main->ship_country ne 'US'; - foreach ( qsearch('cust_main_county',{}) ) { - print "ship_state eq $_->state - && $cust_main->ship_county eq $_->county - && $cust_main->ship_country eq $_->country - ); - print ">",$_->state; - print " (",$_->county,")" if $_->county; - print " / ", $_->country; - } - print qq!${r}Zip!; + + my($ship_county_html, $ship_state_html, $ship_country_html) = + FS::cust_main_county::regionselector( $cust_main->ship_county, + $cust_main->ship_state, + $cust_main->ship_country, + 'ship_', + 'changed(this)', ); + + print "$ship_county_html $ship_state_html"; + + print qq!${r}Zip!; my($ship_daytime,$ship_night,$ship_fax)=( $cust_main->ship_daytime, @@ -298,12 +290,13 @@ END ); print <${r}Country$ship_country_html Day Phone Night Phone Fax END - print "$r required fields
"; + print "${r}required fields
"; } @@ -345,29 +338,29 @@ print "
Billing information", &itable("#cccccc"), print qq! CHECKED! if $cust_main->tax eq "Y"; print qq!>Tax Exempt!; print qq!invoicing_list; +my @invoicing_list = $cust_main->invoicing_list; print qq! CHECKED! 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!
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!
Attention
!, 'COMP' => qq!Complimentary
${r}Approved by
${r}Exp !. expselect("COMP", $cust_main->paydate), @@ -434,8 +427,8 @@ unless ( $custnum ) { #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 <otaker; +my $otaker = $cust_main->otaker; print qq!!, qq!
!,