Bug 24223: Convert OpacNav system preference to additional content
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-account.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE AuthorisedValues %]
6 [% USE Price %]
7 [% SET ENABLE_OPAC_PAYMENTS = payment_methods %]
8 [% USE AdditionalContents %]
9 [% SET DISPLAY_PAYMENT_BLOCK = 0 %]
10 [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode, blocktitle => 0 ) %]
11 [% INCLUDE 'doc-head-open.inc' %]
12 <title>Your charges &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
13 [% INCLUDE 'doc-head-close.inc' %]
14 [% BLOCK cssinclude %]
15     [% Asset.css("css/datatables.css") | $raw %]
16 [% END %]
17 </head>
18
19 [% INCLUDE 'bodytag.inc' bodyid='opac-account' bodyclass='scrollto' %]
20 [% INCLUDE 'masthead.inc' %]
21
22 <div class="main">
23     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumbs">
24         <ol class="breadcrumb">
25             <li class="breadcrumb-item">
26                 <a href="/cgi-bin/koha/opac-main.pl">Home</a>
27             </li>
28             <li class="breadcrumb-item">
29                 <a href="/cgi-bin/koha/opac-user.pl">[% INCLUDE 'patron-title.inc' patron = logged_in_user %]</a>
30             </li>
31             <li class="breadcrumb-item active">
32                 <a href="#" aria-current="page">Your charges</a>
33             </li>
34         </ol>
35     </nav> <!-- /#breadcrumbs -->
36
37     <div class="container-fluid">
38         <div class="row">
39             <div class="col col-lg-2 order-2 order-lg-1">
40                 <div id="navigation">
41                     [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
42                 </div>
43             </div>
44             <div class="col-md-12 col-lg-10 order-1">
45                 <div id="useraccount" class="maincontent">
46
47                     <h1>Charges</h1>
48                     [% IF message %]
49                         <div class="alert alert-info">
50                             [% IF message == 'valid_payment' %]
51                                 <p>Your payment of $[% message_value | html %] has been processed successfully!</p>
52                             [% ELSIF message == 'duplicate_payment' %]
53                                 <p>A payment with the transaction id '[% message_value | html %]' has already been posted to an account.</p>
54                                 <p>Please contact a librarian for details.</p>
55                             [% ELSIF message == 'invalid_payment' %]
56                                 <p>The transaction id '[% message_value | html %]' for this payment is invalid.</p>
57                                 <p>Please contact a librarian for details.</p>
58                             [% END %]
59                         </div>
60                     [% END %]
61
62                     [% IF payment_error %]
63                         <div id="error" class="alert alert-warning">
64                             <p><strong>Error:</strong> there was a problem processing your payment</p>
65                         </div>
66                     [% ELSIF payment %]
67                         <div class="alert alert-info">
68                             <p><strong>Payment applied:</strong> your payment of [% payment | html %] has been applied to your account</p>
69                         </div>
70                     [% END %]
71
72                     [% PROCESS 'account-table.inc' ACCOUNT_LINES = ACCOUNT_LINES, ENABLE_OPAC_PAYMENTS = ENABLE_OPAC_PAYMENTS, plugins = plugins %]
73
74                 </div> <!-- / #useraccount -->
75             </div> <!-- / .col-10 -->
76         </div> <!-- / .row -->
77     </div> <!-- / .container-fluid -->
78 </div> <!-- / .main -->
79
80 [% INCLUDE 'opac-bottom.inc' %]
81 [% BLOCK jsinclude %]
82 [% INCLUDE 'datatables.inc' %]
83 <script>
84 $( document ).ready(function() {
85
86     var MSG_MIN_THRESHOLD = _("Minimum amount needed by this service is %s");
87     var txtActivefilter = _("Filter paid transactions");
88     var txtInactivefilter = _("Show all transactions");
89
90     var fines_table = $("#finestable").dataTable($.extend(true, {}, dataTablesDefaults, {
91          [% IF ENABLE_OPAC_PAYMENTS %]
92          "order": [[ 1, "desc" ]],
93          [% ELSE %]
94          "order": [[ 0, "desc" ]],
95          [% END %]
96          "dom": '<"#filter_p">',
97     } ));
98
99     $("#filter_p").html('<p><a href="#" id="filter_paid"><i class="fa fa-filter" aria-hidden="true"></i> '+txtActivefilter+'</a>');
100     $('#filter_paid').click(function(e) {
101         e.preventDefault();
102         if ($(this).hasClass('filtered')) {
103             var filteredValue = '';
104             $(this).html('<i class="fa fa-filter" aria-hidden="true"></i> '+txtActivefilter);
105         } else { //Not filtered. Let's do it!
106             var filteredValue = '^((?!0.00).*)$'; //Filter not matching 0.00 http://stackoverflow.com/a/406408
107             $(this).html('<i class="fa fa-filter" aria-hidden="true"></i> '+txtInactivefilter);
108         }
109         fines_table.fnFilter(filteredValue, -1, true, false);
110         $(this).toggleClass('filtered');
111     });
112
113     //Start filtered
114     $('#filter_paid').click();
115
116     $(".pay-online").removeClass("hidden");
117
118     $("#amount-to-pay-label").hide();
119
120     $(".checkbox-pay, input[name='payment_method']").change( function() {
121         // Disable the pay button if no fees are selected
122         //$("#submit-pay").prop("disabled", ! $(".checkbox-pay:checked").length );
123
124         // Calculate the total amount to be paid based on selected fees
125         var total = 0;
126         $(".checkbox-pay").each( function() {
127             if ( $(this).is(":checked") ) {
128                 var id = this.id.split("checkbox-pay-")[1];
129                 total += parseFloat( $("#amount-" + id).val() );
130             }
131         });
132
133         var p = Promise.resolve();
134         if ( total ) {
135             p = Promise.all(
136                 $('input[name="payment_method"]').map(function() {
137                     var self = this;
138                     return new Promise(function(resolve, reject) {
139                         var threshold = $(self).data('threshold');
140                         var help = $(self).parent().siblings('.help-block');
141                         if(!threshold || threshold == '' || threshold <= total) {
142                             $(self).prop('disabled', false);
143                             help.addClass('hide');
144                         } else {
145                             $(self).prop('disabled', true);
146                             help.html(MSG_MIN_THRESHOLD.format(parseInt(threshold,10).toFixed(2))).removeClass('hide');
147                         }
148                         resolve();
149                     })
150                 }).toArray()
151             );
152
153             $("#amount-to-pay").html( total.toFixed(2) );
154             $("#amount-to-pay-label").show();
155         } else {
156             $('input[name="payment_method"]').prop('disabled', false).parent().siblings('.help-block').addClass('hide');
157             $("#amount-to-pay-label").hide();
158         }
159         p.then(function() {
160             $("#submit-pay").prop("disabled", ! $(".checkbox-pay:checked").length || ! $('input[name="payment_method"]:checked:not(:disabled)').length);
161         })
162     });
163 });
164 </script>
165 [% END %]