Bug 20226: Centralize update child code (CATCODE_MULTI)
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / paycollect.tt
1 [% USE Asset %]
2 [% USE Koha %]
3 [% USE Branches %]
4 [% USE AuthorisedValues %]
5 [% USE Price %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha &rsaquo; Patrons &rsaquo; Collect fine payment for  [% patron.firstname %] [% patron.surname %]</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 </head>
11
12 <body id="pat_paycollect" class="pat">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'patron-search.inc' %]
15 <div id="breadcrumbs">
16     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
17     <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> &rsaquo;
18     <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Pay fines for [% patron.firstname %] [% patron.surname %]</a> &rsaquo;
19     [% IF    ( pay_individual )      %]Pay an individual fine
20     [% ELSIF ( writeoff_individual ) %]Write off an individual fine
21     [% ELSE %]
22         [% IF ( selected_accts ) %]
23             [% IF type == 'writeoff' %]Write off an amount toward selected fines
24             [% ELSE                  %]Pay an amount toward selected fines
25             [% END %]
26         [% ELSE                      %]Pay an amount toward all fines
27         [% END %]
28     [% END %]
29 </div>
30
31 <div id="doc3" class="yui-t2">
32
33 <div id="bd">
34 <div id="yui-main">
35 <div class="yui-b">
36 [% INCLUDE 'members-toolbar.inc' borrowernumber=patron.borrowernumber %]
37
38
39 <!-- The manual invoice and credit buttons -->
40 <div class="statictabs">
41 <ul>
42     <li>
43     <a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber %]">Account</a>
44     </li>
45     <li class="active">
46     <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]" >Pay fines</a>
47     </li>
48     <li>
49     <a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% patron.borrowernumber %]" >Create manual invoice</a>
50     </li>
51     <li>
52     <a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber %]" >Create manual credit</a>
53     </li>
54 </ul>
55 <div class="tabs-container">
56 [% IF ( error_over ) %]
57     <div id="error_message" class="dialog alert">
58     You must pay a value less than or equal to [% total_due | format('%.2f') %].
59     </div>
60 [% END %]
61
62 [% IF ( pay_individual ) %]
63     <form name="payindivfine" id="payindivfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
64     <input type="hidden" name="csrf_token" value="[% csrf_token %]" />
65     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber %]" />
66     <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual %]" />
67     <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber %]" />
68     <input type="hidden" name="description" id="description" value="[% description %]" />
69     <input type="hidden" name="accounttype" id="accounttype" value="[% accounttype %]" />
70     <input type="hidden" name="amount" id="amount" value="[% amount %]" />
71     <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
72     <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id %]" />
73     <input type="hidden" name="title" id="title" value="[% title %]" />
74
75 <fieldset class="rows">
76     <legend>Pay an individual fine</legend>
77     <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
78     <table>
79     <thead><tr>
80             <th>Description</th>
81             <th>Account type</th>
82             <th>Amount</th>
83             <th>Amount outstanding</th>
84         </tr></thead>
85     <tfoot>
86         <td colspan="3">Total amount payable:</td><td>[% amountoutstanding | format('%.2f') %]</td>
87     </tfoot>
88     <tbody><tr>
89             <td>
90                 [% individual_description %]
91             </td>
92             <td>[% accounttype %]</td>
93             <td class="debit">[% amount | format('%.2f') %]</td>
94             <td class="debit">[% amountoutstanding | format('%.2f') %]</td>
95         </tr></tbody>
96 </table>
97
98 <ol>
99
100     <li>
101         <label for="paid">Collect from patron: </label>
102             <!-- default to paying all -->
103         <input name="paid" id="paid" value="[% amountoutstanding %]" />
104     </li>
105     [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
106     [% IF payment_types %]
107         <li>
108             <label for="payment_type">Payment type: </label>
109             <select name="payment_type" id="payment_type">
110                 <option value=""></option>
111                 [% FOREACH pt IN payment_types %]
112                     <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
113                 [% END %]
114             </select>
115         </li>
116     [% END %]
117 </ol>
118 </fieldset>
119
120     <div class="action"><input type="submit" name="submitbutton" value="Confirm" />
121         <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a></div>
122     </form>
123 [% ELSIF ( writeoff_individual ) %]
124     <form name="woindivfine" id="woindivfine" action="/cgi-bin/koha/members/pay.pl" method="post" >
125     <input type="hidden" name="csrf_token" value="[% csrf_token %]" />
126     <fieldset class="rows">
127     <legend>Write off an individual fine</legend>
128     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber %]" />
129     <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual %]" />
130     <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber %]" />
131     <input type="hidden" name="description" id="description" value="[% description %]" />
132     <input type="hidden" name="accounttype" id="accounttype" value="[% accounttype %]" />
133     <input type="hidden" name="amount" id="amount" value="[% amount %]" />
134     <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id %]" />
135     <input type="hidden" name="title" id="title" value="[% title %]" />
136     <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
137     <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
138     <input type="hidden" name="confirm_writeoff" id="confirm_writeoff" value="1" />
139     <table>
140     <thead><tr>
141             <th>Description</th>
142             <th>Account type</th>
143             <th>Amount</th>
144             <th>Amount outstanding</th>
145         </tr></thead>
146     <tfoot><td colspan="3">Total amount outstanding:</td><td>[% amountoutstanding | format('%.2f') %]</td></tfoot>
147     <tbody><tr>
148             <td>[% description %] [% title %]</td>
149             <td>[% accounttype %]</td>
150             <td class="debit">[% amount | format('%.2f') %]</td>
151             <td class="debit">[% amountoutstanding | format('%.2f') %]</td>
152         </tr></tbody>
153     </table>
154
155             <ol>
156                 <li>
157                     <label for="paid">Writeoff amount: </label>
158                     <!-- default to writing off all -->
159                     <input name="amountwrittenoff" id="amountwrittenoff" value="[% amountoutstanding | $Price on_editing => 1 %]" />
160                 </li>
161             </ol>
162         </fieldset>
163         <div class="action">
164             <input type="submit" value="Write off this charge" />
165             <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a>
166         </div>
167     </form>
168 [% ELSE %]
169
170     <form name="payfine" id="payfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
171     <input type="hidden" name="csrf_token" value="[% csrf_token %]" />
172     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber %]" />
173     <input type="hidden" name="selected_accts" id="selected_accts" value="[% selected_accts %]" />
174     <input type="hidden" name="total" id="total" value="[% total %]" />
175     <input type="hidden" name="type" value="[% type %]" />
176
177     <fieldset class="rows">
178     [% IF ( selected_accts ) %]
179         [% IF type == 'writeoff' %]
180             <legend>Write off an amount toward selected fines</legend>
181         [% ELSE %]
182             <legend>Pay an amount toward selected fines</legend>
183         [% END %]
184     [% ELSE %]
185         <legend>Pay an amount toward all fines</legend>
186     [% END %]
187
188     <ol>
189         <li>
190             <span class="label">Total amount outstanding: </span>
191             <span class="debit">[% total | format('%.2f') %]</span>
192         </li>
193     <li>
194         [% IF type == 'writeoff' %]
195             <label for="paid">Writeoff amount: </label>
196         [% ELSE %]
197             <label for="paid">Collect from patron: </label>
198         [% END %]
199         <!-- default to paying all -->
200         <input name="paid" id="paid" value="[% total | format('%.2f') %]" />
201     </li>
202     [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
203     [% IF payment_types %]
204         <li>
205             <label for="payment_type">Payment type: </label>
206             <select name="payment_type" id="payment_type">
207                 <option value=""></option>
208                 [% FOREACH pt IN payment_types %]
209                     <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
210                 [% END %]
211             </select>
212         </li>
213     [% END %]
214     <li>
215         <label for="selected_accts_notes">Note: </label>
216         <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
217     </li>
218     </ol>
219     </fieldset>
220     <div class="action">
221         <input type="submit" name="submitbutton" value="Confirm" />
222         <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a>
223     </div>
224     </form>
225 [% END %]
226 </div></div>
227 </div>
228 </div>
229
230 <div class="yui-b">
231 [% INCLUDE 'circ-menu.inc' %]
232 </div>
233 </div>
234
235 [% MACRO jsinclude BLOCK %]
236     [% INCLUDE 'str/members-menu.inc' %]
237     [% Asset.js("js/members-menu.js") %]
238     <script type= "text/javascript">
239         $(document).ready(function() {
240             $('#payindivfine, #payfine').preventDoubleFormSubmit();
241             $("#paid").on("change",function(){
242                 moneyFormat( this );
243             });
244         });
245
246         prevent_default = 1;
247         $('#woindivfine').on('submit', function(e){
248             if ( prevent_default ) {
249                 e.preventDefault();
250
251                 let amount_outstanding = parseFloat( $('#amountoutstanding').attr('value') );
252                 let amount_writeoff = parseFloat( $('#amountwrittenoff').attr('value') );
253                 if ( amount_writeoff > amount_outstanding ) {
254                     alert(_("You are attemping to writeoff more than the value of the fee."));
255                     $('#woindivfine').beenSubmitted = false;
256                 } else {
257                     prevent_default = 0;
258                     $('#woindivfine').preventDoubleFormSubmit();
259                     $('#woindivfine').submit();
260                 }
261             }
262         });
263
264         function moneyFormat(textObj) {
265             var newValue = textObj.value;
266             var decAmount = "";
267             var dolAmount = "";
268             var decFlag   = false;
269             var aChar     = "";
270
271             for(i=0; i < newValue.length; i++) {
272                 aChar = newValue.substring(i, i+1);
273                 if (aChar >= "0" && aChar <= "9") {
274                     if(decFlag) {
275                         decAmount = "" + decAmount + aChar;
276                     }
277                     else {
278                         dolAmount = "" + dolAmount + aChar;
279                     }
280                 }
281                 if (aChar == ".") {
282                     if (decFlag) {
283                         dolAmount = "";
284                         break;
285                     }
286                     decFlag = true;
287                 }
288             }
289
290             if (dolAmount == "") {
291                 dolAmount = "0";
292             }
293         // Strip leading 0s
294             if (dolAmount.length > 1) {
295                 while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
296                     dolAmount = dolAmount.substring(1,dolAmount.length);
297                 }
298             }
299             if (decAmount.length > 2) {
300                 decAmount = decAmount.substring(0,2);
301             }
302         // Pad right side
303             if (decAmount.length == 1) {
304                decAmount = decAmount + "0";
305             }
306             if (decAmount.length == 0) {
307                decAmount = decAmount + "00";
308             }
309
310             textObj.value = dolAmount + "." + decAmount;
311         }
312     </script>
313 [% END %]
314
315 [% INCLUDE 'intranet-bottom.inc' %]