% include( 'elements/browse.html',
'title' => 'Billing Event Definitions',
'html_init' => $html_init,
'name' => 'billing event definitions',
'disableable' => 1,
'disabled_statuspos' => 2,
'agent_virt' => 1,
'agent_null_right' => 'Edit global billing events',
'agent_pos' => 3,
'query' => { 'select' => 'part_event.*',
'table' => 'part_event',
'addl_from' => $join_conditions,
'hashref' => $hashref,
'order_by' => $order_conditions,
},
'count_query' => $count_query,
'header' => [ '#',
'Event',
'Type',
'Check freq.',
'Conditions',
'Action',
],
'fields' => [ 'eventpart',
$event_sub,
$eventtable_sub,
$check_freq_sub,
$conditions_sub,
$action_sub,
],
'links' => [ $link,
'',
'',
'',
'',
'',
],
'align' => 'rllccc',
)
%>
<%once>
my $link = [ $p.'edit/part_event.html?', 'eventpart' ];
my $event_sub = sub {
my $part_event = shift;
my $onclick = include('/elements/popup_link_onclick.html',
action => $p.'view/part_event-targets.html?eventpart='.
$part_event->eventpart,
actionlabel => 'Event query', #no, XSS - '.$part_event->event,
width => 650,
height => 420,
close_text => 'Close',
);
[#rows
[#subcolumns
{
'data' => encode_entities($part_event->event),
'link' => $p.'edit/part_event.html?'.$part_event->eventpart,
},
{
'data' => ' (query) ',
'size' => '-1',
'data_style' => 'b',
'onclick' => $onclick,
},
],
];
};
my $eventtable_labels = FS::part_event->eventtable_labels;
my $eventtable_sub = sub { $eventtable_labels->{ shift->eventtable }; };
my $check_freq_labels = FS::part_event->check_freq_labels;
my $check_freq_sub = sub { $check_freq_labels->{ shift->check_freq }; };
my $conditions_sub = sub {
my $part_event = shift;
my $addl = 0;
[
map {
my $part_event_condition = $_;
my %options = $part_event_condition->options;
my $desc = $part_event_condition->description;
if ( $cgi->param('test_eventtable_num') =~ /^(\d+)$/ ) {
my $tablenum = $1;
if ( $cgi->param('eventtable') =~ /^(cust_main|cust_pkg|cust_bill)$/ ) {
my $eventtable = "FS::$1";
my $object = $eventtable->by_key($tablenum);
my $cust_event = $part_event->new_cust_event($object);
my $test = $part_event_condition->condition(
$object,
'cust_event' => $cust_event,
);
my $yesno = $test ? '(yes)'
: '(no)';
$desc .= " $yesno";
}
}
[
{
'data' => $desc,
'width' => '100%',
'align' => 'center',
'colspan' => 2,
'style' => ( $addl++ ? 'border-top: 1px solid gray' : '' ),
},
],
map {
my $data = $options{$_};
if ( ref($data) ) {
$data = join('
', keys %$data); #XXX display hash values too?
}
[
{
'data' => $part_event_condition->option_label($_). ':',
'align' => 'right',
'valign' => 'top',
'size' => '-1',
},
{
'data' => $data,
'align' => 'left',
'size' => '-1',
},
];
} keys %options
}
$part_event->part_event_condition
];
};
my $action_sub = sub {
my $part_event = shift;
my %options = $part_event->options;
[
[
{
'data' => $part_event->description,
'width' => '100%',
'align' => 'center',
'colspan' => 2,
},
],
map {
[
{
'data' => $part_event->option_label($_). ':',
'align' => 'right',
'size' => '-1',
},
{
'data' => $options{$_},
'align' => 'left',
'size' => '-1',
},
];
}
keys %options
];
};
%once>
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Edit billing events')
|| $FS::CurrentUser::CurrentUser->access_right('Edit global billing events');
my $html_init =
#XXX better description
'Events are billing, collection or other actions triggered when certain '.
'customer, invoice, package or other conditions are met.
'.
qq!