380e4d78b364aee8f192148c71f1810a6d9fb5c1
[freeside.git] / httemplate / browse / part_bill_event.cgi
1 <% 
2 my %search;
3 if ( $cgi->param('showdisabled') ) {
4   %search = ();
5 } else {
6   %search = ( 'disabled' => '' );
7 }
8
9 my @part_bill_event = qsearch('part_bill_event', \%search );
10 my $total = scalar(@part_bill_event);
11 %>
12
13 <%= include("/elements/header.html",'Invoice Event Listing', menubar( 'Main Menu' => $p) ) %>
14
15     Invoice events are actions taken on open invoices.<BR><BR>
16
17 <A HREF="<%= $p %>edit/part_bill_event.cgi"><I>Add a new invoice event</I></A>
18 <BR><BR>
19
20 <%= $total %> events
21 <%= $cgi->param('showdisabled')
22       ? do { $cgi->param('showdisabled', 0);
23              '( <a href="'. $cgi->self_url. '">hide disabled events</a> )'; }
24       : do { $cgi->param('showdisabled', 1);
25              '( <a href="'. $cgi->self_url. '">show disabled events</a> )'; }
26 %>
27 <BR><BR>
28
29 <% tie my %payby, 'Tie::IxHash', FS::payby->cust_payby2longname;
30    tie my %freq, 'Tie::IxHash', '1d' => 'daily', '1m' => 'monthly';
31    foreach my $payby ( keys %payby ) {
32      my $oldfreq = '';
33
34      my @payby_part_bill_event =  grep { $payby eq $_->payby }
35                                   sort {    $a->freq      cmp $b->freq # for now
36                                          || $a->seconds   <=> $b->seconds
37                                          || $a->weight    <=> $b->weight
38                                          || $a->eventpart <=> $b->eventpart
39                                        }
40                                   @part_bill_event;
41
42 %>
43
44   <% if ( @payby_part_bill_event ) { %>
45
46     <%= include('/elements/table-grid.html') %>
47   
48     <% my $bgcolor1 = '#eeeeee';
49        my $bgcolor2 = '#ffffff';
50        my $bgcolor;
51     %>
52   
53     <%
54        foreach my $part_bill_event ( @payby_part_bill_event ) {
55          my $url = "${p}edit/part_bill_event.cgi?". $part_bill_event->eventpart;
56          my $delay = duration_exact($part_bill_event->seconds);
57          ( my $plandata = $part_bill_event->plandata ) =~ s/\n/<BR>/go;
58          my $freq = $part_bill_event->freq || '1d';
59     %>
60   
61       <% if ( $oldfreq ne $freq ) { %>
62   
63         <TR>
64           <TH CLASS="grid" BGCOLOR="#999999" COLSPAN=<%= $cgi->param('showdisabled') ? 7 : 8 %>><%= ucfirst($freq{$freq}) %> event tests for <FONT SIZE="+1"><I><%= $payby{$payby} %> customers</I></FONT></TH>
65         </TR>
66       
67         <TR>
68           <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<%= $cgi->param('showdisabled') ? 2 : 3 %>>Event</TH>
69           <TH CLASS="grid" BGCOLOR="#cccccc">After</TH>
70           <TH CLASS="grid" BGCOLOR="#cccccc">Action</TH>
71           <TH CLASS="grid" BGCOLOR="#cccccc">Options</TH>
72           <TH CLASS="grid" BGCOLOR="#cccccc">Code</TH>
73         </TR>
74   
75         <%
76            $oldfreq = $freq;
77            $bgcolor = '';
78         %>
79   
80       <% } %>
81   
82       <%
83          if ( $bgcolor eq $bgcolor1 ) {
84             $bgcolor = $bgcolor2;
85           } else {
86             $bgcolor = $bgcolor1;
87           }
88       %>
89   
90       <TR>
91         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><A HREF="<%= $url %>">
92           <%= $part_bill_event->eventpart %></A></TD>
93     <% unless ( $cgi->param('showdisabled') ) { %>
94         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>">
95           <%= $part_bill_event->disabled ? 'DISABLED' : '' %></TD>
96     <% } %>
97         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><A HREF="<%= $url %>">
98           <%= $part_bill_event->event %></A></TD>
99         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>">
100           <%= $delay %></TD>
101         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>">
102           <%= $part_bill_event->plan %></TD>
103         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>">
104           <%= $plandata %></TD>
105         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><FONT SIZE="-1">
106           <%= $part_bill_event->eventcode %></FONT></TD>
107       </TR>
108     <% } %>
109     </TABLE>
110     <BR><BR>
111
112   <% } %>
113
114 <% } %>
115
116 </BODY>
117 </HTML>