diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index d59ae56fc8..cb7ae132c9 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2179,6 +2179,7 @@ sub GetHistory { my $get_canceled_order = $params{get_canceled_order} || 0; my $ordernumber = $params{ordernumber}; my $search_children_too = $params{search_children_too} || 0; + my $created_by = $params{created_by} || []; my @order_loop; my $total_qty = 0; @@ -2195,6 +2196,8 @@ sub GetHistory { aqorders.basketno, aqbasket.basketname, aqbasket.basketgroupid, + aqbasket.authorisedby, + concat( borrowers.firstname,' ',borrowers.surname) AS authorisedbyname, aqbasketgroups.name as groupname, aqbooksellers.name, aqbasket.creationdate, @@ -2223,12 +2226,9 @@ sub GetHistory { LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid LEFT JOIN deletedbiblio ON deletedbiblio.biblionumber=aqorders.biblionumber LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber=aqorders.biblionumber + LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber "; - if ( C4::Context->preference("IndependentBranches") ) { - $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"; - } - $query .= " WHERE 1 "; unless ($get_canceled_order or (defined $orderstatus and $orderstatus eq 'cancelled')) { @@ -2316,6 +2316,11 @@ sub GetHistory { $query .= ") "; } + if ( @$created_by ) { + $query .= ' AND aqbasket.authorisedby IN ( ' . join( ',', ('?') x @$created_by ) . ')'; + push @query_params, @$created_by; + } + if ( C4::Context->preference("IndependentBranches") ) { unless ( C4::Context->IsSuperLibrarian() ) { diff --git a/acqui/histsearch.pl b/acqui/histsearch.pl index 5bc54040d3..06f3e26656 100755 --- a/acqui/histsearch.pl +++ b/acqui/histsearch.pl @@ -76,6 +76,7 @@ my $budget = $input->param( 'budget' ); my $orderstatus = $input->param( 'orderstatus' ); my $ordernumber = $input->param( 'ordernumber' ); my $search_children_too = $input->param( 'search_children_too' ); +my @created_by = $input->param('created_by'); if ( not $input->param('from') ) { # FIXME Dirty but we can't sent a Date::Calc to C4::Dates ? @@ -121,6 +122,7 @@ if ($do_search) { orderstatus => $orderstatus, ordernumber => $ordernumber, search_children_too => $search_children_too, + created_by => \@created_by, ); } 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 3bb7fcb706..75bc84288a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt @@ -5,6 +5,8 @@ [% INCLUDE 'doc-head-close.inc' %] [% INCLUDE 'calendar.inc' %] [% INCLUDE 'datatables.inc' %] + + @@ -43,6 +54,12 @@ [% END %]