Bug 11551: Allow to search on parent ordernumber in histsearch.pl
authorJulian Maurice <julian.maurice@biblibre.com>
Fri, 10 Jan 2014 14:50:34 +0000 (15:50 +0100)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 21 Apr 2014 04:23:09 +0000 (04:23 +0000)
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 <juliette.levast@iepg.fr>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works nicely, passes all tests and QA script.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
C4/Acquisition.pm
acqui/histsearch.pl
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt

index ba61da8..170829c 100644 (file)
@@ -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 ='' ) ";
index 4e152e9..bd1aa4c 100755 (executable)
@@ -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,
index 56451ac..ffe7537 100644 (file)
             <label for="basketgroupname">Basket group:</label>
             <input type="text" name="basketgroupname" id="basketgroupname" value="[% basketgroupname %]" />
         </li>
+        <li>
+          <label for="ordernumber">Order no.:</label>
+          <input type="text" name="ordernumber" id="ordernumber" value="[% ordernumber %]" />
+          [% IF search_children_too %]
+            <input type="checkbox" name="search_children_too" id="search_children_too" value="1" checked="checked" />
+          [% ELSE %]
+            <input type="checkbox" name="search_children_too" id="search_children_too" value="1" />
+          [% END %]
+          <label class="yesno" for="search_children_too">Display children too.</label>
+        </li>
 
         <li>
             <label for="orderstatus">Order status: </label>