0b6d0cb2b4f492f832b03f830f496aefcd3dfab4
[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->seconds   <=> $b->seconds
36                                          || $a->weight    <=> $b->weight
37                                          || $a->eventpart <=> $b->eventpart
38                                        }
39                                   @part_bill_event;
40
41 %>
42
43   <% if ( @payby_part_bill_event ) { %>
44
45     <%= include('/elements/table-grid.html') %>
46   
47     <% my $bgcolor1 = '#eeeeee';
48        my $bgcolor2 = '#ffffff';
49        my $bgcolor;
50     %>
51   
52     <%
53        foreach my $part_bill_event ( @payby_part_bill_event ) {
54          my $url = "${p}edit/part_bill_event.cgi?". $part_bill_event->eventpart;
55          my $delay = duration_exact($part_bill_event->seconds);
56          ( my $plandata = $part_bill_event->plandata ) =~ s/\n/<BR>/go;
57          my $freq = $part_bill_event->freq || '1d';
58     %>
59   
60       <% if ( $oldfreq ne $freq ) { %>
61   
62         <TR>
63           <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>
64         </TR>
65       
66         <TR>
67           <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<%= $cgi->param('showdisabled') ? 2 : 3 %>>Event</TH>
68           <TH CLASS="grid" BGCOLOR="#cccccc">After</TH>
69           <TH CLASS="grid" BGCOLOR="#cccccc">Action</TH>
70           <TH CLASS="grid" BGCOLOR="#cccccc">Options</TH>
71           <TH CLASS="grid" BGCOLOR="#cccccc">Code</TH>
72         </TR>
73   
74         <%
75            $oldfreq = $freq;
76            $bgcolor = '';
77         %>
78   
79       <% } %>
80   
81       <%
82          if ( $bgcolor eq $bgcolor1 ) {
83             $bgcolor = $bgcolor2;
84           } else {
85             $bgcolor = $bgcolor1;
86           }
87       %>
88   
89       <TR>
90         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><A HREF="<%= $url %>">
91           <%= $part_bill_event->eventpart %></A></TD>
92     <% unless ( $cgi->param('showdisabled') ) { %>
93         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>">
94           <%= $part_bill_event->disabled ? 'DISABLED' : '' %></TD>
95     <% } %>
96         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><A HREF="<%= $url %>">
97           <%= $part_bill_event->event %></A></TD>
98         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>">
99           <%= $delay %></TD>
100         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>">
101           <%= $part_bill_event->plan %></TD>
102         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>">
103           <%= $plandata %></TD>
104         <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><FONT SIZE="-1">
105           <%= $part_bill_event->eventcode %></FONT></TD>
106       </TR>
107     <% } %>
108     </TABLE>
109     <BR><BR>
110
111   <% } %>
112
113 <% } %>
114
115 </BODY>
116 </HTML>