8 [% PROCESS 'payments.inc' %]
9 [% PROCESS 'accounts.inc' %]
10 [% INCLUDE 'doc-head-open.inc' %]
11 [% BLOCK cash_register_required %]
12 <div id="error_message" class="dialog message">
14 You must have at least one cash register associated with the library before you can record payments.
16 [% IF ( CAN_user_parameters_manage_cash_registers ) %]
17 <form action="/cgi-bin/koha/admin/cash_registers.pl" method="get">
18 <input type="hidden" name="op" value="add_form" />
19 <button class="new" type="submit"><i class="fa fa-plus"></i> Create a new cash register</button>
24 [% SET registers = Registers.all( filters => { current_branch => 1 } ) %]
25 <title>Koha › Patrons ›
26 [% IF type == 'WRITEOFF' %]
27 Write off an amount for [% patron.firstname | html %] [% patron.surname | html %]
29 Collect fine payment for [% patron.firstname | html %] [% patron.surname | html %]
32 [% INCLUDE 'doc-head-close.inc' %]
35 <body id="pat_paycollect" class="pat">
36 [% INCLUDE 'header.inc' %]
37 [% INCLUDE 'patron-search.inc' %]
39 <nav aria-label="Breadcrumb" class="breadcrumb">
42 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
45 <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
48 <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]">Pay fines for [% patron.firstname | html %] [% patron.surname | html %]</a>
51 <a href="#" aria-current="page">
52 [% IF ( pay_individual ) %]
53 Pay an individual fine
54 [% ELSIF ( writeoff_individual ) %]
55 Write off an individual fine
57 [% IF ( selected_accts ) %]
58 [% IF type == 'WRITEOFF' %]
59 Write off an amount toward selected fines
61 Pay an amount toward selected fines
64 Pay an amount toward all fines
72 <div class="main container-fluid">
74 <div class="col-sm-10 col-sm-push-2">
77 [% INCLUDE 'members-toolbar.inc' borrowernumber=patron.borrowernumber %]
80 <!-- The manual invoice and credit buttons -->
81 <div class="statictabs">
84 <a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | uri %]">Transactions</a>
87 <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Make a payment</a>
90 <a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual invoice</a>
93 <a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual credit</a>
96 <div class="tabs-container">
97 [% IF ( error_over ) %]
98 <div id="error_message" class="dialog alert">
99 You must pay a value less than or equal to [% total_due | format('%.2f') %].
102 [% IF ( error_under ) %]
103 <div id="error_message" class="dialog alert">
104 You must collect a value greater than or equal to [% total_paid | format('%.2f') %].
108 [% IF ( pay_individual ) %]
109 [% IF Koha.Preference('UseCashRegisters') && ( registers.size == 0 ) %]
110 [% PROCESS 'cash_register_required' %]
113 <ul class="nav nav-pills">
114 <li role="presentation" class="active"><a>Pay</a></li>
115 <li role="presentation"><a href="/cgi-bin/koha/members/paycollect.pl?writeoff_individual=1&borrowernumber=[% patron.borrowernumber | uri %]&debit_type_code=[% debit_type_code | uri %]&amount=[% amount | uri %]&amountoutstanding=[% amountoutstanding | uri %]&description=[% individual_description | uri %]&itemnumber=[% itemnumber | uri %]&accountlines_id=[% accountlines_id | uri %]&payment_note=[% payment_note | uri %]">Write off</a></li>
118 <form name="payindivfine" id="payindivfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
119 <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
120 <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
121 <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual | html %]" />
122 <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber | html %]" />
123 <input type="hidden" name="description" id="description" value="[% individual_description | html %]" />
124 <input type="hidden" name="debit_type_code" id="debit_type_code" value="[% debit_type_code | html %]" />
125 <input type="hidden" name="amount" id="amount" value="[% amount | html %]" />
126 <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding | html %]" />
127 <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id | html %]" />
128 <input type="hidden" name="title" id="title" value="[% title | html %]" />
129 <input type="hidden" name="change_given" id="change_given" />
131 <fieldset class="rows">
132 <legend>Pay an individual fine</legend>
133 <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note | html %]" />
137 <th>Account type</th>
139 <th>Amount outstanding</th>
142 <tr><td colspan="3">Total amount payable:</td><td>[% amountoutstanding | format('%.2f') %]</td></tr>
146 [% individual_description | html %]
148 [% line.debit_type_code = debit_type_code %]
149 <td>[% PROCESS account_type_description account=line %]</td>
150 <td class="debit">[% amount | format('%.2f') %]</td>
151 <td class="debit">[% amountoutstanding | format('%.2f') %]</td>
158 <label for="paid">Amount being paid: </label>
159 <input name="paid" id="paid" type="text" step="0.01" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
162 <label for="collected">Amount tendered: </label>
163 <input name="collected" id="collected" type="text" step="0.01" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
166 <label>Change to give: </label>
167 <span id="change">0.00</span>
170 [% PROCESS account_payment_types %]
172 [% IF Koha.Preference('UseCashRegisters') %]
174 <label for="cash_register">Cash register: </label>
175 <select name="cash_register" id="cash_register">
176 <option id="noregister" disabled selected="selected" value="">-- Select an option--</option>
177 [% PROCESS options_for_registers %]
185 <input type="submit" name="submitbutton" value="Confirm" />
186 <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
190 [% ELSIF ( writeoff_individual ) %]
191 <ul class="nav nav-pills">
192 <li role="presentation"><a href="/cgi-bin/koha/members/paycollect.pl?pay_individual=1&borrowernumber=[% patron.borrowernumber | uri %]&debit_type_code=[% debit_type_code | uri %]&amount=[% amount | uri %]&amountoutstanding=[% amountoutstanding | uri %]&description=[% individual_description | uri %]&itemnumber=[% itemnumber | uri %]&accountlines_id=[% accountlines_id | uri %]&payment_note=[% payment_note | uri %]">Pay</a></li>
193 <li role="presentation" class="active"><a>Write off</a></li>
196 <form name="woindivfine" id="woindivfine" action="/cgi-bin/koha/members/pay.pl" method="post" >
197 <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
198 <fieldset class="rows">
199 <legend>Write off an individual fine</legend>
200 <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
201 <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual | html %]" />
202 <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber | html %]" />
203 <input type="hidden" name="description" id="description" value="[% individual_description | html %]" />
204 <input type="hidden" name="debit_type_code" id="debit_type_code" value="[% debit_type_code | html %]" />
205 <input type="hidden" name="amount" id="amount" value="[% amount | html %]" />
206 <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id | html %]" />
207 <input type="hidden" name="title" id="title" value="[% title | html %]" />
208 <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note | html %]" />
209 <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding | html %]" />
210 <input type="hidden" name="confirm_writeoff" id="confirm_writeoff" value="1" />
211 <input type="hidden" name="change_given" id="change_given" />
215 <th>Account type</th>
217 <th>Amount outstanding</th>
219 <tfoot><tr><td colspan="3">Total amount outstanding:</td><td>[% amountoutstanding | format('%.2f') %]</td></tr></tfoot>
221 <td>[% individual_description | html %]</td>
222 [% line.debit_type_code = debit_type_code %]
223 <td>[% PROCESS account_type_description account=line %]</td>
224 <td class="debit">[% amount | format('%.2f') %]</td>
225 <td class="debit">[% amountoutstanding | format('%.2f') %]</td>
231 <label for="amountwrittenoff">Writeoff amount: </label>
232 <!-- default to writing off all -->
233 <input name="amountwrittenoff" id="amountwrittenoff" value="[% amountoutstanding | $Price on_editing => 1 %]" type="text" />
238 <input type="submit" value="Write off this charge" />
239 <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
243 [% IF Koha.Preference('UseCashRegisters') && ( registers.size == 0 ) && ( type != 'WRITEOFF' ) %]
244 [% PROCESS 'cash_register_required' %]
247 [% IF selected_accts %]
248 <ul class="nav nav-pills">
249 [% IF type == 'WRITEOFF' %]
250 <li role="presentation"><a href="/cgi-bin/koha/members/paycollect.pl?borrowernumber=[% patron.borrowernumber | uri %]&type=PAYMENT&amt=[% amt | uri %]&selected=[% selected_accts | uri %]¬es=[% selected_accts_notes | uri %]">Pay</a></li>
251 <li role="presentation" class="active"><a>Write off</a></li>
253 <li role="presentation" class="active"><a>Pay</a></li>
254 <li role="presentation"><a href="/cgi-bin/koha/members/paycollect.pl?borrowernumber=[% patron.borrowernumber | uri %]&type=WRITEOFF&amt=[% amt | uri %]&selected=[% selected_accts | uri %]¬es=[% selected_accts_notes | uri %]">Write off</a></li>
259 <form name="payfine" id="payfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
260 <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
261 <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
262 <input type="hidden" name="selected_accts" id="selected_accts" value="[% selected_accts | html %]" />
263 <input type="hidden" name="total" id="total" value="[% total | html %]" />
264 <input type="hidden" name="type" value="[% type | html %]" />
265 <input type="hidden" name="change_given" id="change_given" />
267 <fieldset class="rows">
268 [% IF ( selected_accts ) %]
269 [% IF type == 'WRITEOFF' %]
270 <legend>Write off an amount toward selected fines</legend>
272 <legend>Pay an amount toward selected fines</legend>
275 <legend>Pay an amount toward all fines</legend>
280 <span class="label">Total amount outstanding: </span>
281 <span class="debit">[% total | format('%.2f') %]</span>
284 [% IF type == 'WRITEOFF' %]
285 <label for="paid">Writeoff amount: </label>
287 <label for="paid">Amount being paid: </label>
289 <input name="paid" id="paid" type="text" step="0.01" value="[% total | $Price on_editing => 1 %]"/>
291 [% IF type != 'WRITEOFF' %]
293 <label for="collected">Amount tendered: </label>
294 <input name="collected" id="collected" type="text" step="0.01" value="[% total | $Price on_editing => 1 %]"/>
297 <label>Change to give: </label>
298 <span id="change">0.00</span>
301 [% PROCESS account_payment_types %]
303 [% IF Koha.Preference('UseCashRegisters') %]
305 <label for="cash_register">Cash register: </label>
306 <select name="cash_register" id="cash_register">
307 <option id="noregister" disabled selected="selected" value="">-- Select an option--</option>
308 [% PROCESS options_for_registers %]
315 <label for="selected_accts_notes">Note: </label>
316 <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes | html %]</textarea>
321 <input type="submit" name="submitbutton" value="Confirm" />
322 <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
330 </div> <!-- /.col-sm-10.col-sm-push-2 -->
332 <div class="col-sm-2 col-sm-pull-10">
334 [% INCLUDE 'circ-menu.inc' %]
336 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
337 </div> <!-- /.row -->
340 <div id="confirm_change_form" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
341 <div class="modal-dialog">
342 <div class="modal-content">
343 <div class="modal-header">
344 <h3>The amount collected is more than the outstanding charge</h3>
346 <div class="modal-body">
347 <p>The amount collected from the patron is higher than the amount to be paid.</p>
348 <p>The change to give is <strong><span id="modal_change">0.00</span></strong>.</p>
349 <p>Confirm this payment?</p>
351 <div class="modal-footer">
352 <button class="btn btn-default approve" id="modal_submit" type="button"><i class="fa fa-check"></i> Yes</button>
353 <button class="btn btn-default deny cancel" href="#" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> No</button>
359 [% MACRO jsinclude BLOCK %]
360 [% INCLUDE 'str/members-menu.inc' %]
361 [% Asset.js("js/members-menu.js") | $raw %]
363 $(document).ready(function() {
364 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
365 window.open('/cgi-bin/koha/members/printfeercpt.pl?action=print&accountlines_id=[% payment_id | html %]&change_given=[% change_given | html %]&borrowernumber=[% patron.borrowernumber | html %]', '_blank');
368 var forms = $('#payindivfine, #payfine');
369 var change = $('#change')[0];
371 $('#payindivfine, #payfine').preventDoubleFormSubmit();
372 $("#paid, #collected").on("change",function() {
374 if (change != undefined) {
375 updateChangeValues();
379 if (change != undefined) {
380 forms.on("submit", function(e) {
381 if (change.innerHTML > 0.00) {
383 $("#confirm_change_form").modal("show");
390 $("#confirm_change_form").on("hidden.bs.modal", function(){
391 // remove class added by preventDoubleFormSubmit if necessary
392 $("body, form input[type='submit'], form button[type='submit'], form a").removeClass('waiting');
395 $('#modal_submit').click(function() {
399 $( "#payindivfine, #payfine" ).validate({
401 paid: { required: true },
405 [% IF Koha.Preference('UseCashRegisters') %]
407 required: function() {
408 return $('#payment_type').val() == 'CASH'
413 invalidHandler: function(event, validator) {
414 // reset beenSubmitted for prevenDoubleFormSubmit
415 event.target.beenSubmitted = false;
416 // remove class added by preventDoubleFormSubmit
417 $("body, form input[type='submit'], form button[type='submit'], form a").removeClass('waiting');
423 $('#woindivfine').on('submit', function(e){
424 if ( prevent_default ) {
427 let amount_outstanding = parseFloat( $('#amountoutstanding').attr('value') );
428 let amount_writeoff = parseFloat( $('#amountwrittenoff').attr('value') );
429 if ( amount_writeoff > amount_outstanding ) {
430 alert(_("You are attemping to writeoff more than the value of the fee."));
431 $('#woindivfine').beenSubmitted = false;
434 $('#woindivfine').preventDoubleFormSubmit();
435 $('#woindivfine').submit();
440 function moneyFormat(textObj) {
441 var newValue = textObj.value;
447 for(i=0; i < newValue.length; i++) {
448 aChar = newValue.substring(i, i+1);
449 if (aChar >= "0" && aChar <= "9") {
451 decAmount = "" + decAmount + aChar;
454 dolAmount = "" + dolAmount + aChar;
466 if (dolAmount == "") {
470 if (dolAmount.length > 1) {
471 while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
472 dolAmount = dolAmount.substring(1,dolAmount.length);
475 if (decAmount.length > 2) {
476 decAmount = decAmount.substring(0,2);
479 if (decAmount.length == 1) {
480 decAmount = decAmount + "0";
482 if (decAmount.length == 0) {
483 decAmount = decAmount + "00";
486 textObj.value = dolAmount + "." + decAmount;
489 function updateChangeValues() {
490 var change = $('#change')[0];
491 change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
492 if (change.innerHTML <= 0) {
493 var paid = $('#paid')[0];
495 $('#collected').rules( "add", { min: Number(paid.value) });
496 $( "#payindivfine, #payfine" ).valid();
497 change.innerHTML = "0.00";
498 $('input[name="change_given"]').val('0.00');
500 change.value = change.innerHTML;
502 change.innerHTML = change.value;
503 $('input[name="change_given"]').val(change.value);
506 $('#modal_change').html(change.innerHTML);
511 [% INCLUDE 'intranet-bottom.inc' %]