|
Lines 2472-2478
sub CanBookBeRenewed {
Link Here
|
| 2472 |
|
2472 |
|
| 2473 |
my $dbh = C4::Context->dbh; |
2473 |
my $dbh = C4::Context->dbh; |
| 2474 |
my $renews = 1; |
2474 |
my $renews = 1; |
| 2475 |
my $renewokay = 0; |
2475 |
my $renewokay = 1; |
| 2476 |
my $error; |
2476 |
my $error; |
| 2477 |
|
2477 |
|
| 2478 |
my $item = GetItem($itemnumber) or return ( 0, 'no_item' ); |
2478 |
my $item = GetItem($itemnumber) or return ( 0, 'no_item' ); |
|
Lines 2486-2497
sub CanBookBeRenewed {
Link Here
|
| 2486 |
|
2486 |
|
| 2487 |
my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode); |
2487 |
my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode); |
| 2488 |
|
2488 |
|
| 2489 |
if ( ( $issuingrule->{renewalsallowed} > $itemissue->{renewals} ) || $override_limit ) { |
2489 |
if ( $issuingrule->{norenewalbefore} ) { |
| 2490 |
$renewokay = 1; |
2490 |
|
| 2491 |
} else { |
2491 |
# Get current time and add norenewalbefore. If this is smaller than date_due, it's too soon for renewal. |
|
|
2492 |
if ( |
| 2493 |
DateTime->now( time_zone => C4::Context->tz() )->add( |
| 2494 |
$issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} |
| 2495 |
) < $itemissue->{date_due} |
| 2496 |
) |
| 2497 |
{ |
| 2498 |
$renewokay = 0; |
| 2499 |
$error = "too_soon"; |
| 2500 |
} |
| 2501 |
} |
| 2502 |
|
| 2503 |
if ( $issuingrule->{renewalsallowed} <= $itemissue->{renewals} ) { |
| 2504 |
$renewokay = 0; |
| 2492 |
$error = "too_many"; |
2505 |
$error = "too_many"; |
| 2493 |
} |
2506 |
} |
| 2494 |
|
2507 |
|
|
|
2508 |
if ( $override_limit ) { |
| 2509 |
$renewokay = 1; |
| 2510 |
$error = undef; |
| 2511 |
} |
| 2512 |
|
| 2495 |
my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves( $itemnumber ); |
2513 |
my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves( $itemnumber ); |
| 2496 |
|
2514 |
|
| 2497 |
if ( $resfound ) { # '' when no hold was found |
2515 |
if ( $resfound ) { # '' when no hold was found |