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 318-323
A recall for this item was found, and the item needs to be transferred to the re
Link Here
|
318 |
|
319 |
|
319 |
=cut |
320 |
=cut |
320 |
|
321 |
|
|
|
322 |
my $query = CGI->new; |
323 |
|
324 |
my $stickyduedate = $query->param('stickyduedate'); |
325 |
my $duedatespec = $query->param('duedatespec'); |
326 |
my $restoreduedatespec = $query->param('restoreduedatespec') || $duedatespec; |
327 |
if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) { |
328 |
undef $restoreduedatespec; |
329 |
} |
330 |
my $issueconfirmed = $query->param('issueconfirmed'); |
331 |
my $cancelreserve = $query->param('cancelreserve'); |
332 |
my $cancel_recall = $query->param('cancel_recall'); |
333 |
my $recall_id = $query->param('recall_id'); |
334 |
my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice |
335 |
my $charges = $query->param('charges') || q{}; |
336 |
|
321 |
sub transferbook { |
337 |
sub transferbook { |
322 |
my $params = shift; |
338 |
my $params = shift; |
323 |
my $tbr = $params->{to_branch}; |
339 |
my $tbr = $params->{to_branch}; |
Lines 802-810
sub CanBookBeIssued {
Link Here
|
802 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_object, $patron) ); |
818 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_object, $patron) ); |
803 |
|
819 |
|
804 |
my $now = dt_from_string(); |
820 |
my $now = dt_from_string(); |
|
|
821 |
my $message; |
822 |
my @message; |
823 |
|
805 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
824 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
|
|
825 |
|
806 |
if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now |
826 |
if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now |
807 |
$needsconfirmation{INVALID_DATE} = $duedate; |
827 |
$needsconfirmation{INVALID_DATE} = $duedate; |
|
|
828 |
if ($issueconfirmed) { |
829 |
if ($message) { |
830 |
$message = "$message + sticky due date is invalid or due date in the past"; |
831 |
} else { |
832 |
$message = "sticky due date is invalid or due date in the past"; |
833 |
} |
834 |
push( @message, "sticky due date is invalid or due date in the past" ); |
835 |
} |
836 |
|
808 |
} |
837 |
} |
809 |
|
838 |
|
810 |
my $fees = Koha::Charges::Fees->new( |
839 |
my $fees = Koha::Charges::Fees->new( |
Lines 849-854
sub CanBookBeIssued {
Link Here
|
849 |
} |
878 |
} |
850 |
if ( $patron->is_debarred ) { |
879 |
if ( $patron->is_debarred ) { |
851 |
$issuingimpossible{DEBARRED} = 1; |
880 |
$issuingimpossible{DEBARRED} = 1; |
|
|
881 |
if ($issueconfirmed) { |
882 |
if ($message) { |
883 |
$message = "$message + borrower is restricted"; |
884 |
} else { |
885 |
$message = "borrower is restricted"; |
886 |
} |
887 |
push( @message, "borrower is restricted" ); |
888 |
} |
852 |
} |
889 |
} |
853 |
|
890 |
|
854 |
if ( $patron->is_expired ) { |
891 |
if ( $patron->is_expired ) { |
Lines 921-930
sub CanBookBeIssued {
Link Here
|
921 |
} else { |
958 |
} else { |
922 |
if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) { |
959 |
if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) { |
923 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
960 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
|
|
961 |
if ($issueconfirmed) { |
962 |
if ($message) { |
963 |
$message = "$message + borrower had amend"; |
964 |
} else { |
965 |
$message = "borrower had amend"; |
966 |
} |
967 |
push( @message, "borrower had amend" ); |
968 |
} |
924 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) { |
969 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) { |
925 |
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
970 |
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
926 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) { |
971 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) { |
927 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
972 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
|
|
973 |
if ($issueconfirmed) { |
974 |
if ($message) { |
975 |
$message = "$message + borrower had amend"; |
976 |
} else { |
977 |
$message = "borrower had amend"; |
978 |
} |
979 |
push( @message, "borrower had amend" ); |
980 |
} |
928 |
} |
981 |
} |
929 |
} |
982 |
} |
930 |
|
983 |
|
Lines 1002-1014
sub CanBookBeIssued {
Link Here
|
1002 |
} else { |
1055 |
} else { |
1003 |
if ( C4::Context->preference('AutoReturnCheckedOutItems') ) { |
1056 |
if ( C4::Context->preference('AutoReturnCheckedOutItems') ) { |
1004 |
$alerts{RETURNED_FROM_ANOTHER} = { patron => $patron }; |
1057 |
$alerts{RETURNED_FROM_ANOTHER} = { patron => $patron }; |
1005 |
} |
1058 |
} else { |
1006 |
else { |
|
|
1007 |
$needsconfirmation{ISSUED_TO_ANOTHER} = 1; |
1059 |
$needsconfirmation{ISSUED_TO_ANOTHER} = 1; |
1008 |
$needsconfirmation{issued_firstname} = $patron->firstname; |
1060 |
$needsconfirmation{issued_firstname} = $patron->firstname; |
1009 |
$needsconfirmation{issued_surname} = $patron->surname; |
1061 |
$needsconfirmation{issued_surname} = $patron->surname; |
1010 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
1062 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
1011 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
1063 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
|
|
1064 |
if ($issueconfirmed) { |
1065 |
if ($message) { |
1066 |
$message = "$message + item is checked out for someone else "; |
1067 |
} else { |
1068 |
$message = "item is checked out for someone else"; |
1069 |
} |
1070 |
push( @message, "item is checked out for someone else" ); |
1071 |
} |
1012 |
} |
1072 |
} |
1013 |
} |
1073 |
} |
1014 |
} |
1074 |
} |
Lines 1032-1037
sub CanBookBeIssued {
Link Here
|
1032 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
1092 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
1033 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
1093 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
1034 |
$needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; |
1094 |
$needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; |
|
|
1095 |
if ($issueconfirmed) { |
1096 |
if ($message) { |
1097 |
$message = "$message + too many checkout"; |
1098 |
} else { |
1099 |
$message = "too many checkout"; |
1100 |
} |
1101 |
push( @message, "too many checkout" ); |
1102 |
} |
1035 |
} else { |
1103 |
} else { |
1036 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
1104 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
1037 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
1105 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
Lines 1059-1064
sub CanBookBeIssued {
Link Here
|
1059 |
}else{ |
1127 |
}else{ |
1060 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
1128 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
1061 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
1129 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
|
|
1130 |
if ($issueconfirmed) { |
1131 |
if ($message) { |
1132 |
$message = "$message + item not for loan"; |
1133 |
} else { |
1134 |
$message = "item not for loan"; |
1135 |
} |
1136 |
push( @message, "item not for loan" ); |
1137 |
} |
1062 |
} |
1138 |
} |
1063 |
} |
1139 |
} |
1064 |
else { |
1140 |
else { |
Lines 1105-1110
sub CanBookBeIssued {
Link Here
|
1105 |
my $code = $av->count ? $av->next->lib : ''; |
1181 |
my $code = $av->count ? $av->next->lib : ''; |
1106 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
1182 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
1107 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
1183 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
|
|
1184 |
if ($issueconfirmed) { |
1185 |
if ($message) { |
1186 |
$message = "$message + item lost"; |
1187 |
} else { |
1188 |
$message = "item lost"; |
1189 |
} |
1190 |
push( @message, "item lost" ); |
1191 |
} |
1108 |
} |
1192 |
} |
1109 |
if ( C4::Context->preference("IndependentBranches") ) { |
1193 |
if ( C4::Context->preference("IndependentBranches") ) { |
1110 |
my $userenv = C4::Context->userenv; |
1194 |
my $userenv = C4::Context->userenv; |
Lines 1201-1206
sub CanBookBeIssued {
Link Here
|
1201 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1285 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1202 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
1286 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
1203 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1287 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1288 |
if ($issueconfirmed) { |
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( @message, "item is on reserve and waiting, but has been reserved by some other patron" ); |
1296 |
} |
1204 |
} |
1297 |
} |
1205 |
elsif ( $restype eq "Reserved" ) { |
1298 |
elsif ( $restype eq "Reserved" ) { |
1206 |
# The item is on reserve for someone else. |
1299 |
# The item is on reserve for someone else. |
Lines 1212-1217
sub CanBookBeIssued {
Link Here
|
1212 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1305 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1213 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1306 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1214 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1307 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1308 |
if ($issueconfirmed) { |
1309 |
if ($message) { |
1310 |
$message = "$message + item is on reserve for someone else"; |
1311 |
} else { |
1312 |
$message = "item is on reserve for someone else"; |
1313 |
} |
1314 |
push( @message, "item is on reserve for someone else" ); |
1315 |
} |
1215 |
} |
1316 |
} |
1216 |
elsif ( $restype eq "Transferred" ) { |
1317 |
elsif ( $restype eq "Transferred" ) { |
1217 |
# The item is determined hold being transferred for someone else. |
1318 |
# The item is determined hold being transferred for someone else. |
Lines 1223-1228
sub CanBookBeIssued {
Link Here
|
1223 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1324 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1224 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1325 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1225 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1326 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1327 |
if ($issueconfirmed) { |
1328 |
if ($message) { |
1329 |
$message = "$message + item is determined hold being transferred for someone else"; |
1330 |
} else { |
1331 |
$message = "item is determined hold being transferred for someone else"; |
1332 |
} |
1333 |
push( @message, "item is determined hold being transferred for someone else" ); |
1334 |
} |
1226 |
} |
1335 |
} |
1227 |
elsif ( $restype eq "Processing" ) { |
1336 |
elsif ( $restype eq "Processing" ) { |
1228 |
# The item is determined hold being processed for someone else. |
1337 |
# The item is determined hold being processed for someone else. |
Lines 1234-1239
sub CanBookBeIssued {
Link Here
|
1234 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1343 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1235 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1344 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1236 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1345 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1346 |
if ($issueconfirmed) { |
1347 |
if ($message) { |
1348 |
$message = "$message + item is determined hold being processed for someone else"; |
1349 |
} else { |
1350 |
$message = "item is determined hold being processed for someone else"; |
1351 |
} |
1352 |
push( @message, "item is determined hold being processed for someone else" ); |
1353 |
} |
1237 |
} |
1354 |
} |
1238 |
} |
1355 |
} |
1239 |
} |
1356 |
} |
Lines 1277-1282
sub CanBookBeIssued {
Link Here
|
1277 |
if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) { |
1394 |
if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) { |
1278 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1395 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1279 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
1396 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
|
|
1397 |
if ($message) { |
1398 |
$message = "$message + age restriction"; |
1399 |
} else { |
1400 |
$message = "age restriction"; |
1401 |
} |
1402 |
push( @message, "age restriction" ); |
1280 |
} |
1403 |
} |
1281 |
else { |
1404 |
else { |
1282 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
1405 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
Lines 1333-1338
sub CanBookBeIssued {
Link Here
|
1333 |
} |
1456 |
} |
1334 |
} |
1457 |
} |
1335 |
|
1458 |
|
|
|
1459 |
my $borrower = $patron; |
1460 |
my $user = C4::Context->userenv->{number}; |
1461 |
my $branchcode = C4::Context->userenv->{branch}; |
1462 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
1463 |
my $itemnumber = $item->itemnumber; |
1464 |
|
1465 |
# action, cardnumber, barcode, date, heure, user, branche |
1466 |
if ($issueconfirmed) { |
1467 |
|
1468 |
my $infos = ( |
1469 |
{ |
1470 |
message => \@message, |
1471 |
borrowernumber => $borrower->borrowernumber, |
1472 |
barcode => $barcode, |
1473 |
manager_id => $user, |
1474 |
branchcode => $branchcode, |
1475 |
} |
1476 |
); |
1477 |
|
1478 |
my $json_infos = JSON->new->utf8->pretty->encode($infos); |
1479 |
$json_infos =~ s/"/'/g; |
1480 |
|
1481 |
logaction( |
1482 |
"CIRCULATION", "ISSUE", |
1483 |
$borrower->{'borrowernumber'}, |
1484 |
$json_infos, |
1485 |
) if C4::Context->preference("IssueLog"); |
1486 |
} |
1487 |
|
1488 |
|
1336 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1489 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1337 |
} |
1490 |
} |
1338 |
|
1491 |
|
Lines 2354-2362
sub AddReturn {
Link Here
|
2354 |
if ( $transfer->tobranch eq $branch ) { |
2507 |
if ( $transfer->tobranch eq $branch ) { |
2355 |
$transfer->receive; |
2508 |
$transfer->receive; |
2356 |
$messages->{'TransferArrived'} = $transfer->frombranch; |
2509 |
$messages->{'TransferArrived'} = $transfer->frombranch; |
|
|
2510 |
|
2357 |
# validTransfer=1 allows us returning the item back if the reserve is cancelled |
2511 |
# validTransfer=1 allows us returning the item back if the reserve is cancelled |
2358 |
$validTransfer = 1 |
2512 |
$validTransfer = 1 if $transfer->reason eq 'Reserve'; |
2359 |
if defined $transfer->reason && $transfer->reason eq 'Reserve'; |
|
|
2360 |
} |
2513 |
} |
2361 |
else { |
2514 |
else { |
2362 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
2515 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
Lines 3079-3084
sub CanBookBeRenewed {
Link Here
|
3079 |
return ( 0, "on_reserve" ) |
3232 |
return ( 0, "on_reserve" ) |
3080 |
if ( $item->current_holds->search( { non_priority => 0 } )->count ); |
3233 |
if ( $item->current_holds->search( { non_priority => 0 } )->count ); |
3081 |
|
3234 |
|
|
|
3235 |
my $issuing_rule = Koha::CirculationRules->get_effective_rules( |
3236 |
{ |
3237 |
categorycode => $patron->categorycode, |
3238 |
itemtype => $item->effective_itemtype, |
3239 |
branchcode => $branchcode, |
3240 |
rules => [ |
3241 |
'renewalsallowed', |
3242 |
'lengthunit', |
3243 |
'unseen_renewals_allowed' |
3244 |
] |
3245 |
} |
3246 |
); |
3247 |
|
3248 |
return ( 0, "too_many" ) |
3249 |
if not $issuing_rule->{renewalsallowed} |
3250 |
or $issuing_rule->{renewalsallowed} <= $issue->renewals_count; |
3082 |
|
3251 |
|
3083 |
my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item); |
3252 |
my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item); |
3084 |
my @fillable_holds = (); |
3253 |
my @fillable_holds = (); |
Lines 3207-3214
fallback to a true value
Link Here
|
3207 |
|
3376 |
|
3208 |
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron ) |
3377 |
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron ) |
3209 |
|
3378 |
|
3210 |
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing |
3379 |
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing should be skipped for this renewal. |
3211 |
should be skipped for this renewal. |
|
|
3212 |
|
3380 |
|
3213 |
=cut |
3381 |
=cut |
3214 |
|
3382 |
|
Lines 3410-3418
sub AddRenewal {
Link Here
|
3410 |
}); |
3578 |
}); |
3411 |
}); |
3579 |
}); |
3412 |
|
3580 |
|
3413 |
unless( $skip_record_index ){ |
3581 |
unless ($skip_record_index) { |
|
|
3582 |
|
3414 |
# We index now, after the transaction is committed |
3583 |
# We index now, after the transaction is committed |
3415 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
3584 |
my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); |
3416 |
$indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" ); |
3585 |
$indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" ); |
3417 |
} |
3586 |
} |
3418 |
|
3587 |
|