From e7b19b97bf61088ad03f689a04d9c5c69efd64ac Mon Sep 17 00:00:00 2001 From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Date: Tue, 29 May 2018 16:59:05 -0300 Subject: [PATCH] Bug 20726: Add show/hide already received orders links --- .../prog/en/modules/serials/subscription-detail.tt | 21 +++++++++++++++++++-- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 6 +++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt index 771d363100..6a02066257 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt @@ -334,6 +334,12 @@ <div id="acquisition_details"> <h2>Acquisition details</h2> <table id="orders"> + <caption> + <span class="actions"> + <a href="#" id="hide_received_orders">Hide already received orders</a> + | <a href="#" id="show_all_orders">Show all orders</a></span> + </caption> + <thead> <tr> <th>Invoice</th> @@ -367,7 +373,7 @@ [% END %]</td> <td>[% order.ordernumber %]</td> <td><span title="[% order.basket.creationdate %]">[% order.basket.creationdate | $KohaDates%]</span></td> - <td><span title="[% order.datereceived %]">[% order.datereceived | $KohaDates%]</span></td> + <td>[% IF order.datereceived %]<span title="[% order.datereceived %]">[% order.datereceived | $KohaDates %]</span>[% END %]</td> <td> [% SWITCH order.orderstatus %] [% CASE 'new' %]New @@ -424,7 +430,7 @@ return false; }) - $("#orders").dataTable($.extend(true, {}, dataTablesDefaults, { + var table = $("#orders").dataTable($.extend(true, {}, dataTablesDefaults, { 'bPaginate': false, 'bAutoWidth': false, "aaSorting": [[ 4, "desc" ]], @@ -433,6 +439,17 @@ ] })); + $("#hide_received_orders").click(function(e){ + e.preventDefault(); + table.fnFilter( '.', 4, true ); // Not empty "Receive date" columns + }); + $("#show_all_orders").click(function(e){ + e.preventDefault(); + table.fnFilter( '', 4 ); // Not filter, display all columns + }); + $("#show_all_orders").click(); + + }); </script> [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index 9c3caf1703..f8d23b97b4 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -371,7 +371,11 @@ jQuery.extend( jQuery.fn.dataTableExt.oSort, { */ jQuery.extend( jQuery.fn.dataTableExt.oSort, { "title-string-pre": function ( a ) { - return a.match(/title="(.*?)"/)[1].toLowerCase(); + var m = a.match(/title="(.*?)"/); + if ( null !== m && m.length ) { + return m[1].toLowerCase(); + } + return ""; }, "title-string-asc": function ( a, b ) { -- 2.11.0