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