Bugzilla – Attachment 6173 Details for
Bug 6650
no holds message is not always clear
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
0001-bug_6650-CanBookBeReserved-now-returns-array-with-re.patch (text/plain), 6.24 KB, created by
Srdjan Jankovic
on 2011-11-04 01:24:41 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Srdjan Jankovic
Created:
2011-11-04 01:24:41 UTC
Size:
6.24 KB
patch
obsolete
>From 85682fab1eebe2d05e4291ebec277799fd21ba63 Mon Sep 17 00:00:00 2001 >From: Srdjan Jankovic <srdjan@catalyst.net.nz> >Date: Fri, 4 Nov 2011 14:14:07 +1300 >Subject: [PATCH] bug_6650: CanBookBeReserved() now returns array with reason > >CanBookBeReserved() now returns array providing the reason for not being >able to be reserved >Use that reason to give getter message on intranet reserve page. >--- > C4/Reserves.pm | 44 +++++++++++++------- > .../prog/en/modules/reserve/request.tt | 3 + > reserve/request.pl | 21 +++++++--- > 3 files changed, 47 insertions(+), 21 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 4af8a85..041d1de 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -376,35 +376,51 @@ sub GetReservesFromBorrowernumber { > #------------------------------------------------------------------------------------- > =head2 CanBookBeReserved > >- $error = &CanBookBeReserved($borrowernumber, $biblionumber) >+ my ($can, $reason) = CanBookBeReserved($borrowernumber, $biblionumber) > >+Calls CanItemBeReserved() for each item, stopping when first available item is found. >+For return values see CanItemBeReserved(), with addition of reason constant >+ NO_ITEMS > =cut > >+use constant NO_ITEMS => "NO ITEMS"; >+use constant NO_RESERVES_ALLOWED => "NO RESERVES ALLOWED"; >+use constant MAX_RESERVES_REACHED => "BORROWER MAX RESERVES REACHED"; > sub CanBookBeReserved{ > my ($borrowernumber, $biblionumber) = @_; > > my @items = get_itemnumbers_of($biblionumber); > #get items linked via host records >- my @hostitems = get_hostitemnumbers_of($biblionumber); >- if (@hostitems){ >- push (@items,@hostitems); >+ if ( my @hostitems = get_hostitemnumbers_of($biblionumber) ) { >+ push (@items,@hostitems); > } > >+ my ($can, $reason) = (0, NO_ITEMS); > foreach my $item (@items){ >- return 1 if CanItemBeReserved($borrowernumber, $item); >+ ($can, $reason) = _CanItemBeReserved($borrowernumber, $item); >+ last if $can; > } >- return 0; >+ return wantarray ? ($can, $reason) : $can; > } > > =head2 CanItemBeReserved > >- $error = &CanItemBeReserved($borrowernumber, $itemnumber) >+ my ($can, $reason) = CanItemBeReserved($borrowernumber, $itemnumber) > >-This function return 1 if an item can be issued by this borrower. >+This function returns (1) if an item can be issued by this borrower. >+If not, it returns (0, $reason), reson being a constat: >+ NO_RESERVES_ALLOWED >+ MAX_RESERVES_REACHED >+ >+In scalar context it returns $can; > > =cut > > sub CanItemBeReserved{ >+ my ($can, $reason) = _CanItemBeReserved(@_); >+ return wantarray ? ($can, $reason) : $can; >+} >+sub _CanItemBeReserved{ > my ($borrowernumber, $itemnumber) = @_; > > my $dbh = C4::Context->dbh; >@@ -460,6 +476,7 @@ sub CanItemBeReserved{ > }else{ > $itemtype = '*'; > } >+ return (0, NO_RESERVES_ALLOWED) unless $allowedreserves; > > # we retrieve count > >@@ -474,17 +491,14 @@ sub CanItemBeReserved{ > $sthcount->execute($borrowernumber, $branchcode, $itemtype); > } > >- my $reservecount = "0"; >+ my $reservecount = 0; > if(my $rowcount = $sthcount->fetchrow_hashref()){ > $reservecount = $rowcount->{count}; > } >- > # we check if it's ok or not >- if( $reservecount < $allowedreserves ){ >- return 1; >- }else{ >- return 0; >- } >+ return (0, MAX_RESERVES_REACHED) unless $reservecount < $allowedreserves; >+ >+ return (1); > } > #-------------------------------------------------------------------------------- > =head2 GetReserveCount >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index 1719af4..f88c77e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -207,6 +207,9 @@ function checkMultiHold() { > [% IF ( alreadyreserved ) %] > <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>already has a hold</strong> on this item </li> > [% END %] >+ [% IF ( reservesnotallowed ) %] >+ <li> <strong>Items can not be placed on hold</strong></li> >+ [% END %] > [% IF ( none_available ) %] > <li> <strong>No copies are available</strong> to be placed on hold</li> > [% END %] >diff --git a/reserve/request.pl b/reserve/request.pl >index 21183da..0706491 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -141,9 +141,11 @@ if ($borrowernumber_hold && !$action) { > my $number_reserves = > GetReserveCount( $borrowerinfo->{'borrowernumber'} ); > >- if ( C4::Context->preference('maxreserves') && ($number_reserves >= C4::Context->preference('maxreserves')) ) { >- $warnings = 1; >- $maxreserves = 1; >+ if ( my $max = C4::Context->preference('maxreserves') ) { >+ if ( $number_reserves >= $max ) { >+ $warnings = 1; >+ $maxreserves = 1; >+ } > } > > # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn) >@@ -234,12 +236,18 @@ foreach my $biblionumber (@biblionumbers) { > > my %biblioloopiter = (); > my $maxreserves; >+ my $reservesnotallowed; > > my $dat = GetBiblioData($biblionumber); > >- unless ( CanBookBeReserved($borrowerinfo->{borrowernumber}, $biblionumber) ) { >+ my ($can_reserve, $reason) = CanBookBeReserved($borrowerinfo->{borrowernumber}, $biblionumber); >+ unless ( $can_reserve ) { > $warnings = 1; >- $maxreserves = 1; >+ if ($reason eq C4::Reserves->MAX_RESERVES_REACHED) { >+ $maxreserves = 1; >+ } else { >+ $reservesnotallowed = 1; >+ } > } > # get existing reserves ..... > my ( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber,1); >@@ -262,7 +270,8 @@ foreach my $biblionumber (@biblionumbers) { > $template->param( alreadyreserved => $alreadyreserved, > messages => $messages, > warnings => $warnings, >- maxreserves=>$maxreserves >+ maxreserves=>$maxreserves, >+ reservesnotallowed=>$reservesnotallowed, > ); > > >-- >1.6.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6650
: 6173