Bug 24339: Remove SIP payment types from staff pay screens
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / paycollect.tt
blob61220f1584ca5e0dfea1dc36ee9da38df80cae56
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE Branches %]
5 [% USE AuthorisedValues %]
6 [% USE Price %]
7 [% SET footerjs = 1 %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>Koha &rsaquo; Patrons &rsaquo;
10     [% IF type == 'WRITEOFF' %]
11         Write off an amount for [% patron.firstname | html %] [% patron.surname | html %]
12     [% ELSE %]
13         Collect fine payment for [% patron.firstname | html %] [% patron.surname | html %]
14     [% END %]
15 </title>
16 [% INCLUDE 'doc-head-close.inc' %]
17 </head>
19 <body id="pat_paycollect" class="pat">
20 [% INCLUDE 'header.inc' %]
21 [% INCLUDE 'patron-search.inc' %]
22 <div id="breadcrumbs">
23     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
24     <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> &rsaquo;
25     <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]">Pay fines for [% patron.firstname | html %] [% patron.surname | html %]</a> &rsaquo;
26     [% IF    ( pay_individual )      %]Pay an individual fine
27     [% ELSIF ( writeoff_individual ) %]Write off an individual fine
28     [% ELSE %]
29         [% IF ( selected_accts ) %]
30             [% IF type == 'writeoff' %]Write off an amount toward selected fines
31             [% ELSE                  %]Pay an amount toward selected fines
32             [% END %]
33         [% ELSE                      %]Pay an amount toward all fines
34         [% END %]
35     [% END %]
36 </div>
38 <div class="main container-fluid">
39     <div class="row">
40         <div class="col-sm-10 col-sm-push-2">
41             <main>
43 [% INCLUDE 'members-toolbar.inc' borrowernumber=patron.borrowernumber %]
46 <!-- The manual invoice and credit buttons -->
47 <div class="statictabs">
48 <ul>
49     <li>
50     <a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | uri %]">Transactions</a>
51     </li>
52     <li class="active">
53     <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Make a payment</a>
54     </li>
55     <li>
56     <a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual invoice</a>
57     </li>
58     <li>
59     <a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual credit</a>
60     </li>
61 </ul>
62 <div class="tabs-container">
63 [% IF ( error_over ) %]
64     <div id="error_message" class="dialog alert">
65     You must pay a value less than or equal to [% total_due | format('%.2f') %].
66     </div>
67 [% END %]
69 [% IF ( pay_individual ) %]
70     [% IF ( error_registers ) %]
71     <div id="error_message" class="dialog alert">
72         You must have at least one cash register associated with this branch before you can record payments.
73     </div>
74     [% ELSE %]
76     <form name="payindivfine" id="payindivfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
77     <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
78     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
79     <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual | html %]" />
80     <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber | html %]" />
81     <input type="hidden" name="description" id="description" value="[% description | html %]" />
82     <input type="hidden" name="debit_type_code" id="debit_type_code" value="[% debit_type_code | html %]" />
83     <input type="hidden" name="amount" id="amount" value="[% amount | html %]" />
84     <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding | html %]" />
85     <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id | html %]" />
86     <input type="hidden" name="title" id="title" value="[% title | html %]" />
87     <input type="hidden" name="change_given" id="change_given" />
89 <fieldset class="rows">
90     <legend>Pay an individual fine</legend>
91     <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note | html %]" />
92     <table>
93     <thead><tr>
94             <th>Description</th>
95             <th>Account type</th>
96             <th>Amount</th>
97             <th>Amount outstanding</th>
98         </tr></thead>
99     <tfoot>
100         <tr><td colspan="3">Total amount payable:</td><td>[% amountoutstanding | format('%.2f') %]</td></tr>
101     </tfoot>
102     <tbody><tr>
103             <td>
104                 [% individual_description | html %]
105             </td>
106             <td>[% debit_type_code | html %]</td>
107             <td class="debit">[% amount | format('%.2f') %]</td>
108             <td class="debit">[% amountoutstanding | format('%.2f') %]</td>
109         </tr></tbody>
110 </table>
112 <ol>
114     <li>
115         <label for="paid">Amount being paid: </label>
116         <input name="paid" id="paid" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
117     </li>
118     <li>
119         <label for="collected">Collected from patron: </label>
120         <input id="collected" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
121     </li>
122     <li>
123         <label>Change to give: </label>
124         <span id="change">0.00</span>
125     </li>
126     [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
127     [% SET excluded = ['SIP00', 'SIP01', 'SIP02'] %]
128     [% IF payment_types.size > 3 %]
129         <li>
130             <label for="payment_type">Payment type: </label>
131             <select name="payment_type" id="payment_type">
132                 <option value=""></option>
133                 [% FOREACH pt IN payment_types %]
134                     [% UNLESS excluded.grep("^$pt.authorised_value\$").size %]
135                     <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
136                     [% END %]
137                 [% END %]
138             </select>
139         </li>
140     [% END %]
141     [% IF Koha.Preference('UseCashRegisters') %]
142     <li>
143         <label for="cash_register">Cash register: </label>
144         <select name="cash_register" id="cash_register">
145             [% FOREACH register IN registers %]
146               [% IF register.id == registerid %]
147             <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
148               [% ELSE %]
149             <option value="[% register.id | html %]">[% register.name | html %]</option>
150               [% END %]
151             [% END %]
152         </select>
153     </li>
154     [% END %]
155 </ol>
156 </fieldset>
158         <div class="action">
159             <input type="submit" name="submitbutton" value="Confirm" />
160             <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
161         </div>
162     </form>
163     [% END %]
164 [% ELSIF ( writeoff_individual ) %]
165     <form name="woindivfine" id="woindivfine" action="/cgi-bin/koha/members/pay.pl" method="post" >
166     <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
167     <fieldset class="rows">
168     <legend>Write off an individual fine</legend>
169     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
170     <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual | html %]" />
171     <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber | html %]" />
172     <input type="hidden" name="description" id="description" value="[% description | html %]" />
173     <input type="hidden" name="debit_type_code" id="debit_type_code" value="[% debit_type_code | html %]" />
174     <input type="hidden" name="amount" id="amount" value="[% amount | html %]" />
175     <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id | html %]" />
176     <input type="hidden" name="title" id="title" value="[% title | html %]" />
177     <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note | html %]" />
178     <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding | html %]" />
179     <input type="hidden" name="confirm_writeoff" id="confirm_writeoff" value="1" />
180     <input type="hidden" name="change_given" id="change_given" />
181     <table>
182     <thead><tr>
183             <th>Description</th>
184             <th>Account type</th>
185             <th>Amount</th>
186             <th>Amount outstanding</th>
187         </tr></thead>
188     <tfoot><tr><td colspan="3">Total amount outstanding:</td><td>[% amountoutstanding | format('%.2f') %]</td></tr></tfoot>
189     <tbody><tr>
190             <td>[% individual_description | html %]</td>
191             <td>[% debit_type_code | html %]</td>
192             <td class="debit">[% amount | format('%.2f') %]</td>
193             <td class="debit">[% amountoutstanding | format('%.2f') %]</td>
194         </tr></tbody>
195     </table>
197             <ol>
198                 <li>
199                     <label for="paid">Writeoff amount: </label>
200                     <!-- default to writing off all -->
201                     <input name="amountwrittenoff" id="amountwrittenoff" value="[% amountoutstanding | $Price on_editing => 1 %]" type="text" />
202                 </li>
203             </ol>
204         </fieldset>
205         <div class="action">
206             <input type="submit" value="Write off this charge" />
207             <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
208         </div>
209     </form>
210 [% ELSE %]
211     [% IF ( error_registers && type != 'writeoff' ) %]
212     <div id="error_message" class="dialog alert">
213         You must have at least one cash register associated with this branch before you can record payments.
214     </div>
215     [% ELSE %]
217     <form name="payfine" id="payfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
218     <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
219     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
220     <input type="hidden" name="selected_accts" id="selected_accts" value="[% selected_accts | html %]" />
221     <input type="hidden" name="total" id="total" value="[% total | html %]" />
222     <input type="hidden" name="type" value="[% type | html %]" />
223     <input type="hidden" name="change_given" id="change_given" />
225     <fieldset class="rows">
226     [% IF ( selected_accts ) %]
227         [% IF type == 'WRITEOFF' %]
228             <legend>Write off an amount toward selected fines</legend>
229         [% ELSE %]
230             <legend>Pay an amount toward selected fines</legend>
231         [% END %]
232     [% ELSE %]
233         <legend>Pay an amount toward all fines</legend>
234     [% END %]
236     <ol>
237         <li>
238             <span class="label">Total amount outstanding: </span>
239             <span class="debit">[% total | format('%.2f') %]</span>
240         </li>
241     <li>
242         [% IF type == 'WRITEOFF' %]
243             <label for="paid">Writeoff amount:</label>
244         [% ELSE %]
245             <label for="paid">Amount paid: </label>
246         [% END %]
247         <input name="paid" id="paid" value="[% total | $Price on_editing => 1 %]"/>
248     </li>
250     [% IF type != 'WRITEOFF' %]
251         <li>
252             <label for="collected">Collected from patron: </label>
253             <input id="collected" value="[% total | $Price on_editing => 1 %]"/>
254         </li>
255         <li>
256             <label>Change to give: </label>
257             <span id="change">0.00</span>
258         </li>
259     [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
260     [% SET excluded = ['SIP00', 'SIP01', 'SIP02'] %]
261     [% IF payment_types.size > 3 %]
262         <li>
263             <label for="payment_type">Payment type: </label>
264             <select name="payment_type" id="payment_type">
265                 <option value=""></option>
266                 [% FOREACH pt IN payment_types %]
267                     [% UNLESS excluded.grep("^$pt.authorised_value\$").size %]
268                     <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
269                     [% END %]
270                 [% END %]
271             </select>
272         </li>
273     [% END %]
275     [% IF Koha.Preference('UseCashRegisters') %]
276     <li>
277         <label for="cash_register">Cash register: </label>
278         <select name="cash_register" id="cash_register">
279             [% FOREACH register IN registers %]
280               [% IF register.id == registerid %]
281             <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
282               [% ELSE %]
283             <option value="[% register.id | html %]">[% register.name | html %]</option>
284               [% END %]
285             [% END %]
286         </select>
287     </li>
288     [% END %]
289     [% END %]
291     <li>
292         <label for="selected_accts_notes">Note: </label>
293         <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes | html %]</textarea>
294     </li>
295     </ol>
296     </fieldset>
297     <div class="action">
298         <input type="submit" name="submitbutton" value="Confirm" />
299         <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
300     </div>
301     </form>
302     [% END %]
303 [% END %]
304 </div></div>
306             </main>
307         </div> <!-- /.col-sm-10.col-sm-push-2 -->
309         <div class="col-sm-2 col-sm-pull-10">
310             <aside>
311                 [% INCLUDE 'circ-menu.inc' %]
312             </aside>
313         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
314      </div> <!-- /.row -->
316 <!-- Modal -->
317 <div id="confirm_change_form" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
318     <div class="modal-dialog">
319         <div class="modal-content">
320             <div class="modal-header">
321                 <h3>The amount collected is more than the outstanding charge</h3>
322             </div>
323             <div class="modal-body">
324                 <p>The amount collected from the patron is higher than the amount to be paid.</p>
325                 <p>The change to give is <b><span id="modal_change">0.00</span></b>.</p>
326                 <p>Confirm this payment?</p>
327             </div>
328             <div class="modal-footer">
329                 <button class="btn btn-default approve" id="modal_submit" type="button"><i class="fa fa-check"></i> Yes</button>
330                 <button class="btn btn-default deny cancel" href="#" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> No</button>
331             </div>
332         </div>
333     </div>
334 </div>
336 [% MACRO jsinclude BLOCK %]
337     [% INCLUDE 'str/members-menu.inc' %]
338     [% Asset.js("js/members-menu.js") | $raw %]
339     <script>
340         $(document).ready(function() {
341             [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
342                 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');
343             [% END %]
345             var forms = $('#payindivfine, #payfine');
346             var change = $('#change')[0];
348             $('#payindivfine, #payfine').preventDoubleFormSubmit();
349             $("#paid, #collected").on("change",function() {
350                 moneyFormat( this );
351                 if (change != undefined) {
352                     updateChangeValues();
353                 }
354             });
356             if (change != undefined) {
357                 forms.on("submit", function(e) {
358                     if (change.innerHTML > 0.00) {
359                         e.preventDefault();
360                         $("#confirm_change_form").modal("show");
361                     } else {
362                         return true;
363                     }
364                 });
365             }
367             $("#confirm_change_form").on("hidden.bs.modal", function(){
368                 // remove class added by preventDoubleFormSubmit if necessary
369                 $("body, form input[type='submit'], form button[type='submit'], form a").removeClass('waiting');
370             });
372             $('#modal_submit').click(function() {
373                 forms[0].submit();
374             });
375         });
377         prevent_default = 1;
378         $('#woindivfine').on('submit', function(e){
379             if ( prevent_default ) {
380                 e.preventDefault();
382                 let amount_outstanding = parseFloat( $('#amountoutstanding').attr('value') );
383                 let amount_writeoff = parseFloat( $('#amountwrittenoff').attr('value') );
384                 if ( amount_writeoff > amount_outstanding ) {
385                     alert(_("You are attemping to writeoff more than the value of the fee."));
386                     $('#woindivfine').beenSubmitted = false;
387                 } else {
388                     prevent_default = 0;
389                     $('#woindivfine').preventDoubleFormSubmit();
390                     $('#woindivfine').submit();
391                 }
392             }
393         });
395         function moneyFormat(textObj) {
396             var newValue = textObj.value;
397             var decAmount = "";
398             var dolAmount = "";
399             var decFlag   = false;
400             var aChar     = "";
402             for(i=0; i < newValue.length; i++) {
403                 aChar = newValue.substring(i, i+1);
404                 if (aChar >= "0" && aChar <= "9") {
405                     if(decFlag) {
406                         decAmount = "" + decAmount + aChar;
407                     }
408                     else {
409                         dolAmount = "" + dolAmount + aChar;
410                     }
411                 }
412                 if (aChar == ".") {
413                     if (decFlag) {
414                         dolAmount = "";
415                         break;
416                     }
417                     decFlag = true;
418                 }
419             }
421             if (dolAmount == "") {
422                 dolAmount = "0";
423             }
424         // Strip leading 0s
425             if (dolAmount.length > 1) {
426                 while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
427                     dolAmount = dolAmount.substring(1,dolAmount.length);
428                 }
429             }
430             if (decAmount.length > 2) {
431                 decAmount = decAmount.substring(0,2);
432             }
433         // Pad right side
434             if (decAmount.length == 1) {
435                decAmount = decAmount + "0";
436             }
437             if (decAmount.length == 0) {
438                decAmount = decAmount + "00";
439             }
441             textObj.value = dolAmount + "." + decAmount;
442         }
444         function updateChangeValues() {
445             var change = $('#change')[0];
446             change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
447             if (change.innerHTML <= 0) {
448                 change.innerHTML = "0.00";
449                 $('input[name="change_given"]').val('0.00');
450             } else {
451                 change.value = change.innerHTML;
452                 moneyFormat(change);
453                 change.innerHTML = change.value;
454                 $('input[name="change_given"]').val(change.value);
455             }
457             $('#modal_change').html(change.innerHTML);
458         }
459     </script>
460 [% END %]
462 [% INCLUDE 'intranet-bottom.inc' %]