5 include( 'elements/report_cust_pay_or_refund.html',
7 'name_singular' => 'payment',
10 include( 'elements/report_cust_pay_or_refund.html',
12 'name_singular' => 'refund',
16 <& /elements/header.html, mt($title) &>
18 <FORM ACTION="<% $table %>.html" METHOD="GET">
19 <INPUT TYPE="hidden" NAME="magic" VALUE="_date">
20 <INPUT TYPE="hidden" NAME="unapplied" VALUE="<% $unapplied %>">
22 <FONT CLASS="fsinnerbox-title"><% emt('[_1] search options', ucfirst($name_singular)) %></FONT>
23 <TABLE CLASS="fsinnerbox">
25 <& /elements/tr-select.html,
26 label => ucfirst(PL($name_singular)) . ' of type:',
28 options => [ keys %payby ],
34 % if (substr($conf->config('card_masking_method'), -5) eq 'last4' || !$conf->config('card_masking_method')) {
36 <TH ALIGN="right"><% mt('Card Last 4 #:') |h %></TH>
38 <INPUT TYPE="text" ID="paymask" NAME="paymask">
43 <TH ALIGN="right"><% mt('Check #:') |h %> </TH>
45 <INPUT TYPE="text" ID="payinfo" NAME="payinfo">
49 <TH ALIGN="right"><% mt('Transaction #:') |h %> </TH>
51 <INPUT TYPE="text" ID="ccpay" NAME="ccpay">
55 <& /elements/tr-select-user.html &>
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'),
66 extra_sql => " WHERE EXISTS(SELECT 1 FROM $table WHERE $table.reasonnum = reason.reasonnum) ",
67 empty_label => emt('any'),
72 <TH ALIGN="right" VALIGN="center"><% mt(ucfirst($name_singular). ' date') |h %></TH>
75 <& /elements/tr-input-beginning_ending.html,
77 input_time => $conf->exists('report-cust_pay-select_time'),
85 <TH ALIGN="right" VALIGN="center"><% mt('Voided') |h %></TH>
88 <& /elements/tr-input-beginning_ending.html,
97 % if ( $table eq 'cust_pay' ) {
100 % # <& /elements/tr-select-batchnum.html &>
102 % #payment "entry" batch (should probably just all become the same thing)
103 <& /elements/tr-select-paybatch.html &>
107 <& /elements/tr-input-lessthan_greaterthan.html,
108 'label' => emt('Amount'),
117 <FONT CLASS="fsinnerbox-title"><% emt('Customer search options') %></FONT>
118 <TABLE CLASS="fsinnerbox">
120 <& /elements/tr-select-cust_tag.html,
121 'custnum' => $opt{'custnum'},
124 <& /elements/tr-select-agent.html,
125 'curr_value' => scalar($cgi->param('agentnum')),
126 'label' => emt('Agent'),
127 'disable_empty' => 0,
130 <& /elements/tr-select-cust_class.html,
131 'label' => emt('Customer class'),
132 'field' => 'cust_classnum',
134 'pre_options' => [ 0 => emt('(none)') ],
137 <& options_cust_location.html &>
141 % if ( $table eq 'cust_pay' ) {
145 <FONT CLASS="fsinnerbox-title"><% emt('Display options') %></FONT>
146 <TABLE CLASS="fsinnerbox">
148 <& /elements/tr-checkbox.html,
149 'label' => emt('Include tax names'),
150 'field' => 'tax_names',
154 <& /elements/tr-checkbox.html,
155 'label' => emt('Include order number'),
156 'field' => 'show_order_number',
165 <INPUT TYPE="submit" VALUE="<% mt('Get Report') |h %>">
169 <& /elements/footer.html &>
173 my $table = 'cust_'.$opt{'thing'};
174 my $name_singular = $opt{'name_singular'};
177 unless $FS::CurrentUser::CurrentUser->access_right('Basic payment and refund reports');
179 my $conf = new FS::Conf;
181 my $void = $cgi->param('void') ? 1 : 0;
182 my $unapplied = $cgi->param('unapplied') ? 1 : 0;
184 my $title = $void ? "Voided $name_singular report" :
185 $unapplied ? "Unapplied $name_singular report" :
186 "\u$name_singular report" ;
187 $table .= '_void' if $void;
189 my $has_reason = dbdef->table($table)->column('reasonnum');
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)',
198 'CHEK' => 'electronic check / ACH',
202 'APPL' => 'Apple Store',
203 'ANRD' => 'Android Market',
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',