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