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