${r}Contact name (last, first) |
-END
-
-print < ,
-
-END
-
-print <SS# | |
-Company | |
-${r}Address | |
- | |
-${r}City | | ${r}State/Country | | ${r}Zip | | !;
+%# billing info
+<& cust_main/billing.html, $cust_main,
+ 'invoicing_list' => \@invoicing_list,
+&>
-($daytime,$night,$fax)=(
- $cust_main->daytime,
- $cust_main->night,
- $cust_main->fax,
-);
+% my $ro_comments = $conf->exists('cust_main-use_comments')?'':'readonly';
+% if (!$ro_comments || $cust_main->comments) {
-print <Day Phone | |
-Night Phone | |
-Fax | |
-END
+
+ <% mt('Comments') |h %>
+
-print "$r required fields ";
+% }
-# service address
+% unless ( $custnum ) {
-if ( defined $cust_main->dbdef_table->column('ship_last') ) {
+ <& 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,
+ &>
- print "\n", <
- function changed(what) {
- what.form.same.checked = false;
- }
- function samechanged(what) {
- if ( what.checked ) {
-END
-print " what.form.ship_$_.value = what.form.$_.value;\n"
- for (qw( last first company address1 address2 city zip daytime night fax ));
-print <
+
+
+
+<& cust_main/bottomfixup.html, 'custnum' => $custnum &>
+
+
+"
+ onClick = "this.disabled=true; bottomfixup(this.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;
+
+#get record
+
+my($custnum, $cust_main, $ss, $stateid, @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 ( $cgi->param('error') ) {
+
+ $same = ($cgi->param('same') || '') eq 'Y';
+ # false laziness w/ edit/process/cust_main.cgi
+ my %locations;
+ for my $pre (qw(bill ship)) {
+ my %hash;
+ foreach my $locfield ( FS::cust_main->location_fields ) {
+ # don't search on lat/long, string values can cause qsearchs to die
+ next if grep {$_ eq $locfield} qw(latitude longitude);
+ $hash{$locfield} = scalar($cgi->param($pre.'_'.$locfield));
}
- }
-
-END
-
- print ' Service address ',
- '(ship_last ) {
- print ' CHECKED';
- foreach (
- qw( last first company address1 address2 city state zip daytime night fax)
- ) {
- $cust_main->set("ship_$_", $cust_main->get($_) );
+ $hash{'custnum'} = $cgi->param('custnum');
+ $locations{$pre} = qsearchs('cust_location', \%hash)
+ || FS::cust_location->new( \%hash );
+ # now set lat/long, for redisplay of entered values
+ foreach my $locfield ( qw(latitude longitude) ) {
+ my $locvalue = scalar($cgi->param($pre.'_'.$locfield));
+ $locations{$pre}->set($locfield,$locvalue);
}
}
- print '>same as billing address) ';
-
- my($ship_last,$ship_first,$ship_company,$ship_address1,$ship_address2,$ship_city,$ship_zip)=(
- $cust_main->ship_last,
- $cust_main->ship_first,
- $cust_main->ship_company,
- $cust_main->ship_address1,
- $cust_main->ship_address2,
- $cust_main->ship_city,
- $cust_main->ship_zip,
- );
-
- print &itable("#cccccc"), <${r}Contact name (last, first) |
-END
-
- print < ,
-
-END
-
- print <
- Company | |
- ${r}Address | |
- | |
- ${r}City | | ${r}State/Country | | ${r}Zip | | !;
- my($ship_daytime,$ship_night,$ship_fax)=(
- $cust_main->ship_daytime,
- $cust_main->ship_night,
- $cust_main->ship_fax,
- );
+ $cust_main = new FS::cust_main ( {
+ map { ( $_, scalar($cgi->param($_)) ) } (fields('cust_main')),
+ map { ( "ship_$_", '' ) } (FS::cust_main->location_fields)
+ } );
- print <Day Phone | |
- Night Phone | |
- Fax | |
-END
+ for my $pre (qw(bill ship)) {
+ $cust_main->set($pre.'_location', $locations{$pre});
+ $cust_main->set($pre.'_locationnum', $locations{$pre}->locationnum);
+ }
- print "$r required fields ";
+ $custnum = $cust_main->custnum;
-}
+ die "access denied"
+ unless $curuser->access_right($custnum ? 'Edit customer' : 'New customer');
-# billing info
-
-sub expselect {
- my $prefix = shift;
- my( $m, $y ) = (0, 0);
- if ( scalar(@_) ) {
- my $date = shift || '01-2000';
- if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
- ( $m, $y ) = ( $2, $1 );
- } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
- ( $m, $y ) = ( $1, $3 );
- } else {
- die "unrecognized expiration date format: $date";
- }
- }
+ @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') );
+ $cust_main->setfield( 'paid' => scalar($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
- my $return = qq! | |