Lines 23-28
use DateTime;
Link Here
|
23 |
use POSIX qw( floor ); |
23 |
use POSIX qw( floor ); |
24 |
use YAML::XS; |
24 |
use YAML::XS; |
25 |
use Encode; |
25 |
use Encode; |
|
|
26 |
use JSON; |
26 |
|
27 |
|
27 |
use C4::Context; |
28 |
use C4::Context; |
28 |
use C4::Stats qw( UpdateStats ); |
29 |
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 794-802
sub CanBookBeIssued {
Link Here
|
794 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_object, $patron) ); |
810 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_object, $patron) ); |
795 |
|
811 |
|
796 |
my $now = dt_from_string(); |
812 |
my $now = dt_from_string(); |
|
|
813 |
my $message; |
814 |
my @message; |
815 |
|
797 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
816 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron ); |
|
|
817 |
|
798 |
if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now |
818 |
if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now |
799 |
$needsconfirmation{INVALID_DATE} = $duedate; |
819 |
$needsconfirmation{INVALID_DATE} = $duedate; |
|
|
820 |
if ($issueconfirmed) { |
821 |
if ($message ) { |
822 |
$message = "$message + sticky due date is invalid or due date in the past"; |
823 |
} else { |
824 |
$message = "sticky due date is invalid or due date in the past"; |
825 |
} |
826 |
push(@message, "sticky due date is invalid or due date in the past"); |
827 |
} |
828 |
|
800 |
} |
829 |
} |
801 |
|
830 |
|
802 |
my $fees = Koha::Charges::Fees->new( |
831 |
my $fees = Koha::Charges::Fees->new( |
Lines 905-914
sub CanBookBeIssued {
Link Here
|
905 |
else { |
934 |
else { |
906 |
if ( $non_issues_charges > $amountlimit && $allowfineoverride ) { |
935 |
if ( $non_issues_charges > $amountlimit && $allowfineoverride ) { |
907 |
$needsconfirmation{DEBT} = $non_issues_charges; |
936 |
$needsconfirmation{DEBT} = $non_issues_charges; |
|
|
937 |
if ($issueconfirmed) { |
938 |
if ($message) { |
939 |
$message = "$message + borrower had amend"; |
940 |
} else { |
941 |
$message = "borrower had amend"; |
942 |
} |
943 |
push(@message, "borrower had amend"); |
944 |
} |
908 |
} elsif ( $non_issues_charges > $amountlimit && !$allowfineoverride) { |
945 |
} elsif ( $non_issues_charges > $amountlimit && !$allowfineoverride) { |
909 |
$issuingimpossible{DEBT} = $non_issues_charges; |
946 |
$issuingimpossible{DEBT} = $non_issues_charges; |
910 |
} elsif ( $non_issues_charges > 0 && $allfinesneedoverride ) { |
947 |
} elsif ( $non_issues_charges > 0 && $allfinesneedoverride ) { |
911 |
$needsconfirmation{DEBT} = $non_issues_charges; |
948 |
$needsconfirmation{DEBT} = $non_issues_charges; |
|
|
949 |
if ($issueconfirmed) { |
950 |
if ($message) { |
951 |
$message = "$message + borrower had amend"; |
952 |
} else { |
953 |
$message = "borrower had amend"; |
954 |
} |
955 |
push(@message, "borrower had amend"); |
956 |
} |
912 |
} |
957 |
} |
913 |
} |
958 |
} |
914 |
|
959 |
|
Lines 985-997
sub CanBookBeIssued {
Link Here
|
985 |
} else { |
1030 |
} else { |
986 |
if ( C4::Context->preference('AutoReturnCheckedOutItems') ) { |
1031 |
if ( C4::Context->preference('AutoReturnCheckedOutItems') ) { |
987 |
$alerts{RETURNED_FROM_ANOTHER} = { patron => $patron }; |
1032 |
$alerts{RETURNED_FROM_ANOTHER} = { patron => $patron }; |
988 |
} |
1033 |
} else { |
989 |
else { |
|
|
990 |
$needsconfirmation{ISSUED_TO_ANOTHER} = 1; |
1034 |
$needsconfirmation{ISSUED_TO_ANOTHER} = 1; |
991 |
$needsconfirmation{issued_firstname} = $patron->firstname; |
1035 |
$needsconfirmation{issued_firstname} = $patron->firstname; |
992 |
$needsconfirmation{issued_surname} = $patron->surname; |
1036 |
$needsconfirmation{issued_surname} = $patron->surname; |
993 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
1037 |
$needsconfirmation{issued_cardnumber} = $patron->cardnumber; |
994 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
1038 |
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber; |
|
|
1039 |
if ($issueconfirmed) { |
1040 |
if ($message) { |
1041 |
$message = "$message + item is checked out for someone else "; |
1042 |
} else { |
1043 |
$message = "item is checked out for someone else"; |
1044 |
} |
1045 |
push(@message, "item is checked out for someone else"); |
1046 |
} |
995 |
} |
1047 |
} |
996 |
} |
1048 |
} |
997 |
} |
1049 |
} |
Lines 1013-1018
sub CanBookBeIssued {
Link Here
|
1013 |
$needsconfirmation{TOO_MANY} = $toomany->{reason}; |
1065 |
$needsconfirmation{TOO_MANY} = $toomany->{reason}; |
1014 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
1066 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
1015 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
1067 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
|
|
1068 |
if ($issueconfirmed) { |
1069 |
if ($message) { |
1070 |
$message = "$message + too many checkout"; |
1071 |
} else { |
1072 |
$message = "too many checkout"; |
1073 |
} |
1074 |
push(@message, "too many checkout"); |
1075 |
} |
1016 |
} else { |
1076 |
} else { |
1017 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
1077 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
1018 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
1078 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
Lines 1039-1044
sub CanBookBeIssued {
Link Here
|
1039 |
}else{ |
1099 |
}else{ |
1040 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
1100 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
1041 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
1101 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
|
|
1102 |
if ($issueconfirmed) { |
1103 |
if ($message) { |
1104 |
$message = "$message + item not for loan"; |
1105 |
} else { |
1106 |
$message = "item not for loan"; |
1107 |
} |
1108 |
push(@message, "item not for loan"); |
1109 |
} |
1042 |
} |
1110 |
} |
1043 |
} |
1111 |
} |
1044 |
else { |
1112 |
else { |
Lines 1085-1090
sub CanBookBeIssued {
Link Here
|
1085 |
my $code = $av->count ? $av->next->lib : ''; |
1153 |
my $code = $av->count ? $av->next->lib : ''; |
1086 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
1154 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
1087 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
1155 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
|
|
1156 |
if ($issueconfirmed) { |
1157 |
if ($message) { |
1158 |
$message = "$message + item lost"; |
1159 |
} else { |
1160 |
$message = "item lost"; |
1161 |
} |
1162 |
push(@message, "item lost"); |
1163 |
} |
1088 |
} |
1164 |
} |
1089 |
if ( C4::Context->preference("IndependentBranches") ) { |
1165 |
if ( C4::Context->preference("IndependentBranches") ) { |
1090 |
my $userenv = C4::Context->userenv; |
1166 |
my $userenv = C4::Context->userenv; |
Lines 1181-1186
sub CanBookBeIssued {
Link Here
|
1181 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1257 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1182 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
1258 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
1183 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1259 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1260 |
if ($issueconfirmed) { |
1261 |
if($message) { |
1262 |
$message = "$message + item is on reserve and waiting, but has been reserved by some other patron."; |
1263 |
} else { |
1264 |
$message = "item is on reserve and waiting, but has been reserved by some other patron."; |
1265 |
} |
1266 |
push(@message, "item is on reserve and waiting, but has been reserved by some other patron"); |
1267 |
} |
1184 |
} |
1268 |
} |
1185 |
elsif ( $restype eq "Reserved" ) { |
1269 |
elsif ( $restype eq "Reserved" ) { |
1186 |
# The item is on reserve for someone else. |
1270 |
# The item is on reserve for someone else. |
Lines 1192-1197
sub CanBookBeIssued {
Link Here
|
1192 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1276 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1193 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1277 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1194 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1278 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1279 |
if ($issueconfirmed) { |
1280 |
if($message) { |
1281 |
$message = "$message + item is on reserve for someone else"; |
1282 |
} else { |
1283 |
$message = "item is on reserve for someone else"; |
1284 |
} |
1285 |
push(@message, "item is on reserve for someone else"); |
1286 |
} |
1195 |
} |
1287 |
} |
1196 |
elsif ( $restype eq "Transferred" ) { |
1288 |
elsif ( $restype eq "Transferred" ) { |
1197 |
# The item is determined hold being transferred for someone else. |
1289 |
# The item is determined hold being transferred for someone else. |
Lines 1203-1208
sub CanBookBeIssued {
Link Here
|
1203 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1295 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1204 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1296 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1205 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1297 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1298 |
if ($issueconfirmed) { |
1299 |
if($message) { |
1300 |
$message = "$message + item is determined hold being transferred for someone else"; |
1301 |
} else { |
1302 |
$message = "item is determined hold being transferred for someone else"; |
1303 |
} |
1304 |
push(@message, "item is determined hold being transferred for someone else"); |
1305 |
} |
1206 |
} |
1306 |
} |
1207 |
elsif ( $restype eq "Processing" ) { |
1307 |
elsif ( $restype eq "Processing" ) { |
1208 |
# The item is determined hold being processed for someone else. |
1308 |
# The item is determined hold being processed for someone else. |
Lines 1214-1219
sub CanBookBeIssued {
Link Here
|
1214 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1314 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1215 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1315 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1216 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1316 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1317 |
if ($issueconfirmed) { |
1318 |
if($message) { |
1319 |
$message = "$message + item is determined hold being processed for someone else"; |
1320 |
} else { |
1321 |
$message = "item is determined hold being processed for someone else"; |
1322 |
} |
1323 |
push(@message, "item is determined hold being processed for someone else"); |
1324 |
} |
1217 |
} |
1325 |
} |
1218 |
} |
1326 |
} |
1219 |
} |
1327 |
} |
Lines 1225-1230
sub CanBookBeIssued {
Link Here
|
1225 |
if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) { |
1333 |
if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) { |
1226 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1334 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1227 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
1335 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
|
|
1336 |
if($message) { |
1337 |
$message = "$message + age restriction"; |
1338 |
} else { |
1339 |
$message = "age restriction"; |
1340 |
} |
1341 |
push(@message, "age restriction"); |
1228 |
} |
1342 |
} |
1229 |
else { |
1343 |
else { |
1230 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
1344 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
Lines 1281-1290
sub CanBookBeIssued {
Link Here
|
1281 |
} |
1395 |
} |
1282 |
} |
1396 |
} |
1283 |
|
1397 |
|
|
|
1398 |
my $borrower = $patron; |
1399 |
#my $borrowernumber = $patron->cardnumber; |
1400 |
my $user = C4::Context->userenv->{number}; |
1401 |
my $branchcode = C4::Context->userenv->{branch}; |
1402 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
1403 |
my $itemnumber = $item->itemnumber; |
1404 |
|
1405 |
# action, cardnumber, barcode, date, heure, user, branche |
1406 |
if ($issueconfirmed) { |
1407 |
|
1408 |
my $infos = ({ |
1409 |
message => \@message, |
1410 |
borrowernumber => $borrower->borrowernumber, |
1411 |
barcode => $barcode, |
1412 |
manager_id => $user, |
1413 |
branchcode => $branchcode, |
1414 |
}); |
1415 |
|
1416 |
my $json_infos = JSON->new->utf8->pretty->encode($infos); |
1417 |
$json_infos =~ s/"/'/g; |
1418 |
|
1419 |
logaction( |
1420 |
"CIRCULATION", "ISSUE", |
1421 |
$borrower->{'borrowernumber'}, |
1422 |
$json_infos, |
1423 |
) if C4::Context->preference("IssueLog"); |
1424 |
} |
1425 |
|
1426 |
|
1284 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1427 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1285 |
} |
1428 |
} |
1286 |
|
1429 |
|
1287 |
=head2 CanBookBeReturned |
1430 |
=head2 CanBookBeReturnedcd |
1288 |
|
1431 |
|
1289 |
($returnallowed, $message) = CanBookBeReturned($item, $branch) |
1432 |
($returnallowed, $message) = CanBookBeReturned($item, $branch) |
1290 |
|
1433 |
|
Lines 1741-1765
sub AddIssue {
Link Here
|
1741 |
} |
1884 |
} |
1742 |
} |
1885 |
} |
1743 |
|
1886 |
|
1744 |
my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckout'); |
|
|
1745 |
if ($yaml) { |
1746 |
$yaml = "$yaml\n\n"; |
1747 |
|
1748 |
my $rules; |
1749 |
eval { $rules = YAML::XS::Load(Encode::encode_utf8($yaml)); }; |
1750 |
if ($@) { |
1751 |
warn "Unable to parse UpdateNotForLoanStatusOnCheckout syspref : $@"; |
1752 |
} |
1753 |
else { |
1754 |
foreach my $key ( keys %$rules ) { |
1755 |
if ( $item_object->notforloan eq $key ) { |
1756 |
$item_object->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1 }); |
1757 |
last; |
1758 |
} |
1759 |
} |
1760 |
} |
1761 |
} |
1762 |
|
1763 |
# Record the fact that this book was issued. |
1887 |
# Record the fact that this book was issued. |
1764 |
C4::Stats::UpdateStats( |
1888 |
C4::Stats::UpdateStats( |
1765 |
{ |
1889 |
{ |
Lines 2333-2340
sub AddReturn {
Link Here
|
2333 |
$transfer->receive; |
2457 |
$transfer->receive; |
2334 |
$messages->{'TransferArrived'} = $transfer->frombranch; |
2458 |
$messages->{'TransferArrived'} = $transfer->frombranch; |
2335 |
# validTransfer=1 allows us returning the item back if the reserve is cancelled |
2459 |
# validTransfer=1 allows us returning the item back if the reserve is cancelled |
2336 |
$validTransfer = 1 |
2460 |
$validTransfer = 1 if $transfer->reason eq 'Reserve'; |
2337 |
if defined $transfer->reason && $transfer->reason eq 'Reserve'; |
|
|
2338 |
} |
2461 |
} |
2339 |
else { |
2462 |
else { |
2340 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
2463 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
Lines 3125-3133
fallback to a true value
Link Here
|
3125 |
|
3248 |
|
3126 |
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron ) |
3249 |
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron ) |
3127 |
|
3250 |
|
3128 |
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing |
|
|
3129 |
should be skipped for this renewal. |
3130 |
|
3131 |
=cut |
3251 |
=cut |
3132 |
|
3252 |
|
3133 |
sub AddRenewal { |
3253 |
sub AddRenewal { |
Lines 3238-3244
sub AddRenewal {
Link Here
|
3238 |
$renews = ( $item_object->renewals || 0 ) + 1; |
3358 |
$renews = ( $item_object->renewals || 0 ) + 1; |
3239 |
$item_object->renewals($renews); |
3359 |
$item_object->renewals($renews); |
3240 |
$item_object->onloan($datedue); |
3360 |
$item_object->onloan($datedue); |
3241 |
# Don't index as we are in a transaction, skip hardcoded here |
3361 |
# Don't index as we are in a transaction |
3242 |
$item_object->store({ log_action => 0, skip_record_index => 1 }); |
3362 |
$item_object->store({ log_action => 0, skip_record_index => 1 }); |
3243 |
|
3363 |
|
3244 |
# Charge a new rental fee, if applicable |
3364 |
# Charge a new rental fee, if applicable |
Lines 3325-3336
sub AddRenewal {
Link Here
|
3325 |
} |
3445 |
} |
3326 |
}); |
3446 |
}); |
3327 |
}); |
3447 |
}); |
3328 |
|
3448 |
# We index now, after the transaction is committed |
3329 |
unless( $skip_record_index ){ |
3449 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
3330 |
# We index now, after the transaction is committed |
3450 |
$indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" ); |
3331 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
|
|
3332 |
$indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" ); |
3333 |
} |
3334 |
|
3451 |
|
3335 |
return $datedue; |
3452 |
return $datedue; |
3336 |
} |
3453 |
} |