event refactor, landing on HEAD!
[freeside.git] / FS / FS / part_event / Action / cust_bill_send_agent.pm
1 package FS::part_event::Action::cust_bill_send_agent;
2
3 use strict;
4 use base qw( FS::part_event::Action );
5
6 sub description {
7   'Send invoice (email/print/fax) with alternate template, for specific agents';
8 }
9
10 sub eventtable_hashref {
11   { 'cust_bill' => 1 };
12 }
13
14 sub option_fields {
15   (
16     'agentnum'           => { label    => 'Only for agent(s)',
17                               type     => 'select-agent',
18                               multiple => 1
19                             },
20     'agent_templatename' => { label    => 'Template',
21                               type     => 'select-invoice_template',
22                             },
23     'agent_invoice_from' => 'Invoice email From: address',
24   );
25 }
26
27 sub default_weight {
28   50;
29 }
30
31 sub do_action {
32   my( $self, $cust_bill ) = @_;
33
34   #my $cust_main = $self->cust_main($cust_bill);
35   my $cust_main = $cust_bill->cust_main;
36
37   $cust_bill->send(
38     $self->option('agent_templatename'),
39     [ split(/\s*,\s*/, $self->option('agentnum') ) ],
40     $self->option('agent_invoice_from'),
41   );
42 }
43
44 1;