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