Bugzilla – Attachment 18346 Details for
Bug 10314
CanItemBeReserved does not respect the holds policies
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10314 - CanItemBeReserved does not respect the holds policies - Followup - Tidy up CanItemBeReserved
Bug-10314---CanItemBeReserved-does-not-respect-the.patch (text/plain), 5.65 KB, created by
Kyle M Hall (khall)
on 2013-05-23 11:21:32 UTC
(
hide
)
Description:
Bug 10314 - CanItemBeReserved does not respect the holds policies - Followup - Tidy up CanItemBeReserved
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-05-23 11:21:32 UTC
Size:
5.65 KB
patch
obsolete
>From 241551d51d99854fb47ab505cde893eb6c956ff5 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 23 May 2013 07:20:54 -0400 >Subject: [PATCH] Bug 10314 - CanItemBeReserved does not respect the holds policies - Followup - Tidy up CanItemBeReserved > >--- > C4/Reserves.pm | 113 +++++++++++++++++++++++++++++--------------------------- > 1 files changed, 59 insertions(+), 54 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index a2aba81..684fe23 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -415,19 +415,20 @@ This function return 1 if an item can be issued by this borrower. > > =cut > >-sub CanItemBeReserved{ >- my ($borrowernumber, $itemnumber) = @_; >- >+sub CanItemBeReserved { >+ my ( $borrowernumber, $itemnumber ) = @_; >+ > my $dbh = C4::Context->dbh; > my $allowedreserves = 0; >- >+ > my $controlbranch = C4::Context->preference('ReservesControlBranch'); >- my $itype = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype"; >+ my $itype = >+ C4::Context->preference('item-level_itypes') ? "itype" : "itemtype"; > > # we retrieve borrowers and items informations # >- my $item = GetItem($itemnumber); >- my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber); >- >+ my $item = GetItem($itemnumber); >+ my $borrower = >+ C4::Members::GetMember( 'borrowernumber' => $borrowernumber ); > > # Before we check too see if the borrower has exceed the > # maximum number of holds allowed for this itemtype, >@@ -455,71 +456,75 @@ sub CanItemBeReserved{ > # If we've gotten this far, the holds policy does not prevent the patron > # from placing this hold. We now need to see if the patron has exceeded > # the maximum number of holds allowed for this itemtype based on the patrons >- my $sth = $dbh->prepare("SELECT categorycode, itemtype, branchcode, reservesallowed >- FROM issuingrules >- WHERE (categorycode in (?,'*') ) >- AND (itemtype IN (?,'*')) >- AND (branchcode IN (?,'*')) >- ORDER BY >- categorycode DESC, >- itemtype DESC, >- branchcode DESC;" >- ); >- >- my $querycount ="SELECT >- count(*) as count >- FROM reserves >- LEFT JOIN items USING (itemnumber) >- LEFT JOIN biblioitems ON (reserves.biblionumber=biblioitems.biblionumber) >- LEFT JOIN borrowers USING (borrowernumber) >- WHERE borrowernumber = ? >- "; >- >- >+ my $sth = $dbh->prepare(q{ >+ SELECT categorycode, itemtype, branchcode, reservesallowed >+ FROM issuingrules >+ WHERE (categorycode in (?,'*') ) >+ AND (itemtype IN (?,'*')) >+ AND (branchcode IN (?,'*')) >+ ORDER BY >+ categorycode DESC, >+ itemtype DESC, >+ branchcode DESC; >+ }); >+ >+ my $querycount = q{ >+ SELECT count(*) as count >+ FROM reserves >+ LEFT JOIN items USING (itemnumber) >+ LEFT JOIN biblioitems USING (biblionumber) >+ LEFT JOIN borrowers USING (borrowernumber) >+ WHERE borrowernumber = ? >+ }; >+ > my $itemtype = $item->{$itype}; > my $categorycode = $borrower->{categorycode}; > my $branchcode = ""; > my $branchfield = "reserves.branchcode"; >- >- if( $controlbranch eq "ItemHomeLibrary" ){ >+ >+ if ( $controlbranch eq "ItemHomeLibrary" ) { > $branchfield = "items.homebranch"; >- $branchcode = $item->{homebranch}; >- }elsif( $controlbranch eq "PatronLibrary" ){ >+ $branchcode = $item->{homebranch}; >+ } >+ elsif ( $controlbranch eq "PatronLibrary" ) { > $branchfield = "borrowers.branchcode"; >- $branchcode = $borrower->{branchcode}; >+ $branchcode = $borrower->{branchcode}; > } >- >- # we retrieve rights >- $sth->execute($categorycode, $itemtype, $branchcode); >- if(my $rights = $sth->fetchrow_hashref()){ >+ >+ # we retrieve rights >+ $sth->execute( $categorycode, $itemtype, $branchcode ); >+ if ( my $rights = $sth->fetchrow_hashref() ) { > $itemtype = $rights->{itemtype}; >- $allowedreserves = $rights->{reservesallowed}; >- }else{ >+ $allowedreserves = $rights->{reservesallowed}; >+ } >+ else { > $itemtype = '*'; > } >- >+ > # we retrieve count >- >+ > $querycount .= "AND $branchfield = ?"; >- >- $querycount .= " AND $itype = ?" if ($itemtype ne "*"); >+ >+ $querycount .= " AND $itype = ?" if ( $itemtype ne "*" ); > my $sthcount = $dbh->prepare($querycount); >- >- if($itemtype eq "*"){ >- $sthcount->execute($borrowernumber, $branchcode); >- }else{ >- $sthcount->execute($borrowernumber, $branchcode, $itemtype); >+ >+ if ( $itemtype eq "*" ) { >+ $sthcount->execute( $borrowernumber, $branchcode ); > } >- >+ else { >+ $sthcount->execute( $borrowernumber, $branchcode, $itemtype ); >+ } >+ > my $reservecount = "0"; >- if(my $rowcount = $sthcount->fetchrow_hashref()){ >+ if ( my $rowcount = $sthcount->fetchrow_hashref() ) { > $reservecount = $rowcount->{count}; > } >- >+ > # we check if it's ok or not >- if( $reservecount < $allowedreserves ){ >+ if ( $reservecount < $allowedreserves ) { > return 1; >- }else{ >+ } >+ else { > return 0; > } > } >-- >1.7.2.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 10314
:
18345
|
18346
|
18485
|
18486
|
20231
|
20488
|
20489
|
20490
|
40761
|
40762