deposit slips
[freeside.git] / httemplate / search / cust_event_fee.html
1 <& elements/search.html,
2                  'title'       => 'Billing event fees',
3                  'html_init'   => include('.init'),
4                  'menubar'     => $menubar,
5                  'name'        => 'billing events',
6                  'query'       => $sql_query,
7                  'count_query' => $count_sql,
8                  'header'      => [ 'Event',
9                                     'Event date',
10                                     'Fee',
11                                     'Invoice',
12                                     'Invoice date',
13                                     FS::UI::Web::cust_header(),
14                                   ],
15                  'fields' => [
16                                'event',
17                                sub { time2str("%b %d %Y %T", $_[0]->_date) },
18                                'itemdesc',
19                                $inv_sub,
20                                sub { my $d = $_[0]->fee_cust_bill_date;
21                                      $d ? time2str("%b %d %Y %T", $d) : '' },
22                                \&FS::UI::Web::cust_fields,
23                              ],
24                 'align' => 'lrlrr'.FS::UI::Web::cust_aligns(),
25                 'links' => [
26                               '',
27                               '',
28                               '',
29                               $inv_link,
30                               $inv_link,
31                               ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
32                                     FS::UI::Web::cust_header()
33                               ),
34                             ],
35                  'color' => [ 
36                               '',
37                               '',
38                               '',
39                               '',
40                               '',
41                               FS::UI::Web::cust_colors(),
42                             ],
43                  'style' => [ 
44                               '',
45                               '',
46                               '',
47                               '',
48                               '',
49                               FS::UI::Web::cust_styles(),
50                             ],
51 &>
52 <%once>
53
54 my $inv_sub = sub {
55   my $cust_event_fee = shift;
56   my $fee_invnum = $cust_event_fee->fee_invnum;
57   $fee_invnum || ( $cust_event_fee->nextbill ? '(next bill)' : '(not yet)' );
58 };
59
60 my $inv_link = sub {
61   $_[0]->fee_invnum
62     ?  [ "${p}view/cust_bill.cgi?", 'fee_invnum' ]
63     : '';
64 };
65
66 my $link_cust = sub {
67   my $cust_event_fee = shift;
68   $cust_event_fee->custnum
69     ? [ "${p}view/cust_main.cgi?", 'custnum' ]
70     : '';
71 };
72
73 </%once>
74 <%shared>
75 my @scalars = qw( billpkgnum ); #qw( agentnum status custnum invnum pkgnum failed );
76 my @lists = qw( eventpart );
77 my %search;
78 </%shared>
79 <%init>
80
81 my $curuser = $FS::CurrentUser::CurrentUser;
82
83 die "access denied"
84   unless $curuser->access_right('Billing event reports');
85
86 for my $param (@scalars) {
87   $search{$param} = scalar( $cgi->param($param) )
88     if $cgi->param($param);
89 }
90
91 #lists
92 foreach my $param (@lists) {
93   $search{$param} = [ $cgi->param($param) ];
94 }
95
96 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
97 $search{'beginning'} = $beginning;
98 $search{'ending'}    = $ending;
99
100 my $where = ' WHERE '. FS::cust_event_fee->search_sql_where( \%search );
101
102 my $join = FS::cust_event_fee->join_sql();
103
104 my $sql_query = {
105   'table'     => 'cust_event_fee',
106   'select'    => join(', ',
107                     'cust_event_fee.*',
108                     'cust_event.*',
109                     'part_event.*',
110                     'cust_bill_pkg.invnum AS fee_invnum',
111                     'fee_cust_bill._date AS fee_cust_bill_date',
112                     'part_fee.itemdesc',
113                     'cust_main.custnum',
114                     FS::UI::Web::cust_sql_fields(),
115                   ),
116   'hashref'   => {}, 
117   'extra_sql' => $where,
118   'order_by'  => 'ORDER BY eventfeenum ASC', #'ORDER BY _date ASC',
119   'addl_from' => $join,
120 };
121
122 my $count_sql = "SELECT COUNT(*) FROM cust_event_fee $join $where";
123
124 my $conf = new FS::Conf;
125
126 my $menubar = [];
127 push @$menubar, 'Delete these fees' => "javascript:confirm_delete_fees()"
128   if $curuser->access_right('Delete fees');
129
130 </%init>
131 <%def .init>
132 <& /elements/progress-init.html,
133   'delete_fees_form',
134   [ @scalars, @lists, 'beginning', 'ending' ],
135   "../misc/delete_fees.cgi",
136   { 'message' => 'Fees deleted', #would be nice to show the number of them...
137     #what we were just displaying is gone, so where to go?
138     # woudl be nice to not keep displaying the deleted data
139     #'url'     => 
140   },
141 &>
142 <FORM NAME="delete_fees_form">
143 %   foreach my $param (@scalars, 'beginning', 'ending') {
144   <INPUT TYPE="hidden" NAME="<% $param %>" VALUE="<% $search{$param} |h %>">
145 %   }
146 %   foreach my $param (@lists) {
147 %     foreach my $value (@{ $search{$param} }) {
148   <INPUT TYPE="hidden" NAME="<% $param %>" VALUE="<% $value |h %>">
149 %     }
150 %   }
151 </FORM>
152 <SCRIPT TYPE="text/javascript">
153
154 function confirm_delete_fees() {
155   if ( ! confirm("Are you sure you want to delete these fees?") ) {
156     return;
157   }
158   process();
159 }
160
161 </SCRIPT>
162 </%def>