X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_main.cgi;h=857e769a375e4131e0fa8994bad3c74fc9c25720;hp=2941acdf32fbda66964ca19ab00d990cabeb485a;hb=eb9668a6f3181ee02cb335272c5ee4616e61fd09;hpb=3dddb60bd783aaf5fa1fda90a351f1e877b7e19b diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index 2941acdf3..857e769a3 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -1,93 +1,92 @@ + <% -# - -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); +my(@invoicing_list); 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'); $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 } ); - $pkgpart = 0; + 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 ( {} ); - $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; + @invoicing_list = (); } -$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", '', ' onUnload="myclose()"'); +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 %agent_search = dbdef->table('agent')->column('disabled') + ? ( 'disabled' => '' ) : (); +my @agents = qsearch( 'agent', \%agent_search ); #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 +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!!; } else { @@ -98,23 +97,26 @@ if ( scalar(@agents) == 1 ) { } @agents) { print '