@@ -, +, @@ search - Create some baskets with orders - Set managing library for some, but also have some without - Apply patch - prove t/db_dependent/Acquisition.t - Go to Aquisition > Orders search tab on top > Advanced search link - Search for orders without limiting Orders with and without managing library set should show up - Limit search to a specific managing library - Verify results match expectations --- C4/Acquisition.pm | 11 +++++- acqui/histsearch.pl | 6 ++-- .../prog/en/includes/filter-orders.inc | 8 +++++ .../prog/en/modules/acqui/histsearch.tt | 5 ++- t/db_dependent/Acquisition.t | 40 +++++++++++++++++++++- 5 files changed, 65 insertions(+), 5 deletions(-) --- a/C4/Acquisition.pm +++ a/C4/Acquisition.pm @@ -2276,6 +2276,7 @@ params: budget orderstatus (note that orderstatus '' will retrieve orders of any status except cancelled) + managing_library biblionumber get_canceled_order (if set to a true value, cancelled orders will be included) @@ -2296,7 +2297,8 @@ returns: 'ordernumber' => '1', 'quantity' => 1, 'quantityreceived' => undef, - 'title' => 'The Adventures of Huckleberry Finn' + 'title' => 'The Adventures of Huckleberry Finn', + 'managing_library' => 'CPL' } =cut @@ -2322,6 +2324,7 @@ sub GetHistory { my $ordernumber = $params{ordernumber}; my $search_children_too = $params{search_children_too} || 0; my $created_by = $params{created_by} || []; + my $managing_library = $params{managing_library}; my $ordernumbers = $params{ordernumbers} || []; my $additional_fields = $params{additional_fields} // []; @@ -2358,6 +2361,7 @@ sub GetHistory { aqbasket.basketgroupid, aqbasket.authorisedby, concat( borrowers.firstname,' ',borrowers.surname) AS authorisedbyname, + branch as managing_library, aqbasketgroups.name as groupname, aqbooksellers.name, aqbasket.creationdate, @@ -2484,6 +2488,11 @@ sub GetHistory { push @query_params, @$created_by; } + if ( $managing_library ) { + $query .= " AND aqbasket.branch = ? "; + push @query_params, $managing_library; + } + if ( @$ordernumbers ) { $query .= ' AND (aqorders.ordernumber IN ( ' . join (',', ('?') x @$ordernumbers ) . '))'; push @query_params, @$ordernumbers; --- a/acqui/histsearch.pl +++ a/acqui/histsearch.pl @@ -89,15 +89,17 @@ my $filters = { ordernumber => scalar $input->param('ordernumber'), search_children_too => scalar $input->param('search_children_too'), created_by => [ $input->multi_param('created_by') ], + managing_library => scalar $input->param('managing_library'), }; + my $from_placed_on = eval { dt_from_string( scalar $input->param('from') ) } || dt_from_string; my $to_placed_on = eval { dt_from_string( scalar $input->param('to') ) } || dt_from_string; unless ( $input->param('from') ) { # Fill the form with year-1 $from_placed_on->set_time_zone('floating')->subtract( years => 1 ); } -$filters->{from_placed_on} = output_pref( { dt => $from_placed_on, dateformat => 'iso', dateonly => 1 } ), -$filters->{to_placed_on} = output_pref( { dt => $to_placed_on, dateformat => 'iso', dateonly => 1 } ), +$filters->{from_placed_on} = output_pref( { dt => $from_placed_on, dateformat => 'iso', dateonly => 1 } ); +$filters->{to_placed_on} = output_pref( { dt => $to_placed_on, dateformat => 'iso', dateonly => 1 } ); my @additional_fields = Koha::AdditionalFields->search( { tablename => 'aqbasket', searchable => 1 } ); $template->param( available_additional_fields => \@additional_fields ); my @additional_field_filters; --- a/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc @@ -1,4 +1,5 @@ [% USE Koha %] +[% USE Branches %] [% USE KohaDates %]