From 8a8612c845c112372a22cab32db13a8e43d86ec8 Mon Sep 17 00:00:00 2001 From: Devinim Date: Tue, 1 Oct 2019 09:38:24 +0000 Subject: [PATCH] Bug 22773: Bulk Close invoices and Filter invoice view (open/closed) Signed-off-by: Andrew Fuerste-Henry --- acqui/invoice.pl | 10 +++- acqui/invoices.pl | 11 ++++ .../lib/jquery/plugins/dataTables.fnFilterAll.js | 39 +++++++++++++ .../prog/en/modules/acqui/invoices.tt | 64 ++++++++++++++++++++-- 4 files changed, 116 insertions(+), 8 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/lib/jquery/plugins/dataTables.fnFilterAll.js diff --git a/acqui/invoice.pl b/acqui/invoice.pl index 0e3d8214c5..c8af01dd89 100755 --- a/acqui/invoice.pl +++ b/acqui/invoice.pl @@ -62,7 +62,10 @@ if ( C4::Context->preference('AcqEnableFiles') ) { } if ( $op && $op eq 'close' ) { - CloseInvoice($invoiceid); + my @invoiceid = $input->multi_param('invoiceid'); + foreach my $invoiceid ( @invoiceid ) { + CloseInvoice($invoiceid); + } my $referer = $input->param('referer'); if ($referer) { print $input->redirect($referer); @@ -70,7 +73,10 @@ if ( $op && $op eq 'close' ) { } } elsif ( $op && $op eq 'reopen' ) { - ReopenInvoice($invoiceid); + my @invoiceid = $input->multi_param('invoiceid'); + foreach my $invoiceid ( @invoiceid ) { + ReopenInvoice($invoiceid); + } my $referer = $input->param('referer'); if ($referer) { print $input->redirect($referer); diff --git a/acqui/invoices.pl b/acqui/invoices.pl index 8ab7a3256d..ec65579c88 100755 --- a/acqui/invoices.pl +++ b/acqui/invoices.pl @@ -112,9 +112,20 @@ foreach my $budget (@$budgets) { push @budgets_loop, $budget if CanUserUseBudget( $loggedinuser, $budget, $flags ); } +my (@openedinvoices, @closedinvoices); +for my $sub ( @{$invoices} ) { + unless ( $sub->{closedate} ) { + push @openedinvoices, $sub + } else { + push @closedinvoices, $sub + } +} + $template->{'VARS'}->{'budgets_loop'} = \@budgets_loop; $template->param( + openedinvoices => \@openedinvoices, + closedinvoices => \@closedinvoices, do_search => ( $op and $op eq 'do_search' ) ? 1 : 0, invoices => $invoices, invoicenumber => $invoicenumber, diff --git a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/dataTables.fnFilterAll.js b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/dataTables.fnFilterAll.js new file mode 100644 index 0000000000..91c9d2093e --- /dev/null +++ b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/dataTables.fnFilterAll.js @@ -0,0 +1,39 @@ +/** + * Apply the same filter to all DataTable instances on a particular page. The + * function call exactly matches that used by `fnFilter()` so regular expression + * and individual column sorting can be used. + * + * DataTables 1.10+ provides this ability through its new API, which is able to + * to control multiple tables at a time. + * `$('.dataTable').DataTable().search( ... )` for example will apply the same + * filter to all tables on the page. The new API should be used in preference + * to this older method if at all possible. + * + * @name fnFilterAll + * @summary Apply a common filter to all DataTables on a page + * @author [Kristoffer Karlström](http://www.kmmtiming.se/) + * @deprecated + * + * @param {string} sInput Filtering input + * @param {integer} [iColumn=null] Column to apply the filter to + * @param {boolean} [bRegex] Regular expression flag + * @param {boolean} [bSmart] Smart filtering flag + * + * @example + * $(document).ready(function() { + * var table = $(".dataTable").dataTable(); + * + * $("#search").keyup( function () { + * // Filter on the column (the index) of this element + * table.fnFilterAll(this.value); + * } ); + * }); + */ + +jQuery.fn.dataTableExt.oApi.fnFilterAll = function(oSettings, sInput, iColumn, bRegex, bSmart) { + var settings = $.fn.dataTableSettings; + + for ( var i=0 ; i Show only subscriptions - + [% BLOCK invoices_table %] + [% IF closed %] + [% SET tab = 'closed' %] + [% ELSE %] + [% SET tab = 'opened' %] + [% END %] +
@@ -95,7 +101,40 @@ [% END %]
 
- Merge selected invoices + Merge selected invoices + [% IF tab == 'closed' %] + Reopen Selected Invoices + [% ELSE %] + Close Selected Invoices + [% END %] + + [% END %] +
+ +
+ [% IF openedinvoices %] + [% INCLUDE invoices_table invoices = openedinvoices %] + [% ELSE %] +
+

Your search returned no open invoices.

+
+ [% END %] +
+
+ [% IF closedinvoices %] + [% INCLUDE invoices_table invoices = closedinvoices closed = 1 %] + [% ELSE %] +
+

Your search returned no closed invoices.

+
+ [% END %] +
+
+ +
@@ -300,13 +339,15 @@ [% MACRO jsinclude BLOCK %] [% Asset.js("js/acquisitions-menu.js") | $raw %] [% INCLUDE 'datatables.inc' %] + [% Asset.js("lib/jquery/plugins/dataTables.fnFilterAll.js") | $raw %] [% INCLUDE 'calendar.inc' %]