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