% include('/elements/header.html', $title, '', ' onUnload="myclose()"' #hmm, in billing.html ) %> <% include('/elements/error.html') %>
<% include('/elements/footer.html') %> <%init> my $curuser = $FS::CurrentUser::CurrentUser; #probably redundant given the checks below... die "access denied" unless $curuser->access_right('New customer') || $curuser->access_right('Edit customer'); my $conf = new FS::Conf; #get record my($custnum, $cust_main, $ss, $stateid, $payinfo, @invoicing_list); my $same = ''; my $pkgpart_svcpart = ''; #first_pkg my($username, $password, $popnum, $saved_domsvc) = ( '', '', 0, 0 ); #svc_acct my %svc_phone = (); if ( $cgi->param('error') ) { $cust_main = new FS::cust_main ( { map { $_, scalar($cgi->param($_)) } fields('cust_main') } ); $custnum = $cust_main->custnum; die "access denied" unless $curuser->access_right($custnum ? 'Edit customer' : 'New customer'); @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') ); $same = $cgi->param('same'); $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid'); $ss = $cust_main->ss; # don't mask an entered value on errors $stateid = $cust_main->stateid; # don't mask an entered value on errors $payinfo = $cust_main->payinfo; # don't mask an entered value on errors $pkgpart_svcpart = $cgi->param('pkgpart_svcpart') || ''; #svc_acct $username = $cgi->param('username'); $password = $cgi->param('_password'); $popnum = $cgi->param('popnum'); $saved_domsvc = $cgi->param('domsvc') || ''; if ( $saved_domsvc =~ /^(\d+)$/ ) { $saved_domsvc = $1; } else { $saved_domsvc = ''; } #svc_phone $svc_phone{$_} = $cgi->param($_) foreach qw( countrycode phonenum sip_password pin phone_name ); } elsif ( $cgi->keywords ) { #editing die "access denied" unless $curuser->access_right('Edit customer'); 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); } @invoicing_list = $cust_main->invoicing_list; $ss = $cust_main->masked('ss'); $stateid = $cust_main->masked('stateid'); $payinfo = $cust_main->paymask; } else { #new customer die "access denied" unless $curuser->access_right('New customer'); $custnum=''; $cust_main = new FS::cust_main ( {} ); $cust_main->otaker( &getotaker ); $cust_main->referral_custnum( $cgi->param('referral_custnum') ); @invoicing_list = (); push @invoicing_list, 'POST' unless $conf->exists('disablepostalinvoicedefault'); $ss = ''; $stateid = ''; $payinfo = ''; if ( $cgi->param('lock_pkgpart') =~ /^(\d+)$/ ) { my $pkgpart = $1; my $part_pkg = qsearchs('part_pkg', { 'pkgpart' => $pkgpart } ) or die "unknown pkgpart $pkgpart"; my $svcpart = $part_pkg->svcpart; $pkgpart_svcpart = $pkgpart.'_'.$svcpart; } } my %keep = map { $_=>1 } qw( error tagnum lock_agentnum lock_pkgpart ); $cgi->delete( grep !$keep{$_}, $cgi->param ); my $title = $custnum ? 'Edit Customer' : 'Add Customer'; $title .= ": ". $cust_main->name if $custnum; my $r = qq!* !; %init>