1 <% include( 'elements/browse.html',
2 'title' => 'Billing Event Definitions',
3 'html_init' => $html_init,
4 'name' => 'billing event definitions',
6 'disabled_statuspos' => 2,
8 'agent_null_right' => 'Edit global billing events',
10 'query' => { 'select' => 'part_event.*',
11 'table' => 'part_event',
12 'addl_from' => $join_conditions,
14 'order_by' => $order_conditions,
16 'count_query' => $count_query,
24 'fields' => [ 'eventpart',
43 my $link = [ $p.'edit/part_event.html?', 'eventpart' ];
46 my $part_event = shift;
47 my $onclick = include('/elements/popup_link_onclick.html',
48 action => $p.'view/part_event-targets.html?eventpart='.
49 $part_event->eventpart,
50 actionlabel => 'Event query', #no, XSS - '.$part_event->event,
53 close_text => 'Close',
58 'data' => encode_entities($part_event->event),
59 'link' => $p.'edit/part_event.html?'.$part_event->eventpart,
65 'onclick' => $onclick,
71 my $eventtable_labels = FS::part_event->eventtable_labels;
72 my $eventtable_sub = sub { $eventtable_labels->{ shift->eventtable }; };
74 my $check_freq_labels = FS::part_event->check_freq_labels;
75 my $check_freq_sub = sub { $check_freq_labels->{ shift->check_freq }; };
77 my $conditions_sub = sub {
78 my $part_event = shift;
83 my $part_event_condition = $_;
84 my %options = $part_event_condition->options;
88 'data' => $part_event_condition->description,
92 'style' => ( $addl++ ? 'border-top: 1px solid gray' : '' ),
98 my $data = $options{$_};
100 $data = join('<BR>', keys %$data); #XXX display hash values too?
105 'data' => $part_event_condition->option_label($_). ':',
120 $part_event->part_event_condition
126 my $action_sub = sub {
127 my $part_event = shift;
129 my %options = $part_event->options;
135 'data' => $part_event->description,
145 'data' => $part_event->option_label($_). ':',
150 'data' => $options{$_},
166 unless $FS::CurrentUser::CurrentUser->access_right('Edit billing events')
167 || $FS::CurrentUser::CurrentUser->access_right('Edit global billing events');
170 #XXX better description
171 'Events are billing, collection or other actions triggered when certain '.
172 'customer, invoice, package or other conditions are met.<BR><BR>'.
173 qq!<FORM METHOD="POST" ACTION="${p}edit/part_event.html">!.
174 qq!<A HREF="${p}edit/part_event.html"><I>Add a new event</I></A>!.
175 ' or <SELECT NAME="clone"><OPTION></OPTION>';
177 foreach my $part_event ( qsearch('part_event', {'disabled'=>''}) ) {
178 $html_init .= '<OPTION VALUE="'. $part_event->eventpart. '">'.
179 $part_event->eventpart. ': '.
180 encode_entities($part_event->event).
184 $html_init .= '</SELECT><INPUT TYPE="submit" VALUE="Clone existing event">'.
187 my $count_query = 'SELECT COUNT(*) FROM part_event WHERE '.
188 $FS::CurrentUser::CurrentUser->agentnums_sql(
189 'null_right' => 'Edit global billing events',
190 'viewall_right' => 'None',
193 my $join_conditions = FS::part_event_condition->join_conditions_sql('', 'time' => time);
194 my $order_conditions = FS::part_event_condition->order_conditions_sql;