Bug 22521: Update UI to use accountlines.status
[koha-equinox.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-account.tt
index 574d2db..c6f6cc7 100644 (file)
@@ -1,20 +1,26 @@
+[% USE raw %]
+[% USE Asset %]
 [% USE Koha %]
 [% USE KohaDates %]
-[% SET ENABLE_OPAC_PAYMENTS = Koha.Preference('EnablePayPalOpacPayments') %]
-
+[% USE AuthorisedValues %]
+[% USE Price %]
+[% SET ENABLE_OPAC_PAYMENTS = Koha.Preference('EnablePayPalOpacPayments') || plugins %]
+[% SET DISPLAY_PAYMENT_BLOCK = 0 %]
 [% INCLUDE 'doc-head-open.inc' %]
-<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your fines and charges</title>
+<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your fines and charges</title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% BLOCK cssinclude %][% END %]
+[% BLOCK cssinclude %]
+    [% Asset.css("css/datatables.css") | $raw %]
+[% END %]
 </head>
-<body id="opac-account" class="scrollto">
+
 [% INCLUDE 'bodytag.inc' bodyid='opac-account' bodyclass='scrollto' %]
 [% INCLUDE 'masthead.inc' %]
 
 <div class="main">
     <ul class="breadcrumb">
         <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
-        <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>
+        <li>[% IF logged_in_user %]<a href="/cgi-bin/koha/opac-user.pl">[% INCLUDE 'patron-title.inc' patron = logged_in_user %]</a>[% END %] <span class="divider">&rsaquo;</span></li>
         <li><a href="#">Your fines and charges</a></li>
     </ul>
 
                     [% IF message %]
                         <div class="alert alert-info">
                             [% IF message == 'valid_payment' %]
-                                <p>Your payment of $[% message_value %] has been processed sucessfully!</p>
+                                <p>Your payment of $[% message_value | html %] has been processed successfully!</p>
                             [% ELSIF message == 'duplicate_payment' %]
-                                <p>A payment with the transaction id <i>[% message_value %]</i> has already been posted to an account.</p>
+                                <p>A payment with the transaction id '[% message_value | html %]' has already been posted to an account.</p>
                                 <p>Please contact a librarian for details.</p>
                             [% ELSIF message == 'invalid_payment' %]
-                                <p>The transaction id <i>[% message_value %]</i> for this payment is invalid.</p>
+                                <p>The transaction id '[% message_value | html %]' for this payment is invalid.</p>
                                 <p>Please contact a librarian for details.</p>
                             [% END %]
                         </div>
@@ -44,7 +50,7 @@
 
                     [% IF payment_error %]
                         <div id="error" class="dialog alert">
-                            <p><strong>Error:</strong> there was an problem processing your payment</p>
+                            <p><strong>Error:</strong> there was a problem processing your payment</p>
 
                             [% IF payment_error == "PAYPAL_UNABLE_TO_CONNECT" %]
                                 <p>Unable to connect to PayPal.</p>
                         </div>
                     [% ELSIF payment %]
                         <div class="alert alert-info">
-                            <p><strong>Payment applied:</strong> your payment of [% payment %] has been applied to your account</p>
+                            <p><strong>Payment applied:</strong> your payment of [% payment | html %] has been applied to your account</p>
                         </div>
                     [% END %]
 
-                    <h3>Fines and charges</h3>
-
-                    [% IF ( ACCOUNT_LINES ) %]
-                        <form method="post" action="opac-account-pay.pl" class="form-horizontal">
-                        <table class="table table-bordered table-striped">
-                            <thead>
-                                <tr>
-                                    [% IF ENABLE_OPAC_PAYMENTS %]<th>&nbsp;</th>[% END %]
-                                    <th>Date</th>
-                                    <th>Description</th>
-                                    <th>Fine amount</th>
-                                    <th>Amount outstanding</th>
-                                </tr>
-                            </thead>
-
-                            <tfoot>
-                            <tr>
-                                [%- IF ENABLE_OPAC_PAYMENTS -%]
-                                    [%- SET COLSPAN = 4 -%]
-                                [%- ELSE -%]
-                                    [%- SET COLSPAN = 3 -%]
-                                [%- END -%]
-                                <th class="sum" colspan="[% COLSPAN %]">Total due</th>
-                                <td class="sum">[% total %]</td>
-                            </tr>
-                            </tfoot>
-
-                            <tbody>
-                                [% FOREACH ACCOUNT_LINE IN ACCOUNT_LINES %]
-                                    [% IF ( ACCOUNT_LINE.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
-                                        [% IF ENABLE_OPAC_PAYMENTS %]
-                                            <td>
-                                                [% IF ACCOUNT_LINE.amountoutstanding > 0 %]
-                                                    <input class="checkbox-pay pay-online hidden" name="accountline" type="checkbox" id="checkbox-pay-[% ACCOUNT_LINE.accountlines_id %]" value="[% ACCOUNT_LINE.accountlines_id %]">
-                                                    <input type="hidden" id="amount-[% ACCOUNT_LINE.accountlines_id %]" value="[% ACCOUNT_LINE.amountoutstanding %]" />
-                                                [% END %]
-                                            </td>
-                                        [% END %]
-                                        <td>[% ACCOUNT_LINE.date | $KohaDates %]</td>
-                                        <td>
-                                            [% SWITCH ACCOUNT_LINE.accounttype %]
-                                            [% CASE 'Pay' %]Payment, thanks
-                                            [% CASE 'Pay00' %]Payment, thanks (cash via SIP2)
-                                            [% CASE 'Pay01' %]Payment, thanks (VISA via SIP2)
-                                            [% CASE 'Pay02' %]Payment, thanks (credit card via SIP2)
-                                            [% CASE 'N' %]New card
-                                            [% CASE 'F' %]Fine
-                                            [% CASE 'A' %]Account management fee
-                                            [% CASE 'M' %]Sundry
-                                            [% CASE 'L' %]Lost item
-                                            [% CASE 'W' %]Writeoff
-                                            [% CASE 'FU' %]Accruing fine
-                                            [% CASE 'Rent' %]Rental fee
-                                            [% CASE 'FOR' %]Forgiven
-                                            [% CASE 'LR' %]Lost item fee refund
-                                            [% CASE 'PAY' %]Payment
-                                            [% CASE 'WO' %]Writeoff
-                                            [% CASE 'C' %]Credit
-                                            [% CASE 'CR' %]Credit
-                                            [% CASE %][% ACCOUNT_LINE.accounttype %]
-                                          [%- END -%]
-                                          [%- IF ACCOUNT_LINE.description %], [% ACCOUNT_LINE.description %][% END %]
-                                          [% IF ACCOUNT_LINE.title %]([% ACCOUNT_LINE.title %])[% END %]
-                                        </td>
-                                        [% IF ( ACCOUNT_LINE.amountcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% ACCOUNT_LINE.amount %]</td>
-                                        [% IF ( ACCOUNT_LINE.amountoutstandingcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% ACCOUNT_LINE.amountoutstanding %]</td>
-                                    </tr>
-                                [% END %]
-                            </tbody>
-
-                        </table>
-
-                            [% IF ENABLE_OPAC_PAYMENTS %]
-                                <fieldset class="pay-online hidden">
-                                    <legend>Pay selected fines and charges</legend>
-                                        <span class="help-block"><h3>Payment method</h3></span>
-                                        <div class="control-group">
-                                            <label class="radio">
-                                                <input type="radio" name="payment_method" id="payment_method-paypal" value="paypal" checked="checked">
-                                                <!-- 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 -->
-                                            </label>
-                                        </div>
-                                        <!-- look to the future
-                                        <div class="control-group">
-                                            <label class="radio">
-                                                <input type="radio" name="payment_method" id="payment_method-paypal" value="paypal" checked="checked">
-                                                PayPal
-                                            </label>
-                                        </div>
-                                        -->
-
-                                        <div class="control-group">
-                                            <input type="hidden" id="payment-amount" name="payment_amount" value="0" />
-                                            <button id="submit-pay" type="submit" class="btn" disabled="disabled">Make payment</button>
-                                            <span id="amount-to-pay-label">
-                                                Amount to pay: <span id="amount-to-pay">0.00</span>
-                                            </span>
-                                        </div>
-                                </fieldset>
-                            [% END %]
-                        </form>
-                    [% ELSE %]
-                        <h4>You have no fines or charges</h4>
-                    [% END %]
+                    [% PROCESS 'account-table.inc' ACCOUNT_LINES = ACCOUNT_LINES, ENABLE_OPAC_PAYMENTS = ENABLE_OPAC_PAYMENTS, plugins = plugins %]
+
+
                 </div> <!-- / #useraccount -->
             </div> <!-- / .span10 -->
         </div> <!-- / .row-fluid -->
 
 [% INCLUDE 'opac-bottom.inc' %]
 [% BLOCK jsinclude %]
-<script type="text/javascript">
+[% INCLUDE 'datatables.inc' %]
+<script>
 $( document ).ready(function() {
+
+    $("#finestable").dataTable($.extend(true, {}, dataTablesDefaults, {
+        "columnDefs": [
+             { "type": "title-string", "targets" : [ "title-string" ] }
+         ],
+         "order": [[ 0, "desc" ]]
+    } ));
+
+    $(".paypal").on("click", function() {
+        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;
+    });
+
     $(".pay-online").removeClass("hidden");
 
     $("#amount-to-pay-label").hide();