Lines 314-323
sub CanItemBeReserved {
Link Here
|
314 |
my $ruleitemtype; # itemtype of the matching issuing rule |
314 |
my $ruleitemtype; # itemtype of the matching issuing rule |
315 |
my $allowedreserves = 0; # Total number of holds allowed across all records |
315 |
my $allowedreserves = 0; # Total number of holds allowed across all records |
316 |
my $holds_per_record = 1; # Total number of holds allowed for this one given record |
316 |
my $holds_per_record = 1; # Total number of holds allowed for this one given record |
|
|
317 |
my $holds_per_day = 0; # Total number of holds allowed per day for the given patron |
317 |
|
318 |
|
318 |
# we retrieve borrowers and items informations # |
319 |
# we retrieve borrowers and items informations # |
319 |
# item->{itype} will come for biblioitems if necessery |
320 |
# item->{itype} will come for biblioitems if necessery |
320 |
my $item = GetItem($itemnumber); |
321 |
my $item = C4::Items::GetItem($itemnumber); |
321 |
my $biblio = Koha::Biblios->find( $item->{biblionumber} ); |
322 |
my $biblio = Koha::Biblios->find( $item->{biblionumber} ); |
322 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
323 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
323 |
my $borrower = $patron->unblessed; |
324 |
my $borrower = $patron->unblessed; |
Lines 364-369
sub CanItemBeReserved {
Link Here
|
364 |
$ruleitemtype = $rights->{itemtype}; |
365 |
$ruleitemtype = $rights->{itemtype}; |
365 |
$allowedreserves = $rights->{reservesallowed}; |
366 |
$allowedreserves = $rights->{reservesallowed}; |
366 |
$holds_per_record = $rights->{holds_per_record}; |
367 |
$holds_per_record = $rights->{holds_per_record}; |
|
|
368 |
$holds_per_day = $rights->{holds_per_day}; |
367 |
} |
369 |
} |
368 |
else { |
370 |
else { |
369 |
$ruleitemtype = '*'; |
371 |
$ruleitemtype = '*'; |
Lines 381-386
sub CanItemBeReserved {
Link Here
|
381 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
383 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
382 |
} |
384 |
} |
383 |
|
385 |
|
|
|
386 |
my $today_holds = Koha::Holds->search({ |
387 |
borrowernumber => $borrowernumber, |
388 |
reservedate => dt_from_string->date |
389 |
}); |
390 |
|
391 |
if ( defined $holds_per_day && |
392 |
( ( $holds_per_day > 0 && $today_holds->count() >= $holds_per_day ) |
393 |
or ( $holds_per_day == 0 ) ) |
394 |
) { |
395 |
return { status => 'tooManyReservesToday', limit => $holds_per_day }; |
396 |
} |
397 |
|
384 |
# we retrieve count |
398 |
# we retrieve count |
385 |
|
399 |
|
386 |
$querycount .= "AND $branchfield = ?"; |
400 |
$querycount .= "AND $branchfield = ?"; |
Lines 2122-2128
sub GetHoldRule {
Link Here
|
2122 |
|
2136 |
|
2123 |
my $sth = $dbh->prepare( |
2137 |
my $sth = $dbh->prepare( |
2124 |
q{ |
2138 |
q{ |
2125 |
SELECT categorycode, itemtype, branchcode, reservesallowed, holds_per_record |
2139 |
SELECT categorycode, itemtype, branchcode, reservesallowed, holds_per_record, holds_per_day |
2126 |
FROM issuingrules |
2140 |
FROM issuingrules |
2127 |
WHERE (categorycode in (?,'*') ) |
2141 |
WHERE (categorycode in (?,'*') ) |
2128 |
AND (itemtype IN (?,'*')) |
2142 |
AND (itemtype IN (?,'*')) |
2129 |
- |
|
|