From 377e0395ee5b25e8978d00c103339a4200a5c3fb 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 | 26 +++++++++++++++++++- .../en/modules/admin/preferences/circulation.pref | 2 +- .../en/modules/admin/preferences/web_services.pref | 3 ++- 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 7941a70..38b02c4 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; @@ -623,9 +623,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; @@ -702,9 +704,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 5514796..286a604 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -134,7 +134,10 @@ BEGIN { &GetReservesControlBranch ); - @EXPORT_OK = qw( MergeHolds ); + @EXPORT_OK = qw( + MergeHolds + GetReserveNextRank + ); } =head2 AddReserve @@ -2211,6 +2214,27 @@ sub GetReservesControlBranch { return $branchcode; } +=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 96b6d34..59641ae 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 @@ -418,7 +418,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.10.4