|
Lines 22-32
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 ); |
| 28 |
use C4::Reserves |
29 |
use C4::Reserves |
| 29 |
qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority RevertWaitingStatus IsAvailableForItemLevelRequest ); |
30 |
qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority RevertWaitingStatus IsItemOnHoldAndFound IsAvailableForItemLevelRequest ); |
| 30 |
use C4::Biblio qw( UpdateTotalIssues ); |
31 |
use C4::Biblio qw( UpdateTotalIssues ); |
| 31 |
use C4::Items qw( ModItemTransfer ModDateLastSeen CartToShelf ); |
32 |
use C4::Items qw( ModItemTransfer ModDateLastSeen CartToShelf ); |
| 32 |
use C4::Accounts; |
33 |
use C4::Accounts; |
|
Lines 109-114
BEGIN {
Link Here
|
| 109 |
transferbook |
110 |
transferbook |
| 110 |
TooMany |
111 |
TooMany |
| 111 |
GetTransfersFromTo |
112 |
GetTransfersFromTo |
|
|
113 |
updateWrongTransfer |
| 112 |
CalcDateDue |
114 |
CalcDateDue |
| 113 |
CheckValidBarcode |
115 |
CheckValidBarcode |
| 114 |
IsBranchTransferAllowed |
116 |
IsBranchTransferAllowed |
|
Lines 319-324
A recall for this item was found, and the item needs to be transferred to the re
Link Here
|
| 319 |
|
321 |
|
| 320 |
=cut |
322 |
=cut |
| 321 |
|
323 |
|
|
|
324 |
my $query = CGI->new; |
| 325 |
|
| 326 |
my $stickyduedate = $query->param('stickyduedate'); |
| 327 |
my $duedatespec = $query->param('duedatespec'); |
| 328 |
my $restoreduedatespec = $query->param('restoreduedatespec') || $duedatespec; |
| 329 |
if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) { |
| 330 |
undef $restoreduedatespec; |
| 331 |
} |
| 332 |
my $issueconfirmed = $query->param('issueconfirmed'); |
| 333 |
my $cancelreserve = $query->param('cancelreserve'); |
| 334 |
my $cancel_recall = $query->param('cancel_recall'); |
| 335 |
my $recall_id = $query->param('recall_id'); |
| 336 |
my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice |
| 337 |
my $charges = $query->param('charges') || q{}; |
| 338 |
|
| 322 |
sub transferbook { |
339 |
sub transferbook { |
| 323 |
my $params = shift; |
340 |
my $params = shift; |
| 324 |
my $tbr = $params->{to_branch}; |
341 |
my $tbr = $params->{to_branch}; |
|
Lines 816-824
sub CanBookBeIssued {
Link Here
|
| 816 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
833 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
| 817 |
|
834 |
|
| 818 |
my $now = dt_from_string(); |
835 |
my $now = dt_from_string(); |
|
|
836 |
my $message; |
| 837 |
my @message; |
| 838 |
|
| 819 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
839 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
|
|
840 |
|
| 820 |
if ( DateTime->compare( $duedate, $now ) == -1 ) { # duedate cannot be before now |
841 |
if ( DateTime->compare( $duedate, $now ) == -1 ) { # duedate cannot be before now |
| 821 |
$needsconfirmation{INVALID_DATE} = $duedate; |
842 |
$needsconfirmation{INVALID_DATE} = $duedate; |
|
|
843 |
if ($issueconfirmed) { |
| 844 |
if ($message) { |
| 845 |
$message = "$message + sticky due date is invalid or due date in the past"; |
| 846 |
} else { |
| 847 |
$message = "sticky due date is invalid or due date in the past"; |
| 848 |
} |
| 849 |
push( @message, "sticky due date is invalid or due date in the past" ); |
| 850 |
} |
| 851 |
|
| 822 |
} |
852 |
} |
| 823 |
|
853 |
|
| 824 |
my $fees = Koha::Charges::Fees->new( |
854 |
my $fees = Koha::Charges::Fees->new( |
|
Lines 864-869
sub CanBookBeIssued {
Link Here
|
| 864 |
} |
894 |
} |
| 865 |
if ( $patron->is_debarred ) { |
895 |
if ( $patron->is_debarred ) { |
| 866 |
$issuingimpossible{DEBARRED} = 1; |
896 |
$issuingimpossible{DEBARRED} = 1; |
|
|
897 |
if ($issueconfirmed) { |
| 898 |
if ($message) { |
| 899 |
$message = "$message + borrower is restricted"; |
| 900 |
} else { |
| 901 |
$message = "borrower is restricted"; |
| 902 |
} |
| 903 |
push( @message, "borrower is restricted" ); |
| 904 |
} |
| 867 |
} |
905 |
} |
| 868 |
|
906 |
|
| 869 |
if ( $patron->is_expired ) { |
907 |
if ( $patron->is_expired ) { |
|
Lines 936-945
sub CanBookBeIssued {
Link Here
|
| 936 |
} else { |
974 |
} else { |
| 937 |
if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) { |
975 |
if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) { |
| 938 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
976 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
|
|
977 |
if ($issueconfirmed) { |
| 978 |
if ($message) { |
| 979 |
$message = "$message + borrower had amend"; |
| 980 |
} else { |
| 981 |
$message = "borrower had amend"; |
| 982 |
} |
| 983 |
push( @message, "borrower had amend" ); |
| 984 |
} |
| 939 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) { |
985 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) { |
| 940 |
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
986 |
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
| 941 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) { |
987 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) { |
| 942 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
988 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
|
|
989 |
if ($issueconfirmed) { |
| 990 |
if ($message) { |
| 991 |
$message = "$message + borrower had amend"; |
| 992 |
} else { |
| 993 |
$message = "borrower had amend"; |
| 994 |
} |
| 995 |
push( @message, "borrower had amend" ); |
| 996 |
} |
| 943 |
} |
997 |
} |
| 944 |
} |
998 |
} |
| 945 |
|
999 |
|
|
Lines 1020-1025
sub CanBookBeIssued {
Link Here
|
| 1020 |
$needsconfirmation{issued_surname} = $patron->surname; |
1074 |
$needsconfirmation{issued_surname} = $patron->surname; |
| 1021 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
1075 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
| 1022 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
1076 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
|
|
1077 |
if ($issueconfirmed) { |
| 1078 |
if ($message) { |
| 1079 |
$message = "$message + item is checked out for someone else "; |
| 1080 |
} else { |
| 1081 |
$message = "item is checked out for someone else"; |
| 1082 |
} |
| 1083 |
push( @message, "item is checked out for someone else" ); |
| 1084 |
} |
| 1023 |
} |
1085 |
} |
| 1024 |
} |
1086 |
} |
| 1025 |
} |
1087 |
} |
|
Lines 1047-1052
sub CanBookBeIssued {
Link Here
|
| 1047 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
1109 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
| 1048 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
1110 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
| 1049 |
$needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; |
1111 |
$needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; |
|
|
1112 |
if ($issueconfirmed) { |
| 1113 |
if ($message) { |
| 1114 |
$message = "$message + too many checkout"; |
| 1115 |
} else { |
| 1116 |
$message = "too many checkout"; |
| 1117 |
} |
| 1118 |
push( @message, "too many checkout" ); |
| 1119 |
} |
| 1050 |
} else { |
1120 |
} else { |
| 1051 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
1121 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
| 1052 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
1122 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
|
Lines 1074-1079
sub CanBookBeIssued {
Link Here
|
| 1074 |
} else { |
1144 |
} else { |
| 1075 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
1145 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
| 1076 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
1146 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
|
|
1147 |
if ($issueconfirmed) { |
| 1148 |
if ($message) { |
| 1149 |
$message = "$message + item not for loan"; |
| 1150 |
} else { |
| 1151 |
$message = "item not for loan"; |
| 1152 |
} |
| 1153 |
push( @message, "item not for loan" ); |
| 1154 |
} |
| 1077 |
} |
1155 |
} |
| 1078 |
} else { |
1156 |
} else { |
| 1079 |
|
1157 |
|
|
Lines 1119-1124
sub CanBookBeIssued {
Link Here
|
| 1119 |
my $code = $av->count ? $av->next->lib : ''; |
1197 |
my $code = $av->count ? $av->next->lib : ''; |
| 1120 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
1198 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
| 1121 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
1199 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
|
|
1200 |
if ($issueconfirmed) { |
| 1201 |
if ($message) { |
| 1202 |
$message = "$message + item lost"; |
| 1203 |
} else { |
| 1204 |
$message = "item lost"; |
| 1205 |
} |
| 1206 |
push( @message, "item lost" ); |
| 1207 |
} |
| 1122 |
} |
1208 |
} |
| 1123 |
if ( C4::Context->preference("IndependentBranches") ) { |
1209 |
if ( C4::Context->preference("IndependentBranches") ) { |
| 1124 |
my $userenv = C4::Context->userenv; |
1210 |
my $userenv = C4::Context->userenv; |
|
Lines 1219-1224
sub CanBookBeIssued {
Link Here
|
| 1219 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1305 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1220 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
1306 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
| 1221 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1307 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1308 |
|
| 1309 |
if ($issueconfirmed) { |
| 1310 |
if ($message) { |
| 1311 |
$message = |
| 1312 |
"$message + item is on reserve and waiting, but has been reserved by some other patron."; |
| 1313 |
} else { |
| 1314 |
$message = "item is on reserve and waiting, but has been reserved by some other patron."; |
| 1315 |
} |
| 1316 |
push( @message, "item is on reserve and waiting, but has been reserved by some other patron" ); |
| 1317 |
} |
| 1222 |
} elsif ( $restype eq "Reserved" ) { |
1318 |
} elsif ( $restype eq "Reserved" ) { |
| 1223 |
|
1319 |
|
| 1224 |
# The item is on reserve for someone else. |
1320 |
# The item is on reserve for someone else. |
|
Lines 1230-1235
sub CanBookBeIssued {
Link Here
|
| 1230 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1326 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1231 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1327 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
| 1232 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1328 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1329 |
|
| 1330 |
if ($issueconfirmed) { |
| 1331 |
if ($message) { |
| 1332 |
$message = "$message + item is on reserve for someone else"; |
| 1333 |
} else { |
| 1334 |
$message = "item is on reserve for someone else"; |
| 1335 |
} |
| 1336 |
push( @message, "item is on reserve for someone else" ); |
| 1337 |
} |
| 1233 |
} elsif ( $restype eq "Transferred" ) { |
1338 |
} elsif ( $restype eq "Transferred" ) { |
| 1234 |
|
1339 |
|
| 1235 |
# The item is determined hold being transferred for someone else. |
1340 |
# The item is determined hold being transferred for someone else. |
|
Lines 1241-1246
sub CanBookBeIssued {
Link Here
|
| 1241 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1346 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1242 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1347 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
| 1243 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1348 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1349 |
|
| 1350 |
if ($issueconfirmed) { |
| 1351 |
if ($message) { |
| 1352 |
$message = "$message + item is determined hold being transferred for someone else"; |
| 1353 |
} else { |
| 1354 |
$message = "item is determined hold being transferred for someone else"; |
| 1355 |
} |
| 1356 |
push( @message, "item is determined hold being transferred for someone else" ); |
| 1357 |
} |
| 1244 |
} elsif ( $restype eq "Processing" ) { |
1358 |
} elsif ( $restype eq "Processing" ) { |
| 1245 |
|
1359 |
|
| 1246 |
# The item is determined hold being processed for someone else. |
1360 |
# The item is determined hold being processed for someone else. |
|
Lines 1252-1257
sub CanBookBeIssued {
Link Here
|
| 1252 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1366 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1253 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1367 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
| 1254 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1368 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1369 |
|
| 1370 |
if ($issueconfirmed) { |
| 1371 |
if ($message) { |
| 1372 |
$message = "$message + item is determined hold being processed for someone else"; |
| 1373 |
} else { |
| 1374 |
$message = "item is determined hold being processed for someone else"; |
| 1375 |
} |
| 1376 |
push( @message, "item is determined hold being processed for someone else" ); |
| 1377 |
} |
| 1255 |
} |
1378 |
} |
| 1256 |
} |
1379 |
} |
| 1257 |
} |
1380 |
} |
|
Lines 1295-1300
sub CanBookBeIssued {
Link Here
|
| 1295 |
if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) { |
1418 |
if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) { |
| 1296 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1419 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
| 1297 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
1420 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
|
|
1421 |
if ($message) { |
| 1422 |
$message = "$message + age restriction"; |
| 1423 |
} else { |
| 1424 |
$message = "age restriction"; |
| 1425 |
} |
| 1426 |
push( @message, "age restriction" ); |
| 1298 |
} else { |
1427 |
} else { |
| 1299 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
1428 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
| 1300 |
} |
1429 |
} |
|
Lines 1353-1358
sub CanBookBeIssued {
Link Here
|
| 1353 |
} |
1482 |
} |
| 1354 |
} |
1483 |
} |
| 1355 |
|
1484 |
|
|
|
1485 |
my $borrower = $patron; |
| 1486 |
my $user = C4::Context->userenv->{number}; |
| 1487 |
my $branchcode = C4::Context->userenv->{branch}; |
| 1488 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
| 1489 |
my $itemnumber = $item->itemnumber; |
| 1490 |
|
| 1491 |
# action, cardnumber, barcode, date, heure, user, branche |
| 1492 |
if ($issueconfirmed) { |
| 1493 |
|
| 1494 |
my $infos = ( |
| 1495 |
{ |
| 1496 |
message => \@message, |
| 1497 |
borrowernumber => $borrower->borrowernumber, |
| 1498 |
barcode => $barcode, |
| 1499 |
manager_id => $user, |
| 1500 |
branchcode => $branchcode, |
| 1501 |
} |
| 1502 |
); |
| 1503 |
|
| 1504 |
my $json_infos = JSON->new->utf8->pretty->encode($infos); |
| 1505 |
$json_infos =~ s/"/'/g; |
| 1506 |
|
| 1507 |
logaction( |
| 1508 |
"CIRCULATION", "ISSUE", |
| 1509 |
$borrower->{'borrowernumber'}, |
| 1510 |
$json_infos, |
| 1511 |
) if C4::Context->preference("IssueLog"); |
| 1512 |
} |
| 1513 |
|
| 1356 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1514 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
| 1357 |
} |
1515 |
} |
| 1358 |
|
1516 |
|
|
Lines 2371-2378
sub AddReturn {
Link Here
|
| 2371 |
if $message->message eq 'processing_refunded'; |
2529 |
if $message->message eq 'processing_refunded'; |
| 2372 |
$messages->{'LostItemFeeRestored'} = 1 |
2530 |
$messages->{'LostItemFeeRestored'} = 1 |
| 2373 |
if $message->message eq 'lost_restored'; |
2531 |
if $message->message eq 'lost_restored'; |
| 2374 |
$messages->{'LostItemPaymentNotRefunded'} = 1 |
|
|
| 2375 |
if $message->message eq 'payment_not_refunded'; |
| 2376 |
|
2532 |
|
| 2377 |
if ( $message->message eq 'lost_charge' ) { |
2533 |
if ( $message->message eq 'lost_charge' ) { |
| 2378 |
$issue //= Koha::Old::Checkouts->search( |
2534 |
$issue //= Koha::Old::Checkouts->search( |
|
Lines 2413-2420
sub AddReturn {
Link Here
|
| 2413 |
$messages->{'TransferArrived'} = $transfer->frombranch; |
2569 |
$messages->{'TransferArrived'} = $transfer->frombranch; |
| 2414 |
|
2570 |
|
| 2415 |
# validTransfer=1 allows us returning the item back if the reserve is cancelled |
2571 |
# validTransfer=1 allows us returning the item back if the reserve is cancelled |
| 2416 |
$validTransfer = 1 |
2572 |
$validTransfer = 1 if $transfer->reason eq 'Reserve'; |
| 2417 |
if defined $transfer->reason && $transfer->reason eq 'Reserve'; |
|
|
| 2418 |
} else { |
2573 |
} else { |
| 2419 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
2574 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
| 2420 |
$messages->{'WrongTransferItem'} = $item->itemnumber; |
2575 |
$messages->{'WrongTransferItem'} = $item->itemnumber; |
|
Lines 2430-2437
sub AddReturn {
Link Here
|
| 2430 |
} else { |
2585 |
} else { |
| 2431 |
$messages->{'TransferTrigger'} = $transfer->reason; |
2586 |
$messages->{'TransferTrigger'} = $transfer->reason; |
| 2432 |
if ( $transfer->frombranch eq $branch ) { |
2587 |
if ( $transfer->frombranch eq $branch ) { |
| 2433 |
$messages->{'TransferTo'} = $transfer->tobranch; |
2588 |
$transfer->transit; |
| 2434 |
$messages->{'WasTransfered'} = $transfer->id; |
2589 |
$messages->{'WasTransfered'} = $transfer->tobranch; |
| 2435 |
} else { |
2590 |
} else { |
| 2436 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
2591 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
| 2437 |
$messages->{'WrongTransferItem'} = $item->itemnumber; |
2592 |
$messages->{'WrongTransferItem'} = $item->itemnumber; |
|
Lines 2532-2538
sub AddReturn {
Link Here
|
| 2532 |
categorycode => $categorycode, |
2687 |
categorycode => $categorycode, |
| 2533 |
interface => C4::Context->interface, |
2688 |
interface => C4::Context->interface, |
| 2534 |
} |
2689 |
} |
| 2535 |
) unless ( $skip_localuse && !$issue ); |
2690 |
) unless ( $skip_localuse && $stat_type eq 'localuse' ); |
| 2536 |
|
2691 |
|
| 2537 |
# Send a check-in slip. # NOTE: borrower may be undef. Do not try to send messages then. |
2692 |
# Send a check-in slip. # NOTE: borrower may be undef. Do not try to send messages then. |
| 2538 |
if ($patron) { |
2693 |
if ($patron) { |
|
Lines 2601-2612
sub AddReturn {
Link Here
|
| 2601 |
and !IsBranchTransferAllowed( $branch, $returnbranch, $item->$BranchTransferLimitsType ) ) |
2756 |
and !IsBranchTransferAllowed( $branch, $returnbranch, $item->$BranchTransferLimitsType ) ) |
| 2602 |
) |
2757 |
) |
| 2603 |
{ |
2758 |
{ |
| 2604 |
my $transfer = ModItemTransfer( |
2759 |
ModItemTransfer( $item->itemnumber, $branch, $returnbranch, $transfer_trigger, { skip_record_index => 1 } ); |
| 2605 |
$item->itemnumber, $branch, $returnbranch, $transfer_trigger, |
2760 |
$messages->{'WasTransfered'} = $returnbranch; |
| 2606 |
{ skip_record_index => 1 } |
|
|
| 2607 |
); |
| 2608 |
$messages->{'TransferTo'} = $returnbranch; |
| 2609 |
$messages->{'WasTransfered'} = $transfer->id; |
| 2610 |
$messages->{'TransferTrigger'} = $transfer_trigger; |
2761 |
$messages->{'TransferTrigger'} = $transfer_trigger; |
| 2611 |
} else { |
2762 |
} else { |
| 2612 |
$messages->{'NeedsTransfer'} = $returnbranch; |
2763 |
$messages->{'NeedsTransfer'} = $returnbranch; |
|
Lines 2719-2733
sub MarkIssueReturned {
Link Here
|
| 2719 |
$issue->returndate( \'NOW()' )->store->discard_changes; # update and refetch |
2870 |
$issue->returndate( \'NOW()' )->store->discard_changes; # update and refetch |
| 2720 |
} |
2871 |
} |
| 2721 |
|
2872 |
|
| 2722 |
$issue->checkin_library( C4::Context->userenv->{'branch'} ); |
|
|
| 2723 |
|
| 2724 |
# Create the old_issues entry |
2873 |
# Create the old_issues entry |
| 2725 |
my $old_checkout = Koha::Old::Checkout->new( $issue->unblessed )->store; |
2874 |
my $old_checkout = Koha::Old::Checkout->new( $issue->unblessed )->store; |
| 2726 |
|
2875 |
|
| 2727 |
# Update accountlines |
|
|
| 2728 |
my $accountlines = Koha::Account::Lines->search( { issue_id => $issue->issue_id } ); |
| 2729 |
$accountlines->update( { old_issue_id => $issue->issue_id, issue_id => undef } ); |
| 2730 |
|
| 2731 |
# anonymise patron checkout immediately if $privacy set to 2 and AnonymousPatron is set to a valid borrowernumber |
2876 |
# anonymise patron checkout immediately if $privacy set to 2 and AnonymousPatron is set to a valid borrowernumber |
| 2732 |
if ( $privacy && $privacy == 2 ) { |
2877 |
if ( $privacy && $privacy == 2 ) { |
| 2733 |
$old_checkout->anonymize; |
2878 |
$old_checkout->anonymize; |
|
Lines 3172-3177
sub CanBookBeRenewed {
Link Here
|
| 3172 |
return ( 0, "on_reserve" ) |
3317 |
return ( 0, "on_reserve" ) |
| 3173 |
if ( $item->current_holds->search( { non_priority => 0 } )->count ); |
3318 |
if ( $item->current_holds->search( { non_priority => 0 } )->count ); |
| 3174 |
|
3319 |
|
|
|
3320 |
my $issuing_rule = Koha::CirculationRules->get_effective_rules( |
| 3321 |
{ |
| 3322 |
categorycode => $patron->categorycode, |
| 3323 |
itemtype => $item->effective_itemtype, |
| 3324 |
branchcode => $branchcode, |
| 3325 |
rules => [ |
| 3326 |
'renewalsallowed', |
| 3327 |
'lengthunit', |
| 3328 |
'unseen_renewals_allowed' |
| 3329 |
] |
| 3330 |
} |
| 3331 |
); |
| 3332 |
|
| 3333 |
return ( 0, "too_many" ) |
| 3334 |
if not $issuing_rule->{renewalsallowed} |
| 3335 |
or $issuing_rule->{renewalsallowed} <= $issue->renewals_count; |
| 3336 |
|
| 3175 |
my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item); |
3337 |
my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item); |
| 3176 |
my @fillable_holds = (); |
3338 |
my @fillable_holds = (); |
| 3177 |
foreach my $possible_hold ( @{$possible_holds} ) { |
3339 |
foreach my $possible_hold ( @{$possible_holds} ) { |
|
Lines 3200-3206
sub CanBookBeRenewed {
Link Here
|
| 3200 |
|
3362 |
|
| 3201 |
foreach my $other_item (@other_items) { |
3363 |
foreach my $other_item (@other_items) { |
| 3202 |
next if defined $matched_items{ $other_item->itemnumber }; |
3364 |
next if defined $matched_items{ $other_item->itemnumber }; |
| 3203 |
next if $other_item->holds->filter_by_found->count; |
3365 |
next if IsItemOnHoldAndFound( $other_item->itemnumber ); |
| 3204 |
next unless IsAvailableForItemLevelRequest( $other_item, $patron_with_reserve, undef ); |
3366 |
next unless IsAvailableForItemLevelRequest( $other_item, $patron_with_reserve, undef ); |
| 3205 |
next |
3367 |
next |
| 3206 |
unless CanItemBeReserved( |
3368 |
unless CanItemBeReserved( |
|
Lines 3307-3314
fallback to a true value
Link Here
|
| 3307 |
|
3469 |
|
| 3308 |
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron ) |
3470 |
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron ) |
| 3309 |
|
3471 |
|
| 3310 |
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing |
3472 |
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing should be skipped for this renewal. |
| 3311 |
should be skipped for this renewal. |
|
|
| 3312 |
|
3473 |
|
| 3313 |
=cut |
3474 |
=cut |
| 3314 |
|
3475 |
|
|
Lines 3957-3962
sub SendCirculationAlert {
Link Here
|
| 3957 |
return; |
4118 |
return; |
| 3958 |
} |
4119 |
} |
| 3959 |
|
4120 |
|
|
|
4121 |
=head2 updateWrongTransfer |
| 4122 |
|
| 4123 |
$items = updateWrongTransfer($itemNumber,$borrowernumber,$waitingAtLibrary,$FromLibrary); |
| 4124 |
|
| 4125 |
This function validate the line of brachtransfer but with the wrong destination (mistake from a librarian ...), and create a new line in branchtransfer from the actual library to the original library of reservation |
| 4126 |
|
| 4127 |
=cut |
| 4128 |
|
| 4129 |
sub updateWrongTransfer { |
| 4130 |
my ( $itemNumber, $waitingAtLibrary, $FromLibrary ) = @_; |
| 4131 |
|
| 4132 |
# first step: cancel the original transfer |
| 4133 |
my $item = Koha::Items->find($itemNumber); |
| 4134 |
my $transfer = $item->get_transfer; |
| 4135 |
$transfer->set( { datecancelled => dt_from_string, cancellation_reason => 'WrongTransfer' } )->store(); |
| 4136 |
|
| 4137 |
# second step: create a new transfer to the right location |
| 4138 |
my $new_transfer = $item->request_transfer( |
| 4139 |
{ |
| 4140 |
to => $transfer->to_library, |
| 4141 |
reason => $transfer->reason, |
| 4142 |
comment => $transfer->comments, |
| 4143 |
ignore_limits => 1, |
| 4144 |
enqueue => 1 |
| 4145 |
} |
| 4146 |
); |
| 4147 |
|
| 4148 |
return $new_transfer; |
| 4149 |
} |
| 4150 |
|
| 3960 |
=head2 CalcDateDue |
4151 |
=head2 CalcDateDue |
| 3961 |
|
4152 |
|
| 3962 |
$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower); |
4153 |
$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower); |