Merge branch 'master' of git.freeside.biz:/home/git/freeside
[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   <& options_cust_location.html &>
138
139 </TABLE>
140
141 % if ( $table eq 'cust_pay' ) { 
142
143   <BR>
144
145   <FONT CLASS="fsinnerbox-title"><% emt('Display options') %></FONT>
146   <TABLE CLASS="fsinnerbox">
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('Basic payment and refund 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>