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