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