Lines 22-27
use Modern::Perl;
Link Here
|
22 |
use DateTime; |
22 |
use DateTime; |
23 |
use POSIX qw( floor ); |
23 |
use POSIX qw( floor ); |
24 |
use Encode; |
24 |
use Encode; |
|
|
25 |
use JSON; |
25 |
|
26 |
|
26 |
use C4::Context; |
27 |
use C4::Context; |
27 |
use C4::Stats qw( UpdateStats ); |
28 |
use C4::Stats qw( UpdateStats ); |
Lines 319-324
A recall for this item was found, and the item needs to be transferred to the re
Link Here
|
319 |
|
320 |
|
320 |
=cut |
321 |
=cut |
321 |
|
322 |
|
|
|
323 |
my $query = CGI->new; |
324 |
|
325 |
my $stickyduedate = $query->param('stickyduedate'); |
326 |
my $duedatespec = $query->param('duedatespec'); |
327 |
my $restoreduedatespec = $query->param('restoreduedatespec') || $duedatespec; |
328 |
if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) { |
329 |
undef $restoreduedatespec; |
330 |
} |
331 |
my $issueconfirmed = $query->param('issueconfirmed'); |
332 |
my $cancelreserve = $query->param('cancelreserve'); |
333 |
my $cancel_recall = $query->param('cancel_recall'); |
334 |
my $recall_id = $query->param('recall_id'); |
335 |
my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice |
336 |
my $charges = $query->param('charges') || q{}; |
337 |
|
322 |
sub transferbook { |
338 |
sub transferbook { |
323 |
my $params = shift; |
339 |
my $params = shift; |
324 |
my $tbr = $params->{to_branch}; |
340 |
my $tbr = $params->{to_branch}; |
Lines 815-823
sub CanBookBeIssued {
Link Here
|
815 |
|
831 |
|
816 |
my $now = dt_from_string(); |
832 |
my $now = dt_from_string(); |
817 |
my $message; |
833 |
my $message; |
818 |
my @message_log; |
834 |
my @message; |
819 |
|
835 |
|
820 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
836 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
|
|
837 |
|
821 |
if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now |
838 |
if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now |
822 |
$needsconfirmation{INVALID_DATE} = $duedate; |
839 |
$needsconfirmation{INVALID_DATE} = $duedate; |
823 |
if ($issueconfirmed) { |
840 |
if ($issueconfirmed) { |
Lines 826-832
sub CanBookBeIssued {
Link Here
|
826 |
} else { |
843 |
} else { |
827 |
$message = "sticky due date is invalid or due date in the past"; |
844 |
$message = "sticky due date is invalid or due date in the past"; |
828 |
} |
845 |
} |
829 |
push( @message_log, "sticky due date is invalid or due date in the past" ); |
846 |
push( @message, "sticky due date is invalid or due date in the past" ); |
830 |
} |
847 |
} |
831 |
|
848 |
|
832 |
} |
849 |
} |
Lines 880-886
sub CanBookBeIssued {
Link Here
|
880 |
} else { |
897 |
} else { |
881 |
$message = "borrower is restricted"; |
898 |
$message = "borrower is restricted"; |
882 |
} |
899 |
} |
883 |
push( @message_log, "borrower is restricted" ); |
900 |
push( @message, "borrower is restricted" ); |
884 |
} |
901 |
} |
885 |
} |
902 |
} |
886 |
|
903 |
|
Lines 960-966
sub CanBookBeIssued {
Link Here
|
960 |
} else { |
977 |
} else { |
961 |
$message = "borrower had amend"; |
978 |
$message = "borrower had amend"; |
962 |
} |
979 |
} |
963 |
push( @message_log, "borrower had amend" ); |
980 |
push( @message, "borrower had amend" ); |
964 |
} |
981 |
} |
965 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) { |
982 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) { |
966 |
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
983 |
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
Lines 972-978
sub CanBookBeIssued {
Link Here
|
972 |
} else { |
989 |
} else { |
973 |
$message = "borrower had amend"; |
990 |
$message = "borrower had amend"; |
974 |
} |
991 |
} |
975 |
push( @message_log, "borrower had amend" ); |
992 |
push( @message, "borrower had amend" ); |
976 |
} |
993 |
} |
977 |
} |
994 |
} |
978 |
} |
995 |
} |
Lines 1049-1058
sub CanBookBeIssued {
Link Here
|
1049 |
if ( C4::Context->preference('AutoReturnCheckedOutItems') ) { |
1066 |
if ( C4::Context->preference('AutoReturnCheckedOutItems') ) { |
1050 |
$alerts{RETURNED_FROM_ANOTHER} = { patron => $patron }; |
1067 |
$alerts{RETURNED_FROM_ANOTHER} = { patron => $patron }; |
1051 |
} else { |
1068 |
} else { |
1052 |
$needsconfirmation{ISSUED_TO_ANOTHER} = 1; |
1069 |
$needsconfirmation{ISSUED_TO_ANOTHER} = 1; |
1053 |
$needsconfirmation{issued_firstname} = $patron->firstname; |
1070 |
$needsconfirmation{issued_firstname} = $patron->firstname; |
1054 |
$needsconfirmation{issued_surname} = $patron->surname; |
1071 |
$needsconfirmation{issued_surname} = $patron->surname; |
1055 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
1072 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
1056 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
1073 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
1057 |
if ($issueconfirmed) { |
1074 |
if ($issueconfirmed) { |
1058 |
if ($message) { |
1075 |
if ($message) { |
Lines 1060-1066
sub CanBookBeIssued {
Link Here
|
1060 |
} else { |
1077 |
} else { |
1061 |
$message = "item is checked out for someone else"; |
1078 |
$message = "item is checked out for someone else"; |
1062 |
} |
1079 |
} |
1063 |
push( @message_log, "item is checked out for someone else" ); |
1080 |
push( @message, "item is checked out for someone else" ); |
1064 |
} |
1081 |
} |
1065 |
} |
1082 |
} |
1066 |
} |
1083 |
} |
Lines 1095-1101
sub CanBookBeIssued {
Link Here
|
1095 |
} else { |
1112 |
} else { |
1096 |
$message = "too many checkout"; |
1113 |
$message = "too many checkout"; |
1097 |
} |
1114 |
} |
1098 |
push( @message_log, "too many checkout" ); |
1115 |
push( @message, "too many checkout" ); |
1099 |
} |
1116 |
} |
1100 |
} else { |
1117 |
} else { |
1101 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
1118 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
Lines 1130-1136
sub CanBookBeIssued {
Link Here
|
1130 |
} else { |
1147 |
} else { |
1131 |
$message = "item not for loan"; |
1148 |
$message = "item not for loan"; |
1132 |
} |
1149 |
} |
1133 |
push( @message_log, "item not for loan" ); |
1150 |
push( @message, "item not for loan" ); |
1134 |
} |
1151 |
} |
1135 |
} |
1152 |
} |
1136 |
} else { |
1153 |
} else { |
Lines 1183-1189
sub CanBookBeIssued {
Link Here
|
1183 |
} else { |
1200 |
} else { |
1184 |
$message = "item lost"; |
1201 |
$message = "item lost"; |
1185 |
} |
1202 |
} |
1186 |
push( @message_log, "item lost" ); |
1203 |
push( @message, "item lost" ); |
1187 |
} |
1204 |
} |
1188 |
} |
1205 |
} |
1189 |
if ( C4::Context->preference("IndependentBranches") ) { |
1206 |
if ( C4::Context->preference("IndependentBranches") ) { |
Lines 1292-1301
sub CanBookBeIssued {
Link Here
|
1292 |
} else { |
1309 |
} else { |
1293 |
$message = "item is on reserve and waiting, but has been reserved by some other patron."; |
1310 |
$message = "item is on reserve and waiting, but has been reserved by some other patron."; |
1294 |
} |
1311 |
} |
1295 |
push( |
1312 |
push( @message, "item is on reserve and waiting, but has been reserved by some other patron" ); |
1296 |
@message_log, |
|
|
1297 |
"item is on reserve and waiting, but has been reserved by some other patron" |
1298 |
); |
1299 |
} |
1313 |
} |
1300 |
} |
1314 |
} |
1301 |
elsif ( $restype eq "Reserved" ) { |
1315 |
elsif ( $restype eq "Reserved" ) { |
Lines 1314-1320
sub CanBookBeIssued {
Link Here
|
1314 |
} else { |
1328 |
} else { |
1315 |
$message = "item is on reserve for someone else"; |
1329 |
$message = "item is on reserve for someone else"; |
1316 |
} |
1330 |
} |
1317 |
push( @message_log, "item is on reserve for someone else" ); |
1331 |
push( @message, "item is on reserve for someone else" ); |
1318 |
} |
1332 |
} |
1319 |
} |
1333 |
} |
1320 |
elsif ( $restype eq "Transferred" ) { |
1334 |
elsif ( $restype eq "Transferred" ) { |
Lines 1333-1339
sub CanBookBeIssued {
Link Here
|
1333 |
} else { |
1347 |
} else { |
1334 |
$message = "item is determined hold being transferred for someone else"; |
1348 |
$message = "item is determined hold being transferred for someone else"; |
1335 |
} |
1349 |
} |
1336 |
push( @message_log, "item is determined hold being transferred for someone else" ); |
1350 |
push( @message, "item is determined hold being transferred for someone else" ); |
1337 |
} |
1351 |
} |
1338 |
} |
1352 |
} |
1339 |
elsif ( $restype eq "Processing" ) { |
1353 |
elsif ( $restype eq "Processing" ) { |
Lines 1352-1358
sub CanBookBeIssued {
Link Here
|
1352 |
} else { |
1366 |
} else { |
1353 |
$message = "item is determined hold being processed for someone else"; |
1367 |
$message = "item is determined hold being processed for someone else"; |
1354 |
} |
1368 |
} |
1355 |
push( @message_log, "item is determined hold being processed for someone else" ); |
1369 |
push( @message, "item is determined hold being processed for someone else" ); |
1356 |
} |
1370 |
} |
1357 |
} |
1371 |
} |
1358 |
} |
1372 |
} |
Lines 1402-1408
sub CanBookBeIssued {
Link Here
|
1402 |
} else { |
1416 |
} else { |
1403 |
$message = "age restriction"; |
1417 |
$message = "age restriction"; |
1404 |
} |
1418 |
} |
1405 |
push( @message_log, "age restriction" ); |
1419 |
push( @message, "age restriction" ); |
1406 |
} |
1420 |
} |
1407 |
else { |
1421 |
else { |
1408 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
1422 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
Lines 1473-1479
sub CanBookBeIssued {
Link Here
|
1473 |
|
1487 |
|
1474 |
my $infos = ( |
1488 |
my $infos = ( |
1475 |
{ |
1489 |
{ |
1476 |
message => \@message_log, |
1490 |
message => \@message, |
1477 |
borrowernumber => $borrower->borrowernumber, |
1491 |
borrowernumber => $borrower->borrowernumber, |
1478 |
barcode => $barcode, |
1492 |
barcode => $barcode, |
1479 |
manager_id => $user, |
1493 |
manager_id => $user, |
Lines 1492-1498
sub CanBookBeIssued {
Link Here
|
1492 |
} |
1506 |
} |
1493 |
|
1507 |
|
1494 |
|
1508 |
|
1495 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, \@message_log ); |
1509 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1496 |
} |
1510 |
} |
1497 |
|
1511 |
|
1498 |
=head2 CanBookBeReturned |
1512 |
=head2 CanBookBeReturned |
Lines 2552-2560
sub AddReturn {
Link Here
|
2552 |
$messages->{'TransferArrived'} = $transfer->frombranch; |
2566 |
$messages->{'TransferArrived'} = $transfer->frombranch; |
2553 |
|
2567 |
|
2554 |
# validTransfer=1 allows us returning the item back if the reserve is cancelled |
2568 |
# validTransfer=1 allows us returning the item back if the reserve is cancelled |
2555 |
$validTransfer = 1 |
2569 |
$validTransfer = 1 if $transfer->reason eq 'Reserve'; |
2556 |
if defined $transfer->reason && $transfer->reason eq 'Reserve'; |
2570 |
} |
2557 |
} else { |
2571 |
else { |
2558 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
2572 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
2559 |
$messages->{'WrongTransferItem'} = $item->itemnumber; |
2573 |
$messages->{'WrongTransferItem'} = $item->itemnumber; |
2560 |
$messages->{'TransferTrigger'} = $transfer->reason; |
2574 |
$messages->{'TransferTrigger'} = $transfer->reason; |
Lines 3309-3315
sub CanBookBeRenewed {
Link Here
|
3309 |
|
3323 |
|
3310 |
# There is an item level hold on this item, no other item can fill the hold |
3324 |
# There is an item level hold on this item, no other item can fill the hold |
3311 |
return ( 0, "on_reserve" ) |
3325 |
return ( 0, "on_reserve" ) |
3312 |
if ( $item->current_holds->search( { non_priority => 0 } )->count ); |
3326 |
if ( $item->current_holds->search( { non_priority => 0 } )->count ); |
|
|
3327 |
|
3328 |
my $issuing_rule = Koha::CirculationRules->get_effective_rules( |
3329 |
{ |
3330 |
categorycode => $patron->categorycode, |
3331 |
itemtype => $item->effective_itemtype, |
3332 |
branchcode => $branchcode, |
3333 |
rules => [ |
3334 |
'renewalsallowed', |
3335 |
'lengthunit', |
3336 |
'unseen_renewals_allowed' |
3337 |
] |
3338 |
} |
3339 |
); |
3340 |
|
3341 |
return ( 0, "too_many" ) |
3342 |
if not $issuing_rule->{renewalsallowed} |
3343 |
or $issuing_rule->{renewalsallowed} <= $issue->renewals_count; |
3313 |
|
3344 |
|
3314 |
my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item); |
3345 |
my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item); |
3315 |
my @fillable_holds = (); |
3346 |
my @fillable_holds = (); |
Lines 3446-3453
fallback to a true value
Link Here
|
3446 |
|
3477 |
|
3447 |
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron ) |
3478 |
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron ) |
3448 |
|
3479 |
|
3449 |
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing |
3480 |
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing should be skipped for this renewal. |
3450 |
should be skipped for this renewal. |
|
|
3451 |
|
3481 |
|
3452 |
=cut |
3482 |
=cut |
3453 |
|
3483 |
|
Lines 3618-3667
sub AddRenewal {
Link Here
|
3618 |
DelUniqueDebarment( { borrowernumber => $borrowernumber, type => 'OVERDUES' } ); |
3648 |
DelUniqueDebarment( { borrowernumber => $borrowernumber, type => 'OVERDUES' } ); |
3619 |
} |
3649 |
} |
3620 |
|
3650 |
|
3621 |
# Add renewal record |
|
|
3622 |
my $renewal = Koha::Checkouts::Renewal->new( |
3623 |
{ |
3624 |
checkout_id => $issue->issue_id, |
3625 |
interface => C4::Context->interface, |
3626 |
renewal_type => $renewal_type, |
3627 |
renewer_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef, |
3628 |
seen => $seen, |
3629 |
} |
3630 |
)->store(); |
3631 |
|
3632 |
# Add the renewal to stats |
3633 |
C4::Stats::UpdateStats( |
3634 |
{ |
3635 |
branch => $item_object->renewal_branchcode( { branch => $branch } ), |
3636 |
type => 'renew', |
3637 |
amount => $charge, |
3638 |
itemnumber => $itemnumber, |
3639 |
itemtype => $itemtype, |
3640 |
location => $item_object->location, |
3641 |
borrowernumber => $borrowernumber, |
3642 |
ccode => $item_object->ccode, |
3643 |
categorycode => $patron->categorycode, |
3644 |
interface => C4::Context->interface, |
3645 |
} |
3646 |
); |
3647 |
|
3648 |
#Update borrowers.lastseen |
3649 |
$patron->update_lastseen('renewal'); |
3650 |
|
3651 |
#Log the renewal |
3652 |
logaction( "CIRCULATION", "RENEWAL", $borrowernumber, $itemnumber ) |
3653 |
if C4::Context->preference("RenewalLog"); |
3654 |
|
3655 |
Koha::Plugins->call( |
3656 |
'after_circ_action', |
3657 |
{ |
3658 |
action => 'renewal', |
3659 |
payload => { checkout => $issue->get_from_storage } |
3660 |
} |
3661 |
); |
3662 |
} |
3663 |
); |
3664 |
|
3665 |
unless ($skip_record_index) { |
3651 |
unless ($skip_record_index) { |
3666 |
|
3652 |
|
3667 |
# We index now, after the transaction is committed |
3653 |
# We index now, after the transaction is committed |