From 0d02068b5254db95ebbc86f72f6fc731314dd7e8 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Mon, 15 Oct 2012 14:06:04 +0200 Subject: [PATCH] Bug 8918: ILS-DI: Calculate rank when placing hold This is a squash of the 3 following patches Bug 8918: ILS-DI: Calculate rank when placing hold Signed-off-by: Srikanth Dhondi -- Bug 8918: QA fixes - Move C4::ILSDI::_get_reserve_next_rank to C4::Reserves::GetReserveNextRank - Do not calculate rank if ReservesNeedReturns = 0 Signed-off-by: Chris Cormack -- 8918 QA Followup for pref descriptions Updating pref descriptions for ReservesNeedReturns and ILS-DI:AuthorizedIPs. Just sideway related to this report, but not important enough to separate. Signed-off-by: Marcel de Rooy --- C4/ILSDI/Services.pm | 16 ++++++++--- C4/Reserves.pm | 27 +++++++++++++++++++- .../en/modules/admin/preferences/circulation.pref | 2 +- .../en/modules/admin/preferences/web_services.pref | 3 +- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 68cbdb3..51d807a 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -26,7 +26,7 @@ use C4::Circulation; use C4::Branch; use C4::Accounts; use C4::Biblio; -use C4::Reserves qw(AddReserve CancelReserve GetReservesFromBiblionumber GetReservesFromBorrowernumber CanBookBeReserved CanItemBeReserved); +use C4::Reserves qw(AddReserve CancelReserve GetReservesFromBiblionumber GetReservesFromBorrowernumber CanBookBeReserved CanItemBeReserved GetReserveNextRank); use C4::Context; use C4::AuthoritiesMarc; use C4::ILSDI::Utility; @@ -626,9 +626,11 @@ sub HoldTitle { $branch = $$borrower{branchcode}; } + my $rank = GetReserveNextRank($biblionumber); + # Add the reserve # $branch, $borrowernumber, $biblionumber, $constraint, $bibitems, $priority, $notes, $title, $checkitem, $found - AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, 0, undef, $title, undef, undef ); + AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, $rank, undef, $title, undef, undef ); # Hashref building my $out; @@ -705,9 +707,13 @@ sub HoldItem { my $found; # Get rank and found - $rank = '0' unless C4::Context->preference('ReservesNeedReturns'); - if ( $item->{'holdingbranch'} eq $branch ) { - $found = 'W' unless C4::Context->preference('ReservesNeedReturns'); + if (C4::Context->preference('ReservesNeedReturns')) { + $rank = GetReserveNextRank($biblionumber); + } else { + $rank = '0'; + if ($item->{'holdingbranch'} eq $branch) { + $found = 'W'; + } } # Add the reserve diff --git a/C4/Reserves.pm b/C4/Reserves.pm index c8b0cdd..def4c69 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -130,8 +130,12 @@ BEGIN { &ReserveSlip &ToggleSuspend &SuspendAll + + ); + @EXPORT_OK = qw( + MergeHolds + GetReserveNextRank ); - @EXPORT_OK = qw( MergeHolds ); } =head2 AddReserve @@ -2168,6 +2172,27 @@ sub ReserveSlip { ); } +=head2 GetReserveNextRank + + my $next_rank = GetReserveNextRank($biblionumber); + +Calculate the next available reseve rank for a biblionumber. + +=cut + +sub GetReserveNextRank { + my ($biblionumber) = @_; + + my ( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber,1); + foreach my $res (@$reserves) { + $count-- if (defined $res->{found} and $res->{found} eq 'W'); + } + my $rank = $count + 1; + + return $rank; +} + + =head1 AUTHOR Koha Development Team 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 f88d964..4668f2c 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 @@ -399,7 +399,7 @@ Circulation: choices: yes: "Don't automatically" no: Automatically - - mark holds as found and waiting when a hold is placed specifically on them and they are already checked in. + - mark a hold as found and waiting when a hold is placed on a specific item and that item is already checked in. - - Patrons can only have - pref: maxreserves diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref index 7244675..7a4c910 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref @@ -35,9 +35,10 @@ Web services: no: Disable - ILS-DI services for OPAC users - + - Allow IP addresses - pref: ILS-DI:AuthorizedIPs class: Text - - allowed IPs to use the ILS-DI services + - to use the ILS-DI services (when enabled). Separate the IP addresses with commas and without spaces. Leave the field blank to allow any IP address. Reporting: - - Only return -- 1.7.2.5