From ff74dfe2e263475a4582ec12f4629c8766b03443 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 17 Sep 2014 17:13:00 +0200 Subject: [PATCH] Bug 12944: Search orders by basket creator This patch adds the ability to search orders using the basket creator. Test plan: - go on the order advanced search form (acqui/histsearch.pl) - use the autocomplete input to search patrons - launch the search and verify the results are consistent with the values you have filled. Signed-off-by: Paola Rossi Signed-off-by: Kyle M Hall --- C4/Acquisition.pm | 13 +++++++++---- acqui/histsearch.pl | 2 ++ .../prog/en/modules/acqui/histsearch.tt | 21 ++++++++++++++++++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index f9e8c49..a826b78 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2252,6 +2252,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; @@ -2268,6 +2269,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, @@ -2296,12 +2299,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')) { @@ -2389,6 +2389,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 b474ac1..d3efbf7 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 3bb7fcb..75bc842 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 %]
  • +
  • + +
    +
    +
    +
  • @@ -135,6 +152,7 @@ Order line (parent) Status Basket + Basket creator Basket group Invoice number Summary @@ -164,6 +182,7 @@ [% END %] [% order.basketname %] ([% order.basketno %]) + [% order.authorisedbyname %] [% IF ( order.basketgroupid ) %] [% order.groupname %] ([% order.basketgroupid %]) -- 2.1.0