Bug 21454: Remove html filter for Price filtered variables
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-account.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE AuthorisedValues %]
6 [% USE Price %]
7 [% SET ENABLE_OPAC_PAYMENTS = Koha.Preference('EnablePayPalOpacPayments') || plugins %]
8 [% SET DISPLAY_PAYMENT_BLOCK = 0 %]
9 [% INCLUDE 'doc-head-open.inc' %]
10 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your fines and charges</title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 [% BLOCK cssinclude %]
13     [% Asset.css("css/datatables.css") | $raw %]
14 [% END %]
15 </head>
16
17 [% INCLUDE 'bodytag.inc' bodyid='opac-account' bodyclass='scrollto' %]
18 [% INCLUDE 'masthead.inc' %]
19
20 <div class="main">
21     <ul class="breadcrumb">
22         <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
23         <li>[% IF logged_in_user %]<a href="/cgi-bin/koha/opac-user.pl">[% INCLUDE 'patron-title.inc' patron = logged_in_user %]</a>[% END %] <span class="divider">&rsaquo;</span></li>
24         <li><a href="#">Your fines and charges</a></li>
25     </ul>
26
27     <div class="container-fluid">
28         <div class="row-fluid">
29             <div class="span2">
30                 <div id="navigation">
31                     [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
32                 </div>
33             </div>
34             <div class="span10">
35                 <div id="useraccount" class="maincontent">
36
37                     [% IF message %]
38                         <div class="alert alert-info">
39                             [% IF message == 'valid_payment' %]
40                                 <p>Your payment of $[% message_value | html %] has been processed successfully!</p>
41                             [% ELSIF message == 'duplicate_payment' %]
42                                 <p>A payment with the transaction id '[% message_value | html %]' has already been posted to an account.</p>
43                                 <p>Please contact a librarian for details.</p>
44                             [% ELSIF message == 'invalid_payment' %]
45                                 <p>The transaction id '[% message_value | html %]' for this payment is invalid.</p>
46                                 <p>Please contact a librarian for details.</p>
47                             [% END %]
48                         </div>
49                     [% END %]
50
51                     [% IF payment_error %]
52                         <div id="error" class="dialog alert">
53                             <p><strong>Error:</strong> there was a problem processing your payment</p>
54
55                             [% IF payment_error == "PAYPAL_UNABLE_TO_CONNECT" %]
56                                 <p>Unable to connect to PayPal.</p>
57                                 <p>Please contact a librarian to verify your payment.</p>
58                             [% ELSIF payment_error == "PAYPAL_ERROR_PROCESSING" %]
59                                 <p>Unable to verify payment.</p>
60                                 <p>Please contact a librarian to verify your payment.</p>
61                             [% END %]
62                         </div>
63                     [% ELSIF payment %]
64                         <div class="alert alert-info">
65                             <p><strong>Payment applied:</strong> your payment of [% payment | html %] has been applied to your account</p>
66                         </div>
67                     [% END %]
68
69                     <h3>Fines and charges</h3>
70
71                     [% IF ( ACCOUNT_LINES ) %]
72                         <form method="post" action="opac-account-pay.pl" class="form-horizontal">
73                         <table class="table table-bordered table-striped" id="finestable">
74                             <thead>
75                                 <tr>
76                                     [% IF ENABLE_OPAC_PAYMENTS %]<th>&nbsp;</th>[% END %]
77                                     <th class="title-string">Date</th>
78                                     <th>Description</th>
79                                     <th>Fine amount</th>
80                                     <th>Amount outstanding</th>
81                                 </tr>
82                             </thead>
83
84                             <tfoot>
85                             <tr>
86                                 [%- IF ENABLE_OPAC_PAYMENTS -%]
87                                     [%- SET COLSPAN = 4 -%]
88                                 [%- ELSE -%]
89                                     [%- SET COLSPAN = 3 -%]
90                                 [%- END -%]
91                                 <th class="sum" colspan="[% COLSPAN | html %]">Total due</th>
92                                 <td class="sum">[% total | $Price %]</td>
93                             </tr>
94                             </tfoot>
95
96                             <tbody>
97                                 [% FOREACH ACCOUNT_LINE IN ACCOUNT_LINES %]
98                                     [% IF ( ACCOUNT_LINE.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
99                                         [% IF ENABLE_OPAC_PAYMENTS %]
100                                             <td>
101                                                 [% IF ACCOUNT_LINE.amountoutstanding > 0 %]
102                                                     [% SET DISPLAY_PAYMENT_BLOCK = 1 %]
103                                                     <input class="checkbox-pay pay-online hidden" name="accountline" type="checkbox" id="checkbox-pay-[% ACCOUNT_LINE.accountlines_id | html %]" value="[% ACCOUNT_LINE.accountlines_id | html %]">
104                                                     <input type="hidden" id="amount-[% ACCOUNT_LINE.accountlines_id | html %]" value="[% ACCOUNT_LINE.amountoutstanding | html %]" />
105                                                 [% END %]
106                                             </td>
107                                         [% END %]
108                                         <td><span title="[% ACCOUNT_LINE.date | html %]">[% ACCOUNT_LINE.date | $KohaDates %]</span></td>
109                                         <td>
110                                             [% SWITCH ACCOUNT_LINE.accounttype %]
111                                             [% CASE 'Pay' %]Payment, thanks
112                                             [% CASE 'Pay00' %]Payment, thanks (cash via SIP2)
113                                             [% CASE 'Pay01' %]Payment, thanks (VISA via SIP2)
114                                             [% CASE 'Pay02' %]Payment, thanks (credit card via SIP2)
115                                             [% CASE 'N' %]New card
116                                             [% CASE 'F' %]Fine
117                                             [% CASE 'A' %]Account management fee
118                                             [% CASE 'M' %]Sundry
119                                             [% CASE 'L' %]Lost item
120                                             [% CASE 'W' %]Writeoff
121                                             [% CASE 'FU' %]Accruing fine
122                                             [% CASE 'HE' %]Hold waiting too long
123                                             [% CASE 'Rent' %]Rental fee
124                                             [% CASE 'FOR' %]Forgiven
125                                             [% CASE 'LR' %]Lost item fee refund
126                                             [% CASE 'PF' %]Processing fee
127                                             [% CASE 'PAY' %]Payment
128                                             [% CASE 'WO' %]Writeoff
129                                             [% CASE 'C' %]Credit
130                                             [% CASE 'CR' %]Credit
131                                             [% CASE %][% ACCOUNT_LINE.accounttype | html %]
132                                           [%- END -%]
133                                           [%- IF ACCOUNT_LINE.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', ACCOUNT_LINE.payment_type, 1) | html %][% END %]
134                                           [%- IF ACCOUNT_LINE.description %], [% ACCOUNT_LINE.description | html %][% END %]
135                                           [% IF ACCOUNT_LINE.title %]([% ACCOUNT_LINE.title | html %])[% END %]
136                                         </td>
137                                         [% IF ( ACCOUNT_LINE.amountcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% ACCOUNT_LINE.amount | $Price %]</td>
138                                         [% IF ( ACCOUNT_LINE.amountoutstandingcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% ACCOUNT_LINE.amountoutstanding | $Price %]</td>
139                                     </tr>
140                                 [% END %]
141                             </tbody>
142
143                         </table>
144
145                             [% IF ENABLE_OPAC_PAYMENTS && DISPLAY_PAYMENT_BLOCK %]
146                                 <fieldset class="pay-online hidden">
147                                     <legend>Pay selected fines and charges</legend>
148                                         <span class="help-block"><h3>Payment method</h3></span>
149
150                                         [% IF Koha.Preference('EnablePayPalOpacPayments') %]
151                                             <div class="control-group">
152                                                 <label class="radio">
153                                                     <input type="radio" name="payment_method" id="payment_method-paypal" value="paypal" checked="checked">
154                                                     <!-- PayPal Logo --><a href="https://www.paypal.com/webapps/mpp/paypal-popup" title="How PayPal Works" class="paypal"><img src="https://www.paypalobjects.com/webstatic/mktg/logo/AM_SbyPP_mc_vs_dc_ae.jpg" border="0" alt="PayPal Acceptance Mark"></a><!-- PayPal Logo -->
155                                                 </label>
156                                             </div>
157                                         [% END %]
158
159                                         [% FOREACH p IN plugins %]
160                                             <div class="control-group">
161                                                 <label class="radio">
162                                                     <input type="radio" name="payment_method" id="payment_method-[% p.class | html %]" value="[% p.class | html %]" checked="checked">
163                                                     [% p.get_metadata.name | html %]
164                                                 </label>
165                                             </div>
166                                         [% END %]
167
168                                         <div class="control-group">
169                                             <input type="hidden" id="payment-amount" name="payment_amount" value="0" />
170                                             <button id="submit-pay" type="submit" class="btn" disabled="disabled">Make payment</button>
171                                             <span id="amount-to-pay-label">
172                                                 Amount to pay: <span id="amount-to-pay">0.00</span>
173                                             </span>
174                                         </div>
175                                 </fieldset>
176                             [% END %]
177                         </form>
178                     [% ELSE %]
179                         <h4>You have no fines or charges</h4>
180                     [% END %]
181                 </div> <!-- / #useraccount -->
182             </div> <!-- / .span10 -->
183         </div> <!-- / .row-fluid -->
184     </div> <!-- / .container-fluid -->
185 </div> <!-- / .main -->
186
187 [% INCLUDE 'opac-bottom.inc' %]
188 [% BLOCK jsinclude %]
189 [% INCLUDE 'datatables.inc' %]
190 <script>
191 $( document ).ready(function() {
192
193     $("#finestable").dataTable($.extend(true, {}, dataTablesDefaults, {
194         "columnDefs": [
195              { "type": "title-string", "targets" : [ "title-string" ] }
196          ]
197     } ));
198
199     $(".paypal").on("click", function() {
200         window.open('https://www.paypal.com/webapps/mpp/paypal-popup','WIPaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1060, height=700');
201         return false;
202     });
203
204     $(".pay-online").removeClass("hidden");
205
206     $("#amount-to-pay-label").hide();
207
208     $(".checkbox-pay").change( function() {
209         // Disable the pay button if no fees are selected
210         $("#submit-pay").prop("disabled", ! $(".checkbox-pay:checked").length );
211
212         // Calculate the total amount to be paid based on selected fees
213         var total = 0;
214         $(".checkbox-pay").each( function() {
215             if ( $(this).is(":checked") ) {
216                 var id = this.id.split("checkbox-pay-")[1];
217                 total += parseFloat( $("#amount-" + id).val() );
218             }
219         });
220
221         if ( total ) {
222             $("#amount-to-pay").html( total.toFixed(2) );
223             $("#amount-to-pay-label").show();
224         } else {
225             $("#amount-to-pay-label").hide();
226         }
227     });
228 });
229 </script>
230 [% END %]