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