X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_main.cgi;h=857e769a375e4131e0fa8994bad3c74fc9c25720;hp=831b2ab9764230110e11e35db44da1eb5dbc90d0;hb=eb9668a6f3181ee02cb335272c5ee4616e61fd09;hpb=0ccfb017d1075a2def6e151fb78b1a162eb6c0e8 diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index 831b2ab97..857e769a3 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -17,6 +17,7 @@ my $conf = new FS::Conf; my $error = ''; my($custnum, $username, $password, $popnum, $cust_main, $saved_pkgpart); +my(@invoicing_list); if ( $cgi->param('error') ) { $error = $cgi->param('error'); $cust_main = new FS::cust_main ( { @@ -32,15 +33,23 @@ if ( $cgi->param('error') ) { $username = $cgi->param('username'); $password = $cgi->param('_password'); $popnum = $cgi->param('popnum'); + @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') ); } elsif ( $cgi->keywords ) { #editing my( $query ) = $cgi->keywords; $query =~ /^(\d+)$/; $custnum=$1; $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); + if ( $cust_main->dbdef_table->column('paycvv') + && length($cust_main->paycvv) ) { + my $paycvv = $cust_main->paycvv; + $paycvv =~ s/./*/g; + $cust_main->paycvv($paycvv); + } $saved_pkgpart = 0; $username = ''; $password = ''; $popnum = 0; + @invoicing_list = $cust_main->invoicing_list; } else { $custnum=''; $cust_main = new FS::cust_main ( {} ); @@ -50,6 +59,7 @@ if ( $cgi->param('error') ) { $username = ''; $password = ''; $popnum = 0; + @invoicing_list = (); } $cgi->delete_all(); my $action = $custnum ? 'Edit' : 'Add'; @@ -57,7 +67,7 @@ my $action = $custnum ? 'Edit' : 'Add'; # top my $p1 = popurl(1); -print header("Customer $action", ''); +print header("Customer $action", '', ' onUnload="myclose()"'); print qq!Error: !, $error, "" if $error; @@ -71,9 +81,11 @@ print qq!
!, my $r = qq!* !; -my @agents = qsearch( 'agent', {} ); +my %agent_search = dbdef->table('agent')->column('disabled') + ? ( 'disabled' => '' ) : (); +my @agents = qsearch( 'agent', \%agent_search ); #die "No agents created!" unless @agents; -eidiot "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; +eidiot "You have not created any agents (or all agents are disabled). 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; my $agentnum = $cust_main->agentnum || $agents[0]->agentnum; #default to first if ( scalar(@agents) == 1 ) { print qq!!; @@ -120,9 +132,11 @@ 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 } ); +my $referring_cust_main = ''; +if ( $cust_main->referral_custnum + and $referring_cust_main = + qsearchs('cust_main', { custnum => $cust_main->referral_custnum } ) +) { print '

Referring Customer: '. $cust_main->referral_custnum. ': '. @@ -177,8 +191,10 @@ END 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'; +my $statedefault = $conf->config('statedefault') + || ($countrydefault eq 'US' ? 'CA' : ''); +$cust_main->state( $statedefault ) + unless $cust_main->state || $cust_main->country ne $countrydefault; my($county_html, $state_html, $country_html) = FS::cust_main_county::regionselector( $cust_main->county, @@ -195,10 +211,13 @@ my($daytime,$night,$fax)=( $cust_main->fax, ); +my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone'; +my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone'; + print <${r}Country$country_html -Day Phone -Night Phone +$daytime_label +$night_label Fax END @@ -231,7 +250,7 @@ END print '
Service address ', '(ship_last ) { + unless ( $cust_main->ship_last && $cgi->param('same') ne 'Y' ) { print ' CHECKED'; foreach ( qw( last first company address1 address2 city county state zip country @@ -272,8 +291,9 @@ END #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'; + $cust_main->ship_state( $statedefault ) + unless $cust_main->ship_state + || $cust_main->ship_country ne $countrydefault; my($ship_county_html, $ship_state_html, $ship_country_html) = FS::cust_main_county::regionselector( $cust_main->ship_county, @@ -294,8 +314,8 @@ END print <${r}Country$ship_country_html - Day Phone - Night Phone + $daytime_label + $night_label Fax END @@ -326,7 +346,9 @@ sub expselect { $return .= ">$_"; } $return .= qq!/tax eq "Y"; -print qq!>Tax Exempt!; -print qq!invoicing_list; -print qq! CHECKED! - if ( ! @invoicing_list && ! $conf->exists('disablepostalinvoicedefault') ) - || grep { $_ eq 'POST' } @invoicing_list; -print qq!>Postal mail invoice!; -my $invoicing_list = join(', ', grep { $_ ne 'POST' } @invoicing_list ); -print qq!Email invoice !; - -print "Billing type", - "", - &table("#cccccc"), ""; - -my($payinfo, $payname)=( - $cust_main->payinfo, - $cust_main->payname, -); +my $payby_default = $conf->config('payby-default'); + +if ( $payby_default eq 'HIDE' ) { + + $cust_main->payby('BILL') unless $cust_main->payby; + + foreach my $field (qw( tax payby )) { + print qq!'; + } + + print qq!'; + + foreach my $payby (qw( CARD DCRD CHEK DCHK LECB BILL COMP )) { + foreach my $field (qw( payinfo payname )) { + print qq!'; + } + + #false laziness w/expselect + my( $m, $y ); + my $date = $cust_main->paydate || '12-2037'; + if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format + ( $m, $y ) = ( $2, $1 ); + } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { + ( $m, $y ) = ( $1, $3 ); + } else { + die "unrecognized expiration date format: $date"; + } + + print qq!!. + qq!!; + + } -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"), +} else { + + print "
Billing information", &itable("#cccccc"), + qq!tax eq "Y"; + print qq!>Tax Exempt!. + qq!invoicing_list; + print qq! CHECKED! + if ( ! @invoicing_list && ! $conf->exists('disablepostalinvoicedefault') ) + || grep { $_ eq 'POST' } @invoicing_list; + print qq!>Postal mail invoice!; + my $invoicing_list = join(', ', grep { $_ ne 'POST' } @invoicing_list ); + print qq!Email invoice !; + + print "Billing type", + "", '', + &table("#cccccc"), ""; + + my($payinfo, $payname)=( + $cust_main->payinfo, + $cust_main->payname, + ); + + my %payby = ( + 'CARD' => qq!Credit card (automatic)
${r}
${r}Exp !. expselect("CARD"). qq!
${r}Name on card
!, + 'DCRD' => qq!Credit card (on-demand)
${r}
${r}Exp !. expselect("DCRD"). qq!
${r}Name on card
!, + 'CHEK' => qq!Electronic check (automatic)
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'DCHK' => qq!Electronic check (on-demand)
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'LECB' => qq!Phone bill billing
${r}Phone number !, + 'BILL' => qq!Billing
P.O.
Attention
!, + 'COMP' => qq!Complimentary
${r}Approved by
${r}Exp !. expselect("COMP"), ); -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), + + if ( $cust_main->dbdef_table->column('paycvv') ) { + foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5 bs + $payby{$payby} .= qq!
CVV2 (
help!; + } + } + + my( $account, $aba ) = split('@', $payinfo); + + my %paybychecked = ( + 'CARD' => qq!Credit card (automatic)
${r}
${r}Exp !. expselect("CARD", $cust_main->paydate). qq!
${r}Name on card
!, + 'DCRD' => qq!Credit card (on-demand)
${r}
${r}Exp !. expselect("DCRD", $cust_main->paydate). qq!
${r}Name on card
!, + 'CHEK' => qq!Electronic check (automatic)
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'DCHK' => qq!Electronic check (on-demand)
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'LECB' => qq!Phone bill billing
${r}Phone number !, + 'BILL' => qq!Billing
P.O.
Attention
!, + 'COMP' => qq!Complimentary
${r}Approved by
${r}Exp !. expselect("COMP", $cust_main->paydate), ); -for (qw(CARD BILL COMP)) { - print qq!payby eq "$_") { - print qq! CHECKED> $paybychecked{$_}!; - } else { - print qq!> $payby{$_}!; + + if ( $cust_main->dbdef_table->column('paycvv') ) { + my $paycvv = $cust_main->paycvv; + + foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5 bs + $paybychecked{$payby} .= qq!
CVV2 (help!; + } + } + + + $cust_main->payby($payby_default) unless $cust_main->payby; + for (qw(CARD DCRD CHEK DCHK LECB BILL COMP)) { + print qq!payby eq "$_") { + print qq! CHECKED> $paybychecked{$_}!; + } else { + print qq!> $payby{$_}!; + } } -} -print "$r required fields for each billing type"; + print "$r required fields for each billing type"; + +} if ( defined $cust_main->dbdef_table->column('comments') ) { print "

Comments", &itable("#cccccc"), @@ -422,7 +525,7 @@ unless ( $custnum ) { foreach my $part_pkg ( @part_pkg ) { print qq!