From 65748d05b54ff16c49bc9700714bc8ee1f75fad2 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 10 Jan 2014 15:50:34 +0100 Subject: [PATCH] Bug 11551: Allow to search on parent ordernumber in histsearch.pl It is now possible to search on the order number on the order search page. Also searching on parent_ordernumber is possible, allowing one to search to search children for a given order number. Test plan: 1/ create a basket and 1 order with at least 2 items. 2/ receive partialy the order (receive only 1 item). 3/ note that a new ordernumber is created for item not received. 4/ go on the order search form and search for the original ordernumber without checking the new checkbox "Display children too." => only 1 order (the parent) is displayed. 5/ now check the checkbox and search again => the parent order is displayed but children too. Signed-off-by: remy juliette Signed-off-by: Katrin Fischer Works nicely, passes all tests and QA script. Signed-off-by: Galen Charlton --- C4/Acquisition.pm | 13 +++++++++++++ acqui/histsearch.pl | 6 ++++++ .../prog/en/modules/acqui/histsearch.tt | 10 ++++++++++ 3 files changed, 29 insertions(+) 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 %] + +
  • -- 2.39.5