From 19eff82d785e79724eb478f9f9f578004e874b69 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Fri, 15 Sep 2023 17:09:00 +0000 Subject: [PATCH] Bug 14092: Add 'any status' option to acq order search form Sometimes it's really helpful to see all orders for a basket, a vendor or a standing order, including the cancelled ones. Currently this is not possible, as we have search options for every single status and one for "any except cancelled", but no "Any status" option. This patch adds the "Any status" option. The sometimes appearing empty entry is updated to "Any status except cancelled" as this is what it does. Testing data: * Requires multiple order lines with different order status * Must include at least one order line with status 'cancelled' To test: * Go to acquisitions * Open the advanced search page from the top search options: Order search > config icon > Advanced search link * Verify the status pull down looks as described above * Apply patch * Verify there is now an "Any status" option in the pull down * Try searches for different status, including "Any status" * Verify the results are as expected * Create a new basket * Create an order line by 'From an existing order (copy)' * Verify the search form there also works as expected --- acqui/duplicate_orders.pl | 12 ++++++++++++ acqui/histsearch.pl | 10 ++++++++++ .../intranet-tmpl/prog/en/includes/filter-orders.inc | 7 ++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/acqui/duplicate_orders.pl b/acqui/duplicate_orders.pl index c0b82f5431..d8f38993be 100755 --- a/acqui/duplicate_orders.pl +++ b/acqui/duplicate_orders.pl @@ -82,11 +82,23 @@ $filters->{to_placed_on} = $to_placed_on; my ( @result_order_loop, @selected_order_loop ); my @ordernumbers = split ',', scalar $input->param('ordernumbers') || ''; if ( $op eq 'select' ) { + + # Set filter for 'all status' + if ( $filters->{orderstatus} eq "any" ) { + delete( $filters->{orderstatus} ); + $filters->{get_canceled_order} = 1; + } + @result_order_loop = map { my $order = $_; ( grep {$_ eq $order->{ordernumber}} @ordernumbers ) ? () : $order } @{ C4::Acquisition::GetHistory(%$filters) }; + # Reset order status for 'all status' + if ( $filters->{get_canceled_order} ) { + $filters->{orderstatus} = "any"; + } + @selected_order_loop = scalar @ordernumbers ? @{ C4::Acquisition::GetHistory( ordernumbers => \@ordernumbers ) } diff --git a/acqui/histsearch.pl b/acqui/histsearch.pl index 097fa3b217..289c1c1e59 100755 --- a/acqui/histsearch.pl +++ b/acqui/histsearch.pl @@ -114,6 +114,11 @@ while ( my $additional_field = $additional_fields->next ) { } $filters->{additional_fields} = \@additional_field_filters; +# Set filter for 'all status' +if ( $filters->{orderstatus} eq "any" ) { + delete( $filters->{orderstatus} ); + $filters->{get_canceled_order} = 1; +} my $order_loop; # If we're supplied any value then we do a search. Otherwise we don't. @@ -121,6 +126,11 @@ if ($do_search) { $order_loop = GetHistory(%$filters); } +# Reset order status for 'all status' +if ( $filters->{get_canceled_order} ) { + $filters->{orderstatus} = "any"; +} + my $budgetperiods = C4::Budgets::GetBudgetPeriods; my $bp_loop = $budgetperiods; for my $bp ( @{$budgetperiods} ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc index f23c42fbea..2621455506 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc @@ -51,7 +51,12 @@ [% IF filters.orderstatus == "" %] [% ELSE %] - + + [% END %] + [% IF filters.orderstatus == "any" %] + + [% ELSE %] + [% END %] [% IF filters.orderstatus == "new" %] -- 2.30.2