diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index ba61da8e3c..170829cb43 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2262,6 +2262,8 @@ sub GetHistory { my $orderstatus = $params{orderstatus}; my $biblionumber = $params{biblionumber}; my $get_canceled_order = $params{get_canceled_order} || 0; + my $ordernumber = $params{ordernumber}; + my $search_children_too = $params{search_children_too} || 0; my @order_loop; my $total_qty = 0; @@ -2389,6 +2391,17 @@ sub GetHistory { push @query_params, "%$basketgroupname%"; } + if ($ordernumber) { + $query .= " AND (aqorders.ordernumber = ? "; + push @query_params, $ordernumber; + if ($search_children_too) { + $query .= " OR aqorders.parent_ordernumber = ? "; + push @query_params, $ordernumber; + } + $query .= ") "; + } + + if ( C4::Context->preference("IndependentBranches") ) { unless ( C4::Context->IsSuperLibrarian() ) { $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) "; diff --git a/acqui/histsearch.pl b/acqui/histsearch.pl index 4e152e924a..bd1aa4cf8a 100755 --- a/acqui/histsearch.pl +++ b/acqui/histsearch.pl @@ -74,6 +74,8 @@ my $from_placed_on = C4::Dates->new($input->param('from')); my $to_placed_on = C4::Dates->new($input->param('to')); my $budget = $input->param( 'budget' ); my $orderstatus = $input->param( 'orderstatus' ); +my $ordernumber = $input->param( 'ordernumber' ); +my $search_children_too = $input->param( 'search_children_too' ); if ( not $input->param('from') ) { # FIXME Dirty but we can't sent a Date::Calc to C4::Dates ? @@ -117,6 +119,8 @@ if ($do_search) { basketgroupname => $basketgroupname, budget => $budget, orderstatus => $orderstatus, + ordernumber => $ordernumber, + search_children_too => $search_children_too, ); } @@ -147,6 +151,8 @@ $template->param( basket => $basket, booksellerinvoicenumber => $booksellerinvoicenumber, basketgroupname => $basketgroupname, + ordernumber => $ordernumber, + search_children_too => $search_children_too, from_placed_on => $from_date, to_placed_on => $to_date, orderstatus => $orderstatus, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt index 56451ac443..ffe7537320 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt @@ -47,6 +47,16 @@ +
  • + + + [% IF search_children_too %] + + [% ELSE %] + + [% END %] + +