From 1ad107a10b3121d4071355276afc7770daf43217 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 29 May 2013 12:44:44 -0400 Subject: [PATCH] Bug 10378 - Enable checked out items to be transferred without returning them When items are transferred, they are automatically returned to the transferred-from library. Some libraries would like to be able to use the transfer system without automatically returning the item and having it removed from the patron record. Scenario: LibraryA of multi-library system is checking in items from the overnight dropbox. The librarian pulls out a damaged item, but it is an item owned and checked out from LibraryB. Instead of removing the item from the patrons checked out items, the library would like to transfer the item, still checked out, back to LibraryB so that LibraryB may decide how to deal with the damaged item. Test Plan: 1) Apply this patch 2) Run updatedatabase.pl 3) Ensure that ReturnItemWhenTransferred is enabled 4) Check an item out to a borrower 5) Transfer the item to another library 6) Verify the item was returned and removed from the patron's issues 7) Disable ReturnItemWhenTransferred 8) Check an item out to a borrower 9) Transfer the item to another library 10) Verify the item is still listed in the patron's current issues --- C4/Circulation.pm | 8 +++++- circ/branchtransfers.pl | 9 ++++++++ installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 22 ++++++++++++++++++++ .../en/modules/admin/preferences/circulation.pref | 7 ++++++ .../prog/en/modules/circ/branchtransfers.tt | 5 ++++ 6 files changed, 50 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 30cbe2f..db6b39b 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -339,8 +339,12 @@ sub transferbook { # check if it is still issued to someone, return it... if ($issue->{borrowernumber}) { - AddReturn( $barcode, $fbr ); - $messages->{'WasReturned'} = $issue->{borrowernumber}; + if ( C4::Context->preference('ReturnItemWhenTransferred') ) { + AddReturn( $barcode, $fbr ); + $messages->{'WasReturned'} = $issue->{borrowernumber}; + } else { + $messages->{'NotReturned'} = $issue->{borrowernumber}; + } } # find reserves..... diff --git a/circ/branchtransfers.pl b/circ/branchtransfers.pl index ad7aa9a..f7f441b 100755 --- a/circ/branchtransfers.pl +++ b/circ/branchtransfers.pl @@ -221,6 +221,15 @@ foreach my $code ( keys %$messages ) { $err{surname} = $borrower->{'surname'}; $err{cardnumber} = $borrower->{'cardnumber'}; } + elsif ( $code eq 'NotReturned' ) { + $err{NotReturned} = 1; + $err{borrowernumber} = $messages->{'NotReturned'}; + my $borrower = GetMember('borrowernumber'=>$messages->{'NotReturned'}); + $err{title} = $borrower->{'title'}; + $err{firstname} = $borrower->{'firstname'}; + $err{surname} = $borrower->{'surname'}; + $err{cardnumber} = $borrower->{'cardnumber'}; + } $err{errdesteqholding} = ( $code eq 'DestinationEqualsHolding' ); push( @errmsgloop, \%err ); } diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 31485bc..f1dc692 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -427,3 +427,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo'); INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowHoldNotes',0,'Show hold notes on OPAC','','YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo'); +INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReturnItemWhenTransferred','1',NULL,'If enabled, items will be automatically returned when transferred. If disabled, items will not be returned when transferred, and if the item is checked out to a patron, it will remain checked out.','YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index f3a90d8..836b475 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6983,6 +6983,28 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( SetVersion($DBversion); } +$DBversion = "3.13.00.XXX"; +if(CheckVersion($DBversion)) { + $dbh->do( + q{ + INSERT INTO systempreferences ( + variable, + value, + options, + explanation, + type + ) VALUES ( + 'ReturnItemWhenTransferred', + '1', + NULL , + 'If enabled, items will be automatically returned when transferred. If disabled, items will not be returned when transferred, and if the item is checked out to a patron, it will remain checked out.', + 'YesNo' + ) + } + ); + print "Upgrade to $DBversion done (Bug 10378 - Enable checked out items to be transferred without returning them)\n"; + SetVersion($DBversion); +} =head1 FUNCTIONS diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 64cf338..112ffc3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -557,3 +557,10 @@ Circulation: yes: Use no: "Don't use" - course reserves + Transfers Policy: + - + - pref: ReturnItemWhenTransferred + choices: + yes: "Do" + no: "Don't" + - automatically check in items when they are transferred. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt index 1d47060..b684ee1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt @@ -120,6 +120,11 @@ [% errmsgloo.firstname %] [% errmsgloo.surname %] ([% errmsgloo.cardnumber %]) and has been returned. [% END %] + [% IF ( errmsgloo.NotReturned ) %] +
  • Item is on loan to + [% errmsgloo.firstname %] [% errmsgloo.surname %] + ([% errmsgloo.cardnumber %]) but has been not been returned.
  • + [% END %] [% END %] -- 1.7.2.5