|
Lines 825-839
sub CanBookBeIssued {
Link Here
|
| 825 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
825 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
| 826 |
|
826 |
|
| 827 |
my $now = dt_from_string(); |
827 |
my $now = dt_from_string(); |
| 828 |
my @message_log; |
|
|
| 829 |
|
828 |
|
| 830 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
829 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
| 831 |
|
830 |
|
| 832 |
if ( DateTime->compare( $duedate, $now ) == -1 ) { # duedate cannot be before now |
831 |
if ( DateTime->compare( $duedate, $now ) == -1 ) { # duedate cannot be before now |
| 833 |
$needsconfirmation{INVALID_DATE} = $duedate; |
832 |
$needsconfirmation{INVALID_DATE} = $duedate; |
| 834 |
if ($issueconfirmed) { |
|
|
| 835 |
push( @message_log, "sticky due date is invalid or due date in the past" ); |
| 836 |
} |
| 837 |
} |
833 |
} |
| 838 |
|
834 |
|
| 839 |
my $fees = Koha::Charges::Fees->new( |
835 |
my $fees = Koha::Charges::Fees->new( |
|
Lines 879-887
sub CanBookBeIssued {
Link Here
|
| 879 |
} |
875 |
} |
| 880 |
if ( $patron->is_debarred ) { |
876 |
if ( $patron->is_debarred ) { |
| 881 |
$issuingimpossible{DEBARRED} = 1; |
877 |
$issuingimpossible{DEBARRED} = 1; |
| 882 |
if ($issueconfirmed) { |
|
|
| 883 |
push( @message_log, "borrower is restricted" ); |
| 884 |
} |
| 885 |
} |
878 |
} |
| 886 |
|
879 |
|
| 887 |
if ( $patron->is_expired ) { |
880 |
if ( $patron->is_expired ) { |
|
Lines 954-969
sub CanBookBeIssued {
Link Here
|
| 954 |
} else { |
947 |
} else { |
| 955 |
if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) { |
948 |
if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) { |
| 956 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
949 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
| 957 |
if ($issueconfirmed) { |
|
|
| 958 |
push( @message_log, "borrower had amend" ); |
| 959 |
} |
| 960 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) { |
950 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) { |
| 961 |
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
951 |
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
| 962 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) { |
952 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) { |
| 963 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
953 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
| 964 |
if ($issueconfirmed) { |
|
|
| 965 |
push( @message_log, "borrower had amend" ); |
| 966 |
} |
| 967 |
} |
954 |
} |
| 968 |
} |
955 |
} |
| 969 |
|
956 |
|
|
Lines 1044-1052
sub CanBookBeIssued {
Link Here
|
| 1044 |
$needsconfirmation{issued_surname} = $patron->surname; |
1031 |
$needsconfirmation{issued_surname} = $patron->surname; |
| 1045 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
1032 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
| 1046 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
1033 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
| 1047 |
if ($issueconfirmed) { |
|
|
| 1048 |
push( @message_log, "item is checked out for someone else" ); |
| 1049 |
} |
| 1050 |
} |
1034 |
} |
| 1051 |
} |
1035 |
} |
| 1052 |
} |
1036 |
} |
|
Lines 1074-1082
sub CanBookBeIssued {
Link Here
|
| 1074 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
1058 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
| 1075 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
1059 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
| 1076 |
$needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; |
1060 |
$needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; |
| 1077 |
if ($issueconfirmed) { |
|
|
| 1078 |
push( @message_log, "too many checkout" ); |
| 1079 |
} |
| 1080 |
} else { |
1061 |
} else { |
| 1081 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
1062 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
| 1082 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
1063 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
|
Lines 1109-1117
sub CanBookBeIssued {
Link Here
|
| 1109 |
} else { |
1090 |
} else { |
| 1110 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
1091 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
| 1111 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
1092 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
| 1112 |
if ($issueconfirmed) { |
|
|
| 1113 |
push( @message_log, "item not for loan" ); |
| 1114 |
} |
| 1115 |
} |
1093 |
} |
| 1116 |
} else { |
1094 |
} else { |
| 1117 |
|
1095 |
|
|
Lines 1157-1165
sub CanBookBeIssued {
Link Here
|
| 1157 |
my $code = $av->count ? $av->next->lib : ''; |
1135 |
my $code = $av->count ? $av->next->lib : ''; |
| 1158 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
1136 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
| 1159 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
1137 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
| 1160 |
if ($issueconfirmed) { |
|
|
| 1161 |
push( @message_log, "item lost" ); |
| 1162 |
} |
| 1163 |
} |
1138 |
} |
| 1164 |
if ( C4::Context->preference("IndependentBranches") ) { |
1139 |
if ( C4::Context->preference("IndependentBranches") ) { |
| 1165 |
my $userenv = C4::Context->userenv; |
1140 |
my $userenv = C4::Context->userenv; |
|
Lines 1260-1272
sub CanBookBeIssued {
Link Here
|
| 1260 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1235 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1261 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
1236 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
| 1262 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1237 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
| 1263 |
|
|
|
| 1264 |
if ($issueconfirmed) { |
| 1265 |
push( |
| 1266 |
@message_log, |
| 1267 |
"item is on reserve and waiting, but has been reserved by some other patron" |
| 1268 |
); |
| 1269 |
} |
| 1270 |
} elsif ( $restype eq "Reserved" ) { |
1238 |
} elsif ( $restype eq "Reserved" ) { |
| 1271 |
|
1239 |
|
| 1272 |
# The item is on reserve for someone else. |
1240 |
# The item is on reserve for someone else. |
|
Lines 1278-1287
sub CanBookBeIssued {
Link Here
|
| 1278 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1246 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1279 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1247 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
| 1280 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1248 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
| 1281 |
|
|
|
| 1282 |
if ($issueconfirmed) { |
| 1283 |
push( @message_log, "item is on reserve for someone else" ); |
| 1284 |
} |
| 1285 |
} elsif ( $restype eq "Transferred" ) { |
1249 |
} elsif ( $restype eq "Transferred" ) { |
| 1286 |
|
1250 |
|
| 1287 |
# The item is determined hold being transferred for someone else. |
1251 |
# The item is determined hold being transferred for someone else. |
|
Lines 1293-1302
sub CanBookBeIssued {
Link Here
|
| 1293 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1257 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1294 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1258 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
| 1295 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1259 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
| 1296 |
|
|
|
| 1297 |
if ($issueconfirmed) { |
| 1298 |
push( @message_log, "item is determined hold being transferred for someone else" ); |
| 1299 |
} |
| 1300 |
} elsif ( $restype eq "Processing" ) { |
1260 |
} elsif ( $restype eq "Processing" ) { |
| 1301 |
|
1261 |
|
| 1302 |
# The item is determined hold being processed for someone else. |
1262 |
# The item is determined hold being processed for someone else. |
|
Lines 1308-1317
sub CanBookBeIssued {
Link Here
|
| 1308 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1268 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
| 1309 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1269 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
| 1310 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1270 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
| 1311 |
|
|
|
| 1312 |
if ($issueconfirmed) { |
| 1313 |
push( @message_log, "item is determined hold being processed for someone else" ); |
| 1314 |
} |
| 1315 |
} |
1271 |
} |
| 1316 |
} |
1272 |
} |
| 1317 |
} |
1273 |
} |
|
Lines 1355-1363
sub CanBookBeIssued {
Link Here
|
| 1355 |
if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) { |
1311 |
if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) { |
| 1356 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1312 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
| 1357 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
1313 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
| 1358 |
if ($issueconfirmed) { |
|
|
| 1359 |
push( @message_log, "age restriction" ); |
| 1360 |
} |
| 1361 |
} else { |
1314 |
} else { |
| 1362 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
1315 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
| 1363 |
} |
1316 |
} |
|
Lines 1416-1449
sub CanBookBeIssued {
Link Here
|
| 1416 |
} |
1369 |
} |
| 1417 |
} |
1370 |
} |
| 1418 |
|
1371 |
|
| 1419 |
my $borrower = $patron; |
1372 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages ); |
| 1420 |
my $user = C4::Context->userenv->{number}; |
|
|
| 1421 |
my $branchcode = C4::Context->userenv->{branch}; |
| 1422 |
|
| 1423 |
# action, cardnumber, barcode, date, heure, user, branche |
| 1424 |
if ($issueconfirmed) { |
| 1425 |
|
| 1426 |
my $infos = ( |
| 1427 |
{ |
| 1428 |
message => \@message_log, |
| 1429 |
borrowernumber => $borrower->borrowernumber, |
| 1430 |
barcode => $barcode, |
| 1431 |
manager_id => $user, |
| 1432 |
branchcode => $branchcode, |
| 1433 |
} |
| 1434 |
); |
| 1435 |
|
| 1436 |
my $json_infos = JSON->new->utf8->pretty->encode($infos); |
| 1437 |
$json_infos =~ s/"/'/g; |
| 1438 |
|
| 1439 |
logaction( |
| 1440 |
"CIRCULATION", "ISSUE", |
| 1441 |
$borrower->{'borrowernumber'}, |
| 1442 |
$json_infos, |
| 1443 |
) if C4::Context->preference("IssueLog"); |
| 1444 |
} |
| 1445 |
|
| 1446 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, \@message_log ); |
| 1447 |
} |
1373 |
} |
| 1448 |
|
1374 |
|
| 1449 |
=head2 CanBookBeReturned |
1375 |
=head2 CanBookBeReturned |