|
Lines 792-797
sub CanBookBeIssued {
Link Here
|
| 792 |
|
792 |
|
| 793 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
793 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
| 794 |
my $override_high_holds = $params->{override_high_holds} || 0; |
794 |
my $override_high_holds = $params->{override_high_holds} || 0; |
|
|
795 |
my $issueconfirmed = $params->{issueconfirmed} || 0; |
| 795 |
|
796 |
|
| 796 |
my $item_object = !$barcode ? undef : $params->{item} // Koha::Items->find( { barcode => $barcode } ); |
797 |
my $item_object = !$barcode ? undef : $params->{item} // Koha::Items->find( { barcode => $barcode } ); |
| 797 |
|
798 |
|
|
Lines 813-821
sub CanBookBeIssued {
Link Here
|
| 813 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
814 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
| 814 |
|
815 |
|
| 815 |
my $now = dt_from_string(); |
816 |
my $now = dt_from_string(); |
|
|
817 |
my $message; |
| 818 |
my @message_log; |
| 819 |
|
| 816 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
820 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
| 817 |
if ( DateTime->compare( $duedate, $now ) == -1 ) { # duedate cannot be before now |
821 |
if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now |
| 818 |
$needsconfirmation{INVALID_DATE} = $duedate; |
822 |
$needsconfirmation{INVALID_DATE} = $duedate; |
|
|
823 |
if ($issueconfirmed) { |
| 824 |
if ($message) { |
| 825 |
$message = "$message + sticky due date is invalid or due date in the past"; |
| 826 |
} else { |
| 827 |
$message = "sticky due date is invalid or due date in the past"; |
| 828 |
} |
| 829 |
push( @message_log, "sticky due date is invalid or due date in the past" ); |
| 830 |
} |
| 831 |
|
| 819 |
} |
832 |
} |
| 820 |
|
833 |
|
| 821 |
my $fees = Koha::Charges::Fees->new( |
834 |
my $fees = Koha::Charges::Fees->new( |
|
Lines 861-866
sub CanBookBeIssued {
Link Here
|
| 861 |
} |
874 |
} |
| 862 |
if ( $patron->is_debarred ) { |
875 |
if ( $patron->is_debarred ) { |
| 863 |
$issuingimpossible{DEBARRED} = 1; |
876 |
$issuingimpossible{DEBARRED} = 1; |
|
|
877 |
if ($issueconfirmed) { |
| 878 |
if ($message) { |
| 879 |
$message = "$message + borrower is restricted"; |
| 880 |
} else { |
| 881 |
$message = "borrower is restricted"; |
| 882 |
} |
| 883 |
push( @message_log, "borrower is restricted" ); |
| 884 |
} |
| 864 |
} |
885 |
} |
| 865 |
|
886 |
|
| 866 |
if ( $patron->is_expired ) { |
887 |
if ( $patron->is_expired ) { |
|
Lines 933-942
sub CanBookBeIssued {
Link Here
|
| 933 |
} else { |
954 |
} else { |
| 934 |
if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) { |
955 |
if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) { |
| 935 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
956 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
|
|
957 |
if ($issueconfirmed) { |
| 958 |
if ($message) { |
| 959 |
$message = "$message + borrower had amend"; |
| 960 |
} else { |
| 961 |
$message = "borrower had amend"; |
| 962 |
} |
| 963 |
push( @message_log, "borrower had amend" ); |
| 964 |
} |
| 936 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) { |
965 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) { |
| 937 |
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
966 |
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
| 938 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) { |
967 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) { |
| 939 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
968 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
|
|
969 |
if ($issueconfirmed) { |
| 970 |
if ($message) { |
| 971 |
$message = "$message + borrower had amend"; |
| 972 |
} else { |
| 973 |
$message = "borrower had amend"; |
| 974 |
} |
| 975 |
push( @message_log, "borrower had amend" ); |
| 976 |
} |
| 940 |
} |
977 |
} |
| 941 |
} |
978 |
} |
| 942 |
|
979 |
|
|
Lines 1017-1022
sub CanBookBeIssued {
Link Here
|
| 1017 |
$needsconfirmation{issued_surname} = $patron->surname; |
1054 |
$needsconfirmation{issued_surname} = $patron->surname; |
| 1018 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
1055 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
| 1019 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
1056 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
|
|
1057 |
if ($issueconfirmed) { |
| 1058 |
if ($message) { |
| 1059 |
$message = "$message + item is checked out for someone else "; |
| 1060 |
} else { |
| 1061 |
$message = "item is checked out for someone else"; |
| 1062 |
} |
| 1063 |
push( @message_log, "item is checked out for someone else" ); |
| 1064 |
} |
| 1020 |
} |
1065 |
} |
| 1021 |
} |
1066 |
} |
| 1022 |
} |
1067 |
} |
|
Lines 1044-1049
sub CanBookBeIssued {
Link Here
|
| 1044 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
1089 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
| 1045 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
1090 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
| 1046 |
$needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; |
1091 |
$needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; |
|
|
1092 |
if ($issueconfirmed) { |
| 1093 |
if ($message) { |
| 1094 |
$message = "$message + too many checkout"; |
| 1095 |
} else { |
| 1096 |
$message = "too many checkout"; |
| 1097 |
} |
| 1098 |
push( @message_log, "too many checkout" ); |
| 1099 |
} |
| 1047 |
} else { |
1100 |
} else { |
| 1048 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
1101 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
| 1049 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
1102 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
|
Lines 1070-1076
sub CanBookBeIssued {
Link Here
|
| 1070 |
$issuingimpossible{item_notforloan} = $item_object->notforloan; |
1123 |
$issuingimpossible{item_notforloan} = $item_object->notforloan; |
| 1071 |
} else { |
1124 |
} else { |
| 1072 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
1125 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
| 1073 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
1126 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
|
|
1127 |
if ($issueconfirmed) { |
| 1128 |
if ($message) { |
| 1129 |
$message = "$message + item not for loan"; |
| 1130 |
} else { |
| 1131 |
$message = "item not for loan"; |
| 1132 |
} |
| 1133 |
push( @message_log, "item not for loan" ); |
| 1134 |
} |
| 1074 |
} |
1135 |
} |
| 1075 |
} else { |
1136 |
} else { |
| 1076 |
|
1137 |
|
|
Lines 1115-1121
sub CanBookBeIssued {
Link Here
|
| 1115 |
my $av = Koha::AuthorisedValues->search( { category => 'LOST', authorised_value => $item_object->itemlost } ); |
1176 |
my $av = Koha::AuthorisedValues->search( { category => 'LOST', authorised_value => $item_object->itemlost } ); |
| 1116 |
my $code = $av->count ? $av->next->lib : ''; |
1177 |
my $code = $av->count ? $av->next->lib : ''; |
| 1117 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
1178 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
| 1118 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
1179 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
|
|
1180 |
if ($issueconfirmed) { |
| 1181 |
if ($message) { |
| 1182 |
$message = "$message + item lost"; |
| 1183 |
} else { |
| 1184 |
$message = "item lost"; |
| 1185 |
} |
| 1186 |
push( @message_log, "item lost" ); |
| 1187 |
} |
| 1119 |
} |
1188 |
} |
| 1120 |
if ( C4::Context->preference("IndependentBranches") ) { |
1189 |
if ( C4::Context->preference("IndependentBranches") ) { |
| 1121 |
my $userenv = C4::Context->userenv; |
1190 |
my $userenv = C4::Context->userenv; |
|
Lines 1213-1254
sub CanBookBeIssued {
Link Here
|
| 1213 |
$needsconfirmation{'ressurname'} = $patron->surname; |
1282 |
$needsconfirmation{'ressurname'} = $patron->surname; |
| 1214 |
$needsconfirmation{'rescardnumber'} = $patron->cardnumber; |
1283 |
$needsconfirmation{'rescardnumber'} = $patron->cardnumber; |
| 1215 |
$needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; |
1284 |
$needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; |
| 1216 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1285 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1217 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
1286 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
| 1218 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1287 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
| 1219 |
} elsif ( $restype eq "Reserved" ) { |
1288 |
if ($issueconfirmed) { |
| 1220 |
|
1289 |
if ($message) { |
|
|
1290 |
$message = |
| 1291 |
"$message + item is on reserve and waiting, but has been reserved by some other patron."; |
| 1292 |
} else { |
| 1293 |
$message = "item is on reserve and waiting, but has been reserved by some other patron."; |
| 1294 |
} |
| 1295 |
push( |
| 1296 |
@message_log, |
| 1297 |
"item is on reserve and waiting, but has been reserved by some other patron" |
| 1298 |
); |
| 1299 |
} |
| 1300 |
} |
| 1301 |
elsif ( $restype eq "Reserved" ) { |
| 1221 |
# The item is on reserve for someone else. |
1302 |
# The item is on reserve for someone else. |
| 1222 |
$needsconfirmation{RESERVED} = 1; |
1303 |
$needsconfirmation{RESERVED} = 1; |
| 1223 |
$needsconfirmation{'resfirstname'} = $patron->firstname; |
1304 |
$needsconfirmation{'resfirstname'} = $patron->firstname; |
| 1224 |
$needsconfirmation{'ressurname'} = $patron->surname; |
1305 |
$needsconfirmation{'ressurname'} = $patron->surname; |
| 1225 |
$needsconfirmation{'rescardnumber'} = $patron->cardnumber; |
1306 |
$needsconfirmation{'rescardnumber'} = $patron->cardnumber; |
| 1226 |
$needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; |
1307 |
$needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; |
| 1227 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1308 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1228 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1309 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
| 1229 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1310 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
| 1230 |
} elsif ( $restype eq "Transferred" ) { |
1311 |
if ($issueconfirmed) { |
| 1231 |
|
1312 |
if ($message) { |
|
|
1313 |
$message = "$message + item is on reserve for someone else"; |
| 1314 |
} else { |
| 1315 |
$message = "item is on reserve for someone else"; |
| 1316 |
} |
| 1317 |
push( @message_log, "item is on reserve for someone else" ); |
| 1318 |
} |
| 1319 |
} |
| 1320 |
elsif ( $restype eq "Transferred" ) { |
| 1232 |
# The item is determined hold being transferred for someone else. |
1321 |
# The item is determined hold being transferred for someone else. |
| 1233 |
$needsconfirmation{TRANSFERRED} = 1; |
1322 |
$needsconfirmation{TRANSFERRED} = 1; |
| 1234 |
$needsconfirmation{'resfirstname'} = $patron->firstname; |
1323 |
$needsconfirmation{'resfirstname'} = $patron->firstname; |
| 1235 |
$needsconfirmation{'ressurname'} = $patron->surname; |
1324 |
$needsconfirmation{'ressurname'} = $patron->surname; |
| 1236 |
$needsconfirmation{'rescardnumber'} = $patron->cardnumber; |
1325 |
$needsconfirmation{'rescardnumber'} = $patron->cardnumber; |
| 1237 |
$needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; |
1326 |
$needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; |
| 1238 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1327 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1239 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1328 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
| 1240 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1329 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
| 1241 |
} elsif ( $restype eq "Processing" ) { |
1330 |
if ($issueconfirmed) { |
| 1242 |
|
1331 |
if ($message) { |
|
|
1332 |
$message = "$message + item is determined hold being transferred for someone else"; |
| 1333 |
} else { |
| 1334 |
$message = "item is determined hold being transferred for someone else"; |
| 1335 |
} |
| 1336 |
push( @message_log, "item is determined hold being transferred for someone else" ); |
| 1337 |
} |
| 1338 |
} |
| 1339 |
elsif ( $restype eq "Processing" ) { |
| 1243 |
# The item is determined hold being processed for someone else. |
1340 |
# The item is determined hold being processed for someone else. |
| 1244 |
$needsconfirmation{PROCESSING} = 1; |
1341 |
$needsconfirmation{PROCESSING} = 1; |
| 1245 |
$needsconfirmation{'resfirstname'} = $patron->firstname; |
1342 |
$needsconfirmation{'resfirstname'} = $patron->firstname; |
| 1246 |
$needsconfirmation{'ressurname'} = $patron->surname; |
1343 |
$needsconfirmation{'ressurname'} = $patron->surname; |
| 1247 |
$needsconfirmation{'rescardnumber'} = $patron->cardnumber; |
1344 |
$needsconfirmation{'rescardnumber'} = $patron->cardnumber; |
| 1248 |
$needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; |
1345 |
$needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; |
| 1249 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1346 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1250 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1347 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
| 1251 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1348 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1349 |
if ($issueconfirmed) { |
| 1350 |
if ($message) { |
| 1351 |
$message = "$message + item is determined hold being processed for someone else"; |
| 1352 |
} else { |
| 1353 |
$message = "item is determined hold being processed for someone else"; |
| 1354 |
} |
| 1355 |
push( @message_log, "item is determined hold being processed for someone else" ); |
| 1356 |
} |
| 1252 |
} |
1357 |
} |
| 1253 |
} |
1358 |
} |
| 1254 |
} |
1359 |
} |
|
Lines 1292-1298
sub CanBookBeIssued {
Link Here
|
| 1292 |
if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) { |
1397 |
if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) { |
| 1293 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1398 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
| 1294 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
1399 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
| 1295 |
} else { |
1400 |
if ($message) { |
|
|
1401 |
$message = "$message + age restriction"; |
| 1402 |
} else { |
| 1403 |
$message = "age restriction"; |
| 1404 |
} |
| 1405 |
push( @message_log, "age restriction" ); |
| 1406 |
} |
| 1407 |
else { |
| 1296 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
1408 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
| 1297 |
} |
1409 |
} |
| 1298 |
} |
1410 |
} |
|
Lines 1350-1356
sub CanBookBeIssued {
Link Here
|
| 1350 |
} |
1462 |
} |
| 1351 |
} |
1463 |
} |
| 1352 |
|
1464 |
|
| 1353 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1465 |
my $borrower = $patron; |
|
|
1466 |
my $user = C4::Context->userenv->{number}; |
| 1467 |
my $branchcode = C4::Context->userenv->{branch}; |
| 1468 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
| 1469 |
my $itemnumber = $item->itemnumber; |
| 1470 |
|
| 1471 |
# action, cardnumber, barcode, date, heure, user, branche |
| 1472 |
if ($issueconfirmed) { |
| 1473 |
|
| 1474 |
my $infos = ( |
| 1475 |
{ |
| 1476 |
message => \@message_log, |
| 1477 |
borrowernumber => $borrower->borrowernumber, |
| 1478 |
barcode => $barcode, |
| 1479 |
manager_id => $user, |
| 1480 |
branchcode => $branchcode, |
| 1481 |
} |
| 1482 |
); |
| 1483 |
|
| 1484 |
my $json_infos = JSON->new->utf8->pretty->encode($infos); |
| 1485 |
$json_infos =~ s/"/'/g; |
| 1486 |
|
| 1487 |
logaction( |
| 1488 |
"CIRCULATION", "ISSUE", |
| 1489 |
$borrower->{'borrowernumber'}, |
| 1490 |
$json_infos, |
| 1491 |
) if C4::Context->preference("IssueLog"); |
| 1492 |
} |
| 1493 |
|
| 1494 |
|
| 1495 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, \@message_log ); |
| 1354 |
} |
1496 |
} |
| 1355 |
|
1497 |
|
| 1356 |
=head2 CanBookBeReturned |
1498 |
=head2 CanBookBeReturned |