add multiple agent selection to agent-specific invoicing
authorivan <ivan>
Thu, 9 Jun 2005 05:34:07 +0000 (05:34 +0000)
committerivan <ivan>
Thu, 9 Jun 2005 05:34:07 +0000 (05:34 +0000)
FS/FS/cust_bill.pm
FS/FS/part_bill_event.pm
httemplate/edit/part_bill_event.cgi

index f090978..a9bb745 100644 (file)
@@ -550,7 +550,8 @@ emails or print.  See L<FS::cust_main_invoice>.
 TEMPLATENAME, if specified, is the name of a suffix for alternate invoices.
 
 AGENTNUM, if specified, means that this invoice will only be sent for customers
-of the specified agent.
+of the specified agent or agent(s).  AGENTNUM can be a scalar agentnum (for a
+single agent) or an arrayref of agentnums.
 
 INVOICE_FROM, if specified, overrides the default email invoice From: address.
 
@@ -559,7 +560,10 @@ INVOICE_FROM, if specified, overrides the default email invoice From: address.
 sub send {
   my $self = shift;
   my $template = scalar(@_) ? shift : '';
-  return 'N/A' if scalar(@_) && $_[0] && $self->cust_main->agentnum != shift;
+  if ( scalar(@_) && $_[0]  ) {
+    my $agentnums = ref($_[0]) ? shift : [ shift ];
+    return 'N/A' unless grep { $_ == $self->cust_main->agentnum } @$agentnums;
+  }
 
   my $invoice_from =
     scalar(@_)
index 0d03ebf..5731f78 100644 (file)
@@ -126,7 +126,7 @@ sub check {
 
       or $c =~ /^\s*\$cust_bill\->(comp|realtime_(card|ach|lec)|batch_card|send)\(\);\s*$/
 
-      or $c =~ /^\s*\$cust_bill\->send(_if_newest)?\(\'[\w\-\s]+\'\s*(,\s*\d+\s*,\s*'[\w\@\.\-\+]*'\s*)?\);\s*$/
+      or $c =~ /^\s*\$cust_bill\->send(_if_newest)?\(\'[\w\-\s]+\'\s*(,\s*(\d+|\[\s*\d+(,\s*\d+)*\s*\])\s*,\s*'[\w\@\.\-\+]*'\s*)?\);\s*$/
 
       or $c =~ /^\s*\$cust_main\->apply_payments; \$cust_main->apply_credits; "";\s*$/
 
index 99bc260..06bdaf6 100755 (executable)
@@ -83,11 +83,12 @@ sub select_pkgpart {
 
 sub select_agentnum {
   my $plandata = shift;
-  my $agentnum = $plandata->{'agentnum'};
-  '<SELECT NAME="agentnum">'.
+  #my $agentnum = $plandata->{'agentnum'};
+  my %agentnums = map { $_=>1 } split(/,\s*/, $plandata->{'agentnum'});
+  '<SELECT NAME="agentnum" MULTIPLE>'.
   join("\n", map {
     '<OPTION VALUE="'. $_->agentnum. '"'.
-    ( $_->agentnum == $agentnum ? ' SELECTED' : '' ).
+    ( $agentnums{$_->agentnum} ? ' SELECTED' : '' ).
     '>'. $_->agent
   } qsearch('agent', { 'disabled' => '' } ) ).
   '</SELECT>';
@@ -187,11 +188,11 @@ tie my %events, 'Tie::IxHash',
 
   'send_agent' => {
     'name' => 'Send invoice (email/print) ',
-    'code' => '$cust_bill->send(\'%%%agent_templatename%%%\', %%%agentnum%%%, \'%%%agent_invoice_from%%%\');',
+    'code' => '$cust_bill->send(\'%%%agent_templatename%%%\', [ %%%agentnum%%% ], \'%%%agent_invoice_from%%%\');',
     'html' => sub {
         '<TABLE BORDER=0>
           <TR>
-            <TD ALIGN="right">only for agent </TD>
+            <TD ALIGN="right">only for agent(s) </TD>
             <TD>'. &select_agentnum(@_). '</TD>
           </TR>
           <TR>