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

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Katrin Fischer 2023-09-15 17:09:00 +00:00 committed by Tomas Cohen Arazi
parent bcaaffa838
commit e922ac237c
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
3 changed files with 28 additions and 1 deletions

View File

@ -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 ) }

View File

@ -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} ) {

View File

@ -51,7 +51,12 @@
[% IF filters.orderstatus == "" %]
<option value="">Any status except cancelled</option>
[% ELSE %]
<option value="" selected="selected"></option>
<option value="" selected="selected">Any status except cancelled</option>
[% END %]
[% IF filters.orderstatus == "any" %]
<option value="any" selected="selected">Any status</option>
[% ELSE %]
<option value="any">Any status</option>
[% END %]
[% IF filters.orderstatus == "new" %]
<option value="new" selected="selected">New</option>