X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_main.cgi;h=be00213e2797229b57f6d8fe6bd912077173ea14;hb=06fb1346ff8076a84f743fa07de31852942e144f;hp=dfcd0401f5d4a73e56ab8612b73bb46e4615bae8;hpb=3ce7691203a7737406bf2d4442f7fd84b81f847e;p=freeside.git
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index dfcd0401f..be00213e2 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -1,462 +1,392 @@
-%
-%
-% #for misplaced logic below
-% #use FS::part_pkg;
-%
-% #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;
-%
-%my $conf = new FS::Conf;
-%
-%#get record
-%
-%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 ( {
-% map { $_, scalar($cgi->param($_)) } fields('cust_main')
-% } );
-% $custnum = $cust_main->custnum;
-% $saved_pkgpart = $cgi->param('pkgpart_svcpart') || '';
-% if ( $saved_pkgpart =~ /^(\d+)_/ ) {
-% $saved_pkgpart = $1;
-% } else {
-% $saved_pkgpart = '';
-% }
-% $username = $cgi->param('username');
-% $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+)$/;
-% $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 ( {} );
-% $cust_main->otaker( &getotaker );
-% $cust_main->referral_custnum( $cgi->param('referral_custnum') );
-% $saved_pkgpart = 0;
-% $username = '';
-% $password = '';
-% $popnum = 0;
-% @invoicing_list = ();
-%}
-%$cgi->delete_all();
-%
-%my $action = $custnum ? 'Edit' : 'Add';
-%$action .= ": ". $cust_main->name if $custnum;
-%
-%my $r = qq!* !;
-%
-%
-
-
-
-
-<% include('/elements/header.html',
- "Customer $action",
+<& /elements/header.html,
+ $title,
'',
- ' onUnload="myclose()"'
-) %>
-% if ( $error ) {
+ ' onUnload="myclose()"' #hmm, in billing.html
+&>
-Error: <% $error %>
-% }
+<& /elements/error.html &>
+
-
-% if ( defined $cust_main->dbdef_table->column('ship_last') ) {
+<& /elements/footer.html &>
+<%init>
-
-%
-% 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($_) );
-% }
-% }
-%
+ $cust_main = new FS::cust_main ( {
+ map { ( $_, scalar($cgi->param($_)) ) } (fields('cust_main')),
+ map { ( "ship_$_", '' ) } (FS::cust_main->location_fields)
+ } );
-
-Service address
-(>same as billing address)
-<% include('cust_main/contact.html', $cust_main, 'ship_', '', $disabled ) %>
-% }
+ for my $pre (qw(bill ship)) {
+ $cust_main->set($pre.'_location', $locations{$pre});
+ $cust_main->set($pre.'_locationnum', $locations{$pre}->locationnum);
+ }
+ $custnum = $cust_main->custnum;
-
+ die "access denied"
+ unless $curuser->access_right($custnum ? 'Edit customer' : 'New customer');
-<% include( 'cust_main/billing.html', $cust_main,
- 'invoicing_list' => \@invoicing_list,
- )
-%>
+ @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') );
+ $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
-
+ #svc_phone
+ $svc_phone{$_} = $cgi->param($_)
+ foreach qw( countrycode phonenum sip_password pin phone_name );
-
+my %keep = map { $_=>1 } qw( error tagnum lock_agentnum lock_pkgpart );
+$cgi->delete( grep { !$keep{$_} && $_ !~ /^tax_/ } $cgi->param );
+
+my $title = $custnum ? 'Edit Customer' : 'Add Customer';
+$title = mt($title);
+$title .= ": ". $cust_main->name if $custnum;
-<% include('/elements/footer.html') %>
+my $r = qq!* !;
+%init>