From 6dc7a1b8e1827d272e347f9d99e55170691643f7 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 2 Jul 2013 07:45:11 -0400 Subject: [PATCH] Bug 8836 - Resurrect Rotating Collections - Followup 3 * Fix bad TT Tag * Fix bad sql query * Fix capitalization ( HTML4 ) * Allow a rotating collection's location to keep AutomaticItemReturn from sending it back to the branch of origin --- C4/Circulation.pm | 31 ++++++++++++++++---- C4/RotatingCollections.pm | 6 +-- .../intranet-tmpl/prog/en/modules/circ/returns.tt | 2 +- .../rotating_collections/editCollections.tt | 10 ++++-- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 30cbe2f..cd589e2 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -42,6 +42,7 @@ use C4::Koha qw( GetKohaAuthorisedValueLib ); use C4::Overdues qw(CalcFine UpdateFine); +use C4::RotatingCollections qw(GetCollectionItemBranches); use Algorithm::CheckDigits; use Data::Dumper; @@ -1911,15 +1912,32 @@ sub AddReturn { logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'}) if C4::Context->preference("ReturnLog"); - # FIXME: make this comment intelligible. - #adding message if holdingbranch is non equal a userenv branch to return the document to homebranch - #we check, if we don't have reserv or transfert for this document, if not, return it to homebranch . - - if (($doreturn or $messages->{'NotIssued'}) and !$resfound and ($branch ne $hbr) and not $messages->{'WrongTransfer'}){ + # IF + # a) The item is so far returnable or hasn't been issued + # b) There is no hold for this item for pickup at this branch + # c) The item's branch is not this branch + # c) The should not have been transferred to another branch instead of this one + # d) The item is not part of a rotating collection that is currently at this branch + # THEN this return should be considered a transfer + # + # This transfer should be considered valid UNLESS + # a) AutomaticItemReturn is enabled + # OR + # b) There is branch transfer limit that should prevent this item from being transfered to this branch + # + # If the transfer is not valid, a new transfer back to the item's branch will be created + if ( + ( $doreturn or $messages->{'NotIssued'} ) + and !$resfound + and $branch ne $hbr + and !$messages->{'WrongTransfer'} + and [GetCollectionItemBranches( $item->{'itemnumber'} )]->[1] ne $branch + ){ if ( C4::Context->preference("AutomaticItemReturn" ) or (C4::Context->preference("UseBranchTransferLimits") and ! IsBranchTransferAllowed($branch, $hbr, $item->{C4::Context->preference("BranchTransferLimitsType")} ) - )) { + ) + ) { $debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->{'itemnumber'},$branch, $hbr; $debug and warn "item: " . Dumper($item); ModItemTransfer($item->{'itemnumber'}, $branch, $hbr); @@ -1928,6 +1946,7 @@ sub AddReturn { $messages->{'NeedsTransfer'} = 1; # TODO: instead of 1, specify branchcode that the transfer SHOULD go to, $item->{homebranch} } } + return ( $doreturn, $messages, $issue, $borrower ); } diff --git a/C4/RotatingCollections.pm b/C4/RotatingCollections.pm index 7c5bb7c..c708a4d 100644 --- a/C4/RotatingCollections.pm +++ b/C4/RotatingCollections.pm @@ -343,8 +343,8 @@ sub AddItemToCollection { $sth = $dbh->prepare(" INSERT INTO collections_tracking ( ctId, - colId, i - temnumber + colId, + itemnumber ) VALUES ( NULL, ?, ? ) "); $sth->execute( $colId, $itemnumber ) or return ( 0, 3, $sth->errstr() ); @@ -480,8 +480,6 @@ sub GetCollectionItemBranches { my $row = $sth->fetchrow_hashref; - $sth->finish; - return ( $$row{'holdingbranch'}, $$row{'colBranchcode'}, ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index 98d2ae9..44daeb4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -67,7 +67,7 @@ $(document).ready(function () { [% END %] [% IF ( collectionItemNeedsTransferred ) %] -
This item is part of a Rotating Collection and needs to be Transferred to [% collectionBranch %]
+
This item is part of a rotating collection and needs to be transferred to [% collectionBranch %]
[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt index 4917ff2..e1bb2a8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt @@ -44,13 +44,16 @@
[% IF ( collectionsLoop ) %] + - - + + + + [% FOREACH collectionsLoo IN collectionsLoop %] @@ -60,6 +63,7 @@ [% END %] +
Title Description Holding library  
[% collectionsLoo.colTitle %]Delete
[% ELSE %] There are no collections currently defined. @@ -99,7 +103,7 @@ - [% IF (editColDescription ) %] + [% IF (editColDescription ) %] [% ELSE %][% END %] -- 1.7.2.5