From 241eda892e7a420a63ea52346c433c2a2b7372da 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 ordernumber on the order search page. Also search on parent_ordernumber is possible. Like that, you are allow to search children for a given ordernumber. 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. --- C4/Acquisition.pm | 13 +++++++++++++ acqui/histsearch.pl | 6 ++++++ .../intranet-tmpl/prog/en/modules/acqui/histsearch.tt | 10 ++++++++++ 3 files changed, 29 insertions(+) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 33aa8e3..ca2f526 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2190,6 +2190,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; @@ -2317,6 +2319,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 4e152e9..bd1aa4c 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 56451ac..ffe7537 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 %] + +
  • -- 1.7.10.4