X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_main.cgi;h=4399c434895da6de54e5f561960dbb32e5c799de;hb=fc71c5a7a2b5595ef38621ead753c6b261c534ba;hp=c3d1804bcf53741e64f0be9980f9c9cb66e83047;hpb=b19897e1db4c110d7d7e8b52800cda5ab58ce9e0;p=freeside.git
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index c3d1804bc..4399c4348 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -1,452 +1,407 @@
-<%
-
- #for misplaced logic below
- #use FS::part_pkg;
+<& /elements/header.html,
+ $title,
+ '',
+ ' onUnload="myclose()"' #hmm, in billing.html
+&>
- #for false laziness below (now more properly lazy)
- #use FS::svc_acct_pop;
+<& /elements/error.html &>
- #for (other) false laziness below
- #use FS::agent;
- #use FS::type_pkgs;
+
-
- Referring customer |
-
-
- <%= include('/elements/search-cust_main.html',
- 'field_name' => 'referral_custnum',
- )
- %>
- |
-
+<& /elements/footer.html &>
-<% } else { %>
+<%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
-
-Billing address
-<%= include('cust_main/contact.html', $cust_main, '', 'bill_changed(this)', '' ) %>
+my($custnum, $cust_main, $ss, $stateid, $payinfo, @invoicing_list);
+my $pkgpart_svcpart = ''; #first_pkg
+my($username, $password, $popnum, $saved_domsvc) = ( '', '', 0, 0 ); #svc_acct
+my %svc_phone = ();
+my %svc_dsl = ();
+my $prospectnum = '';
+my $locationnum = '';
+my $same = '';
-
+$m->comp('/elements/handle_uri_query', 'secure'=>1);
-<% if ( defined $cust_main->dbdef_table->column('ship_last') ) { %>
+if ( $cgi->param('error') ) {
-
-<%
- 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 );
-<%= include('/elements/footer.html') %>
+my $title = $custnum ? 'Edit Customer' : 'Add Customer';
+$title = mt($title);
+$title .= ": ". $cust_main->name if $custnum;
+
+my $r = qq!* !;
+%init>