X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_main.cgi;h=e10c85f01862ee2cd77b471c151d31afadeff904;hb=cccd0b7cd38a88c131e19981be38434f87abe194;hp=a18114c9d0fc3f6a6b4d13dd5ec031b0b91942ff;hpb=e6b0e9237c4bbc31c820b06ece0029f75166506d;p=freeside.git diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index a18114c9d..e10c85f01 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -1,4 +1,3 @@ - <% #for misplaced logic below @@ -18,6 +17,7 @@ my $conf = new FS::Conf; my $error = ''; my($custnum, $username, $password, $popnum, $cust_main, $saved_pkgpart); my(@invoicing_list); +my $same = ''; if ( $cgi->param('error') ) { $error = $cgi->param('error'); $cust_main = new FS::cust_main ( { @@ -34,6 +34,8 @@ if ( $cgi->param('error') ) { $password = $cgi->param('_password'); $popnum = $cgi->param('popnum'); @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') ); + $same = $cgi->param('same'); + $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid'); } elsif ( $cgi->keywords ) { #editing my( $query ) = $cgi->keywords; $query =~ /^(\d+)$/; @@ -74,9 +76,9 @@ my $action = $custnum ? 'Edit' : 'Add'; Error: <%= $error %> <% } %> -
+ -ustomer # <%= $custnum ? "$custnum" : " (NEW)" %> +Customer # <%= $custnum ? "$custnum" : " (NEW)" %> @@ -103,59 +105,65 @@ my $agentnum = $cust_main->agentnum || $agents[0]->agentnum; #default to first <% } %> + + <% +my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0; +if ( $custnum && ! $conf->exists('editreferrals') ) { +%> -# (referral and referring customer still need to be "template"ized) + -#referral +<% + } else { -my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0; -if ( $custnum && ! $conf->exists('editreferrals') ) { - print qq!!; -} else { - my(@referrals) = qsearch('part_referral',{}); - if ( scalar(@referrals) == 0 ) { - eidiot "You have not created any advertising sources. You must create at least one advertising source before adding a customer. Go to ". popurl(2). "browse/part_referral.cgi and create one or more advertising sources."; - } elsif ( scalar(@referrals) == 1 ) { - $refnum ||= $referrals[0]->refnum; - print qq!!; - } else { - print qq!

${r}Advertising source "; - } -} + my(@referrals) = qsearch('part_referral',{}); + if ( scalar(@referrals) == 0 ) { + eidiot "You have not created any advertising sources. You must create at least one advertising source before adding a customer. Go to ". popurl(2). "browse/part_referral.cgi and create one or more advertising sources."; + } elsif ( scalar(@referrals) == 1 ) { + $refnum ||= $referrals[0]->refnum; +%> -#referring customer + + +<% } else { %> + +

<%=$r%>Advertising source + +<% } %> + +<% } %> -#print qq!

Referring Customer: !; + + +<% 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. ': '. - ( $referring_cust_main->company - || $referring_cust_main->last. ', '. $referring_cust_main->first ). - ''; -} elsif ( ! $conf->exists('disable_customer_referrals') ) { - print '

Referring customer number: '; -} else { - print ''; -} - %> +

Referring Customer: + <%= $cust_main->referral_custnum %>: <%= $referring_cust_main->name %> + + +<% } elsif ( ! $conf->exists('disable_customer_referrals') ) { %> + +

Referring customer number: + + +<% } else { %> + + + +<% } %> +

@@ -172,11 +180,17 @@ function bill_changed(what) { <% for (qw( last first company address1 address2 city zip daytime night fax )) { %> what.form.ship_<%=$_%>.value = what.form.<%=$_%>.value; <% } %> + what.form.ship_country.selectedIndex = what.form.country.selectedIndex; - ship_country_changed(what.form.ship_country); - what.form.ship_state.selectedIndex = what.form.state.selectedIndex; - ship_state_changed(what.form.ship_state); - what.form.ship_county.selectedIndex = what.form.county.selectedIndex; + function fix_ship_state() { + what.form.ship_state.selectedIndex = what.form.state.selectedIndex; + } + ship_country_changed(what.form.ship_country, fix_ship_state ); + + function fix_ship_county() { + what.form.ship_county.selectedIndex = what.form.county.selectedIndex; + } + ship_state_changed(what.form.ship_state, fix_ship_county ); } } function samechanged(what) { @@ -199,7 +213,7 @@ function samechanged(what) { my $checked = ''; my $disabled = ''; my $disabledselect = ''; - unless ( $cust_main->ship_last && $cgi->param('same') ne 'Y' ) { + unless ( $cust_main->ship_last && $same ne 'Y' ) { $checked = 'CHECKED'; $disabled = 'DISABLED style="background-color: #dddddd"'; foreach ( @@ -218,181 +232,135 @@ Service address <% } %> -<% -# billing info - -sub expselect { - my $prefix = shift; - my( $m, $y ) = (0, 0); - if ( scalar(@_) ) { - my $date = shift || '01-2000'; - 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"; - } - } - - my $return = qq!!; - my @t = localtime; - my $thisYear = $t[5] + 1900; - for ( ($thisYear > $y && $y > 0 ? $y : $thisYear) .. 2037 ) { - $return .= "config('payby-default'); - -if ( $payby_default eq 'HIDE' ) { + - $cust_main->payby('BILL') unless $cust_main->payby; +<%= include('cust_main/billing.html', $cust_main ) %> - foreach my $field (qw( tax payby )) { - print qq!'; - } +', - &table("#cccccc"), ""; - - my($payinfo, $payname)=( - $cust_main->payinfo, - $cust_main->payname, + var billing_bottomvars = new Array( + 'tax', + 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX' ); - 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 number (help)
${r}Bank name !, - 'DCHK' => qq!Electronic check (on-demand)
${r}Account number
${r}ABA/Routing number (help)
${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"), -); - - 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!; - } + for ( f=0; f < topvars.length; f++ ) { + var field = topvars[f]; + copyelement( document.topform.elements[field], + document.bottomform.elements[field] + ); } - 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 number (help)
${r}Bank name !, - 'DCHK' => qq!Electronic check (on-demand)
${r}Account number
${r}ABA/Routing number (help)
${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), -); - - if ( $cust_main->dbdef_table->column('paycvv') ) { - my $paycvv = $cust_main->paycvv; + var layerform = document.topform.select.options[document.topform.select.selectedIndex].value; + for ( f=0; f < layervars.length; f++ ) { + var field = layervars[f]; + copyelement( document.forms[layerform].elements[field], + document.bottomform.elements[field] + ); + } - foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5 bs - $paybychecked{$payby} .= qq!
CVV2 (help!; - } + for ( f=0; f < billing_bottomvars.length; f++ ) { + var field = billing_bottomvars[f]; + copyelement( document.billing_bottomform.elements[field], + document.bottomform.elements[field] + ); } +} - $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{$_}!; +function copyelement(from, to) { + if ( from == undefined ) { + to.value = ''; + } else if ( from.type == 'select-one' ) { + to.value = from.options[from.selectedIndex].value; + //alert(from + " (" + from.type + "): " + to.name + " => (" + from.selectedIndex + ") " + to.value); + } else if ( from.type == 'checkbox' ) { + if ( from.checked ) { + to.value = from.value; + } else { + to.value = ''; + } + } else { + if ( from.value == undefined ) { + to.value = ''; } else { - print qq!> $payby{$_}!; + to.value = from.value; } } + //alert(from + " (" + from.type + "): " + to.name + " => " + to.value); +} - print "$r required fields for each billing type"; + -} + + +<% foreach my $hidden ( + 'custnum', 'agentnum', 'refnum', 'referral_custnum', + 'last', 'first', 'ss', 'company', + 'address1', 'address2', 'city', + 'county', 'state', 'zip', 'country', + 'daytime', 'night', 'fax', + + 'same', + + 'ship_last', 'ship_first', 'ship_company', + 'ship_address1', 'ship_address2', 'ship_city', + 'ship_county', 'ship_state', 'ship_zip', 'ship_country', + 'ship_daytime','ship_night', 'ship_fax', + + 'select', #XXX key + + 'payauto', + 'payinfo', 'payinfo1', 'payinfo2', + 'payname', 'exp_month', 'exp_year', 'paycvv', + 'paystart_month', 'paystart_year', 'payissue', + 'payip', + 'paid', + + 'tax', + 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX' + ) { +%> + +<% } %> -if ( defined $cust_main->dbdef_table->column('comments') ) { - print "

Comments", &itable("#cccccc"), - qq!", - ""; -} +
Comments +<%= &ntable("#cccccc") %> + + + + + + + +<% unless ( $custnum ) { # pry the wrong place for this logic. also pretty expensive @@ -422,7 +390,7 @@ unless ( $custnum ) { # print "

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

First package", &itable("#cccccc"), + print "
First package", &ntable("#cccccc"), qq!!, - qq!
!, - "", + qq!

!, + "", ; %>