Bug 24604: Add 'Pay' button under Transactions tab in patron accounting
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / boraccount.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE Branches %]
5 [% USE KohaDates %]
6 [% USE ColumnsSettings %]
7 [% USE AuthorisedValues %]
8 [% USE Price %]
9 [% USE Branches %]
10 [% SET footerjs = 1 %]
11
12 [% PROCESS 'accounts.inc' %]
13
14 [% INCLUDE 'doc-head-open.inc' %]
15 <title>Koha &rsaquo; Patrons &rsaquo; Account for [% INCLUDE 'patron-title.inc' no_html = 1 %]</title>
16 [% INCLUDE 'doc-head-close.inc' %]
17 </head>
18
19 <body id="pat_borraccount" class="pat">
20 [% INCLUDE 'header.inc' %]
21 [% INCLUDE 'patron-search.inc' %]
22
23 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Account for [% INCLUDE 'patron-title.inc' %]</div>
24
25 <div class="main container-fluid">
26     <div class="row">
27         <div class="col-sm-10 col-sm-push-2">
28             <main>
29
30 [% INCLUDE 'members-toolbar.inc' %]
31 <form action="/cgi-bin/koha/members/boraccount.pl" method="get"><input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" /></form>
32
33 <!-- The manual invoice and credit buttons -->
34 <div class="statictabs">
35 <ul>
36     <li class="active"><a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | uri %]">Transactions</a></li>
37     <li><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Make a payment</a></li>
38     <li><a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual invoice</a></li>
39     <li><a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual credit</a></li>
40 </ul>
41 <div class="tabs-container">
42 [% INCLUDE 'renew_results.inc' renew_results=renew_results %]
43 <!-- The table with the account items -->
44 <table id="table_account_fines">
45     <thead>
46       <tr>
47           <th class="title-string">Date</th>
48           <th>Account type</th>
49           <th>Description of charges</th>
50           <th>Barcode</th>
51           <th>Due date</th>
52           <th>Return date</th>
53           <th>Home library</th>
54           <th>Note</th>
55           <th>Amount</th>
56           <th>Outstanding</th>
57           <th>Actions</th>
58         </tr>
59     </thead>
60
61         <!-- FIXME: Shouldn't hardcode dollar signs, since Euro or Pound might be needed -->
62   [% FOREACH account IN accounts %]
63
64    <tr>
65    <td><span title="[% account.date | html %]">[% account.date |$KohaDates %]</span></td>
66         <td>[% PROCESS account_type_description account=account %]</td>
67       <td>
68         [%- IF account.payment_type %][% AuthorisedValues.GetByCode('PAYMENT_TYPE', account.payment_type) | html %][% END %]
69         [%- IF account.description %][% account.description | html %][% END %]
70         &nbsp;[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.item.biblionumber | uri %]&amp;itemnumber=[% account.itemnumber | uri %]">[% account.item.biblio.title | html %]</a>[% END %]</td>
71       <td>[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% account.itemnumber | uri %]&amp;biblionumber=[% account.item.biblionumber | uri %]#item[% account.itemnumber | uri %]">[% account.item.barcode | html %]</a>[% END %]</td>
72       <td>[% IF ( account.issue_id ) %][% account.checkout.date_due | $KohaDates as_due_date => 1 %][% END %]</td>
73       <td>[% IF ( account.issue_id ) %][% account.checkout.returndate | $KohaDates with_hours => 1 %][% END %]</td>
74       <td>[% IF account.itemnumber %][% Branches.GetName( account.item.homebranch ) | html %][% END %]</td>
75       <td>[% account.note | html_line_break %]</td>
76       [% IF account.amount <= 0 %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amount | $Price %]</td>
77       [% IF account.amountoutstanding <= 0 %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amountoutstanding | $Price %]</td>
78       <td class="actions">
79         [% IF ( account.is_credit ) %]
80           <a target="_blank" href="printfeercpt.pl?action=print&amp;accountlines_id=[% account.accountlines_id | uri %]&amp;borrowernumber=[% account.borrowernumber | uri %]" class="btn btn-default btn-xs"><i class="fa fa-print"></i> Print</a>
81         [% ELSE %]
82           <a target="_blank" href="printinvoice.pl?action=print&amp;accountlines_id=[% account.accountlines_id | uri %]&amp;borrowernumber=[% account.borrowernumber | uri %]" class="btn btn-default btn-xs"><i class="fa fa-print"></i> Print</a>
83         [% END %]
84         <a href="accountline-details.pl?accountlines_id=[% account.accountlines_id | uri %]" class="btn btn-default btn-xs"><i class="fa fa-list"></i> Details</a>
85         [% IF account.is_debit && account.amountoutstanding > 0 %]
86             <a class="btn btn-default btn-xs" href="/cgi-bin/koha/members/paycollect.pl?borrowernumber=[% account.borrowernumber | html %]&pay_individual=1&debit_type_code=[% account.debit_type_code | html %]&amount=[% account.amount | html %]&amountoutstanding=[% account.amountoutstanding | html %]&description=[% account.description | html %]&itemnumber=[% account.itemnumber | html %]&accountlines_id=[% account.accountlines_id | html %]">Pay</a>
87         [% END %]
88         [% IF account.is_credit %]
89           <a href="boraccount.pl?action=void&amp;accountlines_id=[% account.accountlines_id | uri %]&amp;borrowernumber=[% account.borrowernumber | uri %]" class="btn btn-default btn-xs void"><i class="fa fa-ban"></i> Void</a>
90         [% END %]
91         [% IF CAN_user_updatecharges_payout && account.is_credit && ( account.amountoutstanding < 0 ) %]
92           <button type="button" data-toggle="modal" data-target="#issuePayoutModal" data-account="[%- PROCESS account_type_description account=account -%]" data-accountline="[% account.accountlines_id | html %]" data-amount="[% account.amountoutstanding | $Price %]" class="btn btn-default btn-xs"><i class="fa fa-money"></i> Issue payout</button>
93         [% END %]
94         [% IF CAN_user_updatecharges_refund && account.is_debit && ( account.amountoutstanding != account.amount ) && !(account.status == 'REFUNDED') && !(account.debit_type_code == 'PAYOUT') %]
95           <button type="button" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=account -%]" data-accountline="[% account.accountlines_id | html %]" data-amount="[% account.amount | $Price %]" data-amountoutstanding="[% account.amountoutstanding | $Price %]" class="btn btn-default btn-xs"><i class="fa fa-money"></i> Issue refund</button>
96         [% END %]
97         [% IF CAN_user_updatecharges_discount && account.is_debit && ( account.amountoutstanding == account.amount ) && !(account.debit_type_code == 'PAYOUT') %]
98           <button type="button" data-toggle="modal" data-target="#applyDiscountModal" data-item="[%- PROCESS account_type_description account=account -%]" data-accountline="[% account.accountlines_id | html %]" data-amount="[% account.amount | $Price %]" data-amountoutstanding="[% account.amountoutstanding | $Price %]" class="btn btn-default btn-xs"><i class="fa fa-percent"></i> Apply discount</button>
99         [% END %]
100       </td>
101     </tr>
102
103   [% END %]
104 <tfoot>
105   <tr>
106     <td colspan="9">Total due</td>
107     [% IF ( totalcredit ) %]
108         <td class="credit" style="text-align: right;">[% total | $Price %]</td>
109     [% ELSE %]
110        <td class="debit"style="text-align: right;">[% total | $Price %]</td>
111     [% END %]
112     <td></td>
113   </tr>
114   </tfoot>
115 </table>
116 </div>
117 </div>
118
119             </main>
120         </div> <!-- /.col-sm-10.col-sm-push-2 -->
121
122         <div class="col-sm-2 col-sm-pull-10">
123             <aside>
124                 [% INCLUDE 'circ-menu.inc' %]
125             </aside>
126         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
127      </div> <!-- /.row -->
128
129     <!-- Issue payout modal -->
130     <div class="modal" id="issuePayoutModal" tabindex="-1" role="dialog" aria-labelledby="issuePayoutLabel">
131         <form  id="payout_form" action="/cgi-bin/koha/members/boraccount.pl" method="get" enctype="multipart/form-data" class="validated">
132             <input type="hidden" name="accountlines_id" value="" id="payoutline">
133             <input type="hidden" name="action" value="payout">
134             <input type="hidden" name="borrowernumber" value="[% account.borrowernumber | html %]">
135             <div class="modal-dialog" role="document">
136                 <div class="modal-content">
137                     <div class="modal-header">
138                         <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
139                         <h4 class="modal-title" id="issuePayoutLabel">Issue payout</h4>
140                     </div>
141                     <div class="modal-body">
142                         <fieldset class="rows">
143                             <ol>
144                                 <li>
145                                     <span id="paid" class="label">Outstanding credit: </span><span>[% payout.amount | $Price %]</span>
146                                 </li>
147                                 <li>
148                                     <label class="required" for="amount">Returned to patron: </label>
149                                     <input type="number" step="0.01" id="amount" name="amount" min="0.00" required="required">
150                                     <span class="required">Required</span>
151                                 </li>
152                                 [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
153                                 [% SET excluded = ['SIP00', 'SIP01', 'SIP02'] %]
154                                 [% IF payment_types > 3 %]
155                                 <li>
156                                     <label for="transaction_type">Transaction type: </label>
157                                     <select name="transaction_type" id="payout_transaction_type">
158                                         [% FOREACH pt IN payment_types %]
159                                             [% UNLESS excluded.grep("^$pt.authorised_value\$").size %]
160                                             <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
161                                             [% END %]
162                                         [% END %]
163                                     </select>
164                                 </li>
165                                 [% END %]
166
167                                 [% IF Koha.Preference('UseCashRegisters') %]
168                                 <li>
169                                     <label for="registerid">Cash register: </label>
170                                     <select name="registerid" id="payout_registerid">
171                                         [% FOREACH register IN registers %]
172                                           [% IF register.id == registerid %]
173                                         <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
174                                           [% ELSE %]
175                                         <option value="[% register.id | html %]">[% register.name | html %]</option>
176                                           [% END %]
177                                         [% END %]
178                                     </select>
179                                 </li>
180                                 [% END %]
181
182                             </ol>
183                         </fieldset> <!-- /.rows -->
184                     </div> <!-- /.modal-body -->
185                     <div class="modal-footer">
186                         <input type="hidden" name="op" value="payout">
187                         <button type="submit" class="btn btn-default" id="borr_payout_confirm">Confirm</button>
188                         <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
189                     </div> <!-- /.modal-footer -->
190                 </div> <!-- /.modal-content -->
191             </div> <!-- /.modal-dialog -->
192         </form> <!-- /#payout_form -->
193     </div> <!-- /#issuePayoutModal -->
194
195     <!-- Issue refund modal -->
196     <div class="modal" id="issueRefundModal" tabindex="-1" role="dialog" aria-labelledby="issueRefundLabel">
197         <form  id="refund_form" action="/cgi-bin/koha/members/boraccount.pl" method="get" enctype="multipart/form-data" class="validated">
198             <input type="hidden" name="accountlines_id" value="" id="refundline">
199             <input type="hidden" name="action" value="refund">
200             <input type="hidden" name="borrowernumber" value="[% account.borrowernumber | html %]">
201             <div class="modal-dialog" role="document">
202                 <div class="modal-content">
203                     <div class="modal-header">
204                         <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
205                         <h4 class="modal-title" id="issueRefundLabel">Issue refund</h4>
206                     </div>
207                     <div class="modal-body">
208                         <fieldset class="rows">
209                             <ol>
210                                 <li>
211                                     <span id="item" class="label">Account: </span><span></span>
212                                 </li>
213                                 <li>
214                                     <span id="paid" class="label">Amount paid: </span><span></span>
215                                 </li>
216                                 <li>
217                                     <label class="required" for="amount">Returned to patron: </label>
218                                     <input type="number" step="0.01" id="returned" name="amount" min="0.00" required="required">
219                                     <span class="required">Required</span>
220                                 </li>
221                                 [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
222                                 <li>
223                                     <label for="transaction_type">Transaction type: </label>
224                                     <select name="transaction_type" id="refund_transaction_type">
225                                         <option value="AC">Account credit</option>
226                                         [% IF payment_types %]
227                                         [% FOREACH pt IN payment_types %]
228                                         <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
229                                         [% END %]
230                                         [% END %]
231                                     </select>
232                                 </li>
233
234                                 [% IF Koha.Preference('UseCashRegisters') %]
235                                 <li>
236                                     <label for="registerid">Cash register: </label>
237                                     <select name="registerid" id="refund_registerid">
238                                         [% FOREACH register IN registers %]
239                                           [% IF register.id == registerid %]
240                                         <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
241                                           [% ELSE %]
242                                         <option value="[% register.id | html %]">[% register.name | html %]</option>
243                                           [% END %]
244                                         [% END %]
245                                     </select>
246                                 </li>
247                                 [% END %]
248
249                             </ol>
250                         </fieldset> <!-- /.rows -->
251                     </div> <!-- /.modal-body -->
252                     <div class="modal-footer">
253                         <input type="hidden" name="op" value="refund">
254                         <button type="submit" class="btn btn-default" id="borr_refund_confirm">Confirm</button>
255                         <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
256                     </div> <!-- /.modal-footer -->
257                 </div> <!-- /.modal-content -->
258             </div> <!-- /.modal-dialog -->
259         </form> <!-- /#refund_form -->
260     </div> <!-- /#issueRefundModal -->
261
262     <!-- Apply discount modal -->
263     <div class="modal" id="applyDiscountModal" tabindex="-1" role="dialog" aria-labelledby="applyDiscountLabel">
264         <form  id="discount_form" action="/cgi-bin/koha/members/boraccount.pl" method="get" enctype="multipart/form-data" class="validated">
265             <input type="hidden" name="accountlines_id" value="" id="discountline">
266             <input type="hidden" name="action" value="discount">
267             <input type="hidden" name="borrowernumber" value="[% account.borrowernumber | html %]">
268             <div class="modal-dialog" role="document">
269                 <div class="modal-content">
270                     <div class="modal-header">
271                         <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
272                         <h4 class="modal-title" id="applyDiscountLabel">Apply discount</h4>
273                     </div>
274                     <div class="modal-body">
275                         <fieldset class="rows">
276                             <ol>
277                                 <li>
278                                     <span id="item" class="label">Account type: </span><span></span>
279                                 </li>
280                                 <li>
281                                     <span id="charged" class="label">Amount charged: </span><span></span>
282                                 </li>
283                                 <li>
284                                     <label class="required" for="amount">Discount to apply: </label>
285                                     <input type="number" step="0.01" id="discount" name="amount" min="0.00" required="required">
286                                     <span class="required">Required</span>
287                                 </li>
288                             </ol>
289                         </fieldset> <!-- /.rows -->
290                     </div> <!-- /.modal-body -->
291                     <div class="modal-footer">
292                         <input type="hidden" name="op" value="discount">
293                         <button type="submit" class="btn btn-default">Confirm</button>
294                         <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
295                     </div> <!-- /.modal-footer -->
296                 </div> <!-- /.modal-content -->
297             </div> <!-- /.modal-dialog -->
298         </form> <!-- /#discount_form -->
299     </div> <!-- /#applyDiscountModal -->
300
301 [% MACRO jsinclude BLOCK %]
302     [% INCLUDE 'datatables.inc' %]
303     [% INCLUDE 'columns_settings.inc' %]
304     [% INCLUDE 'str/members-menu.inc' %]
305     [% Asset.js("js/members-menu.js") | $raw %]
306     <script>
307         $(document).ready(function() {
308             [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
309                 window.open('/cgi-bin/koha/members/printfeercpt.pl?action=print&change_given=[% change_given | html %]&accountlines_id=[% payment_id | html %]&borrowernumber=[% patron.borrowernumber | html %]', '_blank');
310             [% END %]
311
312             var txtActivefilter = _("Filter paid transactions");
313             var txtInactivefilter = _("Show all transactions");
314             var columns_settings = [% ColumnsSettings.GetColumns('members', 'fines', 'account-fines', 'json') | $raw %];
315             var table_account_fines = KohaTable("table_account_fines", {
316                 "sPaginationType": "full",
317                 'aaSorting': [[0, 'desc']],
318                 "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
319                 "aoColumnDefs": [
320                     { "sType": "title-string", "aTargets" : [ "title-string" ] },
321                     { "bSortable": false, "bSearchable": false, "aTargets": [-1] }
322                 ]
323             }, columns_settings);
324             $("#filter_c").html('<p><a href="#" id="filter_transacs"><i class="fa fa-filter"></i> '+txtActivefilter+'</a>');
325             $('#filter_transacs').click(function(e) {
326                 e.preventDefault();
327                 if ($(this).hasClass('filtered')) {
328                     var filteredValue = '';
329                     $(this).html('<i class="fa fa-filter"></i> '+txtActivefilter);
330                 } else { //Not filtered. Let's do it!
331                     var filteredValue = '^((?!0.00).*)$'; //Filter not matching 0.00 http://stackoverflow.com/a/406408
332                     $(this).html('<i class="fa fa-filter"></i> '+txtInactivefilter);
333                 }
334                 table_account_fines.fnFilter(filteredValue, 9, true, false);
335                 $(this).toggleClass('filtered');
336             });
337
338             $(".void").on("click",function(e){
339                 if( confirm( _("Are you sure you want to void this credit?") ) ) {
340                     return true;
341                 } else {
342                     e.preventDefault();
343                 }
344             });
345
346             $("#issuePayoutModal").on("shown.bs.modal", function(e){
347                 var button = $(e.relatedTarget);
348                 var accountline = button.data('accountline');
349                 $('#payoutline').val(accountline);
350                 var amount = button.data('amount') * -1;
351                 $("#paid + span").replaceWith(amount);
352                 $("#amount").attr({ "value": amount, "max": amount });
353                 $("#amount, #payout_transaction_type").focus();
354             });
355
356             $("#issueRefundModal").on("shown.bs.modal", function(e){
357                 var button = $(e.relatedTarget);
358                 var item = button.data('item');
359                 $("#item + span").replaceWith(item);
360                 var accountline = button.data('accountline');
361                 $('#refundline').val(accountline);
362                 var amount = button.data('amount');
363                 var amountoutstanding = button.data('amountoutstanding');
364                 var paid = amount - amountoutstanding;
365                 $("#paid + span").replaceWith(paid);
366                 $("#returned").attr({ "value": paid, "max": paid });
367                 $("#returned, #refund_transaction_type").focus();
368             });
369
370             $("#applyDiscountModal").on("shown.bs.modal", function(e){
371                 var button = $(e.relatedTarget);
372                 var item = button.data('item');
373                 $("#item + span").replaceWith(item);
374                 var accountline = button.data('accountline');
375                 $('#discountline').val(accountline);
376                 var amount = button.data('amount');
377                 $("#charged + span").replaceWith(amount);
378                 $("#discount").attr({ "max": amount });
379                 $("#discount").focus();
380             });
381         });
382     </script>
383 [% END %]
384
385 [% INCLUDE 'intranet-bottom.inc' %]