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 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 816-824
sub CanBookBeIssued {
Link Here
|
816 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
832 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
817 |
|
833 |
|
818 |
my $now = dt_from_string(); |
834 |
my $now = dt_from_string(); |
|
|
835 |
my $message; |
836 |
my @message; |
837 |
|
819 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
838 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
|
|
839 |
|
820 |
if ( DateTime->compare( $duedate, $now ) == -1 ) { # duedate cannot be before now |
840 |
if ( DateTime->compare( $duedate, $now ) == -1 ) { # duedate cannot be before now |
821 |
$needsconfirmation{INVALID_DATE} = $duedate; |
841 |
$needsconfirmation{INVALID_DATE} = $duedate; |
|
|
842 |
if ($issueconfirmed) { |
843 |
if ($message) { |
844 |
$message = "$message + sticky due date is invalid or due date in the past"; |
845 |
} else { |
846 |
$message = "sticky due date is invalid or due date in the past"; |
847 |
} |
848 |
push( @message, "sticky due date is invalid or due date in the past" ); |
849 |
} |
850 |
|
822 |
} |
851 |
} |
823 |
|
852 |
|
824 |
my $fees = Koha::Charges::Fees->new( |
853 |
my $fees = Koha::Charges::Fees->new( |
Lines 864-869
sub CanBookBeIssued {
Link Here
|
864 |
} |
893 |
} |
865 |
if ( $patron->is_debarred ) { |
894 |
if ( $patron->is_debarred ) { |
866 |
$issuingimpossible{DEBARRED} = 1; |
895 |
$issuingimpossible{DEBARRED} = 1; |
|
|
896 |
if ($issueconfirmed) { |
897 |
if ($message) { |
898 |
$message = "$message + borrower is restricted"; |
899 |
} else { |
900 |
$message = "borrower is restricted"; |
901 |
} |
902 |
push( @message, "borrower is restricted" ); |
903 |
} |
867 |
} |
904 |
} |
868 |
|
905 |
|
869 |
if ( $patron->is_expired ) { |
906 |
if ( $patron->is_expired ) { |
Lines 936-945
sub CanBookBeIssued {
Link Here
|
936 |
} else { |
973 |
} else { |
937 |
if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) { |
974 |
if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) { |
938 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
975 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
|
|
976 |
if ($issueconfirmed) { |
977 |
if ($message) { |
978 |
$message = "$message + borrower had amend"; |
979 |
} else { |
980 |
$message = "borrower had amend"; |
981 |
} |
982 |
push( @message, "borrower had amend" ); |
983 |
} |
939 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) { |
984 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) { |
940 |
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
985 |
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
941 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) { |
986 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) { |
942 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
987 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
|
|
988 |
if ($issueconfirmed) { |
989 |
if ($message) { |
990 |
$message = "$message + borrower had amend"; |
991 |
} else { |
992 |
$message = "borrower had amend"; |
993 |
} |
994 |
push( @message, "borrower had amend" ); |
995 |
} |
943 |
} |
996 |
} |
944 |
} |
997 |
} |
945 |
|
998 |
|
Lines 1020-1025
sub CanBookBeIssued {
Link Here
|
1020 |
$needsconfirmation{issued_surname} = $patron->surname; |
1073 |
$needsconfirmation{issued_surname} = $patron->surname; |
1021 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
1074 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
1022 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
1075 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
|
|
1076 |
if ($issueconfirmed) { |
1077 |
if ($message) { |
1078 |
$message = "$message + item is checked out for someone else "; |
1079 |
} else { |
1080 |
$message = "item is checked out for someone else"; |
1081 |
} |
1082 |
push( @message, "item is checked out for someone else" ); |
1083 |
} |
1023 |
} |
1084 |
} |
1024 |
} |
1085 |
} |
1025 |
} |
1086 |
} |
Lines 1047-1052
sub CanBookBeIssued {
Link Here
|
1047 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
1108 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
1048 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
1109 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
1049 |
$needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; |
1110 |
$needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; |
|
|
1111 |
if ($issueconfirmed) { |
1112 |
if ($message) { |
1113 |
$message = "$message + too many checkout"; |
1114 |
} else { |
1115 |
$message = "too many checkout"; |
1116 |
} |
1117 |
push( @message, "too many checkout" ); |
1118 |
} |
1050 |
} else { |
1119 |
} else { |
1051 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
1120 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
1052 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
1121 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
Lines 1074-1079
sub CanBookBeIssued {
Link Here
|
1074 |
} else { |
1143 |
} else { |
1075 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
1144 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
1076 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
1145 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
|
|
1146 |
if ($issueconfirmed) { |
1147 |
if ($message) { |
1148 |
$message = "$message + item not for loan"; |
1149 |
} else { |
1150 |
$message = "item not for loan"; |
1151 |
} |
1152 |
push( @message, "item not for loan" ); |
1153 |
} |
1077 |
} |
1154 |
} |
1078 |
} else { |
1155 |
} else { |
1079 |
|
1156 |
|
Lines 1119-1124
sub CanBookBeIssued {
Link Here
|
1119 |
my $code = $av->count ? $av->next->lib : ''; |
1196 |
my $code = $av->count ? $av->next->lib : ''; |
1120 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
1197 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
1121 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
1198 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
|
|
1199 |
if ($issueconfirmed) { |
1200 |
if ($message) { |
1201 |
$message = "$message + item lost"; |
1202 |
} else { |
1203 |
$message = "item lost"; |
1204 |
} |
1205 |
push( @message, "item lost" ); |
1206 |
} |
1122 |
} |
1207 |
} |
1123 |
if ( C4::Context->preference("IndependentBranches") ) { |
1208 |
if ( C4::Context->preference("IndependentBranches") ) { |
1124 |
my $userenv = C4::Context->userenv; |
1209 |
my $userenv = C4::Context->userenv; |
Lines 1219-1224
sub CanBookBeIssued {
Link Here
|
1219 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1304 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1220 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
1305 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
1221 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1306 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1307 |
|
1308 |
if ($issueconfirmed) { |
1309 |
if ($message) { |
1310 |
$message = |
1311 |
"$message + item is on reserve and waiting, but has been reserved by some other patron."; |
1312 |
} else { |
1313 |
$message = "item is on reserve and waiting, but has been reserved by some other patron."; |
1314 |
} |
1315 |
push( @message, "item is on reserve and waiting, but has been reserved by some other patron" ); |
1316 |
} |
1222 |
} elsif ( $restype eq "Reserved" ) { |
1317 |
} elsif ( $restype eq "Reserved" ) { |
1223 |
|
1318 |
|
1224 |
# The item is on reserve for someone else. |
1319 |
# The item is on reserve for someone else. |
Lines 1230-1235
sub CanBookBeIssued {
Link Here
|
1230 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1325 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1231 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1326 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1232 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1327 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1328 |
|
1329 |
if ($issueconfirmed) { |
1330 |
if ($message) { |
1331 |
$message = "$message + item is on reserve for someone else"; |
1332 |
} else { |
1333 |
$message = "item is on reserve for someone else"; |
1334 |
} |
1335 |
push( @message, "item is on reserve for someone else" ); |
1336 |
} |
1233 |
} elsif ( $restype eq "Transferred" ) { |
1337 |
} elsif ( $restype eq "Transferred" ) { |
1234 |
|
1338 |
|
1235 |
# The item is determined hold being transferred for someone else. |
1339 |
# The item is determined hold being transferred for someone else. |
Lines 1241-1246
sub CanBookBeIssued {
Link Here
|
1241 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1345 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1242 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1346 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1243 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1347 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1348 |
|
1349 |
if ($issueconfirmed) { |
1350 |
if ($message) { |
1351 |
$message = "$message + item is determined hold being transferred for someone else"; |
1352 |
} else { |
1353 |
$message = "item is determined hold being transferred for someone else"; |
1354 |
} |
1355 |
push( @message, "item is determined hold being transferred for someone else" ); |
1356 |
} |
1244 |
} elsif ( $restype eq "Processing" ) { |
1357 |
} elsif ( $restype eq "Processing" ) { |
1245 |
|
1358 |
|
1246 |
# The item is determined hold being processed for someone else. |
1359 |
# The item is determined hold being processed for someone else. |
Lines 1252-1257
sub CanBookBeIssued {
Link Here
|
1252 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1365 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1253 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1366 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1254 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1367 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1368 |
|
1369 |
if ($issueconfirmed) { |
1370 |
if ($message) { |
1371 |
$message = "$message + item is determined hold being processed for someone else"; |
1372 |
} else { |
1373 |
$message = "item is determined hold being processed for someone else"; |
1374 |
} |
1375 |
push( @message, "item is determined hold being processed for someone else" ); |
1376 |
} |
1255 |
} |
1377 |
} |
1256 |
} |
1378 |
} |
1257 |
} |
1379 |
} |
Lines 1295-1300
sub CanBookBeIssued {
Link Here
|
1295 |
if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) { |
1417 |
if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) { |
1296 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1418 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1297 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
1419 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
|
|
1420 |
if ($message) { |
1421 |
$message = "$message + age restriction"; |
1422 |
} else { |
1423 |
$message = "age restriction"; |
1424 |
} |
1425 |
push( @message, "age restriction" ); |
1298 |
} else { |
1426 |
} else { |
1299 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
1427 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
1300 |
} |
1428 |
} |
Lines 1353-1358
sub CanBookBeIssued {
Link Here
|
1353 |
} |
1481 |
} |
1354 |
} |
1482 |
} |
1355 |
|
1483 |
|
|
|
1484 |
my $borrower = $patron; |
1485 |
my $user = C4::Context->userenv->{number}; |
1486 |
my $branchcode = C4::Context->userenv->{branch}; |
1487 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
1488 |
my $itemnumber = $item->itemnumber; |
1489 |
|
1490 |
# action, cardnumber, barcode, date, heure, user, branche |
1491 |
if ($issueconfirmed) { |
1492 |
|
1493 |
my $infos = ( |
1494 |
{ |
1495 |
message => \@message, |
1496 |
borrowernumber => $borrower->borrowernumber, |
1497 |
barcode => $barcode, |
1498 |
manager_id => $user, |
1499 |
branchcode => $branchcode, |
1500 |
} |
1501 |
); |
1502 |
|
1503 |
my $json_infos = JSON->new->utf8->pretty->encode($infos); |
1504 |
$json_infos =~ s/"/'/g; |
1505 |
|
1506 |
logaction( |
1507 |
"CIRCULATION", "ISSUE", |
1508 |
$borrower->{'borrowernumber'}, |
1509 |
$json_infos, |
1510 |
) if C4::Context->preference("IssueLog"); |
1511 |
} |
1512 |
|
1356 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1513 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1357 |
} |
1514 |
} |
1358 |
|
1515 |
|
Lines 3200-3206
sub CanBookBeRenewed {
Link Here
|
3200 |
|
3357 |
|
3201 |
foreach my $other_item (@other_items) { |
3358 |
foreach my $other_item (@other_items) { |
3202 |
next if defined $matched_items{ $other_item->itemnumber }; |
3359 |
next if defined $matched_items{ $other_item->itemnumber }; |
3203 |
next if $other_item->holds->filter_by_found->count; |
3360 |
next if IsItemOnHoldAndFound( $other_item->itemnumber ); |
3204 |
next unless IsAvailableForItemLevelRequest( $other_item, $patron_with_reserve, undef ); |
3361 |
next unless IsAvailableForItemLevelRequest( $other_item, $patron_with_reserve, undef ); |
3205 |
next |
3362 |
next |
3206 |
unless CanItemBeReserved( |
3363 |
unless CanItemBeReserved( |