From 27c1335911978fdffd1103cd74cdd770e9f70e14 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 10 Aug 2016 19:51:09 +0000 Subject: [PATCH] Bug 14576 - (QA Followup) Remove other instances of ReturnToShelvingCart/InprocessingToShelvingCart This patch eliminates ReturnToShelvingCart and InProcessingToShelvingCart, Deletes Returns.t (it only tested those two prefs and new tests are in issue.t) Adds the UpdateItemLocationOnCheckin to svc/checkin Remaining instances found by: git grep "ReturnToShelvingCart\|InProcessingToShelvingCart" | grep -v translator | wc -l are db update files and release notes --- C4/Circulation.pm | 4 -- C4/Items.pm | 2 +- C4/Reserves.pm | 4 +- C4/UsageStats.pm | 2 - installer/data/mysql/sysprefs.sql | 2 - .../en/modules/help/admin/authorised_values.tt | 4 +- svc/checkin | 42 +++++++++++----- t/db_dependent/Circulation/Returns.t | 58 ---------------------- t/db_dependent/UsageStats.t | 2 - 9 files changed, 34 insertions(+), 86 deletions(-) delete mode 100644 t/db_dependent/Circulation/Returns.t diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 5d1b2bb..fe27036 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1460,10 +1460,6 @@ sub AddIssue { UpdateTotalIssues($item->{'biblionumber'}, 1); } - if ( C4::Context->preference('ReturnToShelvingCart') ) { - # ReturnToShelvingCart is on, anything issued should be taken off the cart. - CartToShelf( $item->{'itemnumber'} ); - } $item->{'issues'}++; if ( C4::Context->preference('UpdateTotalIssuesOnCirc') ) { UpdateTotalIssues( $item->{'biblionumber'}, 1 ); diff --git a/C4/Items.pm b/C4/Items.pm index 81a8263..e041934 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -631,7 +631,7 @@ sub ModItemTransfer { my $dbh = C4::Context->dbh; # Remove the 'shelving cart' location status if it is being used. - CartToShelf( $itemnumber ) if ( C4::Context->preference("ReturnToShelvingCart") ); + CartToShelf( $itemnumber ) if ( $item->{'location'} eq 'CART' && $item->{'permanent_location'} ne 'CART' ); #new entry in branchtransfers.... my $sth = $dbh->prepare( diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 79fb11a..60f8ab5 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1281,7 +1281,7 @@ sub ModReserveStatus { my $sth_set = $dbh->prepare($query); $sth_set->execute( $newstatus, $itemnumber ); - if ( C4::Context->preference("ReturnToShelvingCart") && $newstatus ) { + if ( ( $item->{'location'} eq 'CART' && $item->{'permanent_location'} ne 'CART' ) && $newstatus ) { CartToShelf( $itemnumber ); } } @@ -1349,7 +1349,7 @@ sub ModReserveAffect { $sth->execute( $itemnumber, $borrowernumber,$biblionumber); _koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber ) if ( !$transferToDo && !$already_on_shelf ); _FixPriority( { biblionumber => $biblionumber } ); - if ( C4::Context->preference("ReturnToShelvingCart") ) { + if ( ( $item->{'location'} eq 'CART' && $item->{'permanent_location'} ne 'CART' ) ) { CartToShelf( $itemnumber ); } diff --git a/C4/UsageStats.pm b/C4/UsageStats.pm index b8dbb26..dbc76f3 100644 --- a/C4/UsageStats.pm +++ b/C4/UsageStats.pm @@ -129,7 +129,6 @@ sub BuildReport { AutoRemoveOverduesRestrictions CircControl HomeOrHoldingBranch - InProcessingToShelvingCart IssueLostItem IssuingInProcess ManInvInNoissuesCharge @@ -138,7 +137,6 @@ sub BuildReport { RenewalSendNotice RentalsInNoissuesCharge ReturnBeforeExpiry - ReturnToShelvingCart TransfersMaxDaysWarning UseBranchTransferLimits useDaysMode diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 98abb2f..db39885 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -187,7 +187,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('IntranetCatalogSearchPulldown','0', NULL, 'Show a search field pulldown for \"Search the catalog\" boxes','YesNo'), ('OnSiteCheckouts','0','','Enable/Disable the on-site checkouts feature','YesNo'), ('OnSiteCheckoutsForce','0','','Enable/Disable the on-site for all cases (Even if a user is debarred, etc.)','YesNo'), -('InProcessingToShelvingCart','0','','If set, when any item with a location code of PROC is \'checked in\', it\'s location code will be changed to CART.','YesNo'), ('INTRAdidyoumean','',NULL,'Did you mean? configuration for the Intranet. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free'), ('IntranetBiblioDefaultView','normal','normal|marc|isbd|labeled_marc','Choose the default detail view in the staff interface; choose between normal, labeled_marc, marc or isbd','Choice'), ('intranetbookbag','1','','If ON, enables display of Cart feature in the intranet','YesNo'), @@ -424,7 +423,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('RestrictionBlockRenewing','0',NULL,'If patron is restricted, should renewal be allowed or blocked','YesNo'), ('ReturnBeforeExpiry','0',NULL,'If ON, checkout will be prevented if returndate is after patron card expiry','YesNo'), ('ReturnLog','1',NULL,'If ON, enables the circulation (returns) log','YesNo'), -('ReturnToShelvingCart','0','','If set, when any item is \'checked in\', it\'s location code will be changed to CART.','YesNo'), ('reviewson','1','','If ON, enables patron reviews of bibliographic records in the OPAC','YesNo'), ('RisExportAdditionalFields', '', NULL , 'Define additional RIS tags to export from MARC records in YAML format as an associative array with either a marc tag/subfield combination as the value, or a list of tag/subfield combinations.', 'textarea'), ('RoutingListAddReserves','1','','If ON the patrons on routing lists are automatically added to holds on the issue.','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/help/admin/authorised_values.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/help/admin/authorised_values.tt index 2d75968..163074f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/help/admin/authorised_values.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/help/admin/authorised_values.tt @@ -16,7 +16,7 @@
  • 'BOR_NOTES' is for values for custom patron notes that appear on the circulation screen and the OPAC.
  • 'Bsort1' is for patron statistical purposes.
  • 'Bsort2' is used for patron statistical purposes.
  • -
  • 'CART' is the shelving cart location, used by InProcessingToShelvingCart and ReturnToShelvingCart
  • +
  • 'CART' is the shelving cart location, used by UpdateItemLocationOnCheckin
  • 'CCODE' is for collection codes (appears when cataloging and working with items).
  • 'DAMAGED' is for descriptions of damaged items, and appears when cataloging and working with items.
  • 'HINGS_AS' is for General Holdings: Acquisition Status Designator, a data element that specifies the acquisition status for the unit at the time of the holdings report.
  • @@ -32,7 +32,7 @@
  • 'MANUAL_INV' includes values for manual invoicing.
  • 'NOT_LOAN' is used to list reasons why a title is not for loan.
  • -
  • 'PROC' is for the location to be used for NewItemsDefaultLocation (change description as desired), also the location expected by InProcessingToShelvingCart.
  • +
  • 'PROC' is for the location to be used for NewItemsDefaultLocation (change description as desired), also a special location for UpdateItemLocationOnCheckin.
  • 'REPORT_GROUP' provides a way to sort and filter your reports, the default values in this category include the Koha modules (Accounts, Acquisitions, Catalog, Circulation, Patrons)
  • 'REPORT_SUBGROUP' can be used to further sort and filter your reports. This category is empty by default. Values here need to include the authorized value code from REPORT_GROUP in the Description (OPAC) field to link the subgroup to the appropriate group.
  • 'RESTRICTED' is used for the restricted status of an item
  • diff --git a/svc/checkin b/svc/checkin index c10a1b8..6565d3a 100755 --- a/svc/checkin +++ b/svc/checkin @@ -58,19 +58,35 @@ $data->{itemnumber} = $itemnumber; $data->{borrowernumber} = $borrowernumber; $data->{branchcode} = $branchcode; -if ( C4::Context->preference("InProcessingToShelvingCart") ) { - my $item = GetItem($itemnumber); - if ( $item->{'location'} eq 'PROC' ) { - $item->{'location'} = 'CART'; - ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} ); - } -} - -if ( C4::Context->preference("ReturnToShelvingCart") ) { - my $item = GetItem($itemnumber); - $item->{'location'} = 'CART'; - ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} ); -} + my $yaml_loc = C4::Context->preference('UpdateItemLocationOnCheckin'); + if ($yaml_loc) { + $yaml_loc = "$yaml_loc\n\n"; # YAML is strict on ending \n. Surplus does not hurt + my $rules; + eval { $rules = YAML::Load($yaml_loc); }; + if ($@) { + warn "Unable to parse UpdateItemLocationOnCheckin syspref : $@"; + } + else { + my $item = GetItem($itemnumber); + if (defined $rules->{_ALL_}) { + if ($rules->{_ALL_} eq '_PERM_') { $rules->{_ALL_} = $item->{permanent_location}; } + if ($rules->{_ALL_} eq '_BLANK_') { $rules->{_ALL_} = ''; } + if ( $item->{location} ne $rules->{_ALL_}) { + ModItem( { location => $rules->{_ALL_} }, undef, $itemnumber ); + } + } + else { + foreach my $key ( keys %$rules ) { + if ( $rules->{$key} eq '_PERM_' ) { $rules->{$key} = $item->{permanent_location}; } + if ( $rules->{$key} eq '_BLANK_') { $rules->{$key} = '' ;} + if ( ($item->{location} eq $key && $item->{location} ne $rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $rules->{$key} ne '') ) { + ModItem( { location => $rules->{$key} }, undef, $itemnumber ); + last; + } + } + } + } + } ( $data->{returned} ) = AddReturn( $barcode, $branchcode, $exempt_fine ); diff --git a/t/db_dependent/Circulation/Returns.t b/t/db_dependent/Circulation/Returns.t deleted file mode 100644 index bbc96a4..0000000 --- a/t/db_dependent/Circulation/Returns.t +++ /dev/null @@ -1,58 +0,0 @@ -use Modern::Perl; -use Test::More tests => 2; - -use t::lib::Mocks; -use C4::Biblio; -use C4::Circulation; -use C4::Items; -use C4::Members; -use Koha::Database; -use Koha::DateUtils; - -use t::lib::TestBuilder; - -use MARC::Record; - -*C4::Context::userenv = \&Mock_userenv; - -my $schema = Koha::Database->schema; -$schema->storage->txn_begin; -my $builder = t::lib::TestBuilder->new; - -my $library = $builder->build({ - source => 'Branch', -}); - -my $record = MARC::Record->new(); -my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' ); - -my ( undef, undef, $itemnumber ) = AddItem( - { - homebranch => $library->{branchcode}, - holdingbranch => $library->{branchcode}, - barcode => 'i_dont_exist', - location => 'PROC', - permanent_location => 'TEST' - }, - $biblionumber -); - -my $item; - -t::lib::Mocks::mock_preference( "InProcessingToShelvingCart", 1 ); -AddReturn( 'i_dont_exist', $library->{branchcode} ); -$item = GetItem($itemnumber); -is( $item->{location}, 'CART', "InProcessingToShelvingCart functions as intended" ); - -$item->{location} = 'PROC'; -ModItem( $item, undef, $itemnumber ); - -t::lib::Mocks::mock_preference( "InProcessingToShelvingCart", 0 ); -AddReturn( 'i_dont_exist', $library->{branchcode} ); -$item = GetItem($itemnumber); -is( $item->{location}, 'TEST', "InProcessingToShelvingCart functions as intended" ); - -# C4::Context->userenv -sub Mock_userenv { - return { branch => $library->{branchcode} }; -} diff --git a/t/db_dependent/UsageStats.t b/t/db_dependent/UsageStats.t index 76abe49..c9abf64 100644 --- a/t/db_dependent/UsageStats.t +++ b/t/db_dependent/UsageStats.t @@ -381,7 +381,6 @@ sub mocking_systempreferences_to_a_set_value { CircControl HomeOrHoldingBranch HomeOrHoldingBranchReturn - InProcessingToShelvingCart IssueLostItem IssuingInProcess ManInvInNoissuesCharge @@ -390,7 +389,6 @@ sub mocking_systempreferences_to_a_set_value { RenewalSendNotice RentalsInNoissuesCharge ReturnBeforeExpiry - ReturnToShelvingCart TransfersMaxDaysWarning UseBranchTransferLimits useDaysMode -- 2.1.4