@@ -, +, @@
shelving location on issue.
---
C4/Circulation.pm | 6 ++++++
C4/Items.pm | 23 +++++++++++++++++++++-
.../bug_21159-add_UpdateItemLocationOnCheckout.sql | 1 +
.../en/modules/admin/preferences/circulation.pref | 6 ++++++
t/db_dependent/Circulation/issue.t | 23 +++++++++++++++++++++-
5 files changed, 57 insertions(+), 2 deletions(-)
create mode 100644 installer/data/mysql/atomicupdate/bug_21159-add_UpdateItemLocationOnCheckout.sql
--- a/C4/Circulation.pm
+++ a/C4/Circulation.pm
@@ -1393,6 +1393,12 @@ sub AddIssue {
}
}
+ if ( C4->Context->preference('UpdateItemLocationOnCheckout')) {
+ # UpdateItemLocationOnCheckout is on, set the value of the shelving location (items.location) to blank
+ BlankShelvingLocation( $item->{itemnumber});
+ }
+
+
ModItem(
{
issues => $item->{'issues'},
--- a/C4/Items.pm
+++ a/C4/Items.pm
@@ -84,7 +84,7 @@ BEGIN {
GetLatestAcquisitions
CartToShelf
-
+ BlankShelvingLocation
GetAnalyticsCount
SearchItemsByField
@@ -198,6 +198,27 @@ sub CartToShelf {
}
}
+
+=head2 BlankShelvingLocation
+
+ BalnkShelvingLocation($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/installer/data/mysql/atomicupdate/bug_21159-add_UpdateItemLocationOnCheckout.sql
+++ a/installer/data/mysql/atomicupdate/bug_21159-add_UpdateItemLocationOnCheckout.sql
@@ -0,0 +1, @@
+INSERT INTO systempreferences (variable, value, explanation, type) VALUES ('UpdateItemLocationOnCheckout', 0, 'Blank the 952$c (Shelving Location) field of item when it is issued', 'YesNo');
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
@@ -500,6 +500,12 @@ Circulation:
-
**Use of an _ALL_ rule will override/ignore any other values**
-
Each pair of values should be on a separate line.
-
+ - pref: BlankShelvingLocationOnIssue
+ - choices:
+ yes: Blank
+ no: "Don't blank"
+ - Blank the 952$c (shelving location) field of item when it 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 => 44;
+use Test::More tests => 46;
use DateTime::Duration;
use t::lib::Mocks;
@@ -419,8 +419,29 @@ $item2 = GetItem( $itemnumber2 );
ok( $item2->{location} eq '' , q{UpdateItemLocationOnCheckin updates location value from 'PROC' to '' with setting "PROC: _PERM_" } );
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);
+AddIssue($borrower_1, 'barcode_5', $daysago10, 0, $today, '');
+$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,
--