|
Lines 133-138
BEGIN {
Link Here
|
| 133 |
&SuspendAll |
133 |
&SuspendAll |
| 134 |
|
134 |
|
| 135 |
&GetReservesControlBranch |
135 |
&GetReservesControlBranch |
|
|
136 |
&PreventHoldsAnyAvailableItem |
| 136 |
); |
137 |
); |
| 137 |
@EXPORT_OK = qw( MergeHolds ); |
138 |
@EXPORT_OK = qw( MergeHolds ); |
| 138 |
} |
139 |
} |
|
Lines 788-794
If several reserves exist, the reserve with the lower priority is given.
Link Here
|
| 788 |
## the sub is only used once in the codebase. |
789 |
## the sub is only used once in the codebase. |
| 789 |
sub GetReserveStatus { |
790 |
sub GetReserveStatus { |
| 790 |
my ($itemnumber, $biblionumber) = @_; |
791 |
my ($itemnumber, $biblionumber) = @_; |
| 791 |
|
|
|
| 792 |
my $dbh = C4::Context->dbh; |
792 |
my $dbh = C4::Context->dbh; |
| 793 |
|
793 |
|
| 794 |
my ($sth, $found, $priority); |
794 |
my ($sth, $found, $priority); |
|
Lines 2214-2219
sub GetReservesControlBranch {
Link Here
|
| 2214 |
return $branchcode; |
2214 |
return $branchcode; |
| 2215 |
} |
2215 |
} |
| 2216 |
|
2216 |
|
|
|
2217 |
=head2 PreventHoldsAnyAvailableItem |
| 2218 |
Checks if an item is available to have a hold placed on it. |
| 2219 |
Specifically relates to items currently on the shelf (without a datedue). |
| 2220 |
|
| 2221 |
Returns true when any item attached to the bib is on the shelf and available |
| 2222 |
|
| 2223 |
=cut |
| 2224 |
|
| 2225 |
sub PreventHoldsAnyAvailableItem { |
| 2226 |
my $biblionumber = shift; |
| 2227 |
my @items = GetItemsInfo( $biblionumber ); |
| 2228 |
my $prevent_hold = 0; |
| 2229 |
my $not_out = 0; |
| 2230 |
my $checked_out = 0; |
| 2231 |
my $dbh = C4::Context->dbh; |
| 2232 |
my $notforloan_query; |
| 2233 |
if (C4::Context->preference('item-level_itypes')) { |
| 2234 |
$notforloan_query = "SELECT itemtypes.notforloan |
| 2235 |
FROM items |
| 2236 |
JOIN itemtypes ON (itemtypes.itemtype = items.itype) |
| 2237 |
WHERE itemnumber = ?"; |
| 2238 |
} else { |
| 2239 |
$notforloan_query = "SELECT itemtypes.notforloan |
| 2240 |
FROM items |
| 2241 |
JOIN biblioitems USING (biblioitemnumber) |
| 2242 |
JOIN itemtypes USING (itemtype) |
| 2243 |
WHERE itemnumber = ?"; |
| 2244 |
} |
| 2245 |
my $sth = $dbh->prepare($notforloan_query); |
| 2246 |
|
| 2247 |
foreach my $item (@items) { |
| 2248 |
$sth->execute( $item->{itemnumber} ); |
| 2249 |
my $notforloan_itemtype = 0; |
| 2250 |
if (my ($notforloan) = $sth->fetchrow_array) { |
| 2251 |
$notforloan_itemtype = 1 if $notforloan; |
| 2252 |
} |
| 2253 |
|
| 2254 |
if ( not $item->{datedue} ) { |
| 2255 |
my $reserve_status = GetReserveStatus( $item->{itemnumber} ); |
| 2256 |
if ($item->{itemlost} |
| 2257 |
or ( $item->{notforloan} > 0 ) |
| 2258 |
or ( $item->{damaged} and not C4::Context->preference('AllowHoldsOnDamagedItems') ) |
| 2259 |
or $item->{wthdrawn} |
| 2260 |
or $notforloan_itemtype |
| 2261 |
or $reserve_status eq "Waiting" |
| 2262 |
or $reserve_status eq "Reserved") |
| 2263 |
{ |
| 2264 |
next; |
| 2265 |
} |
| 2266 |
else {$prevent_hold++} |
| 2267 |
|
| 2268 |
} |
| 2269 |
|
| 2270 |
} |
| 2271 |
|
| 2272 |
return $prevent_hold; |
| 2273 |
|
| 2274 |
} |
| 2275 |
|
| 2217 |
=head1 AUTHOR |
2276 |
=head1 AUTHOR |
| 2218 |
|
2277 |
|
| 2219 |
Koha Development Team <http://koha-community.org/> |
2278 |
Koha Development Team <http://koha-community.org/> |