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