Bugzilla – Attachment 72951 Details for
Bug 19915
Inventory tool doesn't use cn_sort for callnumber ranges
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19915 - Use cn_sort values for getting inventory items
Bug-19915---Use-cnsort-values-for-getting-inventor.patch (text/plain), 6.24 KB, created by
Nick Clemens
on 2018-03-15 13:27:43 UTC
(
hide
)
Description:
Bug 19915 - Use cn_sort values for getting inventory items
Filename:
MIME Type:
Creator:
Nick Clemens
Created:
2018-03-15 13:27:43 UTC
Size:
6.24 KB
patch
obsolete
>From ff19e20314d0144f2b2c1d9e9ccfcf535a3cace6 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >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 >--- > C4/Items.pm | 12 ++++++++---- > koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt | 13 ++++++++++++- > t/db_dependent/Items/GetItemsForInventory.t | 2 +- > tools/inventory.pl | 10 ++++++++++ > 4 files changed, 31 insertions(+), 6 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index a3ecd87..12c1b73 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -809,6 +809,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'} // ''; >@@ -822,6 +823,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 > }; >@@ -841,13 +845,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 ed55ceb..f27ea97 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt >@@ -79,7 +79,18 @@ > <input type="text" name="minlocation" id="minlocation" value="[% minlocation %]" /> (items.itemcallnumber) </li> > <li><label for="maxlocation">...and: </label> > <input type="text" name="maxlocation" id="maxlocation" value="[% maxlocation %]" /> >- </li> >+ <li> >+ <label for="class_source">Callnumber classification scheme</label> >+ <select name="class_source"> >+ [% FOREACH class_source IN class_sources %] >+ [% IF class_source.cn_source == pref_class %] >+ <option value="[% class_source.cn_source %]" selected="selected">[% class_source.description %] (default)</option> >+ [% ELSE %] >+ <option value="[% class_source.cn_source %]">[% class_source.description %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> > </ol> > </fieldset> > >diff --git a/t/db_dependent/Items/GetItemsForInventory.t b/t/db_dependent/Items/GetItemsForInventory.t >index 40500ad..a09359a 100755 >--- a/t/db_dependent/Items/GetItemsForInventory.t >+++ b/t/db_dependent/Items/GetItemsForInventory.t >@@ -79,7 +79,7 @@ subtest 'Use cn_sort rather than callnumber to determine correct location' => su > minlocation => 'GT90', > class_source => $class_source->{cn_source}, > }); >- is($item_count,1,"We should return GT95 as betwen GT90 and GT100"); >+ is($item_count,1,"We should return GT95 as between GT90 and GT100"); > $schema->storage->txn_rollback; > > }; >diff --git a/tools/inventory.pl b/tools/inventory.pl >index c671488..6944f71 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'); >@@ -114,6 +116,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, >@@ -126,6 +132,8 @@ $template->param( > datelastseen => $datelastseen, > compareinv2barcd => $compareinv2barcd, > uploadedbarcodesflag => $uploadbarcodes ? 1 : 0, >+ class_sources => \@class_sources, >+ pref_class => $pref_class > ); > > # Walk through uploaded barcodes, report errors, mark as seen, check in >@@ -222,6 +230,7 @@ if ( $op && ( !$uploadbarcodes || $compareinv2barcd )) { > ( $inventorylist ) = GetItemsForInventory({ > minlocation => $minlocation, > maxlocation => $maxlocation, >+ class_source => $class_source, > location => $location, > ignoreissued => $ignoreissued, > datelastseen => $datelastseen, >@@ -236,6 +245,7 @@ if( @scanned_items ) { > ( $rightplacelist ) = GetItemsForInventory({ > minlocation => $minlocation, > maxlocation => $maxlocation, >+ class_source => $class_source, > location => $location, > ignoreissued => undef, > datelastseen => undef, >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19915
:
70274
|
70275
|
70338
|
70339
|
72950
|
72951
|
72988
|
72989
|
76120
|
76721
|
76722
|
76723
|
76724
|
81816
|
81817
|
81818
|
81819
|
81820
|
81821
|
83644
|
83645
|
83646
|
83647
|
83648
|
83649
|
84665
|
84666
|
84667
|
84668
|
84669
|
84670