Merge branch 'github/pr/55_reprise'
[freeside.git] / httemplate / search / elements / report_cust_pay_or_refund.html
1 <%doc>
2
3 Examples:
4
5   include( 'elements/report_cust_pay_or_refund.html',
6                'thing'          => 'pay',
7                'name_singular'  => 'payment',
8          )
9
10   include( 'elements/report_cust_pay_or_refund.html',
11                'thing'          => 'refund',
12                'name_singular'  => 'refund',
13          )
14
15 </%doc>
16 <& /elements/header.html, mt($title) &>
17
18 <FORM ACTION="<% $table %>.html" METHOD="GET">
19 <INPUT TYPE="hidden" NAME="magic" VALUE="_date">
20 <INPUT TYPE="hidden" NAME="unapplied" VALUE="<% $unapplied %>">
21
22 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
23
24   <TR>
25     <TH CLASS="background" COLSPAN=2 ALIGN="left">
26       <FONT SIZE="+1"><% mt('[_1] search options', ucfirst($name_singular)) |h %></FONT>
27     </TH>
28   </TR>
29
30   <& /elements/tr-select.html,
31     label     => ucfirst(PL($name_singular)) . ' of type:',
32     field     => 'payby',
33     options   => [ keys(\%payby) ],
34     labels    => \%payby,
35     multiple  => 1,
36     size      => 18,
37   &>
38
39   <TR>
40     <TD ALIGN="right"><% mt('Check #:') |h %> </TD>
41     <TD>
42       <INPUT TYPE="text" ID="payinfo" NAME="payinfo">
43     </TD>
44   </TR>
45   <TR>
46     <TD ALIGN="right"><% mt('Transaction #:') |h %> </TD>
47     <TD>
48       <INPUT TYPE="text" ID="ccpay" NAME="ccpay">
49     </TD>
50   </TR>
51
52   <& /elements/tr-select-user.html &>
53
54 % if ( $has_reason ) {
55 %   # limit to reasons that are in use for the table being reported on
56 %   # (maybe order by count(*) desc?)
57   <& /elements/tr-select-table.html,
58     label       => emt('Reason'),
59     field       => 'reasonnum',
60     id          => 'reasonnum',
61     table       => 'reason',
62     name_col    => 'reason',
63     extra_sql   => " WHERE EXISTS(SELECT 1 FROM $table WHERE $table.reasonnum = reason.reasonnum) ",
64     empty_label => emt('any'),
65   &>
66 % }
67
68   <TR>
69     <TD ALIGN="right" VALIGN="center"><% mt(ucfirst($name_singular). ' date') |h %></TD>
70     <TD>
71       <TABLE>
72         <& /elements/tr-input-beginning_ending.html,
73                       layout     => 'horiz',
74                       input_time => $conf->exists('report-cust_pay-select_time'),
75         &>
76       </TABLE>
77     </TD>
78   </TR>
79
80 % if ( $void ) {
81     <TR>
82       <TD ALIGN="right" VALIGN="center"><% mt('Voided') |h %></TD>
83       <TD>
84         <TABLE>
85           <& /elements/tr-input-beginning_ending.html,
86                         prefix => 'void',
87                         layout => 'horiz',
88           &>
89         </TABLE>
90       </TD>
91     </TR>
92 % }
93
94 % if ( $table eq 'cust_pay' ) {
95
96 % # payment batch
97 % #  <& /elements/tr-select-batchnum.html &>
98
99 % #payment "entry" batch (should probably just all become the same thing)
100   <& /elements/tr-select-paybatch.html &>
101
102 % }
103
104   <& /elements/tr-input-lessthan_greaterthan.html,
105                 'label' => emt('Amount'),
106                 'field' => 'paid',
107   &>
108
109
110 </TABLE>
111 <BR>
112
113
114 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
115
116   <TR>
117     <TH CLASS="background" COLSPAN=2 ALIGN="left">
118       <FONT SIZE="+1"><% mt('Customer search options') |h %></FONT>
119     </TH>
120   </TR>
121
122   <& /elements/tr-select-agent.html,
123                  'curr_value'    => scalar($cgi->param('agentnum')),
124                  'label'         => emt('Agent'),
125                  'disable_empty' => 0,
126   &>
127
128   <& /elements/tr-select-cust_class.html,
129        'label'        => emt('Customer class'),
130        'field'        => 'cust_classnum',
131        'multiple'     => 1,
132        'pre_options'  => [ 0 => emt('(none)') ],
133   &>
134
135 </TABLE>
136
137 % if ( $table eq 'cust_pay' ) { 
138
139   <BR>
140   <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
141
142   <TR>
143     <TH CLASS="background" COLSPAN=2 ALIGN="left">
144       <FONT SIZE="+1"><% mt('Display options') |h %></FONT>
145     </TH>
146   </TR>
147
148   <& /elements/tr-checkbox.html,
149                 'label' => emt('Include tax names'),
150                 'field' => 'tax_names',
151                 'value' => 1,
152   &>
153
154   <& /elements/tr-checkbox.html,
155                 'label' => emt('Include order number'),
156                 'field' => 'show_order_number',
157                 'value' => 1,
158   &>
159
160 </TABLE>
161
162 % }
163
164 <BR>
165 <INPUT TYPE="submit" VALUE="<% mt('Get Report') |h %>">
166
167 </FORM>
168
169 <& /elements/footer.html &>
170 <%init>
171
172 my %opt = @_;
173 my $table = 'cust_'.$opt{'thing'};
174 my $name_singular = $opt{'name_singular'};
175
176 die "access denied"
177   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
178
179 my $conf = new FS::Conf;
180
181 my $void = $cgi->param('void') ? 1 : 0;
182 my $unapplied = $cgi->param('unapplied') ? 1 : 0;
183
184 my $title = $void ? "Voided $name_singular report" :
185             $unapplied ? "Unapplied $name_singular report" :
186             "\u$name_singular report" ;
187 $table .= '_void' if $void;
188
189 my $has_reason = dbdef->table($table)->column('reasonnum');
190
191 tie (my %payby, 'Tie::IxHash',
192   'CARD-VisaMC'    => 'credit card (Visa/MasterCard)',
193   'CARD-Amex'      => 'credit card (American Express)',
194   'CARD-Discover'  => 'credit card (Discover)',
195   'CARD-Maestro'   => 'credit card (Maestro/Switch/Solo)',
196   'CARD-Tokenized' => 'credit card (Tokenized)',
197
198   'CHEK'           => 'electronic check / ACH',
199   'BILL'           => 'check',
200   'CASH'           => 'cash',
201   'PPAL'           => 'Paypal',
202   'APPL'           => 'Apple Store',
203   'ANRD'           => 'Android Market',
204
205   'PREP'           => 'prepaid card',
206   'WIRE'           => 'wire transfer',
207   'WEST'           => 'Western Union',
208   'IDTP'           => 'IDT Payment Services',
209   'EDI'            => 'Electronic Debit (EDI)',
210   'MCRD'           => 'manual credit card',
211   'MCHK'           => 'manual electronic check',
212 );
213
214 </%init>