"same as billing address" box would uncheck itself on errors (only looked
[freeside.git] / httemplate / edit / cust_main.cgi
index 33e72d8..3a5df08 100755 (executable)
@@ -73,7 +73,7 @@ my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
 
 my @agents = qsearch( 'agent', {} );
 #die "No agents created!" unless @agents;
-die "You have not created any agents.  You must create at least one agent before adding a customer.  Go to ". popurl(2). "browse/agent.cgi and create one or more agents." unless @agents;
+eidiot "You have not created any agents.  You must create at least one agent before adding a customer.  Go to ". popurl(2). "browse/agent.cgi and create one or more agents." unless @agents;
 my $agentnum = $cust_main->agentnum || $agents[0]->agentnum; #default to first
 if ( scalar(@agents) == 1 ) {
   print qq!<INPUT TYPE="hidden" NAME="agentnum" VALUE="$agentnum">!;
@@ -98,11 +98,13 @@ if ( $custnum && ! $conf->exists('editreferrals') ) {
   print qq!<INPUT TYPE="hidden" NAME="refnum" VALUE="$refnum">!;
 } else {
   my(@referrals) = qsearch('part_referral',{});
-  if ( scalar(@referrals) == 1 ) {
+  if ( scalar(@referrals) == 0 ) {
+    eidiot "You have not created any advertising sources.  You must create at least one advertising source before adding a customer.  Go to ". popurl(2). "browse/part_referral.cgi and create one or more advertising sources.";
+  } elsif ( scalar(@referrals) == 1 ) {
     $refnum ||= $referrals[0]->refnum;
     print qq!<INPUT TYPE="hidden" NAME="refnum" VALUE="$refnum">!;
   } else {
-    print qq!<BR><BR>${r}Referral <SELECT NAME="refnum" SIZE="1">!;
+    print qq!<BR><BR>${r}Advertising source <SELECT NAME="refnum" SIZE="1">!;
     print "<OPTION> " unless $refnum;
     my($referral);
     foreach $referral (sort {
@@ -229,7 +231,7 @@ END
 
   print '<BR>Service address ',
         '(<INPUT TYPE="checkbox" NAME="same" VALUE="Y" onClick="samechanged(this)"';
-  unless ( $cust_main->ship_last ) {
+  unless ( $cust_main->ship_last && $cgi->param('same') ne 'Y' ) {
     print ' CHECKED';
     foreach (
       qw( last first company address1 address2 city county state zip country