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