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