Bug 19489: Detailed Description of charges in Patron accounting
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / pay.tt
index 9b50924..354bab0 100644 (file)
+[% USE raw %]
+[% USE Asset %]
+[% USE Koha %]
+[% USE AuthorisedValues %]
+[% USE Branches %]
+[% USE Price %]
+[% USE ColumnsSettings %]
+[% USE KohaDates %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Patrons &rsaquo; Pay Fines for  [% borrower.firstname %] [% borrower.surname %]</title>
+<title>Koha &rsaquo; Patrons &rsaquo; Make a payment for  [% patron.firstname | html %] [% patron.surname | html %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
-<script type= "text/javascript">
-//<![CDATA[
-    $(document).ready(function(){
- $('#pay-fines-form').preventDoubleFormSubmit();
-        $("#woall").click(function(event){
-            var answer = confirm(_("Are you sure you want to write off [% total | format('%.2f') %] in outstanding fines? This cannot be undone!"));
-                if (!answer){
-                    event.preventDefault();
-                }
-        });
-        $('#CheckAll').click(function(){ $("#finest").checkCheckboxes(); return false;});
-        $('#CheckNone').click(function(){ $("#finest").unCheckCheckboxes(); return false;});
-    });
-//]]>
-</script>
 </head>
+
 <body id="pat_pay" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
 
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Pay fines for [% borrower.firstname %] [% borrower.surname %]</div>
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Make a payment for [% patron.firstname | html %] [% patron.surname | html %]</div>
+
+<div class="main container-fluid">
+    <div class="row">
+        <div class="col-sm-10 col-sm-push-2">
+            <main>
 
-<div id="doc3" class="yui-t2">
-   
-   <div id="bd">
-       <div id="yui-main">
-       <div class="yui-b">
-[% INCLUDE 'members-toolbar.inc' borrowernumber=borrower.borrowernumber %]
+[% INCLUDE 'members-toolbar.inc' borrowernumber=patron.borrowernumber %]
 
 <!-- The manual invoice and credit buttons -->
 <div class="statictabs">
 <ul>
-       <li><a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrower.borrowernumber %]">Account</a></li>
-    <li class="active"><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrower.borrowernumber %]" >Pay fines</a></li>
-       <li><a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual invoice</a></li>
-       <li><a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual credit</a></li>
+    <li><a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | uri %]">Transactions</a></li>
+    <li class="active"><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Make a payment</a></li>
+    <li><a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual invoice</a></li>
+    <li><a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual credit</a></li>
 </ul>
 <div class="tabs-container">
 
 [% IF ( accounts ) %]
     <form action="/cgi-bin/koha/members/pay.pl" method="post" id="pay-fines-form">
-       <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
-<p><span class="checkall"><a id="CheckAll" href="#">Select all</a></span> | <span class="clearall"><a id="CheckNone" href="#">Clear all</a></span></p>
+    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
+<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>
 <table id="finest">
 <thead>
 <tr>
-    <th>&nbsp;</th>
-    <th>Fines &amp; charges</th>
+    <th class="NoSort">&nbsp;</th>
+    <th class="NoSort">Actions</th>
     <th>Description</th>
-    <th>Payment note</th>
+    <th class="title-string">Date</th>
+    <th>Barcode</th>
+    <th>Due date</th>
+    <th>Return date</th>
+    <th class="NoSort">Payment note</th>
     <th>Account type</th>
-    <th>Notify id</th>
-    <th>Level</th>
     <th>Amount</th>
     <th>Amount outstanding</th>
 </tr>
 </thead>
-<tfoot>
-<tr>
-    <td class="total" colspan="8">Total Due:</td>
-    <td>[% total | format('%.2f') %]</td>
-</tr>
-</tfoot>
+
 <tbody>
-[% FOREACH account_grp IN accounts %]
-    [% FOREACH line IN account_grp.accountlines %]
+[% FOREACH line IN accounts %]
 <tr>
     <td>
     [% IF ( line.amountoutstanding > 0 ) %]
-        <input type="checkbox" checked="checked" name="incl_par_[% line.accountno %]" />
+        <input class="cb" type="checkbox" checked="checked" name="incl_par_[% line.accountlines_id | html %]" />
     [% END %]
     </td>
-    <td>
+    <td class="actions">
     [% IF ( line.amountoutstanding > 0 ) %]
-        <input type="submit" name="pay_indiv_[% line.accountno %]" value="Pay" />
-        <input type="submit" name="wo_indiv_[% line.accountno %]" value="Write off" />
+        <button type="submit" class="btn btn-default btn-xs" name="pay_indiv_[% line.accountlines_id | html %]" value="Pay">Pay</button>
+        [% IF CAN_user_updatecharges_writeoff %]
+            <button type="submit" class="btn btn-default btn-xs" name="wo_indiv_[% line.accountlines_id | html %]" value="Write off">Write off</button>
+        [% END %]
     [% END %]
-    <input type="hidden" name="itemnumber[% line.accountno %]" value="[% line.itemnumber %]" />
-    <input type="hidden" name="description[% line.accountno %]" value="[% line.description %]" />
-    <input type="hidden" name="accounttype[% line.accountno %]" value="[% line.accounttype %]" />
-    <input type="hidden" name="amount[% line.accountno %]" value="[% line.amount %]" />
-    <input type="hidden" name="accountlines_id[% line.accountno %]" value="[% line.accountlines_id %]" />
-    <input type="hidden" name="amountoutstanding[% line.accountno %]" value="[% line.amountoutstanding %]" />
-    <input type="hidden" name="borrowernumber[% line.accountno %]" value="[% line.borrowernumber %]" />
-    <input type="hidden" name="accountno[% line.accountno %]" value="[% line.accountno %]" />
-    <input type="hidden" name="notify_id[% line.accountno %]" value="[% line.notify_id %]" />
-    <input type="hidden" name="notify_level[% line.accountno %]" value="[% line.notify_level %]" />
-    <input type="hidden" name="totals[% line.accountno %]" value="[% line.totals %]" />
+    <input type="hidden" name="itemnumber[% line.accountlines_id | html %]" value="[% line.itemnumber | html %]" />
+    <input type="hidden" name="description[% line.accountlines_id | html %]" value="[% line.description | html %]" />
+    <input type="hidden" name="issue_id[% line.accountlines_id | html %]" value="[% line.issue_id | html %]" />
+    <input type="hidden" name="accounttype[% line.accountlines_id | html %]" value="[% line.accounttype | html %]" />
+    <input type="hidden" name="amount[% line.accountlines_id | html %]" value="[% line.amount | html %]" />
+    <input type="hidden" name="accountlines_id[% line.accountlines_id | html %]" value="[% line.accountlines_id | html %]" />
+    <input type="hidden" name="amountoutstanding[% line.accountlines_id | html %]" value="[% line.amountoutstanding | html %]" />
+    <input type="hidden" name="borrowernumber[% line.accountlines_id | html %]" value="[% line.borrowernumber | html %]" />
     </td>
-    <td>[% line.description %] ([% line.title |html_entity %])</td>
-    <td><input type="text" name="payment_note_[% line.accountno %]" /></td>
-    <td>[% line.accounttype %]</td>
-    <td>[% line.notify_id %]</td>
-    <td>[% line.notify_level %]</td>
-    <td class="debit">[% line.amount | format('%.2f') %]</td>
-    <td class="debit">[% line.amountoutstanding | format('%.2f') %]</td>
-</tr>
-[% END %]
-[% IF ( account_grp.total ) %]
-<tr>
-
-    <td class="total" colspan="8">Sub total:</td>
-    <td>[% account_grp.total | format('%.2f') %]</td>
+    <td>
+        [% SWITCH line.accounttype %]
+          [% CASE 'Pay' %]Payment, thanks
+          [% CASE 'Pay00' %]Payment, thanks (cash via SIP2)
+          [% CASE 'Pay01' %]Payment, thanks (VISA via SIP2)
+          [% CASE 'Pay02' %]Payment, thanks (credit card via SIP2)
+          [% CASE 'N' %]New card
+          [% CASE 'F' %]Fine
+          [% CASE 'A' %]Account management fee
+          [% CASE 'M' %]Sundry
+          [% CASE 'L' %]Lost item
+          [% CASE 'W' %]Writeoff
+          [% CASE 'FU' %]Accruing fine
+          [% CASE 'HE' %]Hold waiting too long
+          [% CASE 'Rent' %]Rental fee
+          [% CASE 'FOR' %]Forgiven
+          [% CASE 'LR' %]Lost item fee refund
+          [% CASE 'PF' %]Processing fee
+          [% CASE 'PAY' %]Payment
+          [% CASE 'WO' %]Writeoff
+          [% CASE 'C' %]Credit
+          [% CASE 'CR' %]Credit
+          [% CASE %][% line.accounttype | html %]
+        [%- END -%]
+        [%- IF line.description %], [% line.description | html %][% END %]
+        [% IF line.itemnumber %]([% line.item.biblio.title | html %])[% END %]
+    </td>
+    <td>
+        <span title="[% line.date | html %]">[% line.date | $KohaDates %]</span>
+    </td>
+    <td>
+        [% IF line.itemnumber %]
+            <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>
+        [% END %]
+    </td>
+    <td>
+        [% IF line.issue_id %]
+            [% line.issue.date_due | $KohaDates as_due_date => 1 %]
+        [% END %]
+    </td>
+    <td>
+        [% IF line.issue_id %]
+            [% line.issue.returndate | $KohaDates with_hours => 1 %]
+        [% END %]
+    </td>
+    <td class="actions">
+        <a href="#" class="add-note" data-accountlines_id="[% line.accountlines_id | html %]"><i class="fa fa-plus"></i> Add note</a>
+        <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>
+    </td>
+    <td>[% line.accounttype | html %]</td>
+    <td class="debit" style="text-align: right;">[% line.amount | $Price %]</td>
+    <td class="debit" style="text-align: right;">[% line.amountoutstanding | $Price %]</td>
 </tr>
 [% END %]
-[% END %]
 </tbody>
+
+<tfoot>
+    [% IF outstanding_credits.total_outstanding < 0 %]
+        <tr>
+            <td class="total" colspan="10">Outstanding credits could be applied: </td>
+            <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>
+        </tr>
+    [% END %]
+    [% IF ( account_grp.total ) %]
+        <tr>
+            <td class="total" colspan="10" style="text-align: right;">Sub total:</td>
+            <td style="text-align: right;">[% account_grp.total | $Price %]</td>
+        </tr>
+    [% END %]
+    <tr>
+        <td class="total" colspan="10">Total due:</td>
+        [% IF outstanding_credits.total_outstanding < 0 %]
+            <td style="text-align: right;">[% total + outstanding_credits.total_outstanding | $Price %]</td>
+        [% ELSE %]
+            <td style="text-align: right;">[% total | $Price %]</td>
+        [% END %]
+    </tr>
+</tfoot>
+
 </table>
 <fieldset class="action">
-<input type="submit" name="paycollect"  value="Pay amount" class="submit" />
-<input type="submit" name="woall"  id="woall" value="Write off all" class="submit" />
-<input type="submit" name="payselected"  value="Pay selected" class="submit" />
-<a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a>
+<input type="submit" id="paycollect" name="paycollect"  value="Pay amount" class="submit" />
+[% IF CAN_user_updatecharges_writeoff %]<input type="submit" name="woall"  id="woall" value="Write off all" class="submit" />[% END %]
+<input type="submit" id="payselected" name="payselected"  value="Pay selected" class="submit" />
+<input type="submit" id="writeoff-selected" name="writeoff_selected"  value="Write off selected" class="submit" />
+<a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
 </fieldset>
 </form>
 [% ELSE %]
-    <p>[% borrower.firstname %] [% borrower.surname %] has no outstanding fines.</p>
+    <p>[% patron.firstname | html %] [% patron.surname | html %] has no outstanding fines.</p>
 [% END %]
 </div></div>
 
-</div>
-</div>
+            </main>
+        </div> <!-- /.col-sm-10.col-sm-push-2 -->
+
+        <div class="col-sm-2 col-sm-pull-10">
+            <aside>
+                [% INCLUDE 'circ-menu.inc' %]
+            </aside>
+        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
+     </div> <!-- /.row -->
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'str/members-menu.inc' %]
+    [% Asset.js("js/members-menu.js") | $raw %]
+    [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
+    [% INCLUDE 'datatables.inc' %]
+    [% INCLUDE 'columns_settings.inc' %]
+    <script>
+        function enableCheckboxActions(){
+            // Enable/disable controls if checkboxes are checked
+            var checkedBoxes = $("input.cb:checked");
+            if ($(checkedBoxes).size()) {
+              $("#payselected, #writeoff-selected").prop("disabled",false);
+            } else {
+              $("#payselected, #writeoff-selected").prop("disabled",true);
+            }
+        }
+        $(document).ready(function(){
+        $('#pay-fines-form').preventDoubleFormSubmit();
+            $("#woall").click(function(event){
+                var msg = _("Are you sure you want to write off %s in outstanding fines? This cannot be undone!").format( "[% total | $Price %]" );
+                var answer = confirm(msg);
+                    if (!answer){
+                        event.preventDefault();
+                    }
+            });
+            $('#CheckAll').click(function(e){
+                e.preventDefault();
+                $("#finest").checkCheckboxes();
+                enableCheckboxActions();
+                return false;
+            });
+            $('#CheckNone').click(function(e){
+                e.preventDefault();
+                $("#finest").unCheckCheckboxes();
+                enableCheckboxActions();
+                return false;
+            });
+            $(".cb").change(function(){
+                enableCheckboxActions();
+            });
+            enableCheckboxActions();
+            $(".add-note").on("click", function(e){
+                e.preventDefault();
+                $(this).hide();
+                var accountlines_id = $(this).data("accountlines_id");
+                $("#payment_note_" + accountlines_id ).show().find("input").focus();
+            });
+            $(".cancel-note").on("click", function(e){
+                e.preventDefault();
+                $(".payment_note").hide().find("input").val("");
+                $(".add-note").show();
+            });
+
+            var columns_settings = [% ColumnsSettings.GetColumns('members', 'pay', 'pay-fines-table', 'json') | $raw %];
+            KohaTable("finest", {
+                "columnDefs": [
+                    { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
+                    { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
+                    { "sType": "title-string", "aTargets" : [ "title-string" ] }
+                ],
+                "paging": false,
+                'sorting': [[ 3, "asc" ]],
+                "autoWidth": false
+            }, columns_settings );
+        });
+    </script>
+[% END %]
 
-<div class="yui-b">
-[% INCLUDE 'circ-menu.tt' %]
-</div>
-</div>
 [% INCLUDE 'intranet-bottom.inc' %]