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