|
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 317-322
A recall for this item was found, and the item needs to be transferred to the re
Link Here
|
| 317 |
|
318 |
|
| 318 |
=cut |
319 |
=cut |
| 319 |
|
320 |
|
|
|
321 |
my $query = CGI->new; |
| 322 |
|
| 323 |
my $stickyduedate = $query->param('stickyduedate'); |
| 324 |
my $duedatespec = $query->param('duedatespec'); |
| 325 |
my $restoreduedatespec = $query->param('restoreduedatespec') || $duedatespec; |
| 326 |
if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) { |
| 327 |
undef $restoreduedatespec; |
| 328 |
} |
| 329 |
my $issueconfirmed = $query->param('issueconfirmed'); |
| 330 |
my $cancelreserve = $query->param('cancelreserve'); |
| 331 |
my $cancel_recall = $query->param('cancel_recall'); |
| 332 |
my $recall_id = $query->param('recall_id'); |
| 333 |
my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice |
| 334 |
my $charges = $query->param('charges') || q{}; |
| 335 |
|
| 320 |
sub transferbook { |
336 |
sub transferbook { |
| 321 |
my $params = shift; |
337 |
my $params = shift; |
| 322 |
my $tbr = $params->{to_branch}; |
338 |
my $tbr = $params->{to_branch}; |
|
Lines 801-809
sub CanBookBeIssued {
Link Here
|
| 801 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_object, $patron) ); |
817 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_object, $patron) ); |
| 802 |
|
818 |
|
| 803 |
my $now = dt_from_string(); |
819 |
my $now = dt_from_string(); |
|
|
820 |
my $message; |
| 821 |
my @message; |
| 822 |
|
| 804 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
823 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
|
|
824 |
|
| 805 |
if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now |
825 |
if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now |
| 806 |
$needsconfirmation{INVALID_DATE} = $duedate; |
826 |
$needsconfirmation{INVALID_DATE} = $duedate; |
|
|
827 |
if ($issueconfirmed) { |
| 828 |
if ($message ) { |
| 829 |
$message = "$message + sticky due date is invalid or due date in the past"; |
| 830 |
} else { |
| 831 |
$message = "sticky due date is invalid or due date in the past"; |
| 832 |
} |
| 833 |
push(@message, "sticky due date is invalid or due date in the past"); |
| 834 |
} |
| 835 |
|
| 807 |
} |
836 |
} |
| 808 |
|
837 |
|
| 809 |
my $fees = Koha::Charges::Fees->new( |
838 |
my $fees = Koha::Charges::Fees->new( |
|
Lines 914-923
sub CanBookBeIssued {
Link Here
|
| 914 |
else { |
943 |
else { |
| 915 |
if ( $non_issues_charges > $amountlimit && $allowfineoverride ) { |
944 |
if ( $non_issues_charges > $amountlimit && $allowfineoverride ) { |
| 916 |
$needsconfirmation{DEBT} = $non_issues_charges; |
945 |
$needsconfirmation{DEBT} = $non_issues_charges; |
|
|
946 |
if ($issueconfirmed) { |
| 947 |
if ($message) { |
| 948 |
$message = "$message + borrower had amend"; |
| 949 |
} else { |
| 950 |
$message = "borrower had amend"; |
| 951 |
} |
| 952 |
push(@message, "borrower had amend"); |
| 953 |
} |
| 917 |
} elsif ( $non_issues_charges > $amountlimit && !$allowfineoverride) { |
954 |
} elsif ( $non_issues_charges > $amountlimit && !$allowfineoverride) { |
| 918 |
$issuingimpossible{DEBT} = $non_issues_charges; |
955 |
$issuingimpossible{DEBT} = $non_issues_charges; |
| 919 |
} elsif ( $non_issues_charges > 0 && $allfinesneedoverride ) { |
956 |
} elsif ( $non_issues_charges > 0 && $allfinesneedoverride ) { |
| 920 |
$needsconfirmation{DEBT} = $non_issues_charges; |
957 |
$needsconfirmation{DEBT} = $non_issues_charges; |
|
|
958 |
if ($issueconfirmed) { |
| 959 |
if ($message) { |
| 960 |
$message = "$message + borrower had amend"; |
| 961 |
} else { |
| 962 |
$message = "borrower had amend"; |
| 963 |
} |
| 964 |
push(@message, "borrower had amend"); |
| 965 |
} |
| 921 |
} |
966 |
} |
| 922 |
} |
967 |
} |
| 923 |
|
968 |
|
|
Lines 994-1006
sub CanBookBeIssued {
Link Here
|
| 994 |
} else { |
1039 |
} else { |
| 995 |
if ( C4::Context->preference('AutoReturnCheckedOutItems') ) { |
1040 |
if ( C4::Context->preference('AutoReturnCheckedOutItems') ) { |
| 996 |
$alerts{RETURNED_FROM_ANOTHER} = { patron => $patron }; |
1041 |
$alerts{RETURNED_FROM_ANOTHER} = { patron => $patron }; |
| 997 |
} |
1042 |
} else { |
| 998 |
else { |
|
|
| 999 |
$needsconfirmation{ISSUED_TO_ANOTHER} = 1; |
1043 |
$needsconfirmation{ISSUED_TO_ANOTHER} = 1; |
| 1000 |
$needsconfirmation{issued_firstname} = $patron->firstname; |
1044 |
$needsconfirmation{issued_firstname} = $patron->firstname; |
| 1001 |
$needsconfirmation{issued_surname} = $patron->surname; |
1045 |
$needsconfirmation{issued_surname} = $patron->surname; |
| 1002 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
1046 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
| 1003 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
1047 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
|
|
1048 |
if ($issueconfirmed) { |
| 1049 |
if ($message) { |
| 1050 |
$message = "$message + item is checked out for someone else "; |
| 1051 |
} else { |
| 1052 |
$message = "item is checked out for someone else"; |
| 1053 |
} |
| 1054 |
push(@message, "item is checked out for someone else"); |
| 1055 |
} |
| 1004 |
} |
1056 |
} |
| 1005 |
} |
1057 |
} |
| 1006 |
} |
1058 |
} |
|
Lines 1024-1029
sub CanBookBeIssued {
Link Here
|
| 1024 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
1076 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
| 1025 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
1077 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
| 1026 |
$needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; |
1078 |
$needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; |
|
|
1079 |
if ($issueconfirmed) { |
| 1080 |
if ($message) { |
| 1081 |
$message = "$message + too many checkout"; |
| 1082 |
} else { |
| 1083 |
$message = "too many checkout"; |
| 1084 |
} |
| 1085 |
push(@message, "too many checkout"); |
| 1086 |
} |
| 1027 |
} else { |
1087 |
} else { |
| 1028 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
1088 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
| 1029 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
1089 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
|
Lines 1051-1056
sub CanBookBeIssued {
Link Here
|
| 1051 |
}else{ |
1111 |
}else{ |
| 1052 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
1112 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
| 1053 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
1113 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
|
|
1114 |
if ($issueconfirmed) { |
| 1115 |
if ($message) { |
| 1116 |
$message = "$message + item not for loan"; |
| 1117 |
} else { |
| 1118 |
$message = "item not for loan"; |
| 1119 |
} |
| 1120 |
push(@message, "item not for loan"); |
| 1121 |
} |
| 1054 |
} |
1122 |
} |
| 1055 |
} |
1123 |
} |
| 1056 |
else { |
1124 |
else { |
|
Lines 1097-1102
sub CanBookBeIssued {
Link Here
|
| 1097 |
my $code = $av->count ? $av->next->lib : ''; |
1165 |
my $code = $av->count ? $av->next->lib : ''; |
| 1098 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
1166 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
| 1099 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
1167 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
|
|
1168 |
if ($issueconfirmed) { |
| 1169 |
if ($message) { |
| 1170 |
$message = "$message + item lost"; |
| 1171 |
} else { |
| 1172 |
$message = "item lost"; |
| 1173 |
} |
| 1174 |
push(@message, "item lost"); |
| 1175 |
} |
| 1100 |
} |
1176 |
} |
| 1101 |
if ( C4::Context->preference("IndependentBranches") ) { |
1177 |
if ( C4::Context->preference("IndependentBranches") ) { |
| 1102 |
my $userenv = C4::Context->userenv; |
1178 |
my $userenv = C4::Context->userenv; |
|
Lines 1193-1198
sub CanBookBeIssued {
Link Here
|
| 1193 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1269 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1194 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
1270 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
| 1195 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1271 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1272 |
if ($issueconfirmed) { |
| 1273 |
if($message) { |
| 1274 |
$message = "$message + item is on reserve and waiting, but has been reserved by some other patron."; |
| 1275 |
} else { |
| 1276 |
$message = "item is on reserve and waiting, but has been reserved by some other patron."; |
| 1277 |
} |
| 1278 |
push(@message, "item is on reserve and waiting, but has been reserved by some other patron"); |
| 1279 |
} |
| 1196 |
} |
1280 |
} |
| 1197 |
elsif ( $restype eq "Reserved" ) { |
1281 |
elsif ( $restype eq "Reserved" ) { |
| 1198 |
# The item is on reserve for someone else. |
1282 |
# The item is on reserve for someone else. |
|
Lines 1204-1209
sub CanBookBeIssued {
Link Here
|
| 1204 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1288 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1205 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1289 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
| 1206 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1290 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1291 |
if ($issueconfirmed) { |
| 1292 |
if($message) { |
| 1293 |
$message = "$message + item is on reserve for someone else"; |
| 1294 |
} else { |
| 1295 |
$message = "item is on reserve for someone else"; |
| 1296 |
} |
| 1297 |
push(@message, "item is on reserve for someone else"); |
| 1298 |
} |
| 1207 |
} |
1299 |
} |
| 1208 |
elsif ( $restype eq "Transferred" ) { |
1300 |
elsif ( $restype eq "Transferred" ) { |
| 1209 |
# The item is determined hold being transferred for someone else. |
1301 |
# The item is determined hold being transferred for someone else. |
|
Lines 1215-1220
sub CanBookBeIssued {
Link Here
|
| 1215 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1307 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1216 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1308 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
| 1217 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1309 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1310 |
if ($issueconfirmed) { |
| 1311 |
if($message) { |
| 1312 |
$message = "$message + item is determined hold being transferred for someone else"; |
| 1313 |
} else { |
| 1314 |
$message = "item is determined hold being transferred for someone else"; |
| 1315 |
} |
| 1316 |
push(@message, "item is determined hold being transferred for someone else"); |
| 1317 |
} |
| 1218 |
} |
1318 |
} |
| 1219 |
elsif ( $restype eq "Processing" ) { |
1319 |
elsif ( $restype eq "Processing" ) { |
| 1220 |
# The item is determined hold being processed for someone else. |
1320 |
# The item is determined hold being processed for someone else. |
|
Lines 1226-1231
sub CanBookBeIssued {
Link Here
|
| 1226 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1326 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1227 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1327 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
| 1228 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1328 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1329 |
if ($issueconfirmed) { |
| 1330 |
if($message) { |
| 1331 |
$message = "$message + item is determined hold being processed for someone else"; |
| 1332 |
} else { |
| 1333 |
$message = "item is determined hold being processed for someone else"; |
| 1334 |
} |
| 1335 |
push(@message, "item is determined hold being processed for someone else"); |
| 1336 |
} |
| 1229 |
} |
1337 |
} |
| 1230 |
} |
1338 |
} |
| 1231 |
} |
1339 |
} |
|
Lines 1269-1274
sub CanBookBeIssued {
Link Here
|
| 1269 |
if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) { |
1377 |
if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) { |
| 1270 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1378 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
| 1271 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
1379 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
|
|
1380 |
if($message) { |
| 1381 |
$message = "$message + age restriction"; |
| 1382 |
} else { |
| 1383 |
$message = "age restriction"; |
| 1384 |
} |
| 1385 |
push(@message, "age restriction"); |
| 1272 |
} |
1386 |
} |
| 1273 |
else { |
1387 |
else { |
| 1274 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
1388 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
|
Lines 1325-1334
sub CanBookBeIssued {
Link Here
|
| 1325 |
} |
1439 |
} |
| 1326 |
} |
1440 |
} |
| 1327 |
|
1441 |
|
|
|
1442 |
my $borrower = $patron; |
| 1443 |
#my $borrowernumber = $patron->cardnumber; |
| 1444 |
my $user = C4::Context->userenv->{number}; |
| 1445 |
my $branchcode = C4::Context->userenv->{branch}; |
| 1446 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
| 1447 |
my $itemnumber = $item->itemnumber; |
| 1448 |
|
| 1449 |
# action, cardnumber, barcode, date, heure, user, branche |
| 1450 |
if ($issueconfirmed) { |
| 1451 |
|
| 1452 |
my $infos = ({ |
| 1453 |
message => \@message, |
| 1454 |
borrowernumber => $borrower->borrowernumber, |
| 1455 |
barcode => $barcode, |
| 1456 |
manager_id => $user, |
| 1457 |
branchcode => $branchcode, |
| 1458 |
}); |
| 1459 |
|
| 1460 |
my $json_infos = JSON->new->utf8->pretty->encode($infos); |
| 1461 |
$json_infos =~ s/"/'/g; |
| 1462 |
|
| 1463 |
logaction( |
| 1464 |
"CIRCULATION", "ISSUE", |
| 1465 |
$borrower->{'borrowernumber'}, |
| 1466 |
$json_infos, |
| 1467 |
) if C4::Context->preference("IssueLog"); |
| 1468 |
} |
| 1469 |
|
| 1470 |
|
| 1328 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1471 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
| 1329 |
} |
1472 |
} |
| 1330 |
|
1473 |
|
| 1331 |
=head2 CanBookBeReturned |
1474 |
=head2 CanBookBeReturnedcd |
| 1332 |
|
1475 |
|
| 1333 |
($returnallowed, $message) = CanBookBeReturned($item, $branch) |
1476 |
($returnallowed, $message) = CanBookBeReturned($item, $branch) |
| 1334 |
|
1477 |
|
|
Lines 2344-2351
sub AddReturn {
Link Here
|
| 2344 |
$transfer->receive; |
2487 |
$transfer->receive; |
| 2345 |
$messages->{'TransferArrived'} = $transfer->frombranch; |
2488 |
$messages->{'TransferArrived'} = $transfer->frombranch; |
| 2346 |
# validTransfer=1 allows us returning the item back if the reserve is cancelled |
2489 |
# validTransfer=1 allows us returning the item back if the reserve is cancelled |
| 2347 |
$validTransfer = 1 |
2490 |
$validTransfer = 1 if $transfer->reason eq 'Reserve'; |
| 2348 |
if defined $transfer->reason && $transfer->reason eq 'Reserve'; |
|
|
| 2349 |
} |
2491 |
} |
| 2350 |
else { |
2492 |
else { |
| 2351 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
2493 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
|
Lines 3181-3189
fallback to a true value
Link Here
|
| 3181 |
|
3323 |
|
| 3182 |
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron ) |
3324 |
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron ) |
| 3183 |
|
3325 |
|
| 3184 |
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing |
|
|
| 3185 |
should be skipped for this renewal. |
| 3186 |
|
| 3187 |
=cut |
3326 |
=cut |
| 3188 |
|
3327 |
|
| 3189 |
sub AddRenewal { |
3328 |
sub AddRenewal { |
|
Lines 3294-3300
sub AddRenewal {
Link Here
|
| 3294 |
$renews = ( $item_object->renewals || 0 ) + 1; |
3433 |
$renews = ( $item_object->renewals || 0 ) + 1; |
| 3295 |
$item_object->renewals($renews); |
3434 |
$item_object->renewals($renews); |
| 3296 |
$item_object->onloan($datedue); |
3435 |
$item_object->onloan($datedue); |
| 3297 |
# Don't index as we are in a transaction, skip hardcoded here |
3436 |
# Don't index as we are in a transaction |
| 3298 |
$item_object->store({ log_action => 0, skip_record_index => 1 }); |
3437 |
$item_object->store({ log_action => 0, skip_record_index => 1 }); |
| 3299 |
|
3438 |
|
| 3300 |
# Charge a new rental fee, if applicable |
3439 |
# Charge a new rental fee, if applicable |
|
Lines 3383-3394
sub AddRenewal {
Link Here
|
| 3383 |
} |
3522 |
} |
| 3384 |
}); |
3523 |
}); |
| 3385 |
}); |
3524 |
}); |
| 3386 |
|
3525 |
# We index now, after the transaction is committed |
| 3387 |
unless( $skip_record_index ){ |
3526 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
| 3388 |
# We index now, after the transaction is committed |
3527 |
$indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" ); |
| 3389 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
|
|
| 3390 |
$indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" ); |
| 3391 |
} |
| 3392 |
|
3528 |
|
| 3393 |
return $datedue; |
3529 |
return $datedue; |
| 3394 |
} |
3530 |
} |