Lines 2463-2479
already renewed the loan. $error will contain the reason the renewal can not pro
Link Here
|
2463 |
=cut |
2463 |
=cut |
2464 |
|
2464 |
|
2465 |
sub CanBookBeRenewed { |
2465 |
sub CanBookBeRenewed { |
2466 |
|
|
|
2467 |
# check renewal status |
2468 |
my ( $borrowernumber, $itemnumber, $override_limit ) = @_; |
2466 |
my ( $borrowernumber, $itemnumber, $override_limit ) = @_; |
|
|
2467 |
|
2469 |
my $dbh = C4::Context->dbh; |
2468 |
my $dbh = C4::Context->dbh; |
2470 |
my $renews = 1; |
2469 |
my $renews = 1; |
2471 |
my $renewokay = 0; |
2470 |
my $renewokay = 0; |
2472 |
my $error; |
2471 |
my $error; |
2473 |
|
2472 |
|
2474 |
my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ) or return; |
2473 |
my $item = GetItem($itemnumber) or return ( 0, 'no_item' ); |
2475 |
my $item = GetItem($itemnumber) or return; |
2474 |
my $itemissue = GetItemIssue($itemnumber) or return ( 0, 'no_checkout' ); |
2476 |
my $itemissue = GetItemIssue($itemnumber) or return; |
2475 |
|
|
|
2476 |
$borrowernumber ||= $itemissue->{borrowernumber}; |
2477 |
my $borrower = C4::Members::GetMemberDetails($borrowernumber) |
2478 |
or return; |
2477 |
|
2479 |
|
2478 |
my $branchcode = _GetCircControlBranch($item, $borrower); |
2480 |
my $branchcode = _GetCircControlBranch($item, $borrower); |
2479 |
|
2481 |
|
Lines 2492-2497
sub CanBookBeRenewed {
Link Here
|
2492 |
$error = "on_reserve"; |
2494 |
$error = "on_reserve"; |
2493 |
} |
2495 |
} |
2494 |
|
2496 |
|
|
|
2497 |
if ( ( $issuingrule->{renewalsallowed} > $itemissue->{renewals} ) || $override_limit ) { |
2498 |
$renewokay = 1; |
2499 |
} else { |
2500 |
$error = "too_many"; |
2501 |
} |
2502 |
|
2495 |
return ( $renewokay, $error ); |
2503 |
return ( $renewokay, $error ); |
2496 |
} |
2504 |
} |
2497 |
|
2505 |
|
Lines 2520-2546
from the book's item type.
Link Here
|
2520 |
=cut |
2528 |
=cut |
2521 |
|
2529 |
|
2522 |
sub AddRenewal { |
2530 |
sub AddRenewal { |
2523 |
my $borrowernumber = shift or return; |
2531 |
my $borrowernumber = shift; |
2524 |
my $itemnumber = shift or return; |
2532 |
my $itemnumber = shift or return; |
2525 |
my $branch = shift; |
2533 |
my $branch = shift; |
2526 |
my $datedue = shift; |
2534 |
my $datedue = shift; |
2527 |
my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd(); |
2535 |
my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd(); |
|
|
2536 |
|
2528 |
my $item = GetItem($itemnumber) or return; |
2537 |
my $item = GetItem($itemnumber) or return; |
2529 |
my $biblio = GetBiblioFromItemNumber($itemnumber) or return; |
2538 |
my $biblio = GetBiblioFromItemNumber($itemnumber) or return; |
2530 |
|
2539 |
|
2531 |
my $dbh = C4::Context->dbh; |
2540 |
my $dbh = C4::Context->dbh; |
|
|
2541 |
|
2532 |
# Find the issues record for this book |
2542 |
# Find the issues record for this book |
2533 |
my $sth = |
2543 |
my $sth = |
2534 |
$dbh->prepare("SELECT * FROM issues |
2544 |
$dbh->prepare("SELECT * FROM issues WHERE itemnumber = ?"); |
2535 |
WHERE borrowernumber=? |
2545 |
$sth->execute( $itemnumber ); |
2536 |
AND itemnumber=?" |
|
|
2537 |
); |
2538 |
$sth->execute( $borrowernumber, $itemnumber ); |
2539 |
my $issuedata = $sth->fetchrow_hashref; |
2546 |
my $issuedata = $sth->fetchrow_hashref; |
2540 |
if(defined $datedue && ref $datedue ne 'DateTime' ) { |
2547 |
|
|
|
2548 |
return unless ( $issuedata ); |
2549 |
|
2550 |
$borrowernumber ||= $issuedata->{borrowernumber}; |
2551 |
|
2552 |
if ( defined $datedue && ref $datedue ne 'DateTime' ) { |
2541 |
carp 'Invalid date passed to AddRenewal.'; |
2553 |
carp 'Invalid date passed to AddRenewal.'; |
2542 |
return; |
2554 |
return; |
2543 |
} |
2555 |
} |
|
|
2556 |
|
2544 |
# If the due date wasn't specified, calculate it by adding the |
2557 |
# If the due date wasn't specified, calculate it by adding the |
2545 |
# book's loan length to today's date or the current due date |
2558 |
# book's loan length to today's date or the current due date |
2546 |
# based on the value of the RenewalPeriodBase syspref. |
2559 |
# based on the value of the RenewalPeriodBase syspref. |