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