Bug 34531: Fix template logic to not hide patron restrictions
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / pay.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE AuthorisedValues %]
5 [% USE Branches %]
6 [% USE Price %]
7 [% USE TablesSettings %]
8 [% USE KohaDates %]
9 [% PROCESS 'i18n.inc' %]
10 [% SET footerjs = 1 %]
11 [% PROCESS 'accounts.inc' %]
12 [% INCLUDE 'doc-head-open.inc' %]
13 <title>[% FILTER collapse %]
14     [% t("Make a payment for") | html %] [% INCLUDE 'patron-title.inc' no_html = 1 %] &rsaquo;
15     [% t("Patrons") | html %] &rsaquo;
16     [% t("Koha") | html %]
17 [% END %]</title>
18 [% INCLUDE 'doc-head-close.inc' %]
19 </head>
20
21 <body id="pat_pay" class="pat">
22 [% WRAPPER 'header.inc' %]
23     [% INCLUDE 'patron-search-header.inc' %]
24 [% END %]
25
26 [% WRAPPER 'sub-header.inc' %]
27     [% WRAPPER breadcrumbs %]
28         [% WRAPPER breadcrumb_item %]
29             <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
30         [% END %]
31         [% WRAPPER breadcrumb_item %]
32             <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">
33                 [% INCLUDE 'patron-title.inc' %]
34             </a>
35         [% END %]
36         [% WRAPPER breadcrumb_item bc_active= 1 %]
37             <span>Make a payment</span>
38         [% END %]
39     [% END #/ WRAPPER breadcrumbs %]
40 [% END #/ WRAPPER sub-header.inc %]
41
42 <div class="main container-fluid">
43     <div class="row">
44         <div class="col-sm-10 col-sm-push-2">
45             <main>
46
47 [% INCLUDE 'members-toolbar.inc' borrowernumber=patron.borrowernumber %]
48
49 <h1>Make a payment</h1>
50
51 <!-- The manual invoice and credit buttons -->
52 <div class="toptabs">
53     <ul class="nav nav-tabs" role="tablist">
54         <li role="presentation" class="transactions">
55             <a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | uri %]" role="tab">Transactions</a>
56         </li>
57         <li role="presentation" class="makepayment active">
58             <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]" role="tab">Make a payment</a>
59         </li>
60         [% IF CAN_user_updatecharges_manual_invoice %]
61             <li role="presentation" class="manualinvoice">
62                 <a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% patron.borrowernumber | uri %]" role="tab">Create manual invoice</a>
63             </li>
64         [% END %]
65         [% IF CAN_user_updatecharges_manual_credit %]
66             <li role="presentation" class="manualcredit">
67                 <a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber | uri %]" role="tab">Create manual credit</a>
68             </li>
69         [% END %]
70     </ul> <!-- /.nav.nav-tabs -->
71     <div class="tab-content">
72         <div role="tabpanel" class="tab-pane active">
73
74 [% INCLUDE 'renew_results.inc' renew_results=renew_results %]
75 [% IF ( accounts ) %]
76     <form action="/cgi-bin/koha/members/pay.pl" method="post" id="pay-fines-form">
77     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
78     [% INCLUDE 'csrf-token.inc' %]
79 <p><span class="checkall"><a id="CheckAll" href="#"><i class="fa fa-check"></i> Select all</a></span> | <span class="clearall"><a id="CheckNone" href="#"><i class="fa fa-times"></i> Clear all</a></span></p>
80 <table id="finest">
81 <thead>
82 <tr>
83     <th class="NoSort">&nbsp;</th>
84     <th class="NoSort noExport">Actions</th>
85     <th>Account type</th>
86     <th>Description</th>
87     <th>Date</th>
88     <th>Barcode</th>
89     <th>Call number</th>
90     <th>Due date</th>
91     <th>Checkin date</th>
92     <th>Checkout date</th>
93     <th class="checked_out_from">Checked out from</th>
94     <th>Home library</th>
95     <th class="NoSort">Payment note</th>
96     <th>Amount</th>
97     <th>Amount outstanding</th>
98 </tr>
99 </thead>
100
101 <tbody>
102 [% FOREACH line IN accounts %]
103 <tr>
104     <td>
105     [% IF ( line.amountoutstanding > 0 ) %]
106         <input class="cb" type="checkbox" checked="checked" name="incl_par_[% line.accountlines_id | html %]" />
107     [% END %]
108     </td>
109     <td class="actions">
110     [% IF ( line.amountoutstanding > 0 ) %]
111         <button type="submit" class="btn btn-default btn-xs" name="pay_indiv_[% line.accountlines_id | html %]" value="Pay">Pay</button>
112         [% IF CAN_user_updatecharges_writeoff %]
113             <button type="submit" class="btn btn-default btn-xs" name="wo_indiv_[% line.accountlines_id | html %]" value="Write off">Write off</button>
114         [% END %]
115     [% END %]
116     <input type="hidden" name="itemnumber[% line.accountlines_id | html %]" value="[% line.itemnumber | html %]" />
117     <input type="hidden" name="description[% line.accountlines_id | html %]" value="[% line.description | html %]" />
118     <input type="hidden" name="debit_type_code[% line.accountlines_id | html %]" value="[% line.debit_type_code | html %]" />
119     <input type="hidden" name="amount[% line.accountlines_id | html %]" value="[% line.amount | html %]" />
120     <input type="hidden" name="accountlines_id[% line.accountlines_id | html %]" value="[% line.accountlines_id | html %]" />
121     <input type="hidden" name="amountoutstanding[% line.accountlines_id | html %]" value="[% line.amountoutstanding | html %]" />
122     <input type="hidden" name="borrowernumber[% line.accountlines_id | html %]" value="[% line.borrowernumber | html %]" />
123     </td>
124     <td>
125         [% PROCESS account_type_description account=line %]
126     </td>
127     <td>
128         [%- IF line.description %][% line.description | html %][% END %]
129         [% IF line.itemnumber %]([% line.item.biblio.title | html %])[% END %]
130     </td>
131     <td data-order="[% line.date | html %]">
132         [% line.date | $KohaDates %]
133     </td>
134     <td>
135         [% IF line.itemnumber %]
136             <a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% line.itemnumber | uri %]&amp;biblionumber=[% line.item.biblionumber | uri %]#item[% line.itemnumber | uri %]">[% line.item.barcode | html %]</a>
137         [% END %]
138     </td>
139     <td>
140         [% IF line.itemnumber %]
141             [% line.item.itemcallnumber | html %]
142         [% END %]
143     </td>
144     <td>
145         [% IF line.issue_id %]
146             [% line.checkout.date_due | $KohaDates as_due_date => 1 %]
147         [% END %]
148     </td>
149     <td>
150         [% IF line.issue_id %]
151             [% line.checkout.returndate | $KohaDates with_hours => 1 %]
152         [% END %]
153     </td>
154     <td>
155         [% IF line.issue_id %]
156             [% line.checkout.issuedate | $KohaDates %]
157         [% END %]
158     </td>
159     <td class="checked_out_from">
160         [% IF line.issue_id && line.checkout.library %]
161             [% line.checkout.library.branchname | html %]
162         [% END %]
163     </td>
164     <td>
165         [% IF line.itemnumber %]
166             [% Branches.GetName( line.item.homebranch ) | html %]
167         [% END %]
168     </td>
169     <td class="actions">
170         <a href="#" class="add-note" data-accountlines_id="[% line.accountlines_id | html %]"><i class="fa fa-plus"></i> Add note</a>
171         <span class="payment_note" id="payment_note_[% line.accountlines_id | html %]" style="display:none"><input type="text" size="10" name="payment_note_[% line.accountlines_id | html %]" value="" /> <a href="#" class="cancel-note"><i class="fa fa-times"></i></a></span>
172     </td>
173     <td class="debit" style="text-align: right;">[% line.amount | $Price %]</td>
174     <td class="debit" style="text-align: right;">[% line.amountoutstanding | $Price %]</td>
175 </tr>
176 [% END %]
177 </tbody>
178
179 <tfoot>
180     <tr>
181         <td class="total" colspan="12">Total due:</td>
182         <td style="text-align: right;">[% total | $Price %]</td>
183     </tr>
184     [% IF outstanding_credits.total_outstanding < 0 %]
185         <tr>
186             <td class="total" colspan="12">Outstanding credits could be applied: </td>
187             <td class="credit" style="text-align: right;"><button type="submit" id="apply_credits" name="apply_credits" value="apply_credits" class="btn btn-default btn-sm">Apply <strong class="credit">[% outstanding_credits.total_outstanding | $Price %]</strong></button></td>
188         </tr>
189         <tr>
190             <td class="total" colspan="12">Total due if credit applied:</td>
191             <td style="text-align: right;">[% total + outstanding_credits.total_outstanding | $Price %]</td>
192         </tr>
193     [% END %]
194 </tfoot>
195
196 </table>
197 <fieldset class="action">
198 <input type="submit" id="paycollect" name="paycollect"  value="Pay amount" class="submit" />
199 <input type="submit" id="payselected" name="payselected"  value="Pay selected" class="submit" />
200 [% IF CAN_user_updatecharges_writeoff %]<input type="submit" name="woall"  id="woall" value="Write off all" class="submit" />
201 <input type="submit" id="writeoff-selected" name="writeoff_selected"  value="Write off selected" class="submit" />[% END %]
202 <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
203 </fieldset>
204 </form>
205 [% ELSE %]
206     <p>[% INCLUDE 'patron-title.inc' %] has no outstanding charges.</p>
207 [% END %]
208         </div> <!-- /.tab-pane -->
209     </div> <!-- /.tab-content -->
210 </div> <!-- /.toptabs -->
211
212             </main>
213         </div> <!-- /.col-sm-10.col-sm-push-2 -->
214
215         <div class="col-sm-2 col-sm-pull-10">
216             <aside>
217                 [% INCLUDE 'circ-menu.inc' %]
218             </aside>
219         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
220      </div> <!-- /.row -->
221
222 [% MACRO jsinclude BLOCK %]
223     [% INCLUDE 'str/members-menu.inc' %]
224     [% Asset.js("js/members-menu.js") | $raw %]
225     [% INCLUDE 'datatables.inc' %]
226     [% INCLUDE 'columns_settings.inc' %]
227     <script>
228         function enableCheckboxActions(){
229             // Enable/disable controls if checkboxes are checked
230             var checkedBoxes = $("input.cb:checked");
231             if ($(checkedBoxes).size()) {
232               $("#payselected, #writeoff-selected").prop("disabled",false);
233             } else {
234               $("#payselected, #writeoff-selected").prop("disabled",true);
235             }
236         }
237         $(document).ready(function(){
238             [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
239                 window.open('/cgi-bin/koha/members/printfeercpt.pl?action=print&accountlines_id=[% payment_id | html %]&change_given=[% change_given | html %]&borrowernumber=[% patron.borrowernumber | html %]', '_blank');
240             [% END %]
241
242             $('#pay-fines-form').preventDoubleFormSubmit();
243             $("#woall").click(function(event){
244                 var msg = _("Are you sure you want to write off %s in outstanding charges? This cannot be undone!").format( "[% total | $Price %]" );
245                 var answer = confirm(msg);
246                     if (!answer){
247                         event.preventDefault();
248                     }
249             });
250             $('#CheckAll').click(function(e){
251                 e.preventDefault();
252                 $(".cb").each(function(){
253                     $(this).prop("checked", true );
254                 });
255                 enableCheckboxActions();
256             });
257             $('#CheckNone').click(function(e){
258                 e.preventDefault();
259                 $(".cb").each(function(){
260                     $(this).prop("checked", false );
261                 });
262                 enableCheckboxActions();
263             });
264             $(".cb").change(function(){
265                 enableCheckboxActions();
266             });
267             enableCheckboxActions();
268             $(".add-note").on("click", function(e){
269                 e.preventDefault();
270                 $(this).hide();
271                 var accountlines_id = $(this).data("accountlines_id");
272                 $("#payment_note_" + accountlines_id ).show().find("input").focus();
273             });
274             $(".cancel-note").on("click", function(e){
275                 e.preventDefault();
276                 $(".payment_note").hide().find("input").val("");
277                 $(".add-note").show();
278             });
279
280             var table_settings = [% TablesSettings.GetTableSettings('members', 'pay', 'pay-fines-table', 'json') | $raw %];
281             KohaTable("finest", {
282                 "paging": false,
283                 "autoWidth": false
284             }, table_settings );
285         });
286     </script>
287 [% END %]
288
289 [% INCLUDE 'intranet-bottom.inc' %]