Bugzilla – Attachment 81821 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: Make behaviour syspref controlled
Bug-19915-Make-behaviour-syspref-controlled.patch (text/plain), 12.33 KB, created by
Nick Clemens (kidclamp)
on 2018-11-01 14:46:47 UTC
(
hide
)
Description:
Bug 19915: Make behaviour syspref controlled
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-11-01 14:46:47 UTC
Size:
12.33 KB
patch
obsolete
>From 34e0e97c8eb6aedf483486bed40c7877cd9b8e84 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 1 Nov 2018 14:38:53 +0000 >Subject: [PATCH] Bug 19915: Make behaviour syspref controlled > >To test: >0 - Apply patch, run updatedatabase >1 - Catalog an item under LCC classification source with callnumber GT95 >2 - Check db, cn_sort should calculate as GT0095 > SELECT cn_sort FROM items where callnumber="GT95"; >3 - Catalog an item under LCC classification source with callnumber >GT101 >4 - Check db, cn_sort should calculate as GT0101 > SELECT cn_sort FROM items where callnumber="GT101"; >5 - Go to inventory tool >6 - Enter a range from GT90 to GT100 >7 - Neither item is not returned >8 - Enter range from GT100 to GT90 >9 - Second item is returned >10 - Set UseCNSortForInventory to 'Use' >11 - Go to invenotry tool >12 - Enter a range from GT90 to GT100 >13 - The first item is returned, the second is not >14 - Enter a range from GT100 to GT90 >15 - Neither item is returned >16 - prove -v t/db_dependent/Items/GetItemsForInventory.t >--- > C4/Items.pm | 30 +++++++++++++----- > .../bug19915_add_UseCNSortForInventory_pref.perl | 9 ++++++ > installer/data/mysql/sysprefs.sql | 1 + > .../en/modules/admin/preferences/staff_client.pref | 6 ++++ > .../prog/en/modules/tools/inventory.tt | 25 ++++++++------- > t/db_dependent/Items/GetItemsForInventory.t | 37 ++++++++++++++++++++-- > tools/inventory.pl | 13 +++++--- > 7 files changed, 94 insertions(+), 27 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug19915_add_UseCNSortForInventory_pref.perl > >diff --git a/C4/Items.pm b/C4/Items.pm >index a242f78c2a..5920d8708f 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -805,7 +805,7 @@ sub GetItemsForInventory { > my ( $parameters ) = @_; > my $minlocation = $parameters->{'minlocation'} // ''; > my $maxlocation = $parameters->{'maxlocation'} // ''; >- my $class_source = $parameters->{'class_source'} // C4::Context->preference('DefaultClassificationSource'); >+ my $class_source = $parameters->{'class_source'} // C4::Context->preference('DefaultClassificationSource'); > my $location = $parameters->{'location'} // ''; > my $itemtype = $parameters->{'itemtype'} // ''; > my $ignoreissued = $parameters->{'ignoreissued'} // ''; >@@ -840,14 +840,28 @@ sub GetItemsForInventory { > } > } > >- if ($minlocation) { >- push @where_strings, 'items.cn_sort >= ?'; >- push @bind_params, $min_cnsort; >- } >+ if( C4::Context->preference('UseCNSortForInventory') ){ >+ my $min_cnsort = GetClassSort($class_source,undef,$minlocation); >+ my $max_cnsort = GetClassSort($class_source,undef,$maxlocation); >+ if ($minlocation) { >+ push @where_strings, 'items.cn_sort >= ?'; >+ push @bind_params, $min_cnsort; >+ } > >- if ($maxlocation) { >- push @where_strings, 'items.cn_sort <= ?'; >- push @bind_params, $max_cnsort; >+ if ($maxlocation) { >+ push @where_strings, 'items.cn_sort <= ?'; >+ push @bind_params, $max_cnsort; >+ } >+ } else { >+ if ($minlocation) { >+ push @where_strings, 'items.itemcallnumber >= ?'; >+ push @bind_params, $minlocation; >+ } >+ >+ if ($maxlocation) { >+ push @where_strings, 'items.itemcallnumber <= ?'; >+ push @bind_params, $maxlocation; >+ } > } > > if ($datelastseen) { >diff --git a/installer/data/mysql/atomicupdate/bug19915_add_UseCNSortForInventory_pref.perl b/installer/data/mysql/atomicupdate/bug19915_add_UseCNSortForInventory_pref.perl >new file mode 100644 >index 0000000000..4142bcdf13 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug19915_add_UseCNSortForInventory_pref.perl >@@ -0,0 +1,9 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do( q{ >+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES >+ ('UseCNSortForInventory','0','','If ON offer choice of Classification source during inventory and convert callnumber ranges when comparing','YesNo') >+ }); >+ SetVersion( $DBversion ); >+ print "Upgrade to $DBversion done (Bug 19915: Add UseCNSortForInventory system preference)\n"; >+} >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 0f86627024..7df6b6c7ed 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -601,6 +601,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('UseACQFrameworkForBiblioRecords','0','','Use the ACQ framework for the catalog details','YesNo'), > ('UseAuthoritiesForTracings','1','0','Use authority record numbers for subject tracings instead of heading strings.','YesNo'), > ('UseBranchTransferLimits','0','','If ON, Koha will will use the rules defined in branch_transfer_limits to decide if an item transfer should be allowed.','YesNo'), >+('UseCNSortForInventory','0','','If ON offer choice of Classification source during inventory and convert callnumber ranges when comparing','YesNo'), > ('UseControlNumber','0','','If ON, record control number (w subfields) and control number (001) are used for linking of bibliographic records.','YesNo'), > ('UseCourseReserves','0',NULL,'Enable the course reserves feature.','YesNo'), > ('useDaysMode','Calendar','Calendar|Days|Datedue','Choose the method for calculating due date: select Calendar to use the holidays module, and Days to ignore the holidays module','Choice'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref >index 1822c7ab24..689468004b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref >@@ -167,3 +167,9 @@ Staff Client: > yes: Show > no: "Don't show" > - a search field pulldown for 'Search the catalog' boxes. >+ - >+ - pref: UseCNSortForInventory >+ choices: >+ yes: Use >+ no: "Don't use" >+ - classification sources to correct sorting for callnumbers during inventory. >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 8b913ae1a7..ae9069ef1f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt >@@ -81,18 +81,21 @@ > <input type="text" name="minlocation" id="minlocation" value="[% minlocation | html %]" /> (items.itemcallnumber) </li> > <li><label for="maxlocation">...and: </label> > <input type="text" name="maxlocation" id="maxlocation" value="[% maxlocation | html %]" /> >- <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 | html %]" selected="selected">[% class_source.description | html %] (default)</option> >- [% ELSE %] >- <option value="[% class_source.cn_source | html %]">[% class_source.description | html %]</option> >+ </li> >+ [% IF class_sources %] >+ <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 | html %]" selected="selected">[% class_source.description | html %] (default)</option> >+ [% ELSE %] >+ <option value="[% class_source.cn_source | html %]">[% class_source.description | html %]</option> >+ [% END %] > [% END %] >- [% END %] >- </select> >- </li> >+ </select> >+ </li> >+ [% END %] > </ol> > </fieldset> > >diff --git a/t/db_dependent/Items/GetItemsForInventory.t b/t/db_dependent/Items/GetItemsForInventory.t >index 7e3f99d56a..eef95be1ac 100755 >--- a/t/db_dependent/Items/GetItemsForInventory.t >+++ b/t/db_dependent/Items/GetItemsForInventory.t >@@ -21,6 +21,7 @@ use Modern::Perl; > use Test::More tests => 2; > > use t::lib::TestBuilder; >+use t::lib::Mocks; > > use C4::Context; > use C4::Biblio; >@@ -43,7 +44,7 @@ subtest 'Verify results with OldWay' => sub { > }; > > subtest 'Use cn_sort rather than callnumber to determine correct location' => sub { >- plan tests => 1; >+ plan tests => 3; > > my $builder = t::lib::TestBuilder->new; > >@@ -58,7 +59,16 @@ subtest 'Use cn_sort rather than callnumber to determine correct location' => su > } > }); > >- #Find if we have any items in our test range before we start >+ t::lib::Mocks::mock_preference('UseCNSortForInventory', '0'); >+ #Find if we have any items in our test range before we start (using callnumber) >+ my( undef, $pre_nosort_item_count) = GetItemsForInventory({ >+ maxlocation => 'GT100', >+ minlocation => 'GT90', >+ class_source => $class_source->{cn_source}, >+ }); >+ >+ t::lib::Mocks::mock_preference('UseCNSortForInventory', '1'); >+ #Find if we have any items in our test range before we start (using cn_sort) > my( undef, $pre_item_count) = GetItemsForInventory({ > maxlocation => 'GT100', > minlocation => 'GT90', >@@ -72,13 +82,34 @@ subtest 'Use cn_sort rather than callnumber to determine correct location' => su > cn_sort => GetClassSort($class_source->{cn_source},undef,'GT95'), > } > }); >+ my $item_1 = $builder->build({ >+ source => 'Item', >+ value => { >+ itemcallnumber => 'GT101', >+ cn_sort => GetClassSort($class_source->{cn_source},undef,'GT101'), >+ } >+ }); > > my( undef, $item_count) = GetItemsForInventory({ > maxlocation => 'GT100', > minlocation => 'GT90', > class_source => $class_source->{cn_source}, > }); >- is($item_count,$pre_item_count + 1,"We should return GT95 as between GT90 and GT100"); >+ is($item_count,$pre_item_count + 1,"We should return GT95 as between GT90 and GT100, but not GT101"); >+ >+ t::lib::Mocks::mock_preference('UseCNSortForInventory', '0'); >+ my( undef, $item_nosort_count) = GetItemsForInventory({ >+ maxlocation => 'GT100', >+ minlocation => 'GT90', >+ class_source => $class_source->{cn_source}, >+ }); >+ is($item_nosort_count,$pre_nosort_item_count,"We won't return GT95 or 101 as between GT90 and GT100 if using callnumber"); >+ my( undef, $item_nosort_count_1) = GetItemsForInventory({ >+ maxlocation => 'GT90', >+ minlocation => 'GT100', >+ class_source => $class_source->{cn_source}, >+ }); >+ is($item_nosort_count_1,$pre_nosort_item_count + 1,"We won't include GT95 but will include GT101 as between GT100 and GT90 if using callnumber"); > > }; > >diff --git a/tools/inventory.pl b/tools/inventory.pl >index 1aba6d68af..9042401bf9 100755 >--- a/tools/inventory.pl >+++ b/tools/inventory.pl >@@ -116,9 +116,14 @@ for my $authvfield (@$statuses) { > } > } > >-my @class_sources = Koha::ClassSources->search({ used => 1 }); >-my $pref_class = C4::Context->preference("DefaultClassificationSource"); >- >+if( C4::Context->preference('UseCNSortForInventory') ){ >+ my @class_sources = Koha::ClassSources->search({ used => 1 }); >+ my $pref_class = C4::Context->preference("DefaultClassificationSource"); >+ $template->param( >+ class_sources => \@class_sources, >+ pref_class => $pref_class >+ ); >+} > > $template->param( > authorised_values => \@authorised_value_list, >@@ -132,8 +137,6 @@ $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 >-- >2.11.0
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