% include( '/elements/header.html', 'Developer Documentation' ) %> <& /elements/menubar.html, 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html', 'Complete Index' => $fsurl.'docs/library/index.html', &>
FS::part_event::Action - Base class for event actions
package FS::part_event::Action::myaction;
use base FS::part_event::Action;
FS::part_event::Action is a base class for event action classes.
These methods are implemented in each action class.
Action classes must define a description method. This method should return a scalar description of the action.
Action classes must define a eventtable_hashref method if they can only be triggered against some kinds of tables. This method should return a hash reference of eventtables (values set true indicate the action can be performed):
sub eventtable_hashref {
{ 'cust_main' => 1,
'cust_bill' => 1,
'cust_pkg' => 0,
'cust_pay_batch' => 0,
};
}
Action classes may define an event_stage method to indicate a preference for being run at a non-standard stage of the billing and collection process.
This method may currently return "collect" (the default) or "pre-bill".
Action classes may define an option_fields method to indicate that they accept one or more options.
This method should return a list of option names and option descriptions. Each option description can be a scalar description, for simple options, or a hashref with the following values:
NOTE: A database connection is not yet available when this subroutine is executed.
Example:
sub option_fields {
(
'field' => 'description',
'another_field' => { 'label'=>'Amount', 'type'=>'money', },
'third_field' => { 'label' => 'Types',
'type' => 'select',
'options' => [ 'h', 's' ],
'option_labels' => { 'h' => 'Happy',
's' => 'Sad',
},
);
}
Action classes may define a default weighting. Weights control execution order relative to other actions (that are triggered at the same time).
Action classes may define a deprecated method that returns true, indicating that this action is deprecated.
Action classes may define a will_send_invoice method that returns true, indicating that this action is sending out an invoice.
Action classes must define an action method. This method is triggered if all conditions have been met.
The object which triggered the event (an FS::cust_main, FS::cust_bill or FS::cust_pkg object) is passed as an argument.
To retreive option values, call the option method on the desired option, i.e.:
my( $self, $cust_object ) = @_;
$value_of_field = $self->option('field');
To indicate sucessful completion, simply return. Optionally, you can return a string of information status information about the sucessful completion, or simply return the empty string.
To indicate a failure and that this event should retry, die with the desired error message.
These methods are defined in the base class for use in action classes.
Return the customer object (see FS::cust_main) associated with the provided object (the object itself if it is already a customer object).
Return the package object (FS::cust_pkg) associated with the provided object. The object must be either a service (FS::svc_Common) or a package.
Returns the label for the specified option name.
Returns the option fields as an (ordered) hash reference.
Returns just the option field names as a list reference.