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?'.$part_event->eventpart,
49 actionlabel => 'Event query - '.$part_event->event,
52 close_text => 'Close',
57 'data' => $part_event->event,
58 'link' => $p.'edit/part_event.html?'.$part_event->eventpart,
61 'data' => ' (query) ',
64 'onclick' => $onclick,
70 my $eventtable_labels = FS::part_event->eventtable_labels;
71 my $eventtable_sub = sub { $eventtable_labels->{ shift->eventtable }; };
73 my $check_freq_labels = FS::part_event->check_freq_labels;
74 my $check_freq_sub = sub { $check_freq_labels->{ shift->check_freq }; };
76 my $conditions_sub = sub {
77 my $part_event = shift;
82 my $part_event_condition = $_;
83 my %options = $part_event_condition->options;
87 'data' => $part_event_condition->description,
91 'style' => ( $addl++ ? 'border-top: 1px solid gray' : '' ),
97 my $data = $options{$_};
99 $data = join('<BR>', keys %$data); #XXX display hash values too?
104 'data' => $part_event_condition->option_label($_). ':',
119 $part_event->part_event_condition
125 my $action_sub = sub {
126 my $part_event = shift;
128 my %options = $part_event->options;
134 'data' => $part_event->description,
144 'data' => $part_event->option_label($_). ':',
149 'data' => $options{$_},
165 unless $FS::CurrentUser::CurrentUser->access_right('Edit billing events')
166 || $FS::CurrentUser::CurrentUser->access_right('Edit global billing events');
169 #XXX better description
170 'Events are billing, collection or other actions triggered when certain '.
171 'customer, invoice, package or other conditions are met.<BR><BR>'.
172 qq!<FORM METHOD="POST" ACTION="${p}edit/part_event.html">!.
173 qq!<A HREF="${p}edit/part_event.html"><I>Add a new event</I></A>!.
174 ' or <SELECT NAME="clone"><OPTION></OPTION>';
176 foreach my $part_event ( qsearch('part_event', {'diabled'=>''}) ) {
177 $html_init .= '<OPTION VALUE="'. $part_event->eventpart. '">'.
178 $part_event->eventpart. ': '. $part_event->event. '</OPTION>';
181 $html_init .= '</SELECT><INPUT TYPE="submit" VALUE="Clone existing event">'.
184 my $count_query = 'SELECT COUNT(*) FROM part_event WHERE '.
185 $FS::CurrentUser::CurrentUser->agentnums_sql(
186 'null_right' => 'Edit global billing events',
187 'viewall_right' => 'None',
190 my $join_conditions = FS::part_event_condition->join_conditions_sql;
191 my $order_conditions = FS::part_event_condition->order_conditions_sql;