+<& /elements/header.html,
+ $title,
+ '',
+ ' onUnload="myclose()"' #hmm, in billing.html
+&>
+
+<& /elements/error.html &>
+
+<FORM NAME = "CustomerForm"
+ METHOD = "POST"
+ ACTION = "<% popurl(1) %>process/cust_main.cgi"
+>
+
+<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
+<INPUT TYPE="hidden" NAME="prospectnum" VALUE="<% $prospectnum %>">
+
+% if ( $custnum ) {
+ <% mt('Customer #') |h %><B><% $cust_main->display_custnum %></B> -
+ <B><FONT COLOR="#<% $cust_main->statuscolor %>">
+ <% ucfirst($cust_main->status) %>
+ </FONT></B>
+ <BR><BR>
+% }
+
+%# agent, agent_custid, refnum (advertising source), referral_custnum
+%# better section title for this?
+<FONT CLASS="fsinnerbox-title"><% mt('Basics') |h %></FONT>
+<& cust_main/top_misc.html, $cust_main, 'custnum' => $custnum &>
+
+%# birthdate
+% if ( $conf->config('national_id-country')
+% || $conf->exists('cust_main-enable_birthdate')
+% || $conf->exists('cust_main-enable_spouse_birthdate')
+% || $conf->exists('cust_main-enable_anniversary_date')
+% )
+% {
+ <BR>
+ <& cust_main/birthdate.html, $cust_main &>
+% }
+% my $has_ship_address = '';
+% if ( $cgi->param('error') ) {
+% $has_ship_address = !$same;
+% } elsif ( $cust_main->custnum ) {
+% $has_ship_address = $cust_main->has_ship_address;
+% }
+<BR>
+<TABLE> <TR>
+ <TD STYLE="width:650px">
+%#; padding-right:2px; vertical-align:top">
+ <FONT CLASS="fsinnerbox-title"><% mt('Billing address') |h %></FONT>
+ <TABLE CLASS="fsinnerbox">
+ <& cust_main/before_bill_location.html, $cust_main &>
+ <& /elements/location.html,
+ object => $cust_main->bill_location,
+ prefix => 'bill_',
+ enable_coords => 1,
+ &>
+ <& cust_main/after_bill_location.html, $cust_main &>
+ </TABLE>
+ </TD>
+</TR>
+<TR><TD STYLE="height:40px"></TD></TR>
+<TR>
+ <TD STYLE="width:650px">
+%#; padding-left:2px; vertical-align:top">
+ <FONT CLASS="fsinnerbox-title"><% mt('Service address') |h %></FONT>
+ <INPUT TYPE="checkbox"
+ NAME="same"
+ ID="same"
+ onclick="samechanged(this)"
+ onkeyup="samechanged(this)"
+ VALUE="Y"
+ <% $has_ship_address ? '' : 'CHECKED' %>
+ ><% mt('same as billing address') |h %>
+ <TABLE CLASS="fsinnerbox" ID="table_ship_location">
+ <& /elements/location.html,
+ object => $cust_main->ship_location,
+ prefix => 'ship_',
+ enable_censustract => 1,
+ enable_district => 1,
+ enable_coords => 1,
+ &>
+ </TABLE>
+ <TABLE CLASS="fsinnerbox" ID="table_ship_location_blank"
+ STYLE="display:none">
+ <TR><TD></TD></TR>
+ </TABLE>
+ </TD>
+</TR></TABLE>
+
+<SCRIPT>
+function samechanged(what) {
+%# not display = 'none', because we still want it to take up space
+%# document.getElementById('table_ship_location').style.visibility =
+%# what.checked ? 'hidden' : 'visible';
+ var t1 = document.getElementById('table_ship_location');
+ var t2 = document.getElementById('table_ship_location_blank');
+ if ( what.checked ) {
+ t2.style.width = t1.clientWidth + 'px';
+ t2.style.height = t1.clientHeight + 'px';
+ t1.style.display = 'none';
+ t2.style.display = '';
+ }
+ else {
+ t2.style.display = 'none';
+ t1.style.display = '';
+ }
+}
+//samechanged(document.getElementById('same'));
+</SCRIPT>
+
+<BR>
+
+<& cust_main/contacts_new.html,
+ 'cust_main' => $cust_main,
+&>
+
+%# billing info
+<& cust_main/billing.html, $cust_main,
+ 'payinfo' => $payinfo,
+ 'invoicing_list' => \@invoicing_list,
+&>
+<BR>
+
+% my $ro_comments = $conf->exists('cust_main-use_comments')?'':'readonly';
+% if (!$ro_comments || $cust_main->comments) {
+
+ <BR>
+ <FONT CLASS="fsinnerbox-title"><% mt('Comments') |h %></FONT>
+ <TABLE CLASS="fsinnerbox">
+ <TR>
+ <TD>
+ <TEXTAREA NAME = "comments"
+ COLS = 80
+ ROWS = 5
+ WRAP = "HARD"
+ <% $ro_comments %>
+ ><% $cust_main->comments %></TEXTAREA>
+ </TD>
+ </TR>
+ </TABLE>
+
+% }
+
+% unless ( $custnum ) {
+
+ <& cust_main/first_pkg.html, $cust_main,
+ 'pkgpart_svcpart' => $pkgpart_svcpart,
+ 'disable_empty' =>
+ scalar( $cgi->param('lock_pkgpart') =~ /^(\d+)$/ ),
+ 'username' => $username,
+ 'password' => $password,
+ 'popnum' => $popnum,
+ 'saved_domsvc' => $saved_domsvc,
+ %svc_phone,
+ %svc_dsl,
+ &>
+
+% }
+
+<INPUT TYPE="hidden" NAME="locationnum" VALUE="<% $locationnum %>">
+
+<INPUT TYPE="hidden" NAME="usernum" VALUE="<% $cust_main->usernum %>">
+
+%# cust_main/bottomfixup.js
+% foreach my $hidden (
+% 'payauto', 'billday',
+% 'payinfo', 'payinfo1', 'payinfo2', 'payinfo3', 'paytype',
+% 'payname', 'paystate', 'exp_month', 'exp_year', 'paycvv',
+% 'paystart_month', 'paystart_year', 'payissue',
+% 'payip',
+% 'paid',
+% ) {
+ <INPUT TYPE="hidden" NAME="<% $hidden %>" VALUE="">
+% }
+
+<& cust_main/bottomfixup.html, 'custnum' => $custnum &>
+
+<BR>
+<INPUT TYPE = "button"
+ NAME = "submitButton"
+ ID = "submitButton"
+ VALUE = "<% $custnum ? emt("Apply changes") : emt("Add Customer") %>"
+ onClick = "this.disabled=true; bottomfixup(this.form);"
+>
+<BR><BR>
+</FORM>
+
+<& /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;