|
Lines 668-684
sub CanBookBeIssued {
Link Here
|
| 668 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
668 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
| 669 |
my $override_high_holds = $params->{override_high_holds} || 0; |
669 |
my $override_high_holds = $params->{override_high_holds} || 0; |
| 670 |
|
670 |
|
| 671 |
my $item = GetItem(undef, $barcode ); |
671 |
my $item = Koha::Items->find({barcode => $barcode }); |
| 672 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
672 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
| 673 |
unless ( $item ) { |
673 |
unless ( $item ) { |
| 674 |
$issuingimpossible{UNKNOWN_BARCODE} = 1; |
674 |
$issuingimpossible{UNKNOWN_BARCODE} = 1; |
| 675 |
} |
675 |
} |
| 676 |
return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; |
676 |
return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; |
| 677 |
|
677 |
|
| 678 |
my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); |
678 |
my $item_unblessed = $item->unblessed; # Transition... |
| 679 |
my $biblio = Koha::Biblios->find( $item->{biblionumber} ); |
679 |
my $issue = $item->checkout; |
|
|
680 |
my $biblio = $item->biblio; |
| 680 |
my $biblioitem = $biblio->biblioitem; |
681 |
my $biblioitem = $biblio->biblioitem; |
| 681 |
my $effective_itemtype = $item->{itype}; # GetItem deals with that |
682 |
my $effective_itemtype = $item->effective_itemtype; |
| 682 |
my $dbh = C4::Context->dbh; |
683 |
my $dbh = C4::Context->dbh; |
| 683 |
my $patron_unblessed = $patron->unblessed; |
684 |
my $patron_unblessed = $patron->unblessed; |
| 684 |
|
685 |
|
|
Lines 692-698
sub CanBookBeIssued {
Link Here
|
| 692 |
unless ( $duedate ) { |
693 |
unless ( $duedate ) { |
| 693 |
my $issuedate = $now->clone(); |
694 |
my $issuedate = $now->clone(); |
| 694 |
|
695 |
|
| 695 |
my $branch = _GetCircControlBranch($item, $patron_unblessed); |
696 |
my $branch = _GetCircControlBranch($item_unblessed, $patron_unblessed); |
| 696 |
$duedate = CalcDateDue( $issuedate, $effective_itemtype, $branch, $patron_unblessed ); |
697 |
$duedate = CalcDateDue( $issuedate, $effective_itemtype, $branch, $patron_unblessed ); |
| 697 |
|
698 |
|
| 698 |
# Offline circ calls AddIssue directly, doesn't run through here |
699 |
# Offline circ calls AddIssue directly, doesn't run through here |
|
Lines 711-727
sub CanBookBeIssued {
Link Here
|
| 711 |
# |
712 |
# |
| 712 |
# BORROWER STATUS |
713 |
# BORROWER STATUS |
| 713 |
# |
714 |
# |
| 714 |
if ( $patron->category->category_type eq 'X' && ( $item->{barcode} )) { |
715 |
if ( $patron->category->category_type eq 'X' && ( $item->barcode )) { |
| 715 |
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . |
716 |
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . |
| 716 |
&UpdateStats({ |
717 |
&UpdateStats({ |
| 717 |
branch => C4::Context->userenv->{'branch'}, |
718 |
branch => C4::Context->userenv->{'branch'}, |
| 718 |
type => 'localuse', |
719 |
type => 'localuse', |
| 719 |
itemnumber => $item->{'itemnumber'}, |
720 |
itemnumber => $item->itemnumber, |
| 720 |
itemtype => $effective_itemtype, |
721 |
itemtype => $effective_itemtype, |
| 721 |
borrowernumber => $patron->borrowernumber, |
722 |
borrowernumber => $patron->borrowernumber, |
| 722 |
ccode => $item->{'ccode'}} |
723 |
ccode => $item->ccode} |
| 723 |
); |
724 |
); |
| 724 |
ModDateLastSeen( $item->{'itemnumber'} ); |
725 |
ModDateLastSeen( $item->itemnumber ); # FIXME Move to Koha::Item |
| 725 |
return( { STATS => 1 }, {}); |
726 |
return( { STATS => 1 }, {}); |
| 726 |
} |
727 |
} |
| 727 |
|
728 |
|
|
Lines 832-838
sub CanBookBeIssued {
Link Here
|
| 832 |
} else { |
833 |
} else { |
| 833 |
my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed( |
834 |
my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed( |
| 834 |
$patron->borrowernumber, |
835 |
$patron->borrowernumber, |
| 835 |
$item->{'itemnumber'}, |
836 |
$item->itemnumber, |
| 836 |
); |
837 |
); |
| 837 |
if ( $CanBookBeRenewed == 0 ) { # no more renewals allowed |
838 |
if ( $CanBookBeRenewed == 0 ) { # no more renewals allowed |
| 838 |
if ( $renewerror eq 'onsite_checkout' ) { |
839 |
if ( $renewerror eq 'onsite_checkout' ) { |
|
Lines 853-859
sub CanBookBeIssued {
Link Here
|
| 853 |
|
854 |
|
| 854 |
my $patron = Koha::Patrons->find( $issue->borrowernumber ); |
855 |
my $patron = Koha::Patrons->find( $issue->borrowernumber ); |
| 855 |
|
856 |
|
| 856 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); |
857 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); |
| 857 |
|
858 |
|
| 858 |
unless ( $can_be_returned ) { |
859 |
unless ( $can_be_returned ) { |
| 859 |
$issuingimpossible{RETURN_IMPOSSIBLE} = 1; |
860 |
$issuingimpossible{RETURN_IMPOSSIBLE} = 1; |
|
Lines 874-880
sub CanBookBeIssued {
Link Here
|
| 874 |
and $issue |
875 |
and $issue |
| 875 |
and $issue->onsite_checkout |
876 |
and $issue->onsite_checkout |
| 876 |
and $issue->borrowernumber == $patron->borrowernumber ? 1 : 0 ); |
877 |
and $issue->borrowernumber == $patron->borrowernumber ? 1 : 0 ); |
| 877 |
my $toomany = TooMany( $patron_unblessed, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } ); |
878 |
my $toomany = TooMany( $patron_unblessed, $item->biblionumber, $item_unblessed, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } ); |
| 878 |
# if TooMany max_allowed returns 0 the user doesn't have permission to check out this book |
879 |
# if TooMany max_allowed returns 0 the user doesn't have permission to check out this book |
| 879 |
if ( $toomany && not exists $needsconfirmation{RENEW_ISSUE} ) { |
880 |
if ( $toomany && not exists $needsconfirmation{RENEW_ISSUE} ) { |
| 880 |
if ( $toomany->{max_allowed} == 0 ) { |
881 |
if ( $toomany->{max_allowed} == 0 ) { |
|
Lines 897-915
sub CanBookBeIssued {
Link Here
|
| 897 |
$patron = Koha::Patrons->find( $patron->borrowernumber ); # FIXME Refetch just in case, to avoid regressions. But must not be needed |
898 |
$patron = Koha::Patrons->find( $patron->borrowernumber ); # FIXME Refetch just in case, to avoid regressions. But must not be needed |
| 898 |
my $wants_check = $patron->wants_check_for_previous_checkout; |
899 |
my $wants_check = $patron->wants_check_for_previous_checkout; |
| 899 |
$needsconfirmation{PREVISSUE} = 1 |
900 |
$needsconfirmation{PREVISSUE} = 1 |
| 900 |
if ($wants_check and $patron->do_check_for_previous_checkout($item)); |
901 |
if ($wants_check and $patron->do_check_for_previous_checkout($item_unblessed)); |
| 901 |
|
902 |
|
| 902 |
# |
903 |
# |
| 903 |
# ITEM CHECKING |
904 |
# ITEM CHECKING |
| 904 |
# |
905 |
# |
| 905 |
if ( $item->{'notforloan'} ) |
906 |
if ( $item->notforloan ) |
| 906 |
{ |
907 |
{ |
| 907 |
if(!C4::Context->preference("AllowNotForLoanOverride")){ |
908 |
if(!C4::Context->preference("AllowNotForLoanOverride")){ |
| 908 |
$issuingimpossible{NOT_FOR_LOAN} = 1; |
909 |
$issuingimpossible{NOT_FOR_LOAN} = 1; |
| 909 |
$issuingimpossible{item_notforloan} = $item->{'notforloan'}; |
910 |
$issuingimpossible{item_notforloan} = $item->notforloan; |
| 910 |
}else{ |
911 |
}else{ |
| 911 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
912 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
| 912 |
$needsconfirmation{item_notforloan} = $item->{'notforloan'}; |
913 |
$needsconfirmation{item_notforloan} = $item->notforloan; |
| 913 |
} |
914 |
} |
| 914 |
} |
915 |
} |
| 915 |
else { |
916 |
else { |
|
Lines 942-958
sub CanBookBeIssued {
Link Here
|
| 942 |
} |
943 |
} |
| 943 |
} |
944 |
} |
| 944 |
} |
945 |
} |
| 945 |
if ( $item->{'withdrawn'} && $item->{'withdrawn'} > 0 ) |
946 |
if ( $item->withdrawn && $item->withdrawn > 0 ) |
| 946 |
{ |
947 |
{ |
| 947 |
$issuingimpossible{WTHDRAWN} = 1; |
948 |
$issuingimpossible{WTHDRAWN} = 1; |
| 948 |
} |
949 |
} |
| 949 |
if ( $item->{'restricted'} |
950 |
if ( $item->restricted |
| 950 |
&& $item->{'restricted'} == 1 ) |
951 |
&& $item->restricted == 1 ) |
| 951 |
{ |
952 |
{ |
| 952 |
$issuingimpossible{RESTRICTED} = 1; |
953 |
$issuingimpossible{RESTRICTED} = 1; |
| 953 |
} |
954 |
} |
| 954 |
if ( $item->{'itemlost'} && C4::Context->preference("IssueLostItem") ne 'nothing' ) { |
955 |
if ( $item->itemlost && C4::Context->preference("IssueLostItem") ne 'nothing' ) { |
| 955 |
my $av = Koha::AuthorisedValues->search({ category => 'LOST', authorised_value => $item->{itemlost} }); |
956 |
my $av = Koha::AuthorisedValues->search({ category => 'LOST', authorised_value => $item->itemlost }); |
| 956 |
my $code = $av->count ? $av->next->lib : ''; |
957 |
my $code = $av->count ? $av->next->lib : ''; |
| 957 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
958 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
| 958 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
959 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
|
Lines 960-968
sub CanBookBeIssued {
Link Here
|
| 960 |
if ( C4::Context->preference("IndependentBranches") ) { |
961 |
if ( C4::Context->preference("IndependentBranches") ) { |
| 961 |
my $userenv = C4::Context->userenv; |
962 |
my $userenv = C4::Context->userenv; |
| 962 |
unless ( C4::Context->IsSuperLibrarian() ) { |
963 |
unless ( C4::Context->IsSuperLibrarian() ) { |
| 963 |
if ( $item->{C4::Context->preference("HomeOrHoldingBranch")} ne $userenv->{branch} ){ |
964 |
my $HomeOrHoldingBranch = C4::Context->preference("HomeOrHoldingBranch"); |
|
|
965 |
if ( $item->$HomeOrHoldingBranch ne $userenv->{branch} ){ |
| 964 |
$issuingimpossible{ITEMNOTSAMEBRANCH} = 1; |
966 |
$issuingimpossible{ITEMNOTSAMEBRANCH} = 1; |
| 965 |
$issuingimpossible{'itemhomebranch'} = $item->{C4::Context->preference("HomeOrHoldingBranch")}; |
967 |
$issuingimpossible{'itemhomebranch'} = $item->$HomeOrHoldingBranch; |
| 966 |
} |
968 |
} |
| 967 |
$needsconfirmation{BORRNOTSAMEBRANCH} = $patron->branchcode |
969 |
$needsconfirmation{BORRNOTSAMEBRANCH} = $patron->branchcode |
| 968 |
if ( $patron->branchcode ne $userenv->{branch} ); |
970 |
if ( $patron->branchcode ne $userenv->{branch} ); |
|
Lines 974-980
sub CanBookBeIssued {
Link Here
|
| 974 |
my $rentalConfirmation = C4::Context->preference("RentalFeesCheckoutConfirmation"); |
976 |
my $rentalConfirmation = C4::Context->preference("RentalFeesCheckoutConfirmation"); |
| 975 |
|
977 |
|
| 976 |
if ( $rentalConfirmation ){ |
978 |
if ( $rentalConfirmation ){ |
| 977 |
my ($rentalCharge) = GetIssuingCharges( $item->{'itemnumber'}, $patron->borrowernumber ); |
979 |
my ($rentalCharge) = GetIssuingCharges( $item->itemnumber, $patron->borrowernumber ); |
| 978 |
if ( $rentalCharge > 0 ){ |
980 |
if ( $rentalCharge > 0 ){ |
| 979 |
$needsconfirmation{RENTALCHARGE} = $rentalCharge; |
981 |
$needsconfirmation{RENTALCHARGE} = $rentalCharge; |
| 980 |
} |
982 |
} |
|
Lines 982-988
sub CanBookBeIssued {
Link Here
|
| 982 |
|
984 |
|
| 983 |
unless ( $ignore_reserves ) { |
985 |
unless ( $ignore_reserves ) { |
| 984 |
# See if the item is on reserve. |
986 |
# See if the item is on reserve. |
| 985 |
my ( $restype, $res ) = C4::Reserves::CheckReserves( $item->{'itemnumber'} ); |
987 |
my ( $restype, $res ) = C4::Reserves::CheckReserves( $item->itemnumber ); |
| 986 |
if ($restype) { |
988 |
if ($restype) { |
| 987 |
my $resbor = $res->{'borrowernumber'}; |
989 |
my $resbor = $res->{'borrowernumber'}; |
| 988 |
if ( $resbor ne $patron->borrowernumber ) { |
990 |
if ( $resbor ne $patron->borrowernumber ) { |
|
Lines 1027-1033
sub CanBookBeIssued {
Link Here
|
| 1027 |
|
1029 |
|
| 1028 |
## check for high holds decreasing loan period |
1030 |
## check for high holds decreasing loan period |
| 1029 |
if ( C4::Context->preference('decreaseLoanHighHolds') ) { |
1031 |
if ( C4::Context->preference('decreaseLoanHighHolds') ) { |
| 1030 |
my $check = checkHighHolds( $item, $patron_unblessed ); |
1032 |
my $check = checkHighHolds( $item_unblessed, $patron_unblessed ); |
| 1031 |
|
1033 |
|
| 1032 |
if ( $check->{exceeded} ) { |
1034 |
if ( $check->{exceeded} ) { |
| 1033 |
if ($override_high_holds) { |
1035 |
if ($override_high_holds) { |
|
Lines 1056-1062
sub CanBookBeIssued {
Link Here
|
| 1056 |
) { |
1058 |
) { |
| 1057 |
# Check if borrower has already issued an item from the same biblio |
1059 |
# Check if borrower has already issued an item from the same biblio |
| 1058 |
# Only if it's not a subscription |
1060 |
# Only if it's not a subscription |
| 1059 |
my $biblionumber = $item->{biblionumber}; |
1061 |
my $biblionumber = $item->biblionumber; |
| 1060 |
require C4::Serials; |
1062 |
require C4::Serials; |
| 1061 |
my $is_a_subscription = C4::Serials::CountSubscriptionFromBiblionumber($biblionumber); |
1063 |
my $is_a_subscription = C4::Serials::CountSubscriptionFromBiblionumber($biblionumber); |
| 1062 |
unless ($is_a_subscription) { |
1064 |
unless ($is_a_subscription) { |
|
Lines 1089-1095
Check whether the item can be returned to the provided branch
Link Here
|
| 1089 |
|
1091 |
|
| 1090 |
=over 4 |
1092 |
=over 4 |
| 1091 |
|
1093 |
|
| 1092 |
=item C<$item> is a hash of item information as returned from GetItem |
1094 |
=item C<$item> is a hash of item information as returned Koha::Items->find->unblessed (Temporary, should be a Koha::Item instead) |
| 1093 |
|
1095 |
|
| 1094 |
=item C<$branch> is the branchcode where the return is taking place |
1096 |
=item C<$branch> is the branchcode where the return is taking place |
| 1095 |
|
1097 |
|
|
Lines 1287-1307
sub AddIssue {
Link Here
|
| 1287 |
# Stop here if the patron or barcode doesn't exist |
1289 |
# Stop here if the patron or barcode doesn't exist |
| 1288 |
if ( $borrower && $barcode && $barcodecheck ) { |
1290 |
if ( $borrower && $barcode && $barcodecheck ) { |
| 1289 |
# find which item we issue |
1291 |
# find which item we issue |
| 1290 |
my $item = GetItem( '', $barcode ) |
1292 |
my $item = Koha::Items->find({ barcode => $barcode }) |
| 1291 |
or return; # if we don't get an Item, abort. |
1293 |
or return; # if we don't get an Item, abort. |
| 1292 |
my $item_object = Koha::Items->find( { barcode => $barcode } ); |
1294 |
my $item_unblessed = $item->unblessed; |
| 1293 |
|
1295 |
|
| 1294 |
my $branch = _GetCircControlBranch( $item, $borrower ); |
1296 |
my $branch = _GetCircControlBranch( $item_unblessed, $borrower ); |
| 1295 |
|
1297 |
|
| 1296 |
# get actual issuing if there is one |
1298 |
# get actual issuing if there is one |
| 1297 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); |
1299 |
my $actualissue = $item->checkout; |
| 1298 |
|
1300 |
|
| 1299 |
# check if we just renew the issue. |
1301 |
# check if we just renew the issue. |
| 1300 |
if ( $actualissue and $actualissue->borrowernumber eq $borrower->{'borrowernumber'} |
1302 |
if ( $actualissue and $actualissue->borrowernumber eq $borrower->{'borrowernumber'} |
| 1301 |
and not $switch_onsite_checkout ) { |
1303 |
and not $switch_onsite_checkout ) { |
| 1302 |
$datedue = AddRenewal( |
1304 |
$datedue = AddRenewal( |
| 1303 |
$borrower->{'borrowernumber'}, |
1305 |
$borrower->{'borrowernumber'}, |
| 1304 |
$item->{'itemnumber'}, |
1306 |
$item->itemnumber, |
| 1305 |
$branch, |
1307 |
$branch, |
| 1306 |
$datedue, |
1308 |
$datedue, |
| 1307 |
$issuedate, # here interpreted as the renewal date |
1309 |
$issuedate, # here interpreted as the renewal date |
|
Lines 1312-1326
sub AddIssue {
Link Here
|
| 1312 |
if ( $actualissue and not $switch_onsite_checkout ) { |
1314 |
if ( $actualissue and not $switch_onsite_checkout ) { |
| 1313 |
# This book is currently on loan, but not to the person |
1315 |
# This book is currently on loan, but not to the person |
| 1314 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1316 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
| 1315 |
my ( $allowed, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); |
1317 |
my ( $allowed, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); |
| 1316 |
return unless $allowed; |
1318 |
return unless $allowed; |
| 1317 |
AddReturn( $item->{'barcode'}, C4::Context->userenv->{'branch'} ); |
1319 |
AddReturn( $item->barcode, C4::Context->userenv->{'branch'} ); |
| 1318 |
} |
1320 |
} |
| 1319 |
|
1321 |
|
| 1320 |
C4::Reserves::MoveReserve( $item->{'itemnumber'}, $borrower->{'borrowernumber'}, $cancelreserve ); |
1322 |
C4::Reserves::MoveReserve( $item->itemnumber, $borrower->{'borrowernumber'}, $cancelreserve ); |
| 1321 |
|
1323 |
|
| 1322 |
# Starting process for transfer job (checking transfert and validate it if we have one) |
1324 |
# Starting process for transfer job (checking transfert and validate it if we have one) |
| 1323 |
my ($datesent) = GetTransfers( $item->{'itemnumber'} ); |
1325 |
my ($datesent) = GetTransfers( $item->itemnumber ); |
| 1324 |
if ($datesent) { |
1326 |
if ($datesent) { |
| 1325 |
# updating line of branchtranfert to finish it, and changing the to branch value, implement a comment for visibility of this case (maybe for stats ....) |
1327 |
# updating line of branchtranfert to finish it, and changing the to branch value, implement a comment for visibility of this case (maybe for stats ....) |
| 1326 |
my $sth = $dbh->prepare( |
1328 |
my $sth = $dbh->prepare( |
|
Lines 1331-1344
sub AddIssue {
Link Here
|
| 1331 |
WHERE itemnumber= ? AND datearrived IS NULL" |
1333 |
WHERE itemnumber= ? AND datearrived IS NULL" |
| 1332 |
); |
1334 |
); |
| 1333 |
$sth->execute( C4::Context->userenv->{'branch'}, |
1335 |
$sth->execute( C4::Context->userenv->{'branch'}, |
| 1334 |
$item->{'itemnumber'} ); |
1336 |
$item->itemnumber ); |
| 1335 |
} |
1337 |
} |
| 1336 |
|
1338 |
|
| 1337 |
# If automatic renewal wasn't selected while issuing, set the value according to the issuing rule. |
1339 |
# If automatic renewal wasn't selected while issuing, set the value according to the issuing rule. |
| 1338 |
unless ($auto_renew) { |
1340 |
unless ($auto_renew) { |
| 1339 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
1341 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
| 1340 |
{ categorycode => $borrower->{categorycode}, |
1342 |
{ categorycode => $borrower->{categorycode}, |
| 1341 |
itemtype => $item->{itype}, |
1343 |
itemtype => $item->effective_itemtype, |
| 1342 |
branchcode => $branch |
1344 |
branchcode => $branch |
| 1343 |
} |
1345 |
} |
| 1344 |
); |
1346 |
); |
|
Lines 1348-1354
sub AddIssue {
Link Here
|
| 1348 |
|
1350 |
|
| 1349 |
# Record in the database the fact that the book was issued. |
1351 |
# Record in the database the fact that the book was issued. |
| 1350 |
unless ($datedue) { |
1352 |
unless ($datedue) { |
| 1351 |
my $itype = $item_object->effective_itemtype; |
1353 |
my $itype = $item->effective_itemtype; |
| 1352 |
$datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower ); |
1354 |
$datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower ); |
| 1353 |
|
1355 |
|
| 1354 |
} |
1356 |
} |
|
Lines 1357-1363
sub AddIssue {
Link Here
|
| 1357 |
$issue = Koha::Database->new()->schema()->resultset('Issue')->update_or_create( |
1359 |
$issue = Koha::Database->new()->schema()->resultset('Issue')->update_or_create( |
| 1358 |
{ |
1360 |
{ |
| 1359 |
borrowernumber => $borrower->{'borrowernumber'}, |
1361 |
borrowernumber => $borrower->{'borrowernumber'}, |
| 1360 |
itemnumber => $item->{'itemnumber'}, |
1362 |
itemnumber => $item->itemnumber, |
| 1361 |
issuedate => $issuedate->strftime('%Y-%m-%d %H:%M:%S'), |
1363 |
issuedate => $issuedate->strftime('%Y-%m-%d %H:%M:%S'), |
| 1362 |
date_due => $datedue->strftime('%Y-%m-%d %H:%M:%S'), |
1364 |
date_due => $datedue->strftime('%Y-%m-%d %H:%M:%S'), |
| 1363 |
branchcode => C4::Context->userenv->{'branch'}, |
1365 |
branchcode => C4::Context->userenv->{'branch'}, |
|
Lines 1368-1416
sub AddIssue {
Link Here
|
| 1368 |
|
1370 |
|
| 1369 |
if ( C4::Context->preference('ReturnToShelvingCart') ) { |
1371 |
if ( C4::Context->preference('ReturnToShelvingCart') ) { |
| 1370 |
# ReturnToShelvingCart is on, anything issued should be taken off the cart. |
1372 |
# ReturnToShelvingCart is on, anything issued should be taken off the cart. |
| 1371 |
CartToShelf( $item->{'itemnumber'} ); |
1373 |
CartToShelf( $item->itemnumber ); |
| 1372 |
} |
1374 |
} |
| 1373 |
$item->{'issues'}++; |
1375 |
|
| 1374 |
if ( C4::Context->preference('UpdateTotalIssuesOnCirc') ) { |
1376 |
if ( C4::Context->preference('UpdateTotalIssuesOnCirc') ) { |
| 1375 |
UpdateTotalIssues( $item->{'biblionumber'}, 1 ); |
1377 |
UpdateTotalIssues( $item->biblionumber, 1 ); |
| 1376 |
} |
1378 |
} |
| 1377 |
|
1379 |
|
| 1378 |
## If item was lost, it has now been found, reverse any list item charges if necessary. |
1380 |
## If item was lost, it has now been found, reverse any list item charges if necessary. |
| 1379 |
if ( $item->{'itemlost'} ) { |
1381 |
if ( $item->itemlost ) { |
| 1380 |
if ( |
1382 |
if ( |
| 1381 |
Koha::RefundLostItemFeeRules->should_refund( |
1383 |
Koha::RefundLostItemFeeRules->should_refund( |
| 1382 |
{ |
1384 |
{ |
| 1383 |
current_branch => C4::Context->userenv->{branch}, |
1385 |
current_branch => C4::Context->userenv->{branch}, |
| 1384 |
item_home_branch => $item->{homebranch}, |
1386 |
item_home_branch => $item->homebranch, |
| 1385 |
item_holding_branch => $item->{holdingbranch} |
1387 |
item_holding_branch => $item->holdingbranch, |
| 1386 |
} |
1388 |
} |
| 1387 |
) |
1389 |
) |
| 1388 |
) |
1390 |
) |
| 1389 |
{ |
1391 |
{ |
| 1390 |
_FixAccountForLostAndReturned( $item->{'itemnumber'}, undef, |
1392 |
_FixAccountForLostAndReturned( $item->itemnumber, undef, |
| 1391 |
$item->{'barcode'} ); |
1393 |
$item->barcode ); |
| 1392 |
} |
1394 |
} |
| 1393 |
} |
1395 |
} |
| 1394 |
|
1396 |
|
| 1395 |
ModItem( |
1397 |
ModItem( |
| 1396 |
{ |
1398 |
{ |
| 1397 |
issues => $item->{'issues'}, |
1399 |
issues => $item->issues + 1, |
| 1398 |
holdingbranch => C4::Context->userenv->{'branch'}, |
1400 |
holdingbranch => C4::Context->userenv->{'branch'}, |
| 1399 |
itemlost => 0, |
1401 |
itemlost => 0, |
| 1400 |
onloan => $datedue->ymd(), |
1402 |
onloan => $datedue->ymd(), |
| 1401 |
datelastborrowed => DateTime->now( time_zone => C4::Context->tz() )->ymd(), |
1403 |
datelastborrowed => DateTime->now( time_zone => C4::Context->tz() )->ymd(), |
| 1402 |
}, |
1404 |
}, |
| 1403 |
$item->{'biblionumber'}, |
1405 |
$item->biblionumber, |
| 1404 |
$item->{'itemnumber'}, |
1406 |
$item->itemnumber, |
| 1405 |
{ log_action => 0 } |
1407 |
{ log_action => 0 } |
| 1406 |
); |
1408 |
); |
| 1407 |
ModDateLastSeen( $item->{'itemnumber'} ); |
1409 |
ModDateLastSeen( $item->itemnumber ); |
| 1408 |
|
1410 |
|
| 1409 |
# If it costs to borrow this book, charge it to the patron's account. |
1411 |
# If it costs to borrow this book, charge it to the patron's account. |
| 1410 |
my ( $charge, $itemtype ) = GetIssuingCharges( $item->{'itemnumber'}, $borrower->{'borrowernumber'} ); |
1412 |
my ( $charge, $itemtype ) = GetIssuingCharges( $item->itemnumber, $borrower->{'borrowernumber'} ); |
| 1411 |
if ( $charge > 0 ) { |
1413 |
if ( $charge > 0 ) { |
| 1412 |
AddIssuingCharge( $issue, $charge ); |
1414 |
AddIssuingCharge( $issue, $charge ); |
| 1413 |
$item->{'charge'} = $charge; |
|
|
| 1414 |
} |
1415 |
} |
| 1415 |
|
1416 |
|
| 1416 |
# Record the fact that this book was issued. |
1417 |
# Record the fact that this book was issued. |
|
Lines 1420-1430
sub AddIssue {
Link Here
|
| 1420 |
type => ( $onsite_checkout ? 'onsite_checkout' : 'issue' ), |
1421 |
type => ( $onsite_checkout ? 'onsite_checkout' : 'issue' ), |
| 1421 |
amount => $charge, |
1422 |
amount => $charge, |
| 1422 |
other => ( $sipmode ? "SIP-$sipmode" : '' ), |
1423 |
other => ( $sipmode ? "SIP-$sipmode" : '' ), |
| 1423 |
itemnumber => $item->{'itemnumber'}, |
1424 |
itemnumber => $item->itemnumber, |
| 1424 |
itemtype => $item->{'itype'}, |
1425 |
itemtype => $item->effective_itemtype, |
| 1425 |
location => $item->{location}, |
1426 |
location => $item->location, |
| 1426 |
borrowernumber => $borrower->{'borrowernumber'}, |
1427 |
borrowernumber => $borrower->{'borrowernumber'}, |
| 1427 |
ccode => $item->{'ccode'} |
1428 |
ccode => $item->ccode, |
| 1428 |
} |
1429 |
} |
| 1429 |
); |
1430 |
); |
| 1430 |
|
1431 |
|
|
Lines 1433-1439
sub AddIssue {
Link Here
|
| 1433 |
my %conditions = ( |
1434 |
my %conditions = ( |
| 1434 |
branchcode => $branch, |
1435 |
branchcode => $branch, |
| 1435 |
categorycode => $borrower->{categorycode}, |
1436 |
categorycode => $borrower->{categorycode}, |
| 1436 |
item_type => $item->{itype}, |
1437 |
item_type => $item->effective_itemtype, |
| 1437 |
notification => 'CHECKOUT', |
1438 |
notification => 'CHECKOUT', |
| 1438 |
); |
1439 |
); |
| 1439 |
if ( $circulation_alert->is_enabled_for( \%conditions ) ) { |
1440 |
if ( $circulation_alert->is_enabled_for( \%conditions ) ) { |
|
Lines 1449-1455
sub AddIssue {
Link Here
|
| 1449 |
logaction( |
1450 |
logaction( |
| 1450 |
"CIRCULATION", "ISSUE", |
1451 |
"CIRCULATION", "ISSUE", |
| 1451 |
$borrower->{'borrowernumber'}, |
1452 |
$borrower->{'borrowernumber'}, |
| 1452 |
$item->{'itemnumber'} |
1453 |
$item->itemnumber, |
| 1453 |
) if C4::Context->preference("IssueLog"); |
1454 |
) if C4::Context->preference("IssueLog"); |
| 1454 |
} |
1455 |
} |
| 1455 |
} |
1456 |
} |
|
Lines 1802-1814
sub AddReturn {
Link Here
|
| 1802 |
my $stat_type = 'return'; |
1803 |
my $stat_type = 'return'; |
| 1803 |
|
1804 |
|
| 1804 |
# get information on item |
1805 |
# get information on item |
| 1805 |
my $item = GetItem( undef, $barcode ); |
1806 |
my $item = Koha::Items->find({ barcode => $barcode }); |
| 1806 |
unless ($item) { |
1807 |
unless ($item) { |
| 1807 |
return ( 0, { BadBarcode => $barcode } ); # no barcode means no item or borrower. bail out. |
1808 |
return ( 0, { BadBarcode => $barcode } ); # no barcode means no item or borrower. bail out. |
| 1808 |
} |
1809 |
} |
| 1809 |
|
1810 |
|
| 1810 |
my $itemnumber = $item->{ itemnumber }; |
1811 |
my $itemnumber = $item->itemnumber; |
| 1811 |
my $itemtype = $item->{itype}; # GetItem called effective_itemtype |
1812 |
my $itemtype = $item->effective_itemtype; |
| 1812 |
|
1813 |
|
| 1813 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); |
1814 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); |
| 1814 |
if ( $issue ) { |
1815 |
if ( $issue ) { |
|
Lines 1828-1848
sub AddReturn {
Link Here
|
| 1828 |
} |
1829 |
} |
| 1829 |
} |
1830 |
} |
| 1830 |
|
1831 |
|
| 1831 |
if ( $item->{'location'} eq 'PROC' ) { |
1832 |
my $item_unblessed = $item->unblessed; |
|
|
1833 |
if ( $item->location eq 'PROC' ) { |
| 1832 |
if ( C4::Context->preference("InProcessingToShelvingCart") ) { |
1834 |
if ( C4::Context->preference("InProcessingToShelvingCart") ) { |
| 1833 |
$item->{'location'} = 'CART'; |
1835 |
$item_unblessed->{location} = 'CART'; |
| 1834 |
} |
1836 |
} |
| 1835 |
else { |
1837 |
else { |
| 1836 |
$item->{location} = $item->{permanent_location}; |
1838 |
$item_unblessed->{location} = $item->permanent_location; |
| 1837 |
} |
1839 |
} |
| 1838 |
|
1840 |
|
| 1839 |
ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'}, { log_action => 0 } ); |
1841 |
ModItem( $item_unblessed, $item->biblionumber, $item->itemnumber, { log_action => 0 } ); |
| 1840 |
} |
1842 |
} |
| 1841 |
|
1843 |
|
| 1842 |
# full item data, but no borrowernumber or checkout info (no issue) |
1844 |
# full item data, but no borrowernumber or checkout info (no issue) |
| 1843 |
my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch"; |
1845 |
my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch"; |
| 1844 |
# get the proper branch to which to return the item |
1846 |
# get the proper branch to which to return the item |
| 1845 |
my $returnbranch = $item->{$hbr} || $branch ; |
1847 |
my $returnbranch = $hbr ne 'noreturn' ? $item->$hbr : $branch; |
| 1846 |
# if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch) |
1848 |
# if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch) |
| 1847 |
|
1849 |
|
| 1848 |
my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not |
1850 |
my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not |
|
Lines 1858-1865
sub AddReturn {
Link Here
|
| 1858 |
} |
1860 |
} |
| 1859 |
else { |
1861 |
else { |
| 1860 |
foreach my $key ( keys %$rules ) { |
1862 |
foreach my $key ( keys %$rules ) { |
| 1861 |
if ( $item->{notforloan} eq $key ) { |
1863 |
if ( $item->notforloan eq $key ) { |
| 1862 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->{notforloan}, to => $rules->{$key} }; |
1864 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; |
| 1863 |
ModItem( { notforloan => $rules->{$key} }, undef, $itemnumber, { log_action => 0 } ); |
1865 |
ModItem( { notforloan => $rules->{$key} }, undef, $itemnumber, { log_action => 0 } ); |
| 1864 |
last; |
1866 |
last; |
| 1865 |
} |
1867 |
} |
|
Lines 1868-1874
sub AddReturn {
Link Here
|
| 1868 |
} |
1870 |
} |
| 1869 |
|
1871 |
|
| 1870 |
# check if the return is allowed at this branch |
1872 |
# check if the return is allowed at this branch |
| 1871 |
my ($returnallowed, $message) = CanBookBeReturned($item, $branch); |
1873 |
my ($returnallowed, $message) = CanBookBeReturned($item_unblessed, $branch); |
| 1872 |
unless ($returnallowed){ |
1874 |
unless ($returnallowed){ |
| 1873 |
$messages->{'Wrongbranch'} = { |
1875 |
$messages->{'Wrongbranch'} = { |
| 1874 |
Wrongbranch => $branch, |
1876 |
Wrongbranch => $branch, |
|
Lines 1878-1889
sub AddReturn {
Link Here
|
| 1878 |
return ( $doreturn, $messages, $issue, $patron_unblessed); |
1880 |
return ( $doreturn, $messages, $issue, $patron_unblessed); |
| 1879 |
} |
1881 |
} |
| 1880 |
|
1882 |
|
| 1881 |
if ( $item->{'withdrawn'} ) { # book has been cancelled |
1883 |
if ( $item->withdrawn ) { # book has been cancelled |
| 1882 |
$messages->{'withdrawn'} = 1; |
1884 |
$messages->{'withdrawn'} = 1; |
| 1883 |
$doreturn = 0 if C4::Context->preference("BlockReturnOfWithdrawnItems"); |
1885 |
$doreturn = 0 if C4::Context->preference("BlockReturnOfWithdrawnItems"); |
| 1884 |
} |
1886 |
} |
| 1885 |
|
1887 |
|
| 1886 |
if ( $item->{itemlost} and C4::Context->preference("BlockReturnOfLostItems") ) { |
1888 |
if ( $item->itemlost and C4::Context->preference("BlockReturnOfLostItems") ) { |
| 1887 |
$doreturn = 0; |
1889 |
$doreturn = 0; |
| 1888 |
} |
1890 |
} |
| 1889 |
|
1891 |
|
|
Lines 1900-1906
sub AddReturn {
Link Here
|
| 1900 |
# don't allow dropbox mode to create an invalid entry in issues (issuedate > today) |
1902 |
# don't allow dropbox mode to create an invalid entry in issues (issuedate > today) |
| 1901 |
# FIXME: check issuedate > returndate, factoring in holidays |
1903 |
# FIXME: check issuedate > returndate, factoring in holidays |
| 1902 |
|
1904 |
|
| 1903 |
$circControlBranch = _GetCircControlBranch($item,$patron_unblessed); |
1905 |
$circControlBranch = _GetCircControlBranch($item_unblessed, $patron_unblessed); |
| 1904 |
$is_overdue = $issue->is_overdue( $dropboxdate ); |
1906 |
$is_overdue = $issue->is_overdue( $dropboxdate ); |
| 1905 |
} else { |
1907 |
} else { |
| 1906 |
$is_overdue = $issue->is_overdue; |
1908 |
$is_overdue = $issue->is_overdue; |
|
Lines 1908-1919
sub AddReturn {
Link Here
|
| 1908 |
|
1910 |
|
| 1909 |
if ($patron) { |
1911 |
if ($patron) { |
| 1910 |
eval { |
1912 |
eval { |
| 1911 |
MarkIssueReturned( $borrowernumber, $item->{'itemnumber'}, |
1913 |
MarkIssueReturned( $borrowernumber, $item->itemnumber, |
| 1912 |
$circControlBranch, $return_date, $patron->privacy ); |
1914 |
$circControlBranch, $return_date, $patron->privacy ); |
| 1913 |
}; |
1915 |
}; |
| 1914 |
unless ( $@ ) { |
1916 |
unless ( $@ ) { |
| 1915 |
if ( ( C4::Context->preference('CalculateFinesOnReturn') && $is_overdue ) || $return_date ) { |
1917 |
if ( ( C4::Context->preference('CalculateFinesOnReturn') && $is_overdue ) || $return_date ) { |
| 1916 |
_CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $patron_unblessed, return_date => $return_date } ); |
1918 |
_CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed, return_date => $return_date } ); |
| 1917 |
} |
1919 |
} |
| 1918 |
} else { |
1920 |
} else { |
| 1919 |
carp "The checkin for the following issue failed, Please go to the about page, section 'data corrupted' to know how to fix this problem ($@)" . Dumper( $issue->unblessed ); |
1921 |
carp "The checkin for the following issue failed, Please go to the about page, section 'data corrupted' to know how to fix this problem ($@)" . Dumper( $issue->unblessed ); |
|
Lines 1926-1981
sub AddReturn {
Link Here
|
| 1926 |
|
1928 |
|
| 1927 |
} |
1929 |
} |
| 1928 |
|
1930 |
|
| 1929 |
ModItem( { onloan => undef }, $item->{biblionumber}, $item->{itemnumber}, { log_action => 0 } ); |
1931 |
ModItem( { onloan => undef }, $item->biblionumber, $item->itemnumber, { log_action => 0 } ); |
| 1930 |
} |
1932 |
} |
| 1931 |
|
1933 |
|
| 1932 |
# the holdingbranch is updated if the document is returned to another location. |
1934 |
# the holdingbranch is updated if the document is returned to another location. |
| 1933 |
# this is always done regardless of whether the item was on loan or not |
1935 |
# this is always done regardless of whether the item was on loan or not |
| 1934 |
my $item_holding_branch = $item->{ holdingbranch }; |
1936 |
my $item_holding_branch = $item->holdingbranch; |
| 1935 |
if ($item->{'holdingbranch'} ne $branch) { |
1937 |
if ($item->holdingbranch ne $branch) { |
| 1936 |
UpdateHoldingbranch($branch, $item->{'itemnumber'}); |
1938 |
UpdateHoldingbranch($branch, $item->itemnumber); |
| 1937 |
$item->{'holdingbranch'} = $branch; # update item data holdingbranch too |
1939 |
$item_unblessed->{'holdingbranch'} = $branch; # update item data holdingbranch too # FIXME I guess this is for the _debar_user_on_return call later |
| 1938 |
} |
1940 |
} |
| 1939 |
ModDateLastSeen( $item->{'itemnumber'} ); |
1941 |
ModDateLastSeen( $item->itemnumber ); |
| 1940 |
|
1942 |
|
| 1941 |
# check if we have a transfer for this document |
1943 |
# check if we have a transfer for this document |
| 1942 |
my ($datesent,$frombranch,$tobranch) = GetTransfers( $item->{'itemnumber'} ); |
1944 |
my ($datesent,$frombranch,$tobranch) = GetTransfers( $item->itemnumber ); |
| 1943 |
|
1945 |
|
| 1944 |
# if we have a transfer to do, we update the line of transfers with the datearrived |
1946 |
# if we have a transfer to do, we update the line of transfers with the datearrived |
| 1945 |
my $is_in_rotating_collection = C4::RotatingCollections::isItemInAnyCollection( $item->{'itemnumber'} ); |
1947 |
my $is_in_rotating_collection = C4::RotatingCollections::isItemInAnyCollection( $item->itemnumber ); |
| 1946 |
if ($datesent) { |
1948 |
if ($datesent) { |
| 1947 |
if ( $tobranch eq $branch ) { |
1949 |
if ( $tobranch eq $branch ) { |
| 1948 |
my $sth = C4::Context->dbh->prepare( |
1950 |
my $sth = C4::Context->dbh->prepare( |
| 1949 |
"UPDATE branchtransfers SET datearrived = now() WHERE itemnumber= ? AND datearrived IS NULL" |
1951 |
"UPDATE branchtransfers SET datearrived = now() WHERE itemnumber= ? AND datearrived IS NULL" |
| 1950 |
); |
1952 |
); |
| 1951 |
$sth->execute( $item->{'itemnumber'} ); |
1953 |
$sth->execute( $item->itemnumber ); |
| 1952 |
# if we have a reservation with valid transfer, we can set it's status to 'W' |
1954 |
# if we have a reservation with valid transfer, we can set it's status to 'W' |
| 1953 |
ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") ); |
1955 |
ShelfToCart( $item->itemnumber ) if ( C4::Context->preference("ReturnToShelvingCart") ); |
| 1954 |
C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W'); |
1956 |
C4::Reserves::ModReserveStatus($item->itemnumber, 'W'); |
| 1955 |
} else { |
1957 |
} else { |
| 1956 |
$messages->{'WrongTransfer'} = $tobranch; |
1958 |
$messages->{'WrongTransfer'} = $tobranch; |
| 1957 |
$messages->{'WrongTransferItem'} = $item->{'itemnumber'}; |
1959 |
$messages->{'WrongTransferItem'} = $item->itemnumber; |
| 1958 |
} |
1960 |
} |
| 1959 |
$validTransfert = 1; |
1961 |
$validTransfert = 1; |
| 1960 |
} else { |
1962 |
} else { |
| 1961 |
ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") ); |
1963 |
ShelfToCart( $item->itemnumber ) if ( C4::Context->preference("ReturnToShelvingCart") ); |
| 1962 |
} |
1964 |
} |
| 1963 |
|
1965 |
|
| 1964 |
# fix up the accounts..... |
1966 |
# fix up the accounts..... |
| 1965 |
if ( $item->{'itemlost'} ) { |
1967 |
if ( $item->itemlost ) { |
| 1966 |
$messages->{'WasLost'} = 1; |
1968 |
$messages->{'WasLost'} = 1; |
| 1967 |
unless ( C4::Context->preference("BlockReturnOfLostItems") ) { |
1969 |
unless ( C4::Context->preference("BlockReturnOfLostItems") ) { |
| 1968 |
if ( |
1970 |
if ( |
| 1969 |
Koha::RefundLostItemFeeRules->should_refund( |
1971 |
Koha::RefundLostItemFeeRules->should_refund( |
| 1970 |
{ |
1972 |
{ |
| 1971 |
current_branch => C4::Context->userenv->{branch}, |
1973 |
current_branch => C4::Context->userenv->{branch}, |
| 1972 |
item_home_branch => $item->{homebranch}, |
1974 |
item_home_branch => $item->homebranch, |
| 1973 |
item_holding_branch => $item_holding_branch |
1975 |
item_holding_branch => $item_holding_branch |
| 1974 |
} |
1976 |
} |
| 1975 |
) |
1977 |
) |
| 1976 |
) |
1978 |
) |
| 1977 |
{ |
1979 |
{ |
| 1978 |
_FixAccountForLostAndReturned( $item->{'itemnumber'}, |
1980 |
_FixAccountForLostAndReturned( $item->itemnumber, |
| 1979 |
$borrowernumber, $barcode ); |
1981 |
$borrowernumber, $barcode ); |
| 1980 |
$messages->{'LostItemFeeRefunded'} = 1; |
1982 |
$messages->{'LostItemFeeRefunded'} = 1; |
| 1981 |
} |
1983 |
} |
|
Lines 1984-1997
sub AddReturn {
Link Here
|
| 1984 |
|
1986 |
|
| 1985 |
# fix up the overdues in accounts... |
1987 |
# fix up the overdues in accounts... |
| 1986 |
if ($borrowernumber) { |
1988 |
if ($borrowernumber) { |
| 1987 |
my $fix = _FixOverduesOnReturn($borrowernumber, $item->{itemnumber}, $exemptfine, $dropbox); |
1989 |
my $fix = _FixOverduesOnReturn($borrowernumber, $item->itemnumber, $exemptfine, $dropbox); |
| 1988 |
defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->{itemnumber}...) failed!"; # zero is OK, check defined |
1990 |
defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->itemnumber...) failed!"; # zero is OK, check defined |
| 1989 |
|
1991 |
|
| 1990 |
if ( $issue and $issue->is_overdue ) { |
1992 |
if ( $issue and $issue->is_overdue ) { |
| 1991 |
# fix fine days |
1993 |
# fix fine days |
| 1992 |
$today = dt_from_string($return_date) if $return_date; |
1994 |
$today = dt_from_string($return_date) if $return_date; |
| 1993 |
$today = $dropboxdate if $dropbox; |
1995 |
$today = $dropboxdate if $dropbox; |
| 1994 |
my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item, dt_from_string($issue->date_due), $today ); |
1996 |
my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item_unblessed, dt_from_string($issue->date_due), $today ); |
| 1995 |
if ($reminder){ |
1997 |
if ($reminder){ |
| 1996 |
$messages->{'PrevDebarred'} = $debardate; |
1998 |
$messages->{'PrevDebarred'} = $debardate; |
| 1997 |
} else { |
1999 |
} else { |
|
Lines 2016-2022
sub AddReturn {
Link Here
|
| 2016 |
# if we don't have a reserve with the status W, we launch the Checkreserves routine |
2018 |
# if we don't have a reserve with the status W, we launch the Checkreserves routine |
| 2017 |
my ($resfound, $resrec); |
2019 |
my ($resfound, $resrec); |
| 2018 |
my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds |
2020 |
my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds |
| 2019 |
($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} ); |
2021 |
($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn ); |
| 2020 |
if ($resfound) { |
2022 |
if ($resfound) { |
| 2021 |
$resrec->{'ResFound'} = $resfound; |
2023 |
$resrec->{'ResFound'} = $resfound; |
| 2022 |
$messages->{'ResFound'} = $resrec; |
2024 |
$messages->{'ResFound'} = $resrec; |
|
Lines 2029-2035
sub AddReturn {
Link Here
|
| 2029 |
itemnumber => $itemnumber, |
2031 |
itemnumber => $itemnumber, |
| 2030 |
itemtype => $itemtype, |
2032 |
itemtype => $itemtype, |
| 2031 |
borrowernumber => $borrowernumber, |
2033 |
borrowernumber => $borrowernumber, |
| 2032 |
ccode => $item->{ ccode } |
2034 |
ccode => $item->ccode, |
| 2033 |
}); |
2035 |
}); |
| 2034 |
|
2036 |
|
| 2035 |
# Send a check-in slip. # NOTE: borrower may be undef. Do not try to send messages then. |
2037 |
# Send a check-in slip. # NOTE: borrower may be undef. Do not try to send messages then. |
|
Lines 2038-2056
sub AddReturn {
Link Here
|
| 2038 |
my %conditions = ( |
2040 |
my %conditions = ( |
| 2039 |
branchcode => $branch, |
2041 |
branchcode => $branch, |
| 2040 |
categorycode => $patron->categorycode, |
2042 |
categorycode => $patron->categorycode, |
| 2041 |
item_type => $item->{itype}, |
2043 |
item_type => $itemtype, |
| 2042 |
notification => 'CHECKIN', |
2044 |
notification => 'CHECKIN', |
| 2043 |
); |
2045 |
); |
| 2044 |
if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) { |
2046 |
if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) { |
| 2045 |
SendCirculationAlert({ |
2047 |
SendCirculationAlert({ |
| 2046 |
type => 'CHECKIN', |
2048 |
type => 'CHECKIN', |
| 2047 |
item => $item, |
2049 |
item => $item_unblessed, |
| 2048 |
borrower => $patron->unblessed, |
2050 |
borrower => $patron->unblessed, |
| 2049 |
branch => $branch, |
2051 |
branch => $branch, |
| 2050 |
}); |
2052 |
}); |
| 2051 |
} |
2053 |
} |
| 2052 |
|
2054 |
|
| 2053 |
logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'}) |
2055 |
logaction("CIRCULATION", "RETURN", $borrowernumber, $item->itemnumber) |
| 2054 |
if C4::Context->preference("ReturnLog"); |
2056 |
if C4::Context->preference("ReturnLog"); |
| 2055 |
} |
2057 |
} |
| 2056 |
|
2058 |
|
|
Lines 2066-2078
sub AddReturn {
Link Here
|
| 2066 |
|
2068 |
|
| 2067 |
# Transfer to returnbranch if Automatic transfer set or append message NeedsTransfer |
2069 |
# Transfer to returnbranch if Automatic transfer set or append message NeedsTransfer |
| 2068 |
if (!$is_in_rotating_collection && ($doreturn or $messages->{'NotIssued'}) and !$resfound and ($branch ne $returnbranch) and not $messages->{'WrongTransfer'}){ |
2070 |
if (!$is_in_rotating_collection && ($doreturn or $messages->{'NotIssued'}) and !$resfound and ($branch ne $returnbranch) and not $messages->{'WrongTransfer'}){ |
|
|
2071 |
my $BranchTransferLimitsType = C4::Context->preference("BranchTransferLimitsType"); |
| 2069 |
if (C4::Context->preference("AutomaticItemReturn" ) or |
2072 |
if (C4::Context->preference("AutomaticItemReturn" ) or |
| 2070 |
(C4::Context->preference("UseBranchTransferLimits") and |
2073 |
(C4::Context->preference("UseBranchTransferLimits") and |
| 2071 |
! IsBranchTransferAllowed($branch, $returnbranch, $item->{C4::Context->preference("BranchTransferLimitsType")} ) |
2074 |
! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType ) |
| 2072 |
)) { |
2075 |
)) { |
| 2073 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->{'itemnumber'},$branch, $returnbranch; |
2076 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->itemnumber,$branch, $returnbranch; |
| 2074 |
$debug and warn "item: " . Dumper($item); |
2077 |
$debug and warn "item: " . Dumper($item_unblessed); |
| 2075 |
ModItemTransfer($item->{'itemnumber'}, $branch, $returnbranch); |
2078 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch); |
| 2076 |
$messages->{'WasTransfered'} = 1; |
2079 |
$messages->{'WasTransfered'} = 1; |
| 2077 |
} else { |
2080 |
} else { |
| 2078 |
$messages->{'NeedsTransfer'} = $returnbranch; |
2081 |
$messages->{'NeedsTransfer'} = $returnbranch; |
|
Lines 2590-2596
sub CanBookBeRenewed {
Link Here
|
| 2590 |
my $dbh = C4::Context->dbh; |
2593 |
my $dbh = C4::Context->dbh; |
| 2591 |
my $renews = 1; |
2594 |
my $renews = 1; |
| 2592 |
|
2595 |
|
| 2593 |
my $item = GetItem($itemnumber) or return ( 0, 'no_item' ); |
2596 |
my $item = Koha::Items->find($itemnumber) or return ( 0, 'no_item' ); |
| 2594 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return ( 0, 'no_checkout' ); |
2597 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return ( 0, 'no_checkout' ); |
| 2595 |
return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout; |
2598 |
return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout; |
| 2596 |
|
2599 |
|
|
Lines 2646-2652
sub CanBookBeRenewed {
Link Here
|
| 2646 |
my @reservable; |
2649 |
my @reservable; |
| 2647 |
my %borrowers; |
2650 |
my %borrowers; |
| 2648 |
ITEM: foreach my $i (@itemnumbers) { |
2651 |
ITEM: foreach my $i (@itemnumbers) { |
| 2649 |
my $item = GetItem($i); |
2652 |
my $item = Koha::Items->find($i)->unblessed; |
| 2650 |
next if IsItemOnHoldAndFound($i); |
2653 |
next if IsItemOnHoldAndFound($i); |
| 2651 |
for my $b (@borrowernumbers) { |
2654 |
for my $b (@borrowernumbers) { |
| 2652 |
my $borr = $borrowers{$b} //= Koha::Patrons->find( $b )->unblessed; |
2655 |
my $borr = $borrowers{$b} //= Koha::Patrons->find( $b )->unblessed; |
|
Lines 2667-2676
sub CanBookBeRenewed {
Link Here
|
| 2667 |
|
2670 |
|
| 2668 |
return ( 1, undef ) if $override_limit; |
2671 |
return ( 1, undef ) if $override_limit; |
| 2669 |
|
2672 |
|
| 2670 |
my $branchcode = _GetCircControlBranch( $item, $patron->unblessed ); |
2673 |
my $branchcode = _GetCircControlBranch( $item->unblessed, $patron->unblessed ); |
| 2671 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
2674 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
| 2672 |
{ categorycode => $patron->categorycode, |
2675 |
{ categorycode => $patron->categorycode, |
| 2673 |
itemtype => $item->{itype}, |
2676 |
itemtype => $item->effective_itemtype, |
| 2674 |
branchcode => $branchcode |
2677 |
branchcode => $branchcode |
| 2675 |
} |
2678 |
} |
| 2676 |
); |
2679 |
); |
|
Lines 2794-2808
sub AddRenewal {
Link Here
|
| 2794 |
my $datedue = shift; |
2797 |
my $datedue = shift; |
| 2795 |
my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd(); |
2798 |
my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd(); |
| 2796 |
|
2799 |
|
| 2797 |
my $item = GetItem($itemnumber) or return; |
2800 |
my $item = Koha::Items->find($itemnumber) or return; |
| 2798 |
my $item_object = Koha::Items->find( $itemnumber ); # Should replace $item |
2801 |
my $biblio = $item->biblio; |
| 2799 |
my $biblio = $item_object->biblio; |
2802 |
my $issue = $item->checkout; |
|
|
2803 |
my $item_unblessed = $item->unblessed; |
| 2800 |
|
2804 |
|
| 2801 |
my $dbh = C4::Context->dbh; |
2805 |
my $dbh = C4::Context->dbh; |
| 2802 |
|
2806 |
|
| 2803 |
# Find the issues record for this book |
|
|
| 2804 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); |
| 2805 |
|
| 2806 |
return unless $issue; |
2807 |
return unless $issue; |
| 2807 |
|
2808 |
|
| 2808 |
$borrowernumber ||= $issue->borrowernumber; |
2809 |
$borrowernumber ||= $issue->borrowernumber; |
|
Lines 2816-2822
sub AddRenewal {
Link Here
|
| 2816 |
my $patron_unblessed = $patron->unblessed; |
2817 |
my $patron_unblessed = $patron->unblessed; |
| 2817 |
|
2818 |
|
| 2818 |
if ( C4::Context->preference('CalculateFinesOnReturn') && $issue->is_overdue ) { |
2819 |
if ( C4::Context->preference('CalculateFinesOnReturn') && $issue->is_overdue ) { |
| 2819 |
_CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $patron_unblessed } ); |
2820 |
_CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed } ); |
| 2820 |
} |
2821 |
} |
| 2821 |
_FixOverduesOnReturn( $borrowernumber, $itemnumber ); |
2822 |
_FixOverduesOnReturn( $borrowernumber, $itemnumber ); |
| 2822 |
|
2823 |
|
|
Lines 2825-2835
sub AddRenewal {
Link Here
|
| 2825 |
# based on the value of the RenewalPeriodBase syspref. |
2826 |
# based on the value of the RenewalPeriodBase syspref. |
| 2826 |
unless ($datedue) { |
2827 |
unless ($datedue) { |
| 2827 |
|
2828 |
|
| 2828 |
my $itemtype = $item_object->effective_itemtype; |
2829 |
my $itemtype = $item->effective_itemtype; |
| 2829 |
$datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ? |
2830 |
$datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ? |
| 2830 |
dt_from_string( $issue->date_due, 'sql' ) : |
2831 |
dt_from_string( $issue->date_due, 'sql' ) : |
| 2831 |
DateTime->now( time_zone => C4::Context->tz()); |
2832 |
DateTime->now( time_zone => C4::Context->tz()); |
| 2832 |
$datedue = CalcDateDue($datedue, $itemtype, _GetCircControlBranch($item, $patron_unblessed), $patron_unblessed, 'is a renewal'); |
2833 |
$datedue = CalcDateDue($datedue, $itemtype, _GetCircControlBranch($item_unblessed, $patron_unblessed), $patron_unblessed, 'is a renewal'); |
| 2833 |
} |
2834 |
} |
| 2834 |
|
2835 |
|
| 2835 |
# Update the issues record to have the new due date, and a new count |
2836 |
# Update the issues record to have the new due date, and a new count |
|
Lines 2843-2850
sub AddRenewal {
Link Here
|
| 2843 |
$sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $lastreneweddate, $borrowernumber, $itemnumber ); |
2844 |
$sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $lastreneweddate, $borrowernumber, $itemnumber ); |
| 2844 |
|
2845 |
|
| 2845 |
# Update the renewal count on the item, and tell zebra to reindex |
2846 |
# Update the renewal count on the item, and tell zebra to reindex |
| 2846 |
$renews = $item->{renewals} + 1; |
2847 |
$renews = $item->renewals + 1; |
| 2847 |
ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->{biblionumber}, $itemnumber, { log_action => 0 } ); |
2848 |
ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->biblionumber, $itemnumber, { log_action => 0 } ); |
| 2848 |
|
2849 |
|
| 2849 |
# Charge a new rental fee, if applicable? |
2850 |
# Charge a new rental fee, if applicable? |
| 2850 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
2851 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
|
Lines 2859-2865
sub AddRenewal {
Link Here
|
| 2859 |
VALUES (now(),?,?,?,?,?,?,?,?)" |
2860 |
VALUES (now(),?,?,?,?,?,?,?,?)" |
| 2860 |
); |
2861 |
); |
| 2861 |
$sth->execute( $borrowernumber, $accountno, $charge, $manager_id, |
2862 |
$sth->execute( $borrowernumber, $accountno, $charge, $manager_id, |
| 2862 |
"Renewal of Rental Item " . $biblio->title . " $item->{'barcode'}", |
2863 |
"Renewal of Rental Item " . $biblio->title . " " . $item->barcode, |
| 2863 |
'Rent', $charge, $itemnumber ); |
2864 |
'Rent', $charge, $itemnumber ); |
| 2864 |
} |
2865 |
} |
| 2865 |
|
2866 |
|
|
Lines 2869-2882
sub AddRenewal {
Link Here
|
| 2869 |
my %conditions = ( |
2870 |
my %conditions = ( |
| 2870 |
branchcode => $branch, |
2871 |
branchcode => $branch, |
| 2871 |
categorycode => $patron->categorycode, |
2872 |
categorycode => $patron->categorycode, |
| 2872 |
item_type => $item->{itype}, |
2873 |
item_type => $item->effective_itemtype, |
| 2873 |
notification => 'CHECKOUT', |
2874 |
notification => 'CHECKOUT', |
| 2874 |
); |
2875 |
); |
| 2875 |
if ( $circulation_alert->is_enabled_for( \%conditions ) ) { |
2876 |
if ( $circulation_alert->is_enabled_for( \%conditions ) ) { |
| 2876 |
SendCirculationAlert( |
2877 |
SendCirculationAlert( |
| 2877 |
{ |
2878 |
{ |
| 2878 |
type => 'RENEWAL', |
2879 |
type => 'RENEWAL', |
| 2879 |
item => $item, |
2880 |
item => $item_unblessed, |
| 2880 |
borrower => $patron->unblessed, |
2881 |
borrower => $patron->unblessed, |
| 2881 |
branch => $branch, |
2882 |
branch => $branch, |
| 2882 |
} |
2883 |
} |
|
Lines 2904-2913
sub AddRenewal {
Link Here
|
| 2904 |
type => 'renew', |
2905 |
type => 'renew', |
| 2905 |
amount => $charge, |
2906 |
amount => $charge, |
| 2906 |
itemnumber => $itemnumber, |
2907 |
itemnumber => $itemnumber, |
| 2907 |
itemtype => $item->{itype}, |
2908 |
itemtype => $item->effective_itemtype, |
| 2908 |
location => $item->{location}, |
2909 |
location => $item->location, |
| 2909 |
borrowernumber => $borrowernumber, |
2910 |
borrowernumber => $borrowernumber, |
| 2910 |
ccode => $item->{'ccode'} |
2911 |
ccode => $item->ccode, |
| 2911 |
} |
2912 |
} |
| 2912 |
); |
2913 |
); |
| 2913 |
|
2914 |
|
|
Lines 2925-2931
sub GetRenewCount {
Link Here
|
| 2925 |
my $renewsleft = 0; |
2926 |
my $renewsleft = 0; |
| 2926 |
|
2927 |
|
| 2927 |
my $patron = Koha::Patrons->find( $bornum ); |
2928 |
my $patron = Koha::Patrons->find( $bornum ); |
| 2928 |
my $item = GetItem($itemno); |
2929 |
my $item = Koha::Items->find($itemno); |
| 2929 |
|
2930 |
|
| 2930 |
return (0, 0, 0) unless $patron or $item; # Wrong call, no renewal allowed |
2931 |
return (0, 0, 0) unless $patron or $item; # Wrong call, no renewal allowed |
| 2931 |
|
2932 |
|
|
Lines 2942-2952
sub GetRenewCount {
Link Here
|
| 2942 |
my $data = $sth->fetchrow_hashref; |
2943 |
my $data = $sth->fetchrow_hashref; |
| 2943 |
$renewcount = $data->{'renewals'} if $data->{'renewals'}; |
2944 |
$renewcount = $data->{'renewals'} if $data->{'renewals'}; |
| 2944 |
# $item and $borrower should be calculated |
2945 |
# $item and $borrower should be calculated |
| 2945 |
my $branchcode = _GetCircControlBranch($item, $patron->unblessed); |
2946 |
my $branchcode = _GetCircControlBranch($item->unblessed, $patron->unblessed); |
| 2946 |
|
2947 |
|
| 2947 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
2948 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
| 2948 |
{ categorycode => $patron->categorycode, |
2949 |
{ categorycode => $patron->categorycode, |
| 2949 |
itemtype => $item->{itype}, |
2950 |
itemtype => $item->effective_itemtype, |
| 2950 |
branchcode => $branchcode |
2951 |
branchcode => $branchcode |
| 2951 |
} |
2952 |
} |
| 2952 |
); |
2953 |
); |
|
Lines 2981-2997
sub GetSoonestRenewDate {
Link Here
|
| 2981 |
|
2982 |
|
| 2982 |
my $dbh = C4::Context->dbh; |
2983 |
my $dbh = C4::Context->dbh; |
| 2983 |
|
2984 |
|
| 2984 |
my $item = GetItem($itemnumber) or return; |
2985 |
my $item = Koha::Items->find($itemnumber) or return; |
| 2985 |
my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; |
2986 |
my $itemissue = $item->checkout or return; |
| 2986 |
|
2987 |
|
| 2987 |
$borrowernumber ||= $itemissue->borrowernumber; |
2988 |
$borrowernumber ||= $itemissue->borrowernumber; |
| 2988 |
my $patron = Koha::Patrons->find( $borrowernumber ) |
2989 |
my $patron = Koha::Patrons->find( $borrowernumber ) |
| 2989 |
or return; |
2990 |
or return; |
| 2990 |
|
2991 |
|
| 2991 |
my $branchcode = _GetCircControlBranch( $item, $patron->unblessed ); |
2992 |
my $branchcode = _GetCircControlBranch( $item->unblessed, $patron->unblessed ); |
| 2992 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
2993 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
| 2993 |
{ categorycode => $patron->categorycode, |
2994 |
{ categorycode => $patron->categorycode, |
| 2994 |
itemtype => $item->{itype}, |
2995 |
itemtype => $item->effective_itemtype, |
| 2995 |
branchcode => $branchcode |
2996 |
branchcode => $branchcode |
| 2996 |
} |
2997 |
} |
| 2997 |
); |
2998 |
); |
|
Lines 3040-3056
sub GetLatestAutoRenewDate {
Link Here
|
| 3040 |
|
3041 |
|
| 3041 |
my $dbh = C4::Context->dbh; |
3042 |
my $dbh = C4::Context->dbh; |
| 3042 |
|
3043 |
|
| 3043 |
my $item = GetItem($itemnumber) or return; |
3044 |
my $item = Koha::Items->find($itemnumber) or return; |
| 3044 |
my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; |
3045 |
my $itemissue = $item->checkout or return; |
| 3045 |
|
3046 |
|
| 3046 |
$borrowernumber ||= $itemissue->borrowernumber; |
3047 |
$borrowernumber ||= $itemissue->borrowernumber; |
| 3047 |
my $patron = Koha::Patrons->find( $borrowernumber ) |
3048 |
my $patron = Koha::Patrons->find( $borrowernumber ) |
| 3048 |
or return; |
3049 |
or return; |
| 3049 |
|
3050 |
|
| 3050 |
my $branchcode = _GetCircControlBranch( $item, $patron->unblessed ); |
3051 |
my $branchcode = _GetCircControlBranch( $item->unblessed, $patron->unblessed ); |
| 3051 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
3052 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
| 3052 |
{ categorycode => $patron->categorycode, |
3053 |
{ categorycode => $patron->categorycode, |
| 3053 |
itemtype => $item->{itype}, |
3054 |
itemtype => $item->effective_itemtype, |
| 3054 |
branchcode => $branchcode |
3055 |
branchcode => $branchcode |
| 3055 |
} |
3056 |
} |
| 3056 |
); |
3057 |
); |
|
Lines 3627-3634
sub ReturnLostItem{
Link Here
|
| 3627 |
|
3628 |
|
| 3628 |
MarkIssueReturned( $borrowernumber, $itemnum ); |
3629 |
MarkIssueReturned( $borrowernumber, $itemnum ); |
| 3629 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
3630 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
| 3630 |
my $item = C4::Items::GetItem( $itemnum ); |
3631 |
my $item = Koha::Items->find($itemnum); |
| 3631 |
my $old_note = ($item->{'paidfor'} && ($item->{'paidfor'} ne q{})) ? $item->{'paidfor'}.' / ' : q{}; |
3632 |
my $old_note = ($item->paidfor && ($item->paidfor ne q{})) ? $item->paidfor.' / ' : q{}; |
| 3632 |
my @datearr = localtime(time); |
3633 |
my @datearr = localtime(time); |
| 3633 |
my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3]; |
3634 |
my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3]; |
| 3634 |
my $bor = $patron->firstname . ' ' . $patron->surname . ' ' . $patron->cardnumber; |
3635 |
my $bor = $patron->firstname . ' ' . $patron->surname . ' ' . $patron->cardnumber; |
|
Lines 3816-3823
sub ProcessOfflinePayment {
Link Here
|
| 3816 |
sub TransferSlip { |
3817 |
sub TransferSlip { |
| 3817 |
my ($branch, $itemnumber, $barcode, $to_branch) = @_; |
3818 |
my ($branch, $itemnumber, $barcode, $to_branch) = @_; |
| 3818 |
|
3819 |
|
| 3819 |
my $item = GetItem( $itemnumber, $barcode ) |
3820 |
my $item = |
| 3820 |
or return; |
3821 |
$itemnumber |
|
|
3822 |
? Koha::Items->find($itemnumber) |
| 3823 |
: Koha::Items->find( { barcode => $barcode } ); |
| 3824 |
|
| 3825 |
$item or return; |
| 3821 |
|
3826 |
|
| 3822 |
return C4::Letters::GetPreparedLetter ( |
3827 |
return C4::Letters::GetPreparedLetter ( |
| 3823 |
module => 'circulation', |
3828 |
module => 'circulation', |
|
Lines 3825-3832
sub TransferSlip {
Link Here
|
| 3825 |
branchcode => $branch, |
3830 |
branchcode => $branch, |
| 3826 |
tables => { |
3831 |
tables => { |
| 3827 |
'branches' => $to_branch, |
3832 |
'branches' => $to_branch, |
| 3828 |
'biblio' => $item->{biblionumber}, |
3833 |
'biblio' => $item->biblionumber, |
| 3829 |
'items' => $item, |
3834 |
'items' => $item->unblessed, |
| 3830 |
}, |
3835 |
}, |
| 3831 |
); |
3836 |
); |
| 3832 |
} |
3837 |
} |