X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_main.cgi;h=d4217bbcc3e458c569bffe761aae469538b40bf5;hb=3dfc446d8a4d241787c47ff7e2db72483d62ab7a;hp=45cb69fc2d30c1f033c2b86e594e01377a106c2e;hpb=e47e9758f480c664bfc3917d798cd69c7d354999;p=freeside.git
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index 45cb69fc2..d4217bbcc 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -1,444 +1,376 @@
-<%
+<% include('/elements/header.html',
+ $title,
+ '',
+ ' onUnload="myclose()"' #hmm, in billing.html
+) %>
- #for misplaced logic below
- #use FS::part_pkg;
+<% include('/elements/error.html') %>
- #for false laziness below (now more properly lazy)
- #use FS::svc_acct_pop;
+
-
- Referring customer |
-
- <%= $cust_main->referral_custnum %>: <%= $referring_cust_main->name %>
- |
-
-
+<% include('/elements/footer.html') %>
-<% } elsif ( ! $conf->exists('disable_customer_referrals') ) { %>
+<%init>
-
- Referring customer |
- |
-
+my $curuser = $FS::CurrentUser::CurrentUser;
-<% } else { %>
+#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 = ();
+my %svc_dsl = ();
+my $prospectnum = '';
-
+if ( $cgi->param('error') ) {
-
-Billing address
-<%= include('cust_main/contact.html', $cust_main, '', 'bill_changed(this)', '' ) %>
+ $cust_main = new FS::cust_main ( {
+ map { $_, scalar($cgi->param($_)) } fields('cust_main')
+ } );
-
+ $custnum = $cust_main->custnum;
-<% if ( defined $cust_main->dbdef_table->column('ship_last') ) { %>
+ die "access denied"
+ unless $curuser->access_right($custnum ? 'Edit customer' : 'New customer');
-
-<%
- my $checked = '';
- my $disabled = '';
- my $disabledselect = '';
- unless ( $cust_main->ship_last && $same ne 'Y' ) {
- $checked = 'CHECKED';
- $disabled = 'DISABLED style="background-color: #dddddd"';
- foreach (
- qw( last first company address1 address2 city county state zip country
- daytime night fax )
- ) {
- $cust_main->set("ship_$_", $cust_main->get($_) );
- }
+ #svc_phone
+ $svc_phone{$_} = $cgi->param($_)
+ foreach qw( countrycode phonenum sip_password pin phone_name );
+
+ #svc_dsl (phonenum came in with svc_phone)
+ $svc_phone{$_} = $cgi->param($_)
+ foreach qw( password isp_chg isp_prev vendor_qual_id );
+
+} 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;
-
-Service address
-(>same as billing address)
-<%= include('cust_main/contact.html', $cust_main, 'ship_', '', $disabled ) %>
+} 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 = '';
-<%= include( 'cust_main/billing.html', $cust_main,
- 'invoicing_list' => \@invoicing_list,
- )
-%>
+ if ( $cgi->param('qualnum') =~ /^(\d+)$/ ) {
+ my $qualnum = $1;
+ my $qual = qsearchs('qual', { 'qualnum' => $qualnum } )
+ or die "unknown qualnum $qualnum";
-
+ #location -> address (all prospect quals have location, right?)
+ my $cust_location = $qual->cust_location;
+ $cust_location->dealternize;
+ $cust_main->$_( $cust_location->$_ )
+ foreach qw( address1 address2 city county state zip country geocode );
-
+my $title = $custnum ? 'Edit Customer' : 'Add Customer';
+$title .= ": ". $cust_main->name if $custnum;
-<%= include('/elements/footer.html') %>
+my $r = qq!* !;
+%init>