|
Lines 1176-1182
AddIssue does the following things :
Link Here
|
| 1176 |
=cut |
1176 |
=cut |
| 1177 |
|
1177 |
|
| 1178 |
sub AddIssue { |
1178 |
sub AddIssue { |
| 1179 |
my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode) = @_; |
1179 |
my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode, $auto_renew ) = @_; |
| 1180 |
my $dbh = C4::Context->dbh; |
1180 |
my $dbh = C4::Context->dbh; |
| 1181 |
my $barcodecheck=CheckValidBarcode($barcode); |
1181 |
my $barcodecheck=CheckValidBarcode($barcode); |
| 1182 |
if ($datedue && ref $datedue ne 'DateTime') { |
1182 |
if ($datedue && ref $datedue ne 'DateTime') { |
|
Lines 1242-1253
sub AddIssue {
Link Here
|
| 1242 |
$sth->execute(C4::Context->userenv->{'branch'},$item->{'itemnumber'}); |
1242 |
$sth->execute(C4::Context->userenv->{'branch'},$item->{'itemnumber'}); |
| 1243 |
} |
1243 |
} |
| 1244 |
|
1244 |
|
|
|
1245 |
# If automatic renewal wasn't selected while issuing, set the value according to the issuing rule. |
| 1246 |
unless ($auto_renew) { |
| 1247 |
my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branch); |
| 1248 |
$auto_renew = $issuingrule->{auto_renew}; |
| 1249 |
} |
| 1250 |
|
| 1245 |
# Record in the database the fact that the book was issued. |
1251 |
# Record in the database the fact that the book was issued. |
| 1246 |
my $sth = |
1252 |
my $sth = |
| 1247 |
$dbh->prepare( |
1253 |
$dbh->prepare( |
| 1248 |
"INSERT INTO issues |
1254 |
"INSERT INTO issues |
| 1249 |
(borrowernumber, itemnumber,issuedate, date_due, branchcode) |
1255 |
(borrowernumber, itemnumber,issuedate, date_due, branchcode, auto_renew) |
| 1250 |
VALUES (?,?,?,?,?)" |
1256 |
VALUES (?,?,?,?,?,?)" |
| 1251 |
); |
1257 |
); |
| 1252 |
unless ($datedue) { |
1258 |
unless ($datedue) { |
| 1253 |
my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'}; |
1259 |
my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'}; |
|
Lines 1260-1266
sub AddIssue {
Link Here
|
| 1260 |
$item->{'itemnumber'}, # itemnumber |
1266 |
$item->{'itemnumber'}, # itemnumber |
| 1261 |
$issuedate->strftime('%Y-%m-%d %H:%M:00'), # issuedate |
1267 |
$issuedate->strftime('%Y-%m-%d %H:%M:00'), # issuedate |
| 1262 |
$datedue->strftime('%Y-%m-%d %H:%M:00'), # date_due |
1268 |
$datedue->strftime('%Y-%m-%d %H:%M:00'), # date_due |
| 1263 |
C4::Context->userenv->{'branch'} # branchcode |
1269 |
C4::Context->userenv->{'branch'}, # branchcode |
|
|
1270 |
$auto_renew ? 1 : 0 # automatic renewal |
| 1264 |
); |
1271 |
); |
| 1265 |
if ( C4::Context->preference('ReturnToShelvingCart') ) { ## ReturnToShelvingCart is on, anything issued should be taken off the cart. |
1272 |
if ( C4::Context->preference('ReturnToShelvingCart') ) { ## ReturnToShelvingCart is on, anything issued should be taken off the cart. |
| 1266 |
CartToShelf( $item->{'itemnumber'} ); |
1273 |
CartToShelf( $item->{'itemnumber'} ); |
|
Lines 2553-2559
C<$itemnumber> is the number of the item to renew.
Link Here
|
| 2553 |
|
2560 |
|
| 2554 |
C<$override_limit>, if supplied with a true value, causes |
2561 |
C<$override_limit>, if supplied with a true value, causes |
| 2555 |
the limit on the number of times that the loan can be renewed |
2562 |
the limit on the number of times that the loan can be renewed |
| 2556 |
(as controlled by the item type) to be ignored. |
2563 |
(as controlled by the item type) to be ignored. Overriding also allows |
|
|
2564 |
to renew sooner than "No renewal before" und to manually renew loans |
| 2565 |
that are automatically renewed. |
| 2557 |
|
2566 |
|
| 2558 |
C<$CanBookBeRenewed> returns a true value if the item may be renewed. The |
2567 |
C<$CanBookBeRenewed> returns a true value if the item may be renewed. The |
| 2559 |
item must currently be on loan to the specified borrower; renewals |
2568 |
item must currently be on loan to the specified borrower; renewals |
|
Lines 2565-2574
already renewed the loan. $error will contain the reason the renewal can not pro
Link Here
|
| 2565 |
sub CanBookBeRenewed { |
2574 |
sub CanBookBeRenewed { |
| 2566 |
my ( $borrowernumber, $itemnumber, $override_limit ) = @_; |
2575 |
my ( $borrowernumber, $itemnumber, $override_limit ) = @_; |
| 2567 |
|
2576 |
|
| 2568 |
my $dbh = C4::Context->dbh; |
2577 |
my $dbh = C4::Context->dbh; |
| 2569 |
my $renews = 1; |
2578 |
my $renews = 1; |
| 2570 |
my $renewokay = 1; |
|
|
| 2571 |
my $error; |
| 2572 |
|
2579 |
|
| 2573 |
my $item = GetItem($itemnumber) or return ( 0, 'no_item' ); |
2580 |
my $item = GetItem($itemnumber) or return ( 0, 'no_item' ); |
| 2574 |
my $itemissue = GetItemIssue($itemnumber) or return ( 0, 'no_checkout' ); |
2581 |
my $itemissue = GetItemIssue($itemnumber) or return ( 0, 'no_checkout' ); |
|
Lines 2577-2618
sub CanBookBeRenewed {
Link Here
|
| 2577 |
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) |
2584 |
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) |
| 2578 |
or return; |
2585 |
or return; |
| 2579 |
|
2586 |
|
| 2580 |
my $branchcode = _GetCircControlBranch($item, $borrower); |
2587 |
my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves($itemnumber); |
| 2581 |
|
2588 |
|
| 2582 |
my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode); |
2589 |
return ( 0, "on_reserve" ) if $resfound; # '' when no hold was found |
|
|
2590 |
|
| 2591 |
return ( 1, undef ) if $override_limit; |
| 2592 |
|
| 2593 |
my $branchcode = _GetCircControlBranch( $item, $borrower ); |
| 2594 |
my $issuingrule = |
| 2595 |
GetIssuingRule( $borrower->{categorycode}, $item->{itype}, $branchcode ); |
| 2596 |
|
| 2597 |
return ( 0, "too_many" ) |
| 2598 |
if $issuingrule->{renewalsallowed} <= $itemissue->{renewals}; |
| 2583 |
|
2599 |
|
| 2584 |
if ( $issuingrule->{norenewalbefore} ) { |
2600 |
if ( $issuingrule->{norenewalbefore} ) { |
| 2585 |
|
2601 |
|
| 2586 |
# Get current time and add norenewalbefore. If this is smaller than date_due, it's too soon for renewal. |
2602 |
# Get current time and add norenewalbefore. |
|
|
2603 |
# If this is smaller than date_due, it's too soon for renewal. |
| 2587 |
if ( |
2604 |
if ( |
| 2588 |
DateTime->now( time_zone => C4::Context->tz() )->add( |
2605 |
DateTime->now( time_zone => C4::Context->tz() )->add( |
| 2589 |
$issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} |
2606 |
$issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} |
| 2590 |
) < $itemissue->{date_due} |
2607 |
) < $itemissue->{date_due} |
| 2591 |
) |
2608 |
) |
| 2592 |
{ |
2609 |
{ |
| 2593 |
$renewokay = 0; |
2610 |
return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew}; |
| 2594 |
$error = "too_soon"; |
2611 |
return ( 0, "too_soon" ); |
| 2595 |
} |
2612 |
} |
| 2596 |
} |
2613 |
} |
| 2597 |
|
2614 |
|
| 2598 |
if ( $issuingrule->{renewalsallowed} <= $itemissue->{renewals} ) { |
2615 |
return ( 0, "auto_renew" ) if $itemissue->{auto_renew}; |
| 2599 |
$renewokay = 0; |
2616 |
return ( 1, undef ); |
| 2600 |
$error = "too_many"; |
|
|
| 2601 |
} |
| 2602 |
|
| 2603 |
if ( $override_limit ) { |
| 2604 |
$renewokay = 1; |
| 2605 |
$error = undef; |
| 2606 |
} |
| 2607 |
|
| 2608 |
my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves( $itemnumber ); |
| 2609 |
|
| 2610 |
if ( $resfound ) { # '' when no hold was found |
| 2611 |
$renewokay = 0; |
| 2612 |
$error = "on_reserve"; |
| 2613 |
} |
| 2614 |
|
| 2615 |
return ( $renewokay, $error ); |
| 2616 |
} |
2617 |
} |
| 2617 |
|
2618 |
|
| 2618 |
=head2 AddRenewal |
2619 |
=head2 AddRenewal |