Lines 318-323
A recall for this item was found, and the item needs to be transferred to the re
Link Here
|
318 |
|
318 |
|
319 |
=cut |
319 |
=cut |
320 |
|
320 |
|
|
|
321 |
my $query = CGI->new; |
322 |
|
323 |
my $stickyduedate = $query->param('stickyduedate'); |
324 |
my $duedatespec = $query->param('duedatespec'); |
325 |
my $restoreduedatespec = $query->param('restoreduedatespec') || $duedatespec; |
326 |
if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) { |
327 |
undef $restoreduedatespec; |
328 |
} |
329 |
my $issueconfirmed = $query->param('issueconfirmed'); |
330 |
my $cancelreserve = $query->param('cancelreserve'); |
331 |
my $cancel_recall = $query->param('cancel_recall'); |
332 |
my $recall_id = $query->param('recall_id'); |
333 |
my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice |
334 |
my $charges = $query->param('charges') || q{}; |
335 |
|
321 |
sub transferbook { |
336 |
sub transferbook { |
322 |
my $params = shift; |
337 |
my $params = shift; |
323 |
my $tbr = $params->{to_branch}; |
338 |
my $tbr = $params->{to_branch}; |
Lines 796-804
sub CanBookBeIssued {
Link Here
|
796 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_unblessed, $patron_unblessed) ); |
811 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_unblessed, $patron_unblessed) ); |
797 |
|
812 |
|
798 |
my $now = dt_from_string(); |
813 |
my $now = dt_from_string(); |
|
|
814 |
my $message; |
815 |
|
799 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron_unblessed ); |
816 |
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron_unblessed ); |
800 |
if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now |
817 |
if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now |
801 |
$needsconfirmation{INVALID_DATE} = $duedate; |
818 |
$needsconfirmation{INVALID_DATE} = $duedate; |
|
|
819 |
if ($issueconfirmed) { |
820 |
if ($message ) { |
821 |
$message = "$message + sticky due date is invalid or due date in the past"; |
822 |
} else { |
823 |
$message = "sticky due date is invalid or due date in the past"; |
824 |
} |
825 |
} |
826 |
|
802 |
} |
827 |
} |
803 |
|
828 |
|
804 |
my $fees = Koha::Charges::Fees->new( |
829 |
my $fees = Koha::Charges::Fees->new( |
Lines 906-915
sub CanBookBeIssued {
Link Here
|
906 |
else { |
931 |
else { |
907 |
if ( $non_issues_charges > $amountlimit && $allowfineoverride ) { |
932 |
if ( $non_issues_charges > $amountlimit && $allowfineoverride ) { |
908 |
$needsconfirmation{DEBT} = $non_issues_charges; |
933 |
$needsconfirmation{DEBT} = $non_issues_charges; |
|
|
934 |
if ($issueconfirmed) { |
935 |
if ($message) { |
936 |
$message = "$message + guarantees had amend"; |
937 |
} else { |
938 |
$message = "guarantees had amend"; |
939 |
} |
940 |
} |
909 |
} elsif ( $non_issues_charges > $amountlimit && !$allowfineoverride) { |
941 |
} elsif ( $non_issues_charges > $amountlimit && !$allowfineoverride) { |
910 |
$issuingimpossible{DEBT} = $non_issues_charges; |
942 |
$issuingimpossible{DEBT} = $non_issues_charges; |
911 |
} elsif ( $non_issues_charges > 0 && $allfinesneedoverride ) { |
943 |
} elsif ( $non_issues_charges > 0 && $allfinesneedoverride ) { |
912 |
$needsconfirmation{DEBT} = $non_issues_charges; |
944 |
$needsconfirmation{DEBT} = $non_issues_charges; |
|
|
945 |
if ($issueconfirmed) { |
946 |
if ($message) { |
947 |
$message = "$message + guarantees had amend"; |
948 |
} else { |
949 |
$message = "guarantees had amend"; |
950 |
} |
951 |
} |
913 |
} |
952 |
} |
914 |
} |
953 |
} |
915 |
|
954 |
|
Lines 989-994
sub CanBookBeIssued {
Link Here
|
989 |
} else { |
1028 |
} else { |
990 |
if ( C4::Context->preference('AutoReturnCheckedOutItems') ) { |
1029 |
if ( C4::Context->preference('AutoReturnCheckedOutItems') ) { |
991 |
$alerts{RETURNED_FROM_ANOTHER} = { patron => $patron }; |
1030 |
$alerts{RETURNED_FROM_ANOTHER} = { patron => $patron }; |
|
|
1031 |
if ($issueconfirmed) { |
1032 |
if ($message) { |
1033 |
$message = "$message + Auto Return Checked Out Items"; |
1034 |
} else { |
1035 |
$message = "Auto Return Checked Out Items"; |
1036 |
} |
1037 |
} |
992 |
} else { |
1038 |
} else { |
993 |
$needsconfirmation{ISSUED_TO_ANOTHER} = 1; |
1039 |
$needsconfirmation{ISSUED_TO_ANOTHER} = 1; |
994 |
$needsconfirmation{issued_firstname} = $patron->firstname; |
1040 |
$needsconfirmation{issued_firstname} = $patron->firstname; |
Lines 1016-1021
sub CanBookBeIssued {
Link Here
|
1016 |
$needsconfirmation{TOO_MANY} = $toomany->{reason}; |
1062 |
$needsconfirmation{TOO_MANY} = $toomany->{reason}; |
1017 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
1063 |
$needsconfirmation{current_loan_count} = $toomany->{count}; |
1018 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
1064 |
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; |
|
|
1065 |
if ($issueconfirmed) { |
1066 |
if ($message) { |
1067 |
$message = "$message + too many items for the type"; |
1068 |
} else { |
1069 |
$message = "too many items for the type"; |
1070 |
} |
1071 |
|
1072 |
} |
1019 |
} else { |
1073 |
} else { |
1020 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
1074 |
$issuingimpossible{TOO_MANY} = $toomany->{reason}; |
1021 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
1075 |
$issuingimpossible{current_loan_count} = $toomany->{count}; |
Lines 1042-1047
sub CanBookBeIssued {
Link Here
|
1042 |
}else{ |
1096 |
}else{ |
1043 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
1097 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
1044 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
1098 |
$needsconfirmation{item_notforloan} = $item_object->notforloan; |
|
|
1099 |
if ($issueconfirmed) { |
1100 |
if ($message) { |
1101 |
$message = "$message + item not for loan"; |
1102 |
} else { |
1103 |
$message = "item not for loan"; |
1104 |
} |
1105 |
} |
1045 |
} |
1106 |
} |
1046 |
} |
1107 |
} |
1047 |
else { |
1108 |
else { |
Lines 1088-1093
sub CanBookBeIssued {
Link Here
|
1088 |
my $code = $av->count ? $av->next->lib : ''; |
1149 |
my $code = $av->count ? $av->next->lib : ''; |
1089 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
1150 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
1090 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
1151 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
|
|
1152 |
if ($issueconfirmed) { |
1153 |
if ($message) { |
1154 |
$message = "$message + Item lost"; |
1155 |
} else { |
1156 |
$message = "Item lost"; |
1157 |
} |
1158 |
} |
1091 |
} |
1159 |
} |
1092 |
if ( C4::Context->preference("IndependentBranches") ) { |
1160 |
if ( C4::Context->preference("IndependentBranches") ) { |
1093 |
my $userenv = C4::Context->userenv; |
1161 |
my $userenv = C4::Context->userenv; |
Lines 1184-1189
sub CanBookBeIssued {
Link Here
|
1184 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1252 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1185 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
1253 |
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; |
1186 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1254 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1255 |
if ($issueconfirmed) { |
1256 |
if($message) { |
1257 |
$message = "$message + The item is on reserve and waiting, but has been reserved by some other patron."; |
1258 |
} else { |
1259 |
$message = "The item is on reserve and waiting, but has been reserved by some other patron."; |
1260 |
} |
1261 |
} |
1187 |
} |
1262 |
} |
1188 |
elsif ( $restype eq "Reserved" ) { |
1263 |
elsif ( $restype eq "Reserved" ) { |
1189 |
# The item is on reserve for someone else. |
1264 |
# The item is on reserve for someone else. |
Lines 1195-1200
sub CanBookBeIssued {
Link Here
|
1195 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1270 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1196 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1271 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1197 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1272 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1273 |
if ($issueconfirmed) { |
1274 |
if($message) { |
1275 |
$message = "$message + The item is on reserve for someone else"; |
1276 |
} else { |
1277 |
$message = "The item is on reserve for someone else"; |
1278 |
} |
1279 |
} |
1198 |
} |
1280 |
} |
1199 |
elsif ( $restype eq "Transferred" ) { |
1281 |
elsif ( $restype eq "Transferred" ) { |
1200 |
# The item is determined hold being transferred for someone else. |
1282 |
# The item is determined hold being transferred for someone else. |
Lines 1206-1211
sub CanBookBeIssued {
Link Here
|
1206 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1288 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1207 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1289 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1208 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1290 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1291 |
if ($issueconfirmed) { |
1292 |
if($message) { |
1293 |
$message = "$message + The item is determined hold being transferred for someone else"; |
1294 |
} else { |
1295 |
$message = "The item is determined hold being transferred for someone else"; |
1296 |
} |
1297 |
} |
1209 |
} |
1298 |
} |
1210 |
elsif ( $restype eq "Processing" ) { |
1299 |
elsif ( $restype eq "Processing" ) { |
1211 |
# The item is determined hold being processed for someone else. |
1300 |
# The item is determined hold being processed for someone else. |
Lines 1217-1222
sub CanBookBeIssued {
Link Here
|
1217 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1306 |
$needsconfirmation{'resbranchcode'} = $res->{branchcode}; |
1218 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1307 |
$needsconfirmation{'resreservedate'} = $res->{reservedate}; |
1219 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
1308 |
$needsconfirmation{'reserve_id'} = $res->{reserve_id}; |
|
|
1309 |
if ($issueconfirmed) { |
1310 |
if($message) { |
1311 |
$message = "$message + The item is determined hold being processed for someone else"; |
1312 |
} else { |
1313 |
$message = "The item is determined hold being processed for someone else"; |
1314 |
} |
1315 |
} |
1220 |
} |
1316 |
} |
1221 |
} |
1317 |
} |
1222 |
} |
1318 |
} |
Lines 1228-1233
sub CanBookBeIssued {
Link Here
|
1228 |
if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) { |
1324 |
if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) { |
1229 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1325 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1230 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
1326 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
|
|
1327 |
if($message) { |
1328 |
$message = "$message + Age restriction"; |
1329 |
} else { |
1330 |
$message = "Age restriction"; |
1331 |
} |
1231 |
} |
1332 |
} |
1232 |
else { |
1333 |
else { |
1233 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
1334 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
Lines 1284-1289
sub CanBookBeIssued {
Link Here
|
1284 |
} |
1385 |
} |
1285 |
} |
1386 |
} |
1286 |
|
1387 |
|
|
|
1388 |
my $borrower = $patron; |
1389 |
my $cardnumber = $patron->cardnumber; |
1390 |
my $datestring = localtime(); |
1391 |
my $commis = C4::Context->userenv->{id}; |
1392 |
my $branchcode = C4::Context->userenv->{branch}; |
1393 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
1394 |
my $itemnumber = $item->itemnumber; |
1395 |
|
1396 |
# action, cardnumber, barcode, date, heure, commis, branche |
1397 |
if ($issueconfirmed) { |
1398 |
logaction( |
1399 |
"CIRCULATION", "ISSUE", |
1400 |
$borrower->{'borrowernumber'}, |
1401 |
"$message - $cardnumber - $barcode - $datestring - $commis - $branchcode", |
1402 |
) if C4::Context->preference("IssueLog"); |
1403 |
} else { |
1404 |
$message = "Circulation"; |
1405 |
logaction( |
1406 |
"CIRCULATION", "ISSUE", |
1407 |
$borrower->{'borrowernumber'}, |
1408 |
"$itemnumber", |
1409 |
) if C4::Context->preference("IssueLog"); |
1410 |
} |
1287 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1411 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1288 |
} |
1412 |
} |
1289 |
|
1413 |
|
Lines 1742-1766
sub AddIssue {
Link Here
|
1742 |
} |
1866 |
} |
1743 |
} |
1867 |
} |
1744 |
|
1868 |
|
1745 |
my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckout'); |
|
|
1746 |
if ($yaml) { |
1747 |
$yaml = "$yaml\n\n"; |
1748 |
|
1749 |
my $rules; |
1750 |
eval { $rules = YAML::XS::Load(Encode::encode_utf8($yaml)); }; |
1751 |
if ($@) { |
1752 |
warn "Unable to parse UpdateNotForLoanStatusOnCheckout syspref : $@"; |
1753 |
} |
1754 |
else { |
1755 |
foreach my $key ( keys %$rules ) { |
1756 |
if ( $item_object->notforloan eq $key ) { |
1757 |
$item_object->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1 }); |
1758 |
last; |
1759 |
} |
1760 |
} |
1761 |
} |
1762 |
} |
1763 |
|
1764 |
# Record the fact that this book was issued. |
1869 |
# Record the fact that this book was issued. |
1765 |
C4::Stats::UpdateStats( |
1870 |
C4::Stats::UpdateStats( |
1766 |
{ |
1871 |
{ |
Lines 1795-1805
sub AddIssue {
Link Here
|
1795 |
} |
1900 |
} |
1796 |
); |
1901 |
); |
1797 |
} |
1902 |
} |
1798 |
logaction( |
|
|
1799 |
"CIRCULATION", "ISSUE", |
1800 |
$borrower->{'borrowernumber'}, |
1801 |
$item_object->itemnumber, |
1802 |
) if C4::Context->preference("IssueLog"); |
1803 |
|
1903 |
|
1804 |
Koha::Plugins->call('after_circ_action', { |
1904 |
Koha::Plugins->call('after_circ_action', { |
1805 |
action => 'checkout', |
1905 |
action => 'checkout', |
Lines 2296-2303
sub AddReturn {
Link Here
|
2296 |
$transfer->receive; |
2396 |
$transfer->receive; |
2297 |
$messages->{'TransferArrived'} = $transfer->frombranch; |
2397 |
$messages->{'TransferArrived'} = $transfer->frombranch; |
2298 |
# validTransfer=1 allows us returning the item back if the reserve is cancelled |
2398 |
# validTransfer=1 allows us returning the item back if the reserve is cancelled |
2299 |
$validTransfer = 1 |
2399 |
$validTransfer = 1 if $transfer->reason eq 'Reserve'; |
2300 |
if defined $transfer->reason && $transfer->reason eq 'Reserve'; |
|
|
2301 |
} |
2400 |
} |
2302 |
else { |
2401 |
else { |
2303 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
2402 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
Lines 3083-3091
fallback to a true value
Link Here
|
3083 |
|
3182 |
|
3084 |
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron ) |
3183 |
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron ) |
3085 |
|
3184 |
|
3086 |
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing |
|
|
3087 |
should be skipped for this renewal. |
3088 |
|
3089 |
=cut |
3185 |
=cut |
3090 |
|
3186 |
|
3091 |
sub AddRenewal { |
3187 |
sub AddRenewal { |
Lines 3097-3103
sub AddRenewal {
Link Here
|
3097 |
my $skipfinecalc = shift; |
3193 |
my $skipfinecalc = shift; |
3098 |
my $seen = shift; |
3194 |
my $seen = shift; |
3099 |
my $automatic = shift; |
3195 |
my $automatic = shift; |
3100 |
my $skip_record_index = shift; |
|
|
3101 |
|
3196 |
|
3102 |
# Fallback on a 'seen' renewal |
3197 |
# Fallback on a 'seen' renewal |
3103 |
$seen = defined $seen && $seen == 0 ? 0 : 1; |
3198 |
$seen = defined $seen && $seen == 0 ? 0 : 1; |
Lines 3192-3198
sub AddRenewal {
Link Here
|
3192 |
$renews = ( $item_object->renewals || 0 ) + 1; |
3287 |
$renews = ( $item_object->renewals || 0 ) + 1; |
3193 |
$item_object->renewals($renews); |
3288 |
$item_object->renewals($renews); |
3194 |
$item_object->onloan($datedue); |
3289 |
$item_object->onloan($datedue); |
3195 |
# Don't index as we are in a transaction, skip hardcoded here |
3290 |
# Don't index as we are in a transaction |
3196 |
$item_object->store({ log_action => 0, skip_record_index => 1 }); |
3291 |
$item_object->store({ log_action => 0, skip_record_index => 1 }); |
3197 |
|
3292 |
|
3198 |
# Charge a new rental fee, if applicable |
3293 |
# Charge a new rental fee, if applicable |
Lines 3278-3289
sub AddRenewal {
Link Here
|
3278 |
} |
3373 |
} |
3279 |
}); |
3374 |
}); |
3280 |
}); |
3375 |
}); |
3281 |
|
3376 |
# We index now, after the transaction is committed |
3282 |
unless( $skip_record_index ){ |
3377 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
3283 |
# We index now, after the transaction is committed |
3378 |
$indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" ); |
3284 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
|
|
3285 |
$indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" ); |
3286 |
} |
3287 |
|
3379 |
|
3288 |
return $datedue; |
3380 |
return $datedue; |
3289 |
} |
3381 |
} |