Bugzilla – Attachment 47186 Details for
Bug 14695
Add ability to place multiple item holds on a given record per patron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14695 - Tidy C4::Reserves::CanItemBeReserved
Bug-14695---Tidy-C4ReservesCanItemBeReserved.patch (text/plain), 7.25 KB, created by
Kyle M Hall (khall)
on 2016-01-22 14:31:54 UTC
(
hide
)
Description:
Bug 14695 - Tidy C4::Reserves::CanItemBeReserved
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-01-22 14:31:54 UTC
Size:
7.25 KB
patch
obsolete
>From ac4621cdd18c14fab74d2e12838abdd2ecad52a0 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 28 Dec 2015 17:11:46 +0000 >Subject: [PATCH] Bug 14695 - Tidy C4::Reserves::CanItemBeReserved > >--- > C4/Reserves.pm | 120 ++++++++++++++++++++++++++++++--------------------------- > 1 file changed, 64 insertions(+), 56 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 7bb5d69..196f761 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -448,74 +448,80 @@ sub CanBookBeReserved{ > > =cut > >-sub CanItemBeReserved{ >- my ($borrowernumber, $itemnumber) = @_; >+sub CanItemBeReserved { >+ my ( $borrowernumber, $itemnumber ) = @_; > >- my $dbh = C4::Context->dbh; >- my $ruleitemtype; # itemtype of the matching issuing rule >+ my $dbh = C4::Context->dbh; >+ my $ruleitemtype; # itemtype of the matching issuing rule > my $allowedreserves = 0; >- >+ > # we retrieve borrowers and items informations # > # item->{itype} will come for biblioitems if necessery >- my $item = GetItem($itemnumber); >+ my $item = GetItem($itemnumber); > my $biblioData = C4::Biblio::GetBiblioData( $item->{biblionumber} ); >- my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber); >+ my $borrower = C4::Members::GetMember( 'borrowernumber' => $borrowernumber ); > > # If an item is damaged and we don't allow holds on damaged items, we can stop right here >- return 'damaged' if ( $item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems') ); >+ return 'damaged' >+ if ( $item->{damaged} >+ && !C4::Context->preference('AllowHoldsOnDamagedItems') ); > > #Check for the age restriction >- my ($ageRestriction, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction( $biblioData->{agerestriction}, $borrower ); >+ my ( $ageRestriction, $daysToAgeRestriction ) = >+ C4::Circulation::GetAgeRestriction( $biblioData->{agerestriction}, $borrower ); > return 'ageRestricted' if $daysToAgeRestriction && $daysToAgeRestriction > 0; > > my $controlbranch = C4::Context->preference('ReservesControlBranch'); > > # we retrieve user rights on this itemtype and branchcode >- 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 $branchcode = ""; >- my $branchfield = "reserves.branchcode"; >+ 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 ON (reserves.biblionumber=biblioitems.biblionumber) >+ LEFT JOIN borrowers USING (borrowernumber) >+ WHERE borrowernumber = ? >+ }; > >- if( $controlbranch eq "ItemHomeLibrary" ){ >+ my $branchcode = ""; >+ my $branchfield = "reserves.branchcode"; >+ >+ 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($borrower->{'categorycode'}, $item->{'itype'}, $branchcode); >- if(my $rights = $sth->fetchrow_hashref()){ >+ >+ # we retrieve rights >+ $sth->execute( $borrower->{'categorycode'}, $item->{'itype'}, $branchcode ); >+ if ( my $rights = $sth->fetchrow_hashref() ) { > $ruleitemtype = $rights->{itemtype}; >- $allowedreserves = $rights->{reservesallowed}; >- }else{ >+ $allowedreserves = $rights->{reservesallowed}; >+ } >+ else { > $ruleitemtype = '*'; > } > > # we retrieve count > > $querycount .= "AND $branchfield = ?"; >- >+ > # If using item-level itypes, fall back to the record > # level itemtype if the hold has no associated item > $querycount .= >@@ -525,26 +531,28 @@ sub CanItemBeReserved{ > if ( $ruleitemtype ne "*" ); > > my $sthcount = $dbh->prepare($querycount); >- >- if($ruleitemtype eq "*"){ >- $sthcount->execute($borrowernumber, $branchcode); >- }else{ >- $sthcount->execute($borrowernumber, $branchcode, $ruleitemtype); >+ >+ if ( $ruleitemtype eq "*" ) { >+ $sthcount->execute( $borrowernumber, $branchcode ); >+ } >+ else { >+ $sthcount->execute( $borrowernumber, $branchcode, $ruleitemtype ); > } > > 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 'tooManyReserves'; > } > >- my $circ_control_branch = C4::Circulation::_GetCircControlBranch($item, >- $borrower); >- my $branchitemrule = C4::Circulation::GetBranchItemRule($circ_control_branch, >- $item->{itype}); >+ my $circ_control_branch = >+ C4::Circulation::_GetCircControlBranch( $item, $borrower ); >+ my $branchitemrule = >+ C4::Circulation::GetBranchItemRule( $circ_control_branch, $item->{itype} ); > > if ( $branchitemrule->{holdallowed} == 0 ) { > return 'notReservable'; >@@ -553,7 +561,7 @@ sub CanItemBeReserved{ > if ( $branchitemrule->{holdallowed} == 1 > && $borrower->{branchcode} ne $item->{homebranch} ) > { >- return 'cannotReserveFromOtherBranches'; >+ return 'cannotReserveFromOtherBranches'; > } > > # If reservecount is ok, we check item branch if IndependentBranches is ON >@@ -562,7 +570,7 @@ sub CanItemBeReserved{ > and !C4::Context->preference('canreservefromotherbranches') ) > { > my $itembranch = $item->{homebranch}; >- if ($itembranch ne $borrower->{branchcode}) { >+ if ( $itembranch ne $borrower->{branchcode} ) { > return 'cannotReserveFromOtherBranches'; > } > } >-- >2.1.4
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 14695
:
44143
|
44144
|
44145
|
45058
|
45059
|
45060
|
45061
|
45063
|
45064
|
46548
|
46549
|
46550
|
46551
|
46552
|
46553
|
46554
|
46555
|
46556
|
46557
|
46914
|
46915
|
46916
|
46917
|
46918
|
46919
|
46920
|
47183
|
47184
|
47185
|
47186
|
47187
|
47188
|
47189
|
47190
|
47191
|
47196
|
47227
|
47228
|
47229
|
47230
|
47231
|
47232
|
47233
|
47234
|
47355
|
47372
|
47606
|
47607
|
47608
|
47609
|
47610
|
47611
|
47612
|
47613
|
47614
|
47615
|
48792
|
48795
|
48796
|
48797
|
48798
|
48799
|
48800
|
48801
|
48802
|
48803
|
50056
|
50057
|
50058
|
50059
|
50060
|
50061
|
50062
|
50063
|
50064
|
50065
|
50327
|
50391
|
51006
|
51007
|
51008
|
51009
|
51010
|
51011
|
51012
|
51013
|
51014
|
51015
|
51016
|
51017
|
51027
|
51030
|
51031
|
51032
|
51033
|
51034
|
51035
|
51036
|
51037
|
51038
|
51039
|
51040
|
51041
|
51042
|
51277
|
51278
|
51279
|
51280
|
51281
|
51282
|
51283
|
51284
|
51285
|
51286
|
51287
|
51288
|
51289
|
52457
|
54546
|
54547
|
54548
|
54549
|
54550
|
54551
|
54552
|
54553
|
54554
|
54555
|
54556
|
54557
|
54558
|
54559
|
55114
|
55115
|
55116
|
55117
|
55118
|
55119
|
55120
|
55121
|
55122
|
55123
|
55124
|
55125
|
55126
|
55127
|
55128
|
55148
|
55149
|
55150
|
55151
|
55152
|
55153
|
55154
|
55155
|
55156
|
55157
|
55158
|
55159
|
55160
|
55161
|
55162
|
55163
|
55299
|
55332
|
55730
|
55731