@@ -, +, @@
shelving location on issue. This patch builds upon the functionality
implemented in bug 14576, by allowing library staff to automatically
change the item shelving location of items which are circulated.
In the case of this patch it automatically blanks the item shelving
locations of items
when they are issued if the
BlankItemLocationOnCheckout syspref is enabled.
t/db_dependent/Circulation/issue.t contains tests for
BlankItemLocationOnCheckout.
Test plan:
1. Create a new biblio and associated item and set the value of the
shelving location for the item to 'CART'
2. Checkout the item to a user and notice that the status does not
change
3. Apply patches on bug report 14576, and this patch, and run
./updatedatabase.pl inside the koha shell
4. Now return the checked out item (when you updated the database
you
added one new syspref: UpdateItemLocationOnCheckout which
is off by default)
5. Check the item out again and notice the shelving location is not
changed, showing that when the UpdateItemLocationOnCheckout is not
enabled and the shelving location is not changed upon issue.
6. Enable the aforementioned syspref in the Administration->Global
system preferences->Circulation interface
7. Check out the item and notice the shelving location is changed
to no
value, showing when the UpdateItemLocationOnCheckout syspref is
enabled
it blanks the shelving location on the issue of an item.
8. Run t/db_dependent/Circulation/issue.t
Sponsored-By: Toi Ohomai Institute of Technology, New Zealand
---
C4/Circulation.pm | 5 ++++
C4/Items.pm | 24 ++++++++++++++++++
.../en/modules/admin/preferences/circulation.pref | 6 +++++
t/db_dependent/Circulation/issue.t | 29 +++++++++++++++++++++-
4 files changed, 63 insertions(+), 1 deletion(-)
--- a/C4/Circulation.pm
+++ a/C4/Circulation.pm
@@ -1450,6 +1450,11 @@ sub AddIssue {
}
}
+ if (C4::Context->preference('UpdateItemLocationOnCheckout')) {
+ # UpdateItemLocationOnCheckout is on, set the value of the shelving location (items.location) to blank upon checkout
+ BlankShelvingLocation( $item_object->itemnumber );
+ }
+
ModItem(
{
issues => $item_object->issues + 1,
--- a/C4/Items.pm
+++ a/C4/Items.pm
@@ -47,6 +47,7 @@ BEGIN {
DelItemCheck
MoveItemFromBiblio
CartToShelf
+ BlankShelvingLocation
GetAnalyticsCount
SearchItemsByField
SearchItems
@@ -140,6 +141,29 @@ sub CartToShelf {
}
}
+=head2 BlankShelvingLocation
+
+ BlankShelvingLocation($itemnumber);
+
+Set the value of the shelving location to blank when an
+item is issued or returned.
+
+This is called by
+C4:Circulation->AddIssue if the BlankItemLocationOnCheckout
+syspref is enabled
+
+=cut
+
+sub BlankShelvingLocation {
+ my ($itemnumber) = @_;
+ unless ($itemnumber) {
+ croak "Failed BlankShelvingLocation() - no itemnumber supplied";
+ }
+ my $item = GetItem($itemnumber);
+ $item->location = '';
+ ModItem($item, undef, $itemnumber);
+}
+
=head2 AddItemFromMarc
my ($biblionumber, $biblioitemnumber, $itemnumber)
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
@@ -534,6 +534,12 @@ Circulation:
- "The special term _BLANK_ may be used on either side of a value pair to update or remove the location from items with no locaiton assigned.
"
- "The special term _ALL_ is used on the left side of the colon (:) to affect all items, and overrides all other rules."
-
+ -pref: UpdateItemLocationOnCheckout
+ choices:
+ yes: Blank
+ no: "Don't Blank"
+ - Blank the 952$c (shelving location) field of the item when is is issued.
+ -
- pref: UpdateNotForLoanStatusOnCheckin
type: textarea
class: code
--- a/t/db_dependent/Circulation/issue.t
+++ a/t/db_dependent/Circulation/issue.t
@@ -17,7 +17,7 @@
use Modern::Perl;
-use Test::More tests => 45;
+use Test::More tests => 47;
use DateTime::Duration;
use t::lib::Mocks;
@@ -423,7 +423,34 @@ ok( $item2->location eq '' , q{UpdateItemLocationOnCheckin updates location valu
ok( $item2->permanent_location eq '' , q{UpdateItemLocationOnCheckin does not update permanent_location from '' with setting "PROC: _PERM_" } );
+my $itemnumber3;
+($biblionumber, $biblioitemnumber, $itemnumber3) = C4::Items::AddItem(
+ {
+ barcode => 'barcode_5',
+ itemcallnumber => 'callnumber5',
+ homebranch => $branchcode_1,
+ holdingbranch => $branchcode_1,
+ location => 'CART',
+ itype => $itemtype
+ },
+ $biblionumber
+);
+#BlankItemLocationOnCheckout
+t::lib::Mocks::mock_preference('UpdateItemLocationOnCheckout', 0);
+AddIssue($borrower_1, 'barcode_5', $daysago10, 0, $today, 0);
+my $item3 = GetItem($itemnumber3);
+ok($item3->location eq 'CART'),
+q{UpdateItemLocationOnCheckout does not update item shelving location value from 'CART' to '' when not enabled} );
+
+t::lib::Mocks::mock_preference('UpdateItemLocationOnCheckout', 1);
+if (C4::Context->preference('UpdateItemLocationOnCheckout') )
+{
+ BlankShelvingLocation($itemnumber3);
+}
+$item3 = GetItem($itemnumber3);
+ok($item3->location eq '', q{UpdateItemLocationOnCheckout updates item shelving location value from 'CART'
+ to '' when enabled} );
# Bug 14640 - Cancel the hold on checking out if asked
my $reserve_id = AddReserve($branchcode_1, $borrower_id1, $biblionumber,
--