1 <& /elements/header-popup.html,
3 'title' => 'Event query - '.$part_event->event,
6 <FORM STYLE="display:inline" ACTION=<%$cgi->url%> METHOD="GET">
7 When event is run on <& /elements/input-date-field.html, {
10 'format' => FS::Conf->new->config('date_format') || '%m/%d/%Y',
12 <INPUT TYPE="hidden" NAME="eventpart" VALUE="<%$eventpart%>">
13 <INPUT TYPE="submit" VALUE="Refresh">
16 % if ( $objects > 0 ) {
17 <% emt("[quant,_1,$label]", $objects) %>
18 % if ( $part_event->eventtable ne 'cust_main' ) {
19 <% emt("belonging to [quant,_1,customer]", $customers) %>
22 <TABLE class="grid" cellspacing=0 width="100%" style="font-size:80%">
23 <TR style='background-color:#cccccc'>
24 % foreach my $header ('Trigger', @cust_header, @header) {
25 <TH><% $header %></TH>
29 % my @rowcolors = ('ffffff','eeeeee');
31 % foreach my $object (@targets) {
32 <TR style="background-color:#<% $rowcolors[$row++ % 2] %>">
33 % # now works for all eventtables, including cust_pkg
34 % my $link = $p . 'view/' . $part_event->eventtable . '.cgi?' .
36 <TD><A target="_blank" href="<% $link %>">
37 <% ucfirst $label %> #<% $object->$pkey %></A></TD>
39 % my $cust_main = $object->cust_main; # via Mixin
40 % my $i = 0; # hack to avoid messing with cust_aligns/colors/styles
41 % foreach (@cust_fields) {
42 % if ($cust_header[$i] eq 'Cust. Status') {
43 <TD style="text-align:center;
45 color:#<% $cust_main->cust_statuscolor %>"><% $_->($cust_main) %></TD>
48 <TD><% $_->($cust_main) %></TD>
51 % } #foreach @cust_fields
54 <TD><% ref($_) eq 'CODE' ? $_->($object) : $object->$_ %></TD>
64 <% emt("No matching ${label}s found.") %>
67 <& /elements/footer.html &>
70 my $curuser = $FS::CurrentUser::CurrentUser;
72 unless $curuser->access_right('Edit billing events')
73 || $curuser->access_right('Edit global billing events');
75 my ($eventpart) = $cgi->param('eventpart');
76 $eventpart =~ /^\d+$/ or die 'illegal eventpart';
78 my $time = parse_datetime($cgi->param('date')) || time;
80 my $part_event = FS::part_event->by_key($eventpart)
81 or die "Event definition $eventpart not found.\n";
82 my @targets = $part_event->targets('time' => $time);
85 # in imitation of search/elements/search-html.html
89 $pkey = dbdef->table($part_event->eventtable)->primary_key;
91 for ($part_event->eventtable) {
93 # very likely to appear in events
94 my %paybys = FS::payby->cust_payby2longname;
95 push @header, 'Balance', 'Payment Method';
96 push @fields, 'balance', sub{ $paybys{$_[0]->payby} };
99 elsif (/^cust_bill$/) {
100 push @header, 'Invoice Date', 'Amount', 'Balance';
101 push @fields, date_format('_date'), 'charged', 'owed';
104 elsif (/^cust_statement$/) {
105 push @header, 'Statement Date', 'Amount', 'Balance';
106 push @fields, date_format('_date'), 'charged', 'owed';
107 $label = 'statement';
109 elsif (/^cust_pkg$/) {
110 push @header, 'Package', 'Next Bill', 'Frequency';
111 push @fields, sub {$_[0]->part_pkg->pkg}, date_format('bill'),
112 sub {$_[0]->part_pkg->freq_pretty};
115 elsif (/^svc_acct$/) {
116 push @header, 'Username', 'Domain';
117 push @fields, 'username', 'domain';
123 my @cust_header = FS::UI::Web::cust_header();
124 my @cust_fields = FS::UI::Web::cust_fields_subs();
126 my $objects = scalar(@targets);
127 my $customers = uniq(map {$_->cust_main->custnum} @targets);
131 sub { my $obj = shift;
132 my $value = $obj->get($column);
133 $value ? time2str('%b %d %Y', $value) : '';