e05f1af73e68078fa5fb97cb081cfc4d5dea19a1
[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 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
23
24   <TR>
25     <TH CLASS="background" COLSPAN=2 ALIGN="left">
26       <FONT SIZE="+1"><% mt('[_1] search options', ucfirst($name_singular)) |h %></FONT>
27     </TH>
28   </TR>
29
30   <& /elements/tr-select.html,
31     label     => ucfirst(PL($name_singular)) . ' of type:',
32     field     => 'payby',
33     options   => [ keys %payby ],
34     labels    => \%payby,
35     multiple  => 1,
36     size      => 18,
37   &>
38
39 % if (substr($conf->config('card_masking_method'), -5) eq 'last4' || !$conf->config('card_masking_method')) {
40   <TR>
41     <TD ALIGN="right"><% mt('Card Last 4 #:') |h %></TD>
42     <TD>
43       <INPUT TYPE="text" ID="paymask" NAME="paymask">
44     </TD>
45   </TR>
46 % } 
47   <TR>
48     <TD ALIGN="right"><% mt('Check #:') |h %> </TD>
49     <TD>
50       <INPUT TYPE="text" ID="payinfo" NAME="payinfo">
51     </TD>
52   </TR>
53   <TR>
54     <TD ALIGN="right"><% mt('Transaction #:') |h %> </TD>
55     <TD>
56       <INPUT TYPE="text" ID="ccpay" NAME="ccpay">
57     </TD>
58   </TR>
59
60   <& /elements/tr-select-user.html &>
61
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'),
67     field       => 'reasonnum',
68     id          => 'reasonnum',
69     table       => 'reason',
70     name_col    => 'reason',
71     extra_sql   => " WHERE EXISTS(SELECT 1 FROM $table WHERE $table.reasonnum = reason.reasonnum) ",
72     empty_label => emt('any'),
73   &>
74 % }
75
76   <TR>
77     <TD ALIGN="right" VALIGN="center"><% mt(ucfirst($name_singular). ' date') |h %></TD>
78     <TD>
79       <TABLE>
80         <& /elements/tr-input-beginning_ending.html,
81                       layout     => 'horiz',
82                       input_time => $conf->exists('report-cust_pay-select_time'),
83         &>
84       </TABLE>
85     </TD>
86   </TR>
87
88 % if ( $void ) {
89     <TR>
90       <TD ALIGN="right" VALIGN="center"><% mt('Voided') |h %></TD>
91       <TD>
92         <TABLE>
93           <& /elements/tr-input-beginning_ending.html,
94                         prefix => 'void',
95                         layout => 'horiz',
96           &>
97         </TABLE>
98       </TD>
99     </TR>
100 % }
101
102 % if ( $table eq 'cust_pay' ) {
103
104 % # payment batch
105 % #  <& /elements/tr-select-batchnum.html &>
106
107 % #payment "entry" batch (should probably just all become the same thing)
108   <& /elements/tr-select-paybatch.html &>
109
110 % }
111
112   <& /elements/tr-input-lessthan_greaterthan.html,
113                 'label' => emt('Amount'),
114                 'field' => 'paid',
115   &>
116
117
118 </TABLE>
119 <BR>
120
121
122 <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
123
124   <TR>
125     <TH CLASS="background" COLSPAN=2 ALIGN="left">
126       <FONT SIZE="+1"><% mt('Customer search options') |h %></FONT>
127     </TH>
128   </TR>
129
130   <& /elements/tr-select-cust_tag.html,
131              'custnum' => $opt{'custnum'},
132   &>
133
134   <& /elements/tr-select-agent.html,
135                  'curr_value'    => scalar($cgi->param('agentnum')),
136                  'label'         => emt('Agent'),
137                  'disable_empty' => 0,
138   &>
139
140   <& /elements/tr-select-cust_class.html,
141        'label'        => emt('Customer class'),
142        'field'        => 'cust_classnum',
143        'multiple'     => 1,
144        'pre_options'  => [ 0 => emt('(none)') ],
145   &>
146
147 </TABLE>
148
149 % if ( $table eq 'cust_pay' ) { 
150
151   <BR>
152   <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
153
154   <TR>
155     <TH CLASS="background" COLSPAN=2 ALIGN="left">
156       <FONT SIZE="+1"><% mt('Display options') |h %></FONT>
157     </TH>
158   </TR>
159
160   <& /elements/tr-checkbox.html,
161                 'label' => emt('Include tax names'),
162                 'field' => 'tax_names',
163                 'value' => 1,
164   &>
165
166   <& /elements/tr-checkbox.html,
167                 'label' => emt('Include order number'),
168                 'field' => 'show_order_number',
169                 'value' => 1,
170   &>
171
172 </TABLE>
173
174 % }
175
176 <BR>
177 <INPUT TYPE="submit" VALUE="<% mt('Get Report') |h %>">
178
179 </FORM>
180
181 <& /elements/footer.html &>
182 <%init>
183
184 my %opt = @_;
185 my $table = 'cust_'.$opt{'thing'};
186 my $name_singular = $opt{'name_singular'};
187
188 die "access denied"
189   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
190
191 my $conf = new FS::Conf;
192
193 my $void = $cgi->param('void') ? 1 : 0;
194 my $unapplied = $cgi->param('unapplied') ? 1 : 0;
195
196 my $title = $void ? "Voided $name_singular report" :
197             $unapplied ? "Unapplied $name_singular report" :
198             "\u$name_singular report" ;
199 $table .= '_void' if $void;
200
201 my $has_reason = dbdef->table($table)->column('reasonnum');
202
203 tie (my %payby, 'Tie::IxHash',
204   'CARD-VisaMC'    => 'credit card (Visa/MasterCard)',
205   'CARD-Amex'      => 'credit card (American Express)',
206   'CARD-Discover'  => 'credit card (Discover)',
207   'CARD-Maestro'   => 'credit card (Maestro/Switch/Solo)',
208   'CARD-Tokenized' => 'credit card (Tokenized)',
209
210   'CHEK'           => 'electronic check / ACH',
211   'BILL'           => 'check',
212   'CASH'           => 'cash',
213   'PPAL'           => 'Paypal',
214   'APPL'           => 'Apple Store',
215   'ANRD'           => 'Android Market',
216
217   'PREP'           => 'prepaid card',
218   'WIRE'           => 'wire transfer',
219   'WEST'           => 'Western Union',
220   'IDTP'           => 'IDT Payment Services',
221   'EDI'            => 'Electronic Debit (EDI)',
222   'MCRD'           => 'manual credit card',
223   'MCHK'           => 'manual electronic check',
224 );
225
226 </%init>