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 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
25 <TH CLASS="background" COLSPAN=2 ALIGN="left">
26 <FONT SIZE="+1"><% mt('[_1] search options', ucfirst($name_singular)) |h %></FONT>
30 <& /elements/tr-select.html,
31 label => ucfirst(PL($name_singular)) . ' of type:',
33 options => [ keys %payby ],
39 % if (substr($conf->config('card_masking_method'), -5) eq 'last4' || !$conf->config('card_masking_method')) {
41 <TD ALIGN="right"><% mt('Card Last 4 #:') |h %></TD>
43 <INPUT TYPE="text" ID="paymask" NAME="paymask">
48 <TD ALIGN="right"><% mt('Check #:') |h %> </TD>
50 <INPUT TYPE="text" ID="payinfo" NAME="payinfo">
54 <TD ALIGN="right"><% mt('Transaction #:') |h %> </TD>
56 <INPUT TYPE="text" ID="ccpay" NAME="ccpay">
60 <& /elements/tr-select-user.html &>
62 % if ( $has_reason ) {
63 % # limit to reasons that are in use for the table being reported on
64 % # (maybe order by count(*) desc?)
65 <& /elements/tr-select-table.html,
66 label => emt('Reason'),
71 extra_sql => " WHERE EXISTS(SELECT 1 FROM $table WHERE $table.reasonnum = reason.reasonnum) ",
72 empty_label => emt('any'),
77 <TD ALIGN="right" VALIGN="center"><% mt(ucfirst($name_singular). ' date') |h %></TD>
80 <& /elements/tr-input-beginning_ending.html,
82 input_time => $conf->exists('report-cust_pay-select_time'),
90 <TD ALIGN="right" VALIGN="center"><% mt('Voided') |h %></TD>
93 <& /elements/tr-input-beginning_ending.html,
102 % if ( $table eq 'cust_pay' ) {
105 % # <& /elements/tr-select-batchnum.html &>
107 % #payment "entry" batch (should probably just all become the same thing)
108 <& /elements/tr-select-paybatch.html &>
112 <& /elements/tr-input-lessthan_greaterthan.html,
113 'label' => emt('Amount'),
122 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
125 <TH CLASS="background" COLSPAN=2 ALIGN="left">
126 <FONT SIZE="+1"><% mt('Customer search options') |h %></FONT>
130 <& /elements/tr-select-agent.html,
131 'curr_value' => scalar($cgi->param('agentnum')),
132 'label' => emt('Agent'),
133 'disable_empty' => 0,
136 <& /elements/tr-select-cust_class.html,
137 'label' => emt('Customer class'),
138 'field' => 'cust_classnum',
140 'pre_options' => [ 0 => emt('(none)') ],
145 % if ( $table eq 'cust_pay' ) {
148 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
151 <TH CLASS="background" COLSPAN=2 ALIGN="left">
152 <FONT SIZE="+1"><% mt('Display options') |h %></FONT>
156 <& /elements/tr-checkbox.html,
157 'label' => emt('Include tax names'),
158 'field' => 'tax_names',
162 <& /elements/tr-checkbox.html,
163 'label' => emt('Include order number'),
164 'field' => 'show_order_number',
173 <INPUT TYPE="submit" VALUE="<% mt('Get Report') |h %>">
177 <& /elements/footer.html &>
181 my $table = 'cust_'.$opt{'thing'};
182 my $name_singular = $opt{'name_singular'};
185 unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
187 my $conf = new FS::Conf;
189 my $void = $cgi->param('void') ? 1 : 0;
190 my $unapplied = $cgi->param('unapplied') ? 1 : 0;
192 my $title = $void ? "Voided $name_singular report" :
193 $unapplied ? "Unapplied $name_singular report" :
194 "\u$name_singular report" ;
195 $table .= '_void' if $void;
197 my $has_reason = dbdef->table($table)->column('reasonnum');
199 tie (my %payby, 'Tie::IxHash',
200 'CARD-VisaMC' => 'credit card (Visa/MasterCard)',
201 'CARD-Amex' => 'credit card (American Express)',
202 'CARD-Discover' => 'credit card (Discover)',
203 'CARD-Maestro' => 'credit card (Maestro/Switch/Solo)',
204 'CARD-Tokenized' => 'credit card (Tokenized)',
206 'CHEK' => 'electronic check / ACH',
210 'APPL' => 'Apple Store',
211 'ANRD' => 'Android Market',
213 'PREP' => 'prepaid card',
214 'WIRE' => 'wire transfer',
215 'WEST' => 'Western Union',
216 'IDTP' => 'IDT Payment Services',
217 'EDI' => 'Electronic Debit (EDI)',
218 'MCRD' => 'manual credit card',
219 'MCHK' => 'manual electronic check',