-%
-% my( $refnum, %opt ) = @_;
-%
-% $opt{'part_referrals'} ||=
-% [ FS::part_referral->all_part_referral( 1 ) ]; #1: include global
-%
-% my $r = qq!<font color="#ff0000">*</font> !;
-%
-%
% if ( scalar( @{$opt{'part_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.html and create one or more advertising sources.";
-% } elsif ( scalar( @{$opt{'part_referrals'}} ) == 1 ) {
-%
+ <P><FONT SIZE="+1" COLOR="#ff0000">
+ <% mt('At least one advertising source must be created prior to adding a customer, but none have been created.') |h %>
+% #hack
+% my $createlink = qq!<A HREF="<% popurl(2) %>browse/part_referral.html">!;
+% my $createlabel = emt("To create one, see [_1]advertising source listing","XXXLINKXXX").'</A>';
+% $createlabel =~ s/XXXLINKXXX/$createlink/;
+ <% $createlabel %>
- <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $opt{'part_referrals'}->[0]->refnum %>">
-% } else {
+ </FONT>
+% } elsif ( scalar( @{$opt{'part_referrals'}} ) == 1 ) {
+ <TR><TD COLSPAN="<% $colspan %>">
+ <INPUT TYPE="hidden" NAME="<% $opt{'element_name'} || $opt{'field'} || 'refnum' %>" VALUE="<% $opt{'part_referrals'}->[0]->refnum %>">
+ </TD></TR>
- <TR>
- <TH ALIGN="right"><%$r%>Advertising source</TH>
- <TD>
- <% include( '/elements/select-part_referral.html', $refnum,
- 'part_referrals' => $opt{'part_referrals'},
- )
- %>
+% } else {
+ <& /elements/tr-td-label.html, label => 'Advertising source', %opt &>
+ <TD COLSPAN="<% $colspan %>">
+ <& /elements/select-part_referral.html,
+ 'curr_value' => $refnum,
+ %opt
+ &>
</TD>
</TR>
+
% }
+<%init>
+
+my %opt = @_;
+my $refnum = $opt{'curr_value'} || $opt{'value'};
+
+$opt{'part_referrals'} ||=
+ [ FS::part_referral->all_part_referral( 1 ) ]; #1: include global
+
+my $colspan = delete($opt{'colspan'}) || 1;
+
+my $r = qq!<font color="#ff0000">*</font> !;
+</%init>