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) ],
40 <TD ALIGN="right"><% mt('Check #:') |h %> </TD>
42 <INPUT TYPE="text" ID="payinfo" NAME="payinfo">
46 <TD ALIGN="right"><% mt('Transaction #:') |h %> </TD>
48 <INPUT TYPE="text" ID="ccpay" NAME="ccpay">
52 <& /elements/tr-select-user.html &>
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'),
63 extra_sql => " WHERE EXISTS(SELECT 1 FROM $table WHERE $table.reasonnum = reason.reasonnum) ",
64 empty_label => emt('any'),
69 <TD ALIGN="right" VALIGN="center"><% mt(ucfirst($name_singular). ' date') |h %></TD>
72 <& /elements/tr-input-beginning_ending.html,
74 input_time => $conf->exists('report-cust_pay-select_time'),
82 <TD ALIGN="right" VALIGN="center"><% mt('Voided') |h %></TD>
85 <& /elements/tr-input-beginning_ending.html,
94 % if ( $table eq 'cust_pay' ) {
97 % # <& /elements/tr-select-batchnum.html &>
99 % #payment "entry" batch (should probably just all become the same thing)
100 <& /elements/tr-select-paybatch.html &>
104 <& /elements/tr-input-lessthan_greaterthan.html,
105 'label' => emt('Amount'),
114 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
117 <TH CLASS="background" COLSPAN=2 ALIGN="left">
118 <FONT SIZE="+1"><% mt('Customer search options') |h %></FONT>
122 <& /elements/tr-select-agent.html,
123 'curr_value' => scalar($cgi->param('agentnum')),
124 'label' => emt('Agent'),
125 'disable_empty' => 0,
128 <& /elements/tr-select-cust_class.html,
129 'label' => emt('Customer class'),
130 'field' => 'cust_classnum',
132 'pre_options' => [ 0 => emt('(none)') ],
137 % if ( $table eq 'cust_pay' ) {
140 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
143 <TH CLASS="background" COLSPAN=2 ALIGN="left">
144 <FONT SIZE="+1"><% mt('Display options') |h %></FONT>
148 <& /elements/tr-checkbox.html,
149 'label' => emt('Include tax names'),
150 'field' => 'tax_names',
159 <INPUT TYPE="submit" VALUE="<% mt('Get Report') |h %>">
163 <& /elements/footer.html &>
167 my $table = 'cust_'.$opt{'thing'};
168 my $name_singular = $opt{'name_singular'};
171 unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
173 my $conf = new FS::Conf;
175 my $void = $cgi->param('void') ? 1 : 0;
176 my $unapplied = $cgi->param('unapplied') ? 1 : 0;
178 my $title = $void ? "Voided $name_singular report" :
179 $unapplied ? "Unapplied $name_singular report" :
180 "\u$name_singular report" ;
181 $table .= '_void' if $void;
183 my $has_reason = dbdef->table($table)->column('reasonnum');
185 tie (my %payby, 'Tie::IxHash',
186 'CARD-VisaMC' => 'credit card (Visa/MasterCard)',
187 'CARD-Amex' => 'credit card (American Express)',
188 'CARD-Discover' => 'credit card (Discover)',
189 'CARD-Maestro' => 'credit card (Maestro/Switch/Solo)',
190 'CARD-Tokenized' => 'credit card (Tokenized)',
192 'CHEK' => 'electronic check / ACH',
196 'APPL' => 'Apple Store',
197 'ANRD' => 'Android Market',
199 'PREP' => 'prepaid card',
200 'WIRE' => 'wire transfer',
201 'WEST' => 'Western Union',
202 'IDTP' => 'IDT Payment Services',
203 'EDI' => 'Electronic Debit (EDI)',
204 'MCRD' => 'manual credit card',
205 'MCHK' => 'manual electronic check',