+<%init>
+my $precheck_callback = sub {
+ my $cgi = shift;
+ my $conf = FS::Conf->new;
+ if ( $conf->exists('cust_main-require_invoicing_list_email') ) {
+ my $has_email = 0;
+ foreach my $prefix (grep /^contactnum\d+$/, $cgi->param) {
+ if ( length($cgi->param($prefix . '_emailaddress'))
+ and $cgi->param($prefix . '_invoice_dest') ) {
+ $has_email = 1;
+ last;
+ }
+ }
+ return "At least one contact must receive email invoices"
+ unless $has_email;
+ }
+ '';
+};
+</%init>