Bug 18789: Send Koha::Patron object to the templates
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / paycollect.tt
1 [% USE Koha %]
2 [% USE Branches %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha &rsaquo; Patrons &rsaquo; Collect fine payment for  [% patron.firstname %] [% patron.surname %]</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 </head>
8
9 <body id="pat_paycollect" class="pat">
10 [% INCLUDE 'header.inc' %]
11 [% INCLUDE 'patron-search.inc' %]
12 <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; <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Pay fines for [% patron.firstname %] [% patron.surname %]</a> &rsaquo; [% IF ( pay_individual ) %]Pay an individual fine[% ELSIF ( writeoff_individual ) %]Write off an individual fine[% ELSE %][% IF ( selected_accts ) %]Pay an amount toward selected fines[% ELSE %]Pay an amount toward all fines[% END %][% END %]</div>
13
14 <div id="doc3" class="yui-t2">
15
16 <div id="bd">
17 <div id="yui-main">
18 <div class="yui-b">
19 [% INCLUDE 'members-toolbar.inc' borrowernumber=patron.borrowernumber %]
20
21
22 <!-- The manual invoice and credit buttons -->
23 <div class="statictabs">
24 <ul>
25     <li>
26     <a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber %]">Account</a>
27     </li>
28     <li class="active">
29     <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]" >Pay fines</a>
30     </li>
31     <li>
32     <a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% patron.borrowernumber %]" >Create manual invoice</a>
33     </li>
34     <li>
35     <a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber %]" >Create manual credit</a>
36     </li>
37 </ul>
38 <div class="tabs-container">
39 [% IF ( error_over ) %]
40     <div id="error_message" class="dialog alert">
41     You must pay a value less than or equal to [% total_due | format('%.2f') %].
42     </div>
43 [% END %]
44
45 [% IF ( pay_individual ) %]
46     <form name="payindivfine" id="payindivfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
47     <input type="hidden" name="csrf_token" value="[% csrf_token %]" />
48     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber %]" />
49     <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual %]" />
50     <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber %]" />
51     <input type="hidden" name="description" id="description" value="[% description %]" />
52     <input type="hidden" name="accounttype" id="accounttype" value="[% accounttype %]" />
53     <input type="hidden" name="amount" id="amount" value="[% amount %]" />
54     <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
55     <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id %]" />
56     <input type="hidden" name="title" id="title" value="[% title %]" />
57
58 <fieldset class="rows">
59     <legend>Pay an individual fine</legend>
60     <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
61     <table>
62     <thead><tr>
63             <th>Description</th>
64             <th>Account type</th>
65             <th>Amount</th>
66             <th>Amount outstanding</th>
67         </tr></thead>
68     <tfoot>
69         <td colspan="3">Total amount payable:</td><td>[% amountoutstanding | format('%.2f') %]</td>
70     </tfoot>
71     <tbody><tr>
72             <td>
73                 [% individual_description %]
74             </td>
75             <td>[% accounttype %]</td>
76             <td class="debit">[% amount | format('%.2f') %]</td>
77             <td class="debit">[% amountoutstanding | format('%.2f') %]</td>
78         </tr></tbody>
79 </table>
80
81 <ol>
82
83     <li>
84         <label for="paid">Collect from patron: </label>
85             <!-- default to paying all -->
86         <input name="paid" id="paid" value="[% amountoutstanding %]" />
87     </li>
88 </ol>
89 </fieldset>
90
91     <div class="action"><input type="submit" name="submitbutton" value="Confirm" />
92         <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a></div>
93     </form>
94 [% ELSIF ( writeoff_individual ) %]
95     <form name="woindivfine" id="woindivfine" action="/cgi-bin/koha/members/pay.pl" method="post" >
96     <input type="hidden" name="csrf_token" value="[% csrf_token %]" />
97     <fieldset class="rows">
98     <legend>Write off an individual fine</legend>
99     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber %]" />
100     <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual %]" />
101     <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber %]" />
102     <input type="hidden" name="description" id="description" value="[% description %]" />
103     <input type="hidden" name="accounttype" id="accounttype" value="[% accounttype %]" />
104     <input type="hidden" name="amount" id="amount" value="[% amount %]" />
105     <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id %]" />
106     <input type="hidden" name="title" id="title" value="[% title %]" />
107     <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
108     <table>
109     <thead><tr>
110             <th>Description</th>
111             <th>Account type</th>
112             <th>Amount</th>
113             <th>Amount outstanding</th>
114         </tr></thead>
115     <tfoot><td colspan="3">Total amount outstanding:</td><td>[% amountoutstanding | format('%.2f') %]</td></tfoot>
116     <tbody><tr>
117             <td>[% description %] [% title %]</td>
118             <td>[% accounttype %]</td>
119             <td class="debit">[% amount | format('%.2f') %]</td>
120             <td class="debit">[% amountoutstanding | format('%.2f') %]</td>
121         </tr></tbody>
122     </table>
123
124             <ol>
125                 <li>
126                     <label for="paid">Writeoff amount: </label>
127                     <!-- default to writing off all -->
128                     <input name="amountwrittenoff" id="amountwrittenoff" value="[% amountoutstanding %]" />
129                 </li>
130             </ol>
131         </fieldset>
132         <div class="action"><input type="submit" name="confirm_writeoff" id="confirm_writeoff" value="Write off this charge" />
133         <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a></div>
134     </form>
135 [% ELSE %]
136
137     <form name="payfine" id="payfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
138     <input type="hidden" name="csrf_token" value="[% csrf_token %]" />
139     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber %]" />
140     <input type="hidden" name="selected_accts" id="selected_accts" value="[% selected_accts %]" />
141     <input type="hidden" name="total" id="total" value="[% total %]" />
142
143     <fieldset class="rows">
144     [% IF ( selected_accts ) %]<legend>Pay an amount toward selected fines</legend>[% ELSE %]<legend>Pay an amount toward all fines</legend>[% END %]
145     <ol>
146         <li>
147             <span class="label">Total amount outstanding: </span>
148             <span class="debit">[% total | format('%.2f') %]</span>
149         </li>
150     <li>
151         <label for="paid">Collect from patron: </label>
152         <!-- default to paying all -->
153         <input name="paid" id="paid" value="[% total | format('%.2f') %]" />
154     </li>
155     <li>
156         <label for="selected_accts_notes">Note: </label>
157         <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
158     </li>
159     </ol>
160     </fieldset>
161     <div class="action"><input type="submit" name="submitbutton" value="Confirm" />
162         <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a></div>
163     </form>
164 [% END %]
165 </div></div>
166 </div>
167 </div>
168
169 <div class="yui-b">
170 [% INCLUDE 'circ-menu.inc' %]
171 </div>
172 </div>
173
174 [% MACRO jsinclude BLOCK %]
175     <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
176     <script type= "text/javascript">
177         $(document).ready(function() {
178             $('#payindivfine, #woindivfine, #payfine').preventDoubleFormSubmit();
179             $("#paid").on("change",function(){
180                 moneyFormat( this );
181             });
182         });
183
184         function moneyFormat(textObj) {
185             var newValue = textObj.value;
186             var decAmount = "";
187             var dolAmount = "";
188             var decFlag   = false;
189             var aChar     = "";
190
191             for(i=0; i < newValue.length; i++) {
192                 aChar = newValue.substring(i, i+1);
193                 if (aChar >= "0" && aChar <= "9") {
194                     if(decFlag) {
195                         decAmount = "" + decAmount + aChar;
196                     }
197                     else {
198                         dolAmount = "" + dolAmount + aChar;
199                     }
200                 }
201                 if (aChar == ".") {
202                     if (decFlag) {
203                         dolAmount = "";
204                         break;
205                     }
206                     decFlag = true;
207                 }
208             }
209
210             if (dolAmount == "") {
211                 dolAmount = "0";
212             }
213         // Strip leading 0s
214             if (dolAmount.length > 1) {
215                 while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
216                     dolAmount = dolAmount.substring(1,dolAmount.length);
217                 }
218             }
219             if (decAmount.length > 2) {
220                 decAmount = decAmount.substring(0,2);
221             }
222         // Pad right side
223             if (decAmount.length == 1) {
224                decAmount = decAmount + "0";
225             }
226             if (decAmount.length == 0) {
227                decAmount = decAmount + "00";
228             }
229
230             textObj.value = dolAmount + "." + decAmount;
231         }
232     </script>
233 [% END %]
234
235 [% INCLUDE 'intranet-bottom.inc' %]