summaryrefslogtreecommitdiff
path: root/httemplate/search/elements/report_cust_pay_or_refund.html
blob: f7a81a066c8a56c353f11359661a1bcf54718a13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<%doc>

Examples:

  include( 'elements/report_cust_pay_or_refund.html',
               'thing'          => 'pay',
               'name_singular'  => 'payment',
         )

  include( 'elements/report_cust_pay_or_refund.html',
               'thing'          => 'refund',
               'name_singular'  => 'refund',
         )

</%doc>
<& /elements/header.html, mt($title) &>

<FORM ACTION="<% $table %>.html" METHOD="GET">
<INPUT TYPE="hidden" NAME="magic" VALUE="_date">
<INPUT TYPE="hidden" NAME="unapplied" VALUE="<% $unapplied %>">

  <FONT CLASS="fsinnerbox-title"><% emt('[_1] search options', ucfirst($name_singular)) %></FONT>
  <TABLE CLASS="fsinnerbox">

  <& /elements/tr-select.html,
    label     => ucfirst(PL($name_singular)) . ' of type:',
    field     => 'payby',
    options   => [ keys %payby ],
    labels    => \%payby,
    multiple  => 1,
    size      => 18,
  &>

% if (substr($conf->config('card_masking_method'), -5) eq 'last4' || !$conf->config('card_masking_method')) {
  <TR>
    <TH ALIGN="right"><% mt('Card Last 4 #:') |h %></TH>
    <TD>
      <INPUT TYPE="text" ID="paymask" NAME="paymask">
    </TD>
  </TR>
% } 
  <TR>
    <TH ALIGN="right"><% mt('Check #:') |h %> </TH>
    <TD>
      <INPUT TYPE="text" ID="payinfo" NAME="payinfo">
    </TD>
  </TR>
  <TR>
    <TH ALIGN="right"><% mt('Transaction #:') |h %> </TH>
    <TD>
      <INPUT TYPE="text" ID="ccpay" NAME="ccpay">
    </TD>
  </TR>

  <& /elements/tr-select-user.html &>

% if ( $has_reason ) {
%   # limit to reasons that are in use for the table being reported on
%   # (maybe order by count(*) desc?)
  <& /elements/tr-select-table.html,
    label       => emt('Reason'),
    field       => 'reasonnum',
    id          => 'reasonnum',
    table       => 'reason',
    name_col    => 'reason',
    extra_sql   => " WHERE EXISTS(SELECT 1 FROM $table WHERE $table.reasonnum = reason.reasonnum) ",
    empty_label => emt('any'),
  &>
% }

  <TR>
    <TH ALIGN="right" VALIGN="center"><% mt(ucfirst($name_singular). ' date') |h %></TH>
    <TD>
      <TABLE>
        <& /elements/tr-input-beginning_ending.html,
                      layout     => 'horiz',
                      input_time => $conf->exists('report-cust_pay-select_time'),
        &>
      </TABLE>
    </TD>
  </TR>

% if ( $void ) {
    <TR>
      <TH ALIGN="right" VALIGN="center"><% mt('Voided') |h %></TH>
      <TD>
        <TABLE>
          <& /elements/tr-input-beginning_ending.html,
                        prefix => 'void',
                        layout => 'horiz',
          &>
        </TABLE>
      </TD>
    </TR>
% }

% if ( $table eq 'cust_pay' ) {

% # payment batch
% #  <& /elements/tr-select-batchnum.html &>

% #payment "entry" batch (should probably just all become the same thing)
  <& /elements/tr-select-paybatch.html &>

% }

  <& /elements/tr-input-lessthan_greaterthan.html,
                'label' => emt('Amount'),
                'field' => 'paid',
  &>


</TABLE>
<BR>


<FONT CLASS="fsinnerbox-title"><% emt('Customer search options') %></FONT>
<TABLE CLASS="fsinnerbox">

  <& /elements/tr-select-cust_tag.html,
             'custnum' => $opt{'custnum'},
  &>

  <& /elements/tr-select-agent.html,
                 'curr_value'    => scalar($cgi->param('agentnum')),
                 'label'         => emt('Agent'),
                 'disable_empty' => 0,
  &>

  <& /elements/tr-select-cust_class.html,
       'label'        => emt('Customer class'),
       'field'        => 'cust_classnum',
       'multiple'     => 1,
       'pre_options'  => [ 0 => emt('(none)') ],
  &>

  <& options_cust_location.html &>

</TABLE>

% if ( $table eq 'cust_pay' ) { 

  <BR>

  <FONT CLASS="fsinnerbox-title"><% emt('Display options') %></FONT>
  <TABLE CLASS="fsinnerbox">

  <& /elements/tr-checkbox.html,
                'label' => emt('Include tax names'),
                'field' => 'tax_names',
                'value' => 1,
  &>

  <& /elements/tr-checkbox.html,
                'label' => emt('Include order number'),
                'field' => 'show_order_number',
                'value' => 1,
  &>

</TABLE>

% }

<BR>
<INPUT TYPE="submit" VALUE="<% mt('Get Report') |h %>">

</FORM>

<& /elements/footer.html &>
<%init>

my %opt = @_;
my $table = 'cust_'.$opt{'thing'};
my $name_singular = $opt{'name_singular'};

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Basic payment and refund reports');

my $conf = new FS::Conf;

my $void = $cgi->param('void') ? 1 : 0;
my $unapplied = $cgi->param('unapplied') ? 1 : 0;

my $title = $void ? "Voided $name_singular report" :
            $unapplied ? "Unapplied $name_singular report" :
            "\u$name_singular report" ;
$table .= '_void' if $void;

my $has_reason = dbdef->table($table)->column('reasonnum');

tie (my %payby, 'Tie::IxHash',
  'CARD-VisaMC'    => 'credit card (Visa/MasterCard)',
  'CARD-Amex'      => 'credit card (American Express)',
  'CARD-Discover'  => 'credit card (Discover)',
  'CARD-Maestro'   => 'credit card (Maestro/Switch/Solo)',
  'CARD-Tokenized' => 'credit card (Tokenized)',

  'CHEK'           => 'electronic check / ACH',
  'BILL'           => 'check',
  'CASH'           => 'cash',
  'PPAL'           => 'Paypal',
  'APPL'           => 'Apple Store',
  'ANRD'           => 'Android Market',

  'PREP'           => 'prepaid card',
  'WIRE'           => 'wire transfer',
  'WEST'           => 'Western Union',
  'IDTP'           => 'IDT Payment Services',
  'EDI'            => 'Electronic Debit (EDI)',
  'MCRD'           => 'manual credit card',
  'MCHK'           => 'manual electronic check',
);

</%init>