From d2ce727e260f6b45266a8147aee7654811a44fa1 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 4 Jan 2018 15:00:28 +0000 Subject: [PATCH] Bug 19915: Use cn_sort values for getting inventory items To test: 1 - Catalog an item under LCC with callnumber GT95 2 - cn_sort should calculate as GT0095 3 - Go to inventory tool 4 - Enter a range that should have your item e.g LC GT90 to GT100 5 - Item is not returned 6 - Apply patch 7 - Item should be returned 8 - Verify things otherwise work as expected Signed-off-by: Anne-Claire Bernaudin Signed-off-by: Marcel de Rooy https://bugs.koha-community.org/show_bug.cgi?id=19905 Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens --- C4/Items.pm | 12 ++++++++---- .../prog/en/modules/tools/inventory.tt | 13 ++++++++++++- tools/inventory.pl | 10 ++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 3e7069be2c..e3b3d11dd5 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -803,6 +803,7 @@ sub GetItemsForInventory { my ( $parameters ) = @_; my $minlocation = $parameters->{'minlocation'} // ''; my $maxlocation = $parameters->{'maxlocation'} // ''; + my $class_source = $parameters->{'class_source'} // C4::Context->preference('DefaultClassificationSource'); my $location = $parameters->{'location'} // ''; my $itemtype = $parameters->{'itemtype'} // ''; my $ignoreissued = $parameters->{'ignoreissued'} // ''; @@ -817,6 +818,9 @@ sub GetItemsForInventory { my $dbh = C4::Context->dbh; my ( @bind_params, @where_strings ); + my $min_cnsort = GetClassSort($class_source,undef,$minlocation); + my $max_cnsort = GetClassSort($class_source,undef,$maxlocation); + my $select_columns = q{ SELECT items.itemnumber, barcode, itemcallnumber, title, author, biblio.biblionumber, biblio.frameworkcode, datelastseen, homebranch, location, notforloan, damaged, itemlost, withdrawn, stocknumber }; @@ -836,13 +840,13 @@ sub GetItemsForInventory { } if ($minlocation) { - push @where_strings, 'itemcallnumber >= ?'; - push @bind_params, $minlocation; + push @where_strings, 'items.cn_sort >= ?'; + push @bind_params, $min_cnsort; } if ($maxlocation) { - push @where_strings, 'itemcallnumber <= ?'; - push @bind_params, $maxlocation; + push @where_strings, 'items.cn_sort <= ?'; + push @bind_params, $max_cnsort; } if ($datelastseen) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt index 946ead1302..0dfe86ab31 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt @@ -82,7 +82,18 @@ (items.itemcallnumber)
  • -
  • +
  • + + +
  • diff --git a/tools/inventory.pl b/tools/inventory.pl index b5c94d6d94..c2a105c521 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -39,10 +39,12 @@ use Koha::Biblios; use Koha::DateUtils; use Koha::AuthorisedValues; use Koha::BiblioFrameworks; +use Koha::ClassSources; use List::MoreUtils qw( none ); my $minlocation=$input->param('minlocation') || ''; my $maxlocation=$input->param('maxlocation'); +my $class_source=$input->param('class_source'); $maxlocation=$minlocation.'Z' unless ( $maxlocation || ! $minlocation ); my $location=$input->param('location') || ''; my $ignoreissued=$input->param('ignoreissued'); @@ -116,6 +118,10 @@ for my $authvfield (@$statuses) { } } +my @class_sources = Koha::ClassSources->search(); +my $pref_class = C4::Context->preference("DefaultClassificationSource"); + + $template->param( authorised_values => \@authorised_value_list, today => dt_from_string, @@ -129,6 +135,8 @@ $template->param( compareinv2barcd => $compareinv2barcd, uploadedbarcodesflag => $uploadbarcodes ? 1 : 0, ignore_waiting_holds => $ignore_waiting_holds, + class_sources => \@class_sources, + pref_class => $pref_class ); # Walk through uploaded barcodes, report errors, mark as seen, check in @@ -225,6 +233,7 @@ if ( $op && ( !$uploadbarcodes || $compareinv2barcd )) { ( $inventorylist ) = GetItemsForInventory({ minlocation => $minlocation, maxlocation => $maxlocation, + class_source => $class_source, location => $location, ignoreissued => $ignoreissued, datelastseen => $datelastseen, @@ -240,6 +249,7 @@ if( @scanned_items ) { ( $rightplacelist ) = GetItemsForInventory({ minlocation => $minlocation, maxlocation => $maxlocation, + class_source => $class_source, location => $location, ignoreissued => undef, datelastseen => undef, -- 2.39.5