|
Lines 669-685
sub CanBookBeIssued {
Link Here
|
| 669 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
669 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
| 670 |
my $override_high_holds = $params->{override_high_holds} || 0; |
670 |
my $override_high_holds = $params->{override_high_holds} || 0; |
| 671 |
|
671 |
|
| 672 |
my $item = GetItem(undef, $barcode ); |
672 |
my $item = Koha::Items->find({barcode => $barcode }); |
| 673 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
673 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
| 674 |
unless ( $item ) { |
674 |
unless ( $item ) { |
| 675 |
$issuingimpossible{UNKNOWN_BARCODE} = 1; |
675 |
$issuingimpossible{UNKNOWN_BARCODE} = 1; |
| 676 |
} |
676 |
} |
| 677 |
return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; |
677 |
return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; |
| 678 |
|
678 |
|
| 679 |
my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); |
679 |
my $item_unblessed = $item->unblessed; # Transition... |
| 680 |
my $biblio = Koha::Biblios->find( $item->{biblionumber} ); |
680 |
my $issue = $item->checkout; |
|
|
681 |
my $biblio = $item->biblio; |
| 681 |
my $biblioitem = $biblio->biblioitem; |
682 |
my $biblioitem = $biblio->biblioitem; |
| 682 |
my $effective_itemtype = $item->{itype}; # GetItem deals with that |
683 |
my $effective_itemtype = $item->effective_itemtype; |
| 683 |
my $dbh = C4::Context->dbh; |
684 |
my $dbh = C4::Context->dbh; |
| 684 |
my $patron_unblessed = $patron->unblessed; |
685 |
my $patron_unblessed = $patron->unblessed; |
| 685 |
|
686 |
|
|
Lines 693-699
sub CanBookBeIssued {
Link Here
|
| 693 |
unless ( $duedate ) { |
694 |
unless ( $duedate ) { |
| 694 |
my $issuedate = $now->clone(); |
695 |
my $issuedate = $now->clone(); |
| 695 |
|
696 |
|
| 696 |
my $branch = _GetCircControlBranch($item, $patron_unblessed); |
697 |
my $branch = _GetCircControlBranch($item_unblessed, $patron_unblessed); |
| 697 |
$duedate = CalcDateDue( $issuedate, $effective_itemtype, $branch, $patron_unblessed ); |
698 |
$duedate = CalcDateDue( $issuedate, $effective_itemtype, $branch, $patron_unblessed ); |
| 698 |
|
699 |
|
| 699 |
# Offline circ calls AddIssue directly, doesn't run through here |
700 |
# Offline circ calls AddIssue directly, doesn't run through here |
|
Lines 712-728
sub CanBookBeIssued {
Link Here
|
| 712 |
# |
713 |
# |
| 713 |
# BORROWER STATUS |
714 |
# BORROWER STATUS |
| 714 |
# |
715 |
# |
| 715 |
if ( $patron->category->category_type eq 'X' && ( $item->{barcode} )) { |
716 |
if ( $patron->category->category_type eq 'X' && ( $item->barcode )) { |
| 716 |
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . |
717 |
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . |
| 717 |
&UpdateStats({ |
718 |
&UpdateStats({ |
| 718 |
branch => C4::Context->userenv->{'branch'}, |
719 |
branch => C4::Context->userenv->{'branch'}, |
| 719 |
type => 'localuse', |
720 |
type => 'localuse', |
| 720 |
itemnumber => $item->{'itemnumber'}, |
721 |
itemnumber => $item->itemnumber, |
| 721 |
itemtype => $effective_itemtype, |
722 |
itemtype => $effective_itemtype, |
| 722 |
borrowernumber => $patron->borrowernumber, |
723 |
borrowernumber => $patron->borrowernumber, |
| 723 |
ccode => $item->{'ccode'}} |
724 |
ccode => $item->ccode} |
| 724 |
); |
725 |
); |
| 725 |
ModDateLastSeen( $item->{'itemnumber'} ); |
726 |
ModDateLastSeen( $item->itemnumber ); # FIXME Move to Koha::Item |
| 726 |
return( { STATS => 1 }, {}); |
727 |
return( { STATS => 1 }, {}); |
| 727 |
} |
728 |
} |
| 728 |
|
729 |
|
|
Lines 833-839
sub CanBookBeIssued {
Link Here
|
| 833 |
} else { |
834 |
} else { |
| 834 |
my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed( |
835 |
my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed( |
| 835 |
$patron->borrowernumber, |
836 |
$patron->borrowernumber, |
| 836 |
$item->{'itemnumber'}, |
837 |
$item->itemnumber, |
| 837 |
); |
838 |
); |
| 838 |
if ( $CanBookBeRenewed == 0 ) { # no more renewals allowed |
839 |
if ( $CanBookBeRenewed == 0 ) { # no more renewals allowed |
| 839 |
if ( $renewerror eq 'onsite_checkout' ) { |
840 |
if ( $renewerror eq 'onsite_checkout' ) { |
|
Lines 854-860
sub CanBookBeIssued {
Link Here
|
| 854 |
|
855 |
|
| 855 |
my $patron = Koha::Patrons->find( $issue->borrowernumber ); |
856 |
my $patron = Koha::Patrons->find( $issue->borrowernumber ); |
| 856 |
|
857 |
|
| 857 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); |
858 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); |
| 858 |
|
859 |
|
| 859 |
unless ( $can_be_returned ) { |
860 |
unless ( $can_be_returned ) { |
| 860 |
$issuingimpossible{RETURN_IMPOSSIBLE} = 1; |
861 |
$issuingimpossible{RETURN_IMPOSSIBLE} = 1; |
|
Lines 875-881
sub CanBookBeIssued {
Link Here
|
| 875 |
and $issue |
876 |
and $issue |
| 876 |
and $issue->onsite_checkout |
877 |
and $issue->onsite_checkout |
| 877 |
and $issue->borrowernumber == $patron->borrowernumber ? 1 : 0 ); |
878 |
and $issue->borrowernumber == $patron->borrowernumber ? 1 : 0 ); |
| 878 |
my $toomany = TooMany( $patron_unblessed, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } ); |
879 |
my $toomany = TooMany( $patron_unblessed, $item->biblionumber, $item_unblessed, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } ); |
| 879 |
# if TooMany max_allowed returns 0 the user doesn't have permission to check out this book |
880 |
# if TooMany max_allowed returns 0 the user doesn't have permission to check out this book |
| 880 |
if ( $toomany && not exists $needsconfirmation{RENEW_ISSUE} ) { |
881 |
if ( $toomany && not exists $needsconfirmation{RENEW_ISSUE} ) { |
| 881 |
if ( $toomany->{max_allowed} == 0 ) { |
882 |
if ( $toomany->{max_allowed} == 0 ) { |
|
Lines 898-916
sub CanBookBeIssued {
Link Here
|
| 898 |
$patron = Koha::Patrons->find( $patron->borrowernumber ); # FIXME Refetch just in case, to avoid regressions. But must not be needed |
899 |
$patron = Koha::Patrons->find( $patron->borrowernumber ); # FIXME Refetch just in case, to avoid regressions. But must not be needed |
| 899 |
my $wants_check = $patron->wants_check_for_previous_checkout; |
900 |
my $wants_check = $patron->wants_check_for_previous_checkout; |
| 900 |
$needsconfirmation{PREVISSUE} = 1 |
901 |
$needsconfirmation{PREVISSUE} = 1 |
| 901 |
if ($wants_check and $patron->do_check_for_previous_checkout($item)); |
902 |
if ($wants_check and $patron->do_check_for_previous_checkout($item_unblessed)); |
| 902 |
|
903 |
|
| 903 |
# |
904 |
# |
| 904 |
# ITEM CHECKING |
905 |
# ITEM CHECKING |
| 905 |
# |
906 |
# |
| 906 |
if ( $item->{'notforloan'} ) |
907 |
if ( $item->notforloan ) |
| 907 |
{ |
908 |
{ |
| 908 |
if(!C4::Context->preference("AllowNotForLoanOverride")){ |
909 |
if(!C4::Context->preference("AllowNotForLoanOverride")){ |
| 909 |
$issuingimpossible{NOT_FOR_LOAN} = 1; |
910 |
$issuingimpossible{NOT_FOR_LOAN} = 1; |
| 910 |
$issuingimpossible{item_notforloan} = $item->{'notforloan'}; |
911 |
$issuingimpossible{item_notforloan} = $item->notforloan; |
| 911 |
}else{ |
912 |
}else{ |
| 912 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
913 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
| 913 |
$needsconfirmation{item_notforloan} = $item->{'notforloan'}; |
914 |
$needsconfirmation{item_notforloan} = $item->notforloan; |
| 914 |
} |
915 |
} |
| 915 |
} |
916 |
} |
| 916 |
else { |
917 |
else { |
|
Lines 943-959
sub CanBookBeIssued {
Link Here
|
| 943 |
} |
944 |
} |
| 944 |
} |
945 |
} |
| 945 |
} |
946 |
} |
| 946 |
if ( $item->{'withdrawn'} && $item->{'withdrawn'} > 0 ) |
947 |
if ( $item->withdrawn && $item->withdrawn > 0 ) |
| 947 |
{ |
948 |
{ |
| 948 |
$issuingimpossible{WTHDRAWN} = 1; |
949 |
$issuingimpossible{WTHDRAWN} = 1; |
| 949 |
} |
950 |
} |
| 950 |
if ( $item->{'restricted'} |
951 |
if ( $item->restricted |
| 951 |
&& $item->{'restricted'} == 1 ) |
952 |
&& $item->restricted == 1 ) |
| 952 |
{ |
953 |
{ |
| 953 |
$issuingimpossible{RESTRICTED} = 1; |
954 |
$issuingimpossible{RESTRICTED} = 1; |
| 954 |
} |
955 |
} |
| 955 |
if ( $item->{'itemlost'} && C4::Context->preference("IssueLostItem") ne 'nothing' ) { |
956 |
if ( $item->itemlost && C4::Context->preference("IssueLostItem") ne 'nothing' ) { |
| 956 |
my $av = Koha::AuthorisedValues->search({ category => 'LOST', authorised_value => $item->{itemlost} }); |
957 |
my $av = Koha::AuthorisedValues->search({ category => 'LOST', authorised_value => $item->itemlost }); |
| 957 |
my $code = $av->count ? $av->next->lib : ''; |
958 |
my $code = $av->count ? $av->next->lib : ''; |
| 958 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
959 |
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); |
| 959 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
960 |
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); |
|
Lines 961-969
sub CanBookBeIssued {
Link Here
|
| 961 |
if ( C4::Context->preference("IndependentBranches") ) { |
962 |
if ( C4::Context->preference("IndependentBranches") ) { |
| 962 |
my $userenv = C4::Context->userenv; |
963 |
my $userenv = C4::Context->userenv; |
| 963 |
unless ( C4::Context->IsSuperLibrarian() ) { |
964 |
unless ( C4::Context->IsSuperLibrarian() ) { |
| 964 |
if ( $item->{C4::Context->preference("HomeOrHoldingBranch")} ne $userenv->{branch} ){ |
965 |
my $HomeOrHoldingBranch = C4::Context->preference("HomeOrHoldingBranch"); |
|
|
966 |
if ( $item->$HomeOrHoldingBranch ne $userenv->{branch} ){ |
| 965 |
$issuingimpossible{ITEMNOTSAMEBRANCH} = 1; |
967 |
$issuingimpossible{ITEMNOTSAMEBRANCH} = 1; |
| 966 |
$issuingimpossible{'itemhomebranch'} = $item->{C4::Context->preference("HomeOrHoldingBranch")}; |
968 |
$issuingimpossible{'itemhomebranch'} = $item->$HomeOrHoldingBranch; |
| 967 |
} |
969 |
} |
| 968 |
$needsconfirmation{BORRNOTSAMEBRANCH} = $patron->branchcode |
970 |
$needsconfirmation{BORRNOTSAMEBRANCH} = $patron->branchcode |
| 969 |
if ( $patron->branchcode ne $userenv->{branch} ); |
971 |
if ( $patron->branchcode ne $userenv->{branch} ); |
|
Lines 975-981
sub CanBookBeIssued {
Link Here
|
| 975 |
my $rentalConfirmation = C4::Context->preference("RentalFeesCheckoutConfirmation"); |
977 |
my $rentalConfirmation = C4::Context->preference("RentalFeesCheckoutConfirmation"); |
| 976 |
|
978 |
|
| 977 |
if ( $rentalConfirmation ){ |
979 |
if ( $rentalConfirmation ){ |
| 978 |
my ($rentalCharge) = GetIssuingCharges( $item->{'itemnumber'}, $patron->borrowernumber ); |
980 |
my ($rentalCharge) = GetIssuingCharges( $item->itemnumber, $patron->borrowernumber ); |
| 979 |
if ( $rentalCharge > 0 ){ |
981 |
if ( $rentalCharge > 0 ){ |
| 980 |
$needsconfirmation{RENTALCHARGE} = $rentalCharge; |
982 |
$needsconfirmation{RENTALCHARGE} = $rentalCharge; |
| 981 |
} |
983 |
} |
|
Lines 983-989
sub CanBookBeIssued {
Link Here
|
| 983 |
|
985 |
|
| 984 |
unless ( $ignore_reserves ) { |
986 |
unless ( $ignore_reserves ) { |
| 985 |
# See if the item is on reserve. |
987 |
# See if the item is on reserve. |
| 986 |
my ( $restype, $res ) = C4::Reserves::CheckReserves( $item->{'itemnumber'} ); |
988 |
my ( $restype, $res ) = C4::Reserves::CheckReserves( $item->itemnumber ); |
| 987 |
if ($restype) { |
989 |
if ($restype) { |
| 988 |
my $resbor = $res->{'borrowernumber'}; |
990 |
my $resbor = $res->{'borrowernumber'}; |
| 989 |
if ( $resbor ne $patron->borrowernumber ) { |
991 |
if ( $resbor ne $patron->borrowernumber ) { |
|
Lines 1028-1034
sub CanBookBeIssued {
Link Here
|
| 1028 |
|
1030 |
|
| 1029 |
## check for high holds decreasing loan period |
1031 |
## check for high holds decreasing loan period |
| 1030 |
if ( C4::Context->preference('decreaseLoanHighHolds') ) { |
1032 |
if ( C4::Context->preference('decreaseLoanHighHolds') ) { |
| 1031 |
my $check = checkHighHolds( $item, $patron_unblessed ); |
1033 |
my $check = checkHighHolds( $item_unblessed, $patron_unblessed ); |
| 1032 |
|
1034 |
|
| 1033 |
if ( $check->{exceeded} ) { |
1035 |
if ( $check->{exceeded} ) { |
| 1034 |
if ($override_high_holds) { |
1036 |
if ($override_high_holds) { |
|
Lines 1057-1063
sub CanBookBeIssued {
Link Here
|
| 1057 |
) { |
1059 |
) { |
| 1058 |
# Check if borrower has already issued an item from the same biblio |
1060 |
# Check if borrower has already issued an item from the same biblio |
| 1059 |
# Only if it's not a subscription |
1061 |
# Only if it's not a subscription |
| 1060 |
my $biblionumber = $item->{biblionumber}; |
1062 |
my $biblionumber = $item->biblionumber; |
| 1061 |
require C4::Serials; |
1063 |
require C4::Serials; |
| 1062 |
my $is_a_subscription = C4::Serials::CountSubscriptionFromBiblionumber($biblionumber); |
1064 |
my $is_a_subscription = C4::Serials::CountSubscriptionFromBiblionumber($biblionumber); |
| 1063 |
unless ($is_a_subscription) { |
1065 |
unless ($is_a_subscription) { |
|
Lines 1090-1096
Check whether the item can be returned to the provided branch
Link Here
|
| 1090 |
|
1092 |
|
| 1091 |
=over 4 |
1093 |
=over 4 |
| 1092 |
|
1094 |
|
| 1093 |
=item C<$item> is a hash of item information as returned from GetItem |
1095 |
=item C<$item> is a hash of item information as returned Koha::Items->find->unblessed (Temporary, should be a Koha::Item instead) |
| 1094 |
|
1096 |
|
| 1095 |
=item C<$branch> is the branchcode where the return is taking place |
1097 |
=item C<$branch> is the branchcode where the return is taking place |
| 1096 |
|
1098 |
|
|
Lines 1288-1308
sub AddIssue {
Link Here
|
| 1288 |
# Stop here if the patron or barcode doesn't exist |
1290 |
# Stop here if the patron or barcode doesn't exist |
| 1289 |
if ( $borrower && $barcode && $barcodecheck ) { |
1291 |
if ( $borrower && $barcode && $barcodecheck ) { |
| 1290 |
# find which item we issue |
1292 |
# find which item we issue |
| 1291 |
my $item = GetItem( '', $barcode ) |
1293 |
my $item = Koha::Items->find({ barcode => $barcode }) |
| 1292 |
or return; # if we don't get an Item, abort. |
1294 |
or return; # if we don't get an Item, abort. |
| 1293 |
my $item_object = Koha::Items->find( { barcode => $barcode } ); |
1295 |
my $item_unblessed = $item->unblessed; |
| 1294 |
|
1296 |
|
| 1295 |
my $branch = _GetCircControlBranch( $item, $borrower ); |
1297 |
my $branch = _GetCircControlBranch( $item_unblessed, $borrower ); |
| 1296 |
|
1298 |
|
| 1297 |
# get actual issuing if there is one |
1299 |
# get actual issuing if there is one |
| 1298 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); |
1300 |
my $actualissue = $item->checkout; |
| 1299 |
|
1301 |
|
| 1300 |
# check if we just renew the issue. |
1302 |
# check if we just renew the issue. |
| 1301 |
if ( $actualissue and $actualissue->borrowernumber eq $borrower->{'borrowernumber'} |
1303 |
if ( $actualissue and $actualissue->borrowernumber eq $borrower->{'borrowernumber'} |
| 1302 |
and not $switch_onsite_checkout ) { |
1304 |
and not $switch_onsite_checkout ) { |
| 1303 |
$datedue = AddRenewal( |
1305 |
$datedue = AddRenewal( |
| 1304 |
$borrower->{'borrowernumber'}, |
1306 |
$borrower->{'borrowernumber'}, |
| 1305 |
$item->{'itemnumber'}, |
1307 |
$item->itemnumber, |
| 1306 |
$branch, |
1308 |
$branch, |
| 1307 |
$datedue, |
1309 |
$datedue, |
| 1308 |
$issuedate, # here interpreted as the renewal date |
1310 |
$issuedate, # here interpreted as the renewal date |
|
Lines 1313-1327
sub AddIssue {
Link Here
|
| 1313 |
if ( $actualissue and not $switch_onsite_checkout ) { |
1315 |
if ( $actualissue and not $switch_onsite_checkout ) { |
| 1314 |
# This book is currently on loan, but not to the person |
1316 |
# This book is currently on loan, but not to the person |
| 1315 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1317 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
| 1316 |
my ( $allowed, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); |
1318 |
my ( $allowed, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); |
| 1317 |
return unless $allowed; |
1319 |
return unless $allowed; |
| 1318 |
AddReturn( $item->{'barcode'}, C4::Context->userenv->{'branch'} ); |
1320 |
AddReturn( $item->barcode, C4::Context->userenv->{'branch'} ); |
| 1319 |
} |
1321 |
} |
| 1320 |
|
1322 |
|
| 1321 |
C4::Reserves::MoveReserve( $item->{'itemnumber'}, $borrower->{'borrowernumber'}, $cancelreserve ); |
1323 |
C4::Reserves::MoveReserve( $item->itemnumber, $borrower->{'borrowernumber'}, $cancelreserve ); |
| 1322 |
|
1324 |
|
| 1323 |
# Starting process for transfer job (checking transfert and validate it if we have one) |
1325 |
# Starting process for transfer job (checking transfert and validate it if we have one) |
| 1324 |
my ($datesent) = GetTransfers( $item->{'itemnumber'} ); |
1326 |
my ($datesent) = GetTransfers( $item->itemnumber ); |
| 1325 |
if ($datesent) { |
1327 |
if ($datesent) { |
| 1326 |
# updating line of branchtranfert to finish it, and changing the to branch value, implement a comment for visibility of this case (maybe for stats ....) |
1328 |
# 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 |
my $sth = $dbh->prepare( |
1329 |
my $sth = $dbh->prepare( |
|
Lines 1332-1345
sub AddIssue {
Link Here
|
| 1332 |
WHERE itemnumber= ? AND datearrived IS NULL" |
1334 |
WHERE itemnumber= ? AND datearrived IS NULL" |
| 1333 |
); |
1335 |
); |
| 1334 |
$sth->execute( C4::Context->userenv->{'branch'}, |
1336 |
$sth->execute( C4::Context->userenv->{'branch'}, |
| 1335 |
$item->{'itemnumber'} ); |
1337 |
$item->itemnumber ); |
| 1336 |
} |
1338 |
} |
| 1337 |
|
1339 |
|
| 1338 |
# If automatic renewal wasn't selected while issuing, set the value according to the issuing rule. |
1340 |
# If automatic renewal wasn't selected while issuing, set the value according to the issuing rule. |
| 1339 |
unless ($auto_renew) { |
1341 |
unless ($auto_renew) { |
| 1340 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
1342 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
| 1341 |
{ categorycode => $borrower->{categorycode}, |
1343 |
{ categorycode => $borrower->{categorycode}, |
| 1342 |
itemtype => $item->{itype}, |
1344 |
itemtype => $item->effective_itemtype, |
| 1343 |
branchcode => $branch |
1345 |
branchcode => $branch |
| 1344 |
} |
1346 |
} |
| 1345 |
); |
1347 |
); |
|
Lines 1349-1355
sub AddIssue {
Link Here
|
| 1349 |
|
1351 |
|
| 1350 |
# Record in the database the fact that the book was issued. |
1352 |
# Record in the database the fact that the book was issued. |
| 1351 |
unless ($datedue) { |
1353 |
unless ($datedue) { |
| 1352 |
my $itype = $item_object->effective_itemtype; |
1354 |
my $itype = $item->effective_itemtype; |
| 1353 |
$datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower ); |
1355 |
$datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower ); |
| 1354 |
|
1356 |
|
| 1355 |
} |
1357 |
} |
|
Lines 1358-1364
sub AddIssue {
Link Here
|
| 1358 |
$issue = Koha::Database->new()->schema()->resultset('Issue')->update_or_create( |
1360 |
$issue = Koha::Database->new()->schema()->resultset('Issue')->update_or_create( |
| 1359 |
{ |
1361 |
{ |
| 1360 |
borrowernumber => $borrower->{'borrowernumber'}, |
1362 |
borrowernumber => $borrower->{'borrowernumber'}, |
| 1361 |
itemnumber => $item->{'itemnumber'}, |
1363 |
itemnumber => $item->itemnumber, |
| 1362 |
issuedate => $issuedate->strftime('%Y-%m-%d %H:%M:%S'), |
1364 |
issuedate => $issuedate->strftime('%Y-%m-%d %H:%M:%S'), |
| 1363 |
date_due => $datedue->strftime('%Y-%m-%d %H:%M:%S'), |
1365 |
date_due => $datedue->strftime('%Y-%m-%d %H:%M:%S'), |
| 1364 |
branchcode => C4::Context->userenv->{'branch'}, |
1366 |
branchcode => C4::Context->userenv->{'branch'}, |
|
Lines 1369-1417
sub AddIssue {
Link Here
|
| 1369 |
|
1371 |
|
| 1370 |
if ( C4::Context->preference('ReturnToShelvingCart') ) { |
1372 |
if ( C4::Context->preference('ReturnToShelvingCart') ) { |
| 1371 |
# ReturnToShelvingCart is on, anything issued should be taken off the cart. |
1373 |
# ReturnToShelvingCart is on, anything issued should be taken off the cart. |
| 1372 |
CartToShelf( $item->{'itemnumber'} ); |
1374 |
CartToShelf( $item->itemnumber ); |
| 1373 |
} |
1375 |
} |
| 1374 |
$item->{'issues'}++; |
1376 |
|
| 1375 |
if ( C4::Context->preference('UpdateTotalIssuesOnCirc') ) { |
1377 |
if ( C4::Context->preference('UpdateTotalIssuesOnCirc') ) { |
| 1376 |
UpdateTotalIssues( $item->{'biblionumber'}, 1 ); |
1378 |
UpdateTotalIssues( $item->biblionumber, 1 ); |
| 1377 |
} |
1379 |
} |
| 1378 |
|
1380 |
|
| 1379 |
## If item was lost, it has now been found, reverse any list item charges if necessary. |
1381 |
## If item was lost, it has now been found, reverse any list item charges if necessary. |
| 1380 |
if ( $item->{'itemlost'} ) { |
1382 |
if ( $item->itemlost ) { |
| 1381 |
if ( |
1383 |
if ( |
| 1382 |
Koha::RefundLostItemFeeRules->should_refund( |
1384 |
Koha::RefundLostItemFeeRules->should_refund( |
| 1383 |
{ |
1385 |
{ |
| 1384 |
current_branch => C4::Context->userenv->{branch}, |
1386 |
current_branch => C4::Context->userenv->{branch}, |
| 1385 |
item_home_branch => $item->{homebranch}, |
1387 |
item_home_branch => $item->homebranch, |
| 1386 |
item_holding_branch => $item->{holdingbranch} |
1388 |
item_holding_branch => $item->holdingbranch, |
| 1387 |
} |
1389 |
} |
| 1388 |
) |
1390 |
) |
| 1389 |
) |
1391 |
) |
| 1390 |
{ |
1392 |
{ |
| 1391 |
_FixAccountForLostAndReturned( $item->{'itemnumber'}, undef, |
1393 |
_FixAccountForLostAndReturned( $item->itemnumber, undef, |
| 1392 |
$item->{'barcode'} ); |
1394 |
$item->barcode ); |
| 1393 |
} |
1395 |
} |
| 1394 |
} |
1396 |
} |
| 1395 |
|
1397 |
|
| 1396 |
ModItem( |
1398 |
ModItem( |
| 1397 |
{ |
1399 |
{ |
| 1398 |
issues => $item->{'issues'}, |
1400 |
issues => $item->issues + 1, |
| 1399 |
holdingbranch => C4::Context->userenv->{'branch'}, |
1401 |
holdingbranch => C4::Context->userenv->{'branch'}, |
| 1400 |
itemlost => 0, |
1402 |
itemlost => 0, |
| 1401 |
onloan => $datedue->ymd(), |
1403 |
onloan => $datedue->ymd(), |
| 1402 |
datelastborrowed => DateTime->now( time_zone => C4::Context->tz() )->ymd(), |
1404 |
datelastborrowed => DateTime->now( time_zone => C4::Context->tz() )->ymd(), |
| 1403 |
}, |
1405 |
}, |
| 1404 |
$item->{'biblionumber'}, |
1406 |
$item->biblionumber, |
| 1405 |
$item->{'itemnumber'}, |
1407 |
$item->itemnumber, |
| 1406 |
{ log_action => 0 } |
1408 |
{ log_action => 0 } |
| 1407 |
); |
1409 |
); |
| 1408 |
ModDateLastSeen( $item->{'itemnumber'} ); |
1410 |
ModDateLastSeen( $item->itemnumber ); |
| 1409 |
|
1411 |
|
| 1410 |
# If it costs to borrow this book, charge it to the patron's account. |
1412 |
# If it costs to borrow this book, charge it to the patron's account. |
| 1411 |
my ( $charge, $itemtype ) = GetIssuingCharges( $item->{'itemnumber'}, $borrower->{'borrowernumber'} ); |
1413 |
my ( $charge, $itemtype ) = GetIssuingCharges( $item->itemnumber, $borrower->{'borrowernumber'} ); |
| 1412 |
if ( $charge > 0 ) { |
1414 |
if ( $charge > 0 ) { |
| 1413 |
AddIssuingCharge( $issue, $charge ); |
1415 |
AddIssuingCharge( $issue, $charge ); |
| 1414 |
$item->{'charge'} = $charge; |
|
|
| 1415 |
} |
1416 |
} |
| 1416 |
|
1417 |
|
| 1417 |
# Record the fact that this book was issued. |
1418 |
# Record the fact that this book was issued. |
|
Lines 1421-1431
sub AddIssue {
Link Here
|
| 1421 |
type => ( $onsite_checkout ? 'onsite_checkout' : 'issue' ), |
1422 |
type => ( $onsite_checkout ? 'onsite_checkout' : 'issue' ), |
| 1422 |
amount => $charge, |
1423 |
amount => $charge, |
| 1423 |
other => ( $sipmode ? "SIP-$sipmode" : '' ), |
1424 |
other => ( $sipmode ? "SIP-$sipmode" : '' ), |
| 1424 |
itemnumber => $item->{'itemnumber'}, |
1425 |
itemnumber => $item->itemnumber, |
| 1425 |
itemtype => $item->{'itype'}, |
1426 |
itemtype => $item->effective_itemtype, |
| 1426 |
location => $item->{location}, |
1427 |
location => $item->location, |
| 1427 |
borrowernumber => $borrower->{'borrowernumber'}, |
1428 |
borrowernumber => $borrower->{'borrowernumber'}, |
| 1428 |
ccode => $item->{'ccode'} |
1429 |
ccode => $item->ccode, |
| 1429 |
} |
1430 |
} |
| 1430 |
); |
1431 |
); |
| 1431 |
|
1432 |
|
|
Lines 1434-1440
sub AddIssue {
Link Here
|
| 1434 |
my %conditions = ( |
1435 |
my %conditions = ( |
| 1435 |
branchcode => $branch, |
1436 |
branchcode => $branch, |
| 1436 |
categorycode => $borrower->{categorycode}, |
1437 |
categorycode => $borrower->{categorycode}, |
| 1437 |
item_type => $item->{itype}, |
1438 |
item_type => $item->effective_itemtype, |
| 1438 |
notification => 'CHECKOUT', |
1439 |
notification => 'CHECKOUT', |
| 1439 |
); |
1440 |
); |
| 1440 |
if ( $circulation_alert->is_enabled_for( \%conditions ) ) { |
1441 |
if ( $circulation_alert->is_enabled_for( \%conditions ) ) { |
|
Lines 1450-1456
sub AddIssue {
Link Here
|
| 1450 |
logaction( |
1451 |
logaction( |
| 1451 |
"CIRCULATION", "ISSUE", |
1452 |
"CIRCULATION", "ISSUE", |
| 1452 |
$borrower->{'borrowernumber'}, |
1453 |
$borrower->{'borrowernumber'}, |
| 1453 |
$item->{'itemnumber'} |
1454 |
$item->itemnumber, |
| 1454 |
) if C4::Context->preference("IssueLog"); |
1455 |
) if C4::Context->preference("IssueLog"); |
| 1455 |
} |
1456 |
} |
| 1456 |
} |
1457 |
} |
|
Lines 1803-1815
sub AddReturn {
Link Here
|
| 1803 |
my $stat_type = 'return'; |
1804 |
my $stat_type = 'return'; |
| 1804 |
|
1805 |
|
| 1805 |
# get information on item |
1806 |
# get information on item |
| 1806 |
my $item = GetItem( undef, $barcode ); |
1807 |
my $item = Koha::Items->find({ barcode => $barcode }); |
| 1807 |
unless ($item) { |
1808 |
unless ($item) { |
| 1808 |
return ( 0, { BadBarcode => $barcode } ); # no barcode means no item or borrower. bail out. |
1809 |
return ( 0, { BadBarcode => $barcode } ); # no barcode means no item or borrower. bail out. |
| 1809 |
} |
1810 |
} |
| 1810 |
|
1811 |
|
| 1811 |
my $itemnumber = $item->{ itemnumber }; |
1812 |
my $itemnumber = $item->itemnumber; |
| 1812 |
my $itemtype = $item->{itype}; # GetItem called effective_itemtype |
1813 |
my $itemtype = $item->effective_itemtype; |
| 1813 |
|
1814 |
|
| 1814 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); |
1815 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); |
| 1815 |
if ( $issue ) { |
1816 |
if ( $issue ) { |
|
Lines 1829-1849
sub AddReturn {
Link Here
|
| 1829 |
} |
1830 |
} |
| 1830 |
} |
1831 |
} |
| 1831 |
|
1832 |
|
| 1832 |
if ( $item->{'location'} eq 'PROC' ) { |
1833 |
my $item_unblessed = $item->unblessed; |
|
|
1834 |
if ( $item->location eq 'PROC' ) { |
| 1833 |
if ( C4::Context->preference("InProcessingToShelvingCart") ) { |
1835 |
if ( C4::Context->preference("InProcessingToShelvingCart") ) { |
| 1834 |
$item->{'location'} = 'CART'; |
1836 |
$item_unblessed->{location} = 'CART'; |
| 1835 |
} |
1837 |
} |
| 1836 |
else { |
1838 |
else { |
| 1837 |
$item->{location} = $item->{permanent_location}; |
1839 |
$item_unblessed->{location} = $item->permanent_location; |
| 1838 |
} |
1840 |
} |
| 1839 |
|
1841 |
|
| 1840 |
ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'}, { log_action => 0 } ); |
1842 |
ModItem( $item_unblessed, $item->biblionumber, $item->itemnumber, { log_action => 0 } ); |
| 1841 |
} |
1843 |
} |
| 1842 |
|
1844 |
|
| 1843 |
# full item data, but no borrowernumber or checkout info (no issue) |
1845 |
# full item data, but no borrowernumber or checkout info (no issue) |
| 1844 |
my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch"; |
1846 |
my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch"; |
| 1845 |
# get the proper branch to which to return the item |
1847 |
# get the proper branch to which to return the item |
| 1846 |
my $returnbranch = $item->{$hbr} || $branch ; |
1848 |
my $returnbranch = $hbr ne 'noreturn' ? $item->$hbr : $branch; |
| 1847 |
# if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch) |
1849 |
# if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch) |
| 1848 |
|
1850 |
|
| 1849 |
my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not |
1851 |
my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not |
|
Lines 1859-1866
sub AddReturn {
Link Here
|
| 1859 |
} |
1861 |
} |
| 1860 |
else { |
1862 |
else { |
| 1861 |
foreach my $key ( keys %$rules ) { |
1863 |
foreach my $key ( keys %$rules ) { |
| 1862 |
if ( $item->{notforloan} eq $key ) { |
1864 |
if ( $item->notforloan eq $key ) { |
| 1863 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->{notforloan}, to => $rules->{$key} }; |
1865 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; |
| 1864 |
ModItem( { notforloan => $rules->{$key} }, undef, $itemnumber, { log_action => 0 } ); |
1866 |
ModItem( { notforloan => $rules->{$key} }, undef, $itemnumber, { log_action => 0 } ); |
| 1865 |
last; |
1867 |
last; |
| 1866 |
} |
1868 |
} |
|
Lines 1869-1875
sub AddReturn {
Link Here
|
| 1869 |
} |
1871 |
} |
| 1870 |
|
1872 |
|
| 1871 |
# check if the return is allowed at this branch |
1873 |
# check if the return is allowed at this branch |
| 1872 |
my ($returnallowed, $message) = CanBookBeReturned($item, $branch); |
1874 |
my ($returnallowed, $message) = CanBookBeReturned($item_unblessed, $branch); |
| 1873 |
unless ($returnallowed){ |
1875 |
unless ($returnallowed){ |
| 1874 |
$messages->{'Wrongbranch'} = { |
1876 |
$messages->{'Wrongbranch'} = { |
| 1875 |
Wrongbranch => $branch, |
1877 |
Wrongbranch => $branch, |
|
Lines 1879-1890
sub AddReturn {
Link Here
|
| 1879 |
return ( $doreturn, $messages, $issue, $patron_unblessed); |
1881 |
return ( $doreturn, $messages, $issue, $patron_unblessed); |
| 1880 |
} |
1882 |
} |
| 1881 |
|
1883 |
|
| 1882 |
if ( $item->{'withdrawn'} ) { # book has been cancelled |
1884 |
if ( $item->withdrawn ) { # book has been cancelled |
| 1883 |
$messages->{'withdrawn'} = 1; |
1885 |
$messages->{'withdrawn'} = 1; |
| 1884 |
$doreturn = 0 if C4::Context->preference("BlockReturnOfWithdrawnItems"); |
1886 |
$doreturn = 0 if C4::Context->preference("BlockReturnOfWithdrawnItems"); |
| 1885 |
} |
1887 |
} |
| 1886 |
|
1888 |
|
| 1887 |
if ( $item->{itemlost} and C4::Context->preference("BlockReturnOfLostItems") ) { |
1889 |
if ( $item->itemlost and C4::Context->preference("BlockReturnOfLostItems") ) { |
| 1888 |
$doreturn = 0; |
1890 |
$doreturn = 0; |
| 1889 |
} |
1891 |
} |
| 1890 |
|
1892 |
|
|
Lines 1901-1907
sub AddReturn {
Link Here
|
| 1901 |
# don't allow dropbox mode to create an invalid entry in issues (issuedate > today) |
1903 |
# don't allow dropbox mode to create an invalid entry in issues (issuedate > today) |
| 1902 |
# FIXME: check issuedate > returndate, factoring in holidays |
1904 |
# FIXME: check issuedate > returndate, factoring in holidays |
| 1903 |
|
1905 |
|
| 1904 |
$circControlBranch = _GetCircControlBranch($item,$patron_unblessed); |
1906 |
$circControlBranch = _GetCircControlBranch($item_unblessed, $patron_unblessed); |
| 1905 |
$is_overdue = $issue->is_overdue( $dropboxdate ); |
1907 |
$is_overdue = $issue->is_overdue( $dropboxdate ); |
| 1906 |
} else { |
1908 |
} else { |
| 1907 |
$is_overdue = $issue->is_overdue; |
1909 |
$is_overdue = $issue->is_overdue; |
|
Lines 1909-1920
sub AddReturn {
Link Here
|
| 1909 |
|
1911 |
|
| 1910 |
if ($patron) { |
1912 |
if ($patron) { |
| 1911 |
eval { |
1913 |
eval { |
| 1912 |
MarkIssueReturned( $borrowernumber, $item->{'itemnumber'}, |
1914 |
MarkIssueReturned( $borrowernumber, $item->itemnumber, |
| 1913 |
$circControlBranch, $return_date, $patron->privacy ); |
1915 |
$circControlBranch, $return_date, $patron->privacy ); |
| 1914 |
}; |
1916 |
}; |
| 1915 |
unless ( $@ ) { |
1917 |
unless ( $@ ) { |
| 1916 |
if ( ( C4::Context->preference('CalculateFinesOnReturn') && $is_overdue ) || $return_date ) { |
1918 |
if ( ( C4::Context->preference('CalculateFinesOnReturn') && $is_overdue ) || $return_date ) { |
| 1917 |
_CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $patron_unblessed, return_date => $return_date } ); |
1919 |
_CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed, return_date => $return_date } ); |
| 1918 |
} |
1920 |
} |
| 1919 |
} else { |
1921 |
} else { |
| 1920 |
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 ); |
1922 |
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 1927-1984
sub AddReturn {
Link Here
|
| 1927 |
|
1929 |
|
| 1928 |
} |
1930 |
} |
| 1929 |
|
1931 |
|
| 1930 |
ModItem( { onloan => undef }, $item->{biblionumber}, $item->{itemnumber}, { log_action => 0 } ); |
1932 |
ModItem( { onloan => undef }, $item->biblionumber, $item->itemnumber, { log_action => 0 } ); |
| 1931 |
} |
1933 |
} |
| 1932 |
|
1934 |
|
| 1933 |
# the holdingbranch is updated if the document is returned to another location. |
1935 |
# the holdingbranch is updated if the document is returned to another location. |
| 1934 |
# this is always done regardless of whether the item was on loan or not |
1936 |
# this is always done regardless of whether the item was on loan or not |
| 1935 |
my $item_holding_branch = $item->{ holdingbranch }; |
1937 |
my $item_holding_branch = $item->holdingbranch; |
| 1936 |
if ($item->{'holdingbranch'} ne $branch) { |
1938 |
if ($item->holdingbranch ne $branch) { |
| 1937 |
UpdateHoldingbranch($branch, $item->{'itemnumber'}); |
1939 |
UpdateHoldingbranch($branch, $item->itemnumber); |
| 1938 |
$item->{'holdingbranch'} = $branch; # update item data holdingbranch too |
1940 |
$item_unblessed->{'holdingbranch'} = $branch; # update item data holdingbranch too # FIXME I guess this is for the _debar_user_on_return call later |
| 1939 |
} |
1941 |
} |
| 1940 |
|
1942 |
|
| 1941 |
my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; |
1943 |
my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; |
| 1942 |
ModDateLastSeen( $item->{itemnumber}, $leave_item_lost ); |
1944 |
ModDateLastSeen( $item->itemnumber, $leave_item_lost ); |
| 1943 |
|
1945 |
|
| 1944 |
# check if we have a transfer for this document |
1946 |
# check if we have a transfer for this document |
| 1945 |
my ($datesent,$frombranch,$tobranch) = GetTransfers( $item->{'itemnumber'} ); |
1947 |
my ($datesent,$frombranch,$tobranch) = GetTransfers( $item->itemnumber ); |
| 1946 |
|
1948 |
|
| 1947 |
# if we have a transfer to do, we update the line of transfers with the datearrived |
1949 |
# if we have a transfer to do, we update the line of transfers with the datearrived |
| 1948 |
my $is_in_rotating_collection = C4::RotatingCollections::isItemInAnyCollection( $item->{'itemnumber'} ); |
1950 |
my $is_in_rotating_collection = C4::RotatingCollections::isItemInAnyCollection( $item->itemnumber ); |
| 1949 |
if ($datesent) { |
1951 |
if ($datesent) { |
| 1950 |
if ( $tobranch eq $branch ) { |
1952 |
if ( $tobranch eq $branch ) { |
| 1951 |
my $sth = C4::Context->dbh->prepare( |
1953 |
my $sth = C4::Context->dbh->prepare( |
| 1952 |
"UPDATE branchtransfers SET datearrived = now() WHERE itemnumber= ? AND datearrived IS NULL" |
1954 |
"UPDATE branchtransfers SET datearrived = now() WHERE itemnumber= ? AND datearrived IS NULL" |
| 1953 |
); |
1955 |
); |
| 1954 |
$sth->execute( $item->{'itemnumber'} ); |
1956 |
$sth->execute( $item->itemnumber ); |
| 1955 |
# if we have a reservation with valid transfer, we can set it's status to 'W' |
1957 |
# if we have a reservation with valid transfer, we can set it's status to 'W' |
| 1956 |
ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") ); |
1958 |
ShelfToCart( $item->itemnumber ) if ( C4::Context->preference("ReturnToShelvingCart") ); |
| 1957 |
C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W'); |
1959 |
C4::Reserves::ModReserveStatus($item->itemnumber, 'W'); |
| 1958 |
} else { |
1960 |
} else { |
| 1959 |
$messages->{'WrongTransfer'} = $tobranch; |
1961 |
$messages->{'WrongTransfer'} = $tobranch; |
| 1960 |
$messages->{'WrongTransferItem'} = $item->{'itemnumber'}; |
1962 |
$messages->{'WrongTransferItem'} = $item->itemnumber; |
| 1961 |
} |
1963 |
} |
| 1962 |
$validTransfert = 1; |
1964 |
$validTransfert = 1; |
| 1963 |
} else { |
1965 |
} else { |
| 1964 |
ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") ); |
1966 |
ShelfToCart( $item->itemnumber ) if ( C4::Context->preference("ReturnToShelvingCart") ); |
| 1965 |
} |
1967 |
} |
| 1966 |
|
1968 |
|
| 1967 |
# fix up the accounts..... |
1969 |
# fix up the accounts..... |
| 1968 |
if ( $item->{'itemlost'} ) { |
1970 |
if ( $item->itemlost ) { |
| 1969 |
$messages->{'WasLost'} = 1; |
1971 |
$messages->{'WasLost'} = 1; |
| 1970 |
unless ( C4::Context->preference("BlockReturnOfLostItems") ) { |
1972 |
unless ( C4::Context->preference("BlockReturnOfLostItems") ) { |
| 1971 |
if ( |
1973 |
if ( |
| 1972 |
Koha::RefundLostItemFeeRules->should_refund( |
1974 |
Koha::RefundLostItemFeeRules->should_refund( |
| 1973 |
{ |
1975 |
{ |
| 1974 |
current_branch => C4::Context->userenv->{branch}, |
1976 |
current_branch => C4::Context->userenv->{branch}, |
| 1975 |
item_home_branch => $item->{homebranch}, |
1977 |
item_home_branch => $item->homebranch, |
| 1976 |
item_holding_branch => $item_holding_branch |
1978 |
item_holding_branch => $item_holding_branch |
| 1977 |
} |
1979 |
} |
| 1978 |
) |
1980 |
) |
| 1979 |
) |
1981 |
) |
| 1980 |
{ |
1982 |
{ |
| 1981 |
_FixAccountForLostAndReturned( $item->{'itemnumber'}, |
1983 |
_FixAccountForLostAndReturned( $item->itemnumber, |
| 1982 |
$borrowernumber, $barcode ); |
1984 |
$borrowernumber, $barcode ); |
| 1983 |
$messages->{'LostItemFeeRefunded'} = 1; |
1985 |
$messages->{'LostItemFeeRefunded'} = 1; |
| 1984 |
} |
1986 |
} |
|
Lines 1987-2000
sub AddReturn {
Link Here
|
| 1987 |
|
1989 |
|
| 1988 |
# fix up the overdues in accounts... |
1990 |
# fix up the overdues in accounts... |
| 1989 |
if ($borrowernumber) { |
1991 |
if ($borrowernumber) { |
| 1990 |
my $fix = _FixOverduesOnReturn($borrowernumber, $item->{itemnumber}, $exemptfine, $dropbox); |
1992 |
my $fix = _FixOverduesOnReturn($borrowernumber, $item->itemnumber, $exemptfine, $dropbox); |
| 1991 |
defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->{itemnumber}...) failed!"; # zero is OK, check defined |
1993 |
defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->itemnumber...) failed!"; # zero is OK, check defined |
| 1992 |
|
1994 |
|
| 1993 |
if ( $issue and $issue->is_overdue ) { |
1995 |
if ( $issue and $issue->is_overdue ) { |
| 1994 |
# fix fine days |
1996 |
# fix fine days |
| 1995 |
$today = dt_from_string($return_date) if $return_date; |
1997 |
$today = dt_from_string($return_date) if $return_date; |
| 1996 |
$today = $dropboxdate if $dropbox; |
1998 |
$today = $dropboxdate if $dropbox; |
| 1997 |
my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item, dt_from_string($issue->date_due), $today ); |
1999 |
my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item_unblessed, dt_from_string($issue->date_due), $today ); |
| 1998 |
if ($reminder){ |
2000 |
if ($reminder){ |
| 1999 |
$messages->{'PrevDebarred'} = $debardate; |
2001 |
$messages->{'PrevDebarred'} = $debardate; |
| 2000 |
} else { |
2002 |
} else { |
|
Lines 2019-2025
sub AddReturn {
Link Here
|
| 2019 |
# if we don't have a reserve with the status W, we launch the Checkreserves routine |
2021 |
# if we don't have a reserve with the status W, we launch the Checkreserves routine |
| 2020 |
my ($resfound, $resrec); |
2022 |
my ($resfound, $resrec); |
| 2021 |
my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds |
2023 |
my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds |
| 2022 |
($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} ); |
2024 |
($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn ); |
| 2023 |
if ($resfound) { |
2025 |
if ($resfound) { |
| 2024 |
$resrec->{'ResFound'} = $resfound; |
2026 |
$resrec->{'ResFound'} = $resfound; |
| 2025 |
$messages->{'ResFound'} = $resrec; |
2027 |
$messages->{'ResFound'} = $resrec; |
|
Lines 2032-2038
sub AddReturn {
Link Here
|
| 2032 |
itemnumber => $itemnumber, |
2034 |
itemnumber => $itemnumber, |
| 2033 |
itemtype => $itemtype, |
2035 |
itemtype => $itemtype, |
| 2034 |
borrowernumber => $borrowernumber, |
2036 |
borrowernumber => $borrowernumber, |
| 2035 |
ccode => $item->{ ccode } |
2037 |
ccode => $item->ccode, |
| 2036 |
}); |
2038 |
}); |
| 2037 |
|
2039 |
|
| 2038 |
# Send a check-in slip. # NOTE: borrower may be undef. Do not try to send messages then. |
2040 |
# Send a check-in slip. # NOTE: borrower may be undef. Do not try to send messages then. |
|
Lines 2041-2059
sub AddReturn {
Link Here
|
| 2041 |
my %conditions = ( |
2043 |
my %conditions = ( |
| 2042 |
branchcode => $branch, |
2044 |
branchcode => $branch, |
| 2043 |
categorycode => $patron->categorycode, |
2045 |
categorycode => $patron->categorycode, |
| 2044 |
item_type => $item->{itype}, |
2046 |
item_type => $itemtype, |
| 2045 |
notification => 'CHECKIN', |
2047 |
notification => 'CHECKIN', |
| 2046 |
); |
2048 |
); |
| 2047 |
if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) { |
2049 |
if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) { |
| 2048 |
SendCirculationAlert({ |
2050 |
SendCirculationAlert({ |
| 2049 |
type => 'CHECKIN', |
2051 |
type => 'CHECKIN', |
| 2050 |
item => $item, |
2052 |
item => $item_unblessed, |
| 2051 |
borrower => $patron->unblessed, |
2053 |
borrower => $patron->unblessed, |
| 2052 |
branch => $branch, |
2054 |
branch => $branch, |
| 2053 |
}); |
2055 |
}); |
| 2054 |
} |
2056 |
} |
| 2055 |
|
2057 |
|
| 2056 |
logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'}) |
2058 |
logaction("CIRCULATION", "RETURN", $borrowernumber, $item->itemnumber) |
| 2057 |
if C4::Context->preference("ReturnLog"); |
2059 |
if C4::Context->preference("ReturnLog"); |
| 2058 |
} |
2060 |
} |
| 2059 |
|
2061 |
|
|
Lines 2069-2081
sub AddReturn {
Link Here
|
| 2069 |
|
2071 |
|
| 2070 |
# Transfer to returnbranch if Automatic transfer set or append message NeedsTransfer |
2072 |
# Transfer to returnbranch if Automatic transfer set or append message NeedsTransfer |
| 2071 |
if (!$is_in_rotating_collection && ($doreturn or $messages->{'NotIssued'}) and !$resfound and ($branch ne $returnbranch) and not $messages->{'WrongTransfer'}){ |
2073 |
if (!$is_in_rotating_collection && ($doreturn or $messages->{'NotIssued'}) and !$resfound and ($branch ne $returnbranch) and not $messages->{'WrongTransfer'}){ |
|
|
2074 |
my $BranchTransferLimitsType = C4::Context->preference("BranchTransferLimitsType"); |
| 2072 |
if (C4::Context->preference("AutomaticItemReturn" ) or |
2075 |
if (C4::Context->preference("AutomaticItemReturn" ) or |
| 2073 |
(C4::Context->preference("UseBranchTransferLimits") and |
2076 |
(C4::Context->preference("UseBranchTransferLimits") and |
| 2074 |
! IsBranchTransferAllowed($branch, $returnbranch, $item->{C4::Context->preference("BranchTransferLimitsType")} ) |
2077 |
! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType ) |
| 2075 |
)) { |
2078 |
)) { |
| 2076 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->{'itemnumber'},$branch, $returnbranch; |
2079 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->itemnumber,$branch, $returnbranch; |
| 2077 |
$debug and warn "item: " . Dumper($item); |
2080 |
$debug and warn "item: " . Dumper($item_unblessed); |
| 2078 |
ModItemTransfer($item->{'itemnumber'}, $branch, $returnbranch); |
2081 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch); |
| 2079 |
$messages->{'WasTransfered'} = 1; |
2082 |
$messages->{'WasTransfered'} = 1; |
| 2080 |
} else { |
2083 |
} else { |
| 2081 |
$messages->{'NeedsTransfer'} = $returnbranch; |
2084 |
$messages->{'NeedsTransfer'} = $returnbranch; |
|
Lines 2612-2618
sub CanBookBeRenewed {
Link Here
|
| 2612 |
my $dbh = C4::Context->dbh; |
2615 |
my $dbh = C4::Context->dbh; |
| 2613 |
my $renews = 1; |
2616 |
my $renews = 1; |
| 2614 |
|
2617 |
|
| 2615 |
my $item = GetItem($itemnumber) or return ( 0, 'no_item' ); |
2618 |
my $item = Koha::Items->find($itemnumber) or return ( 0, 'no_item' ); |
| 2616 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return ( 0, 'no_checkout' ); |
2619 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return ( 0, 'no_checkout' ); |
| 2617 |
return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout; |
2620 |
return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout; |
| 2618 |
return ( 0, 'item_denied_renewal') if _item_denied_renewal({ item => $item }); |
2621 |
return ( 0, 'item_denied_renewal') if _item_denied_renewal({ item => $item }); |
|
Lines 2670-2676
sub CanBookBeRenewed {
Link Here
|
| 2670 |
my @reservable; |
2673 |
my @reservable; |
| 2671 |
my %borrowers; |
2674 |
my %borrowers; |
| 2672 |
ITEM: foreach my $i (@itemnumbers) { |
2675 |
ITEM: foreach my $i (@itemnumbers) { |
| 2673 |
my $item = GetItem($i); |
2676 |
my $item = Koha::Items->find($i)->unblessed; |
| 2674 |
next if IsItemOnHoldAndFound($i); |
2677 |
next if IsItemOnHoldAndFound($i); |
| 2675 |
for my $b (@borrowernumbers) { |
2678 |
for my $b (@borrowernumbers) { |
| 2676 |
my $borr = $borrowers{$b} //= Koha::Patrons->find( $b )->unblessed; |
2679 |
my $borr = $borrowers{$b} //= Koha::Patrons->find( $b )->unblessed; |
|
Lines 2691-2700
sub CanBookBeRenewed {
Link Here
|
| 2691 |
|
2694 |
|
| 2692 |
return ( 1, undef ) if $override_limit; |
2695 |
return ( 1, undef ) if $override_limit; |
| 2693 |
|
2696 |
|
| 2694 |
my $branchcode = _GetCircControlBranch( $item, $patron->unblessed ); |
2697 |
my $branchcode = _GetCircControlBranch( $item->unblessed, $patron->unblessed ); |
| 2695 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
2698 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
| 2696 |
{ categorycode => $patron->categorycode, |
2699 |
{ categorycode => $patron->categorycode, |
| 2697 |
itemtype => $item->{itype}, |
2700 |
itemtype => $item->effective_itemtype, |
| 2698 |
branchcode => $branchcode |
2701 |
branchcode => $branchcode |
| 2699 |
} |
2702 |
} |
| 2700 |
); |
2703 |
); |
|
Lines 2818-2832
sub AddRenewal {
Link Here
|
| 2818 |
my $datedue = shift; |
2821 |
my $datedue = shift; |
| 2819 |
my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd(); |
2822 |
my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd(); |
| 2820 |
|
2823 |
|
| 2821 |
my $item = GetItem($itemnumber) or return; |
2824 |
my $item = Koha::Items->find($itemnumber) or return; |
| 2822 |
my $item_object = Koha::Items->find( $itemnumber ); # Should replace $item |
2825 |
my $biblio = $item->biblio; |
| 2823 |
my $biblio = $item_object->biblio; |
2826 |
my $issue = $item->checkout; |
|
|
2827 |
my $item_unblessed = $item->unblessed; |
| 2824 |
|
2828 |
|
| 2825 |
my $dbh = C4::Context->dbh; |
2829 |
my $dbh = C4::Context->dbh; |
| 2826 |
|
2830 |
|
| 2827 |
# Find the issues record for this book |
|
|
| 2828 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); |
| 2829 |
|
| 2830 |
return unless $issue; |
2831 |
return unless $issue; |
| 2831 |
|
2832 |
|
| 2832 |
$borrowernumber ||= $issue->borrowernumber; |
2833 |
$borrowernumber ||= $issue->borrowernumber; |
|
Lines 2840-2846
sub AddRenewal {
Link Here
|
| 2840 |
my $patron_unblessed = $patron->unblessed; |
2841 |
my $patron_unblessed = $patron->unblessed; |
| 2841 |
|
2842 |
|
| 2842 |
if ( C4::Context->preference('CalculateFinesOnReturn') && $issue->is_overdue ) { |
2843 |
if ( C4::Context->preference('CalculateFinesOnReturn') && $issue->is_overdue ) { |
| 2843 |
_CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $patron_unblessed } ); |
2844 |
_CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed } ); |
| 2844 |
} |
2845 |
} |
| 2845 |
_FixOverduesOnReturn( $borrowernumber, $itemnumber ); |
2846 |
_FixOverduesOnReturn( $borrowernumber, $itemnumber ); |
| 2846 |
|
2847 |
|
|
Lines 2849-2859
sub AddRenewal {
Link Here
|
| 2849 |
# based on the value of the RenewalPeriodBase syspref. |
2850 |
# based on the value of the RenewalPeriodBase syspref. |
| 2850 |
unless ($datedue) { |
2851 |
unless ($datedue) { |
| 2851 |
|
2852 |
|
| 2852 |
my $itemtype = $item_object->effective_itemtype; |
2853 |
my $itemtype = $item->effective_itemtype; |
| 2853 |
$datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ? |
2854 |
$datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ? |
| 2854 |
dt_from_string( $issue->date_due, 'sql' ) : |
2855 |
dt_from_string( $issue->date_due, 'sql' ) : |
| 2855 |
DateTime->now( time_zone => C4::Context->tz()); |
2856 |
DateTime->now( time_zone => C4::Context->tz()); |
| 2856 |
$datedue = CalcDateDue($datedue, $itemtype, _GetCircControlBranch($item, $patron_unblessed), $patron_unblessed, 'is a renewal'); |
2857 |
$datedue = CalcDateDue($datedue, $itemtype, _GetCircControlBranch($item_unblessed, $patron_unblessed), $patron_unblessed, 'is a renewal'); |
| 2857 |
} |
2858 |
} |
| 2858 |
|
2859 |
|
| 2859 |
# Update the issues record to have the new due date, and a new count |
2860 |
# Update the issues record to have the new due date, and a new count |
|
Lines 2867-2874
sub AddRenewal {
Link Here
|
| 2867 |
$sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $lastreneweddate, $borrowernumber, $itemnumber ); |
2868 |
$sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $lastreneweddate, $borrowernumber, $itemnumber ); |
| 2868 |
|
2869 |
|
| 2869 |
# Update the renewal count on the item, and tell zebra to reindex |
2870 |
# Update the renewal count on the item, and tell zebra to reindex |
| 2870 |
$renews = $item->{renewals} + 1; |
2871 |
$renews = $item->renewals + 1; |
| 2871 |
ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->{biblionumber}, $itemnumber, { log_action => 0 } ); |
2872 |
ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->biblionumber, $itemnumber, { log_action => 0 } ); |
| 2872 |
|
2873 |
|
| 2873 |
# Charge a new rental fee, if applicable? |
2874 |
# Charge a new rental fee, if applicable? |
| 2874 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
2875 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
|
Lines 2883-2889
sub AddRenewal {
Link Here
|
| 2883 |
VALUES (now(),?,?,?,?,?,?,?,?)" |
2884 |
VALUES (now(),?,?,?,?,?,?,?,?)" |
| 2884 |
); |
2885 |
); |
| 2885 |
$sth->execute( $borrowernumber, $accountno, $charge, $manager_id, |
2886 |
$sth->execute( $borrowernumber, $accountno, $charge, $manager_id, |
| 2886 |
"Renewal of Rental Item " . $biblio->title . " $item->{'barcode'}", |
2887 |
"Renewal of Rental Item " . $biblio->title . " " . $item->barcode, |
| 2887 |
'Rent', $charge, $itemnumber ); |
2888 |
'Rent', $charge, $itemnumber ); |
| 2888 |
} |
2889 |
} |
| 2889 |
|
2890 |
|
|
Lines 2893-2906
sub AddRenewal {
Link Here
|
| 2893 |
my %conditions = ( |
2894 |
my %conditions = ( |
| 2894 |
branchcode => $branch, |
2895 |
branchcode => $branch, |
| 2895 |
categorycode => $patron->categorycode, |
2896 |
categorycode => $patron->categorycode, |
| 2896 |
item_type => $item->{itype}, |
2897 |
item_type => $item->effective_itemtype, |
| 2897 |
notification => 'CHECKOUT', |
2898 |
notification => 'CHECKOUT', |
| 2898 |
); |
2899 |
); |
| 2899 |
if ( $circulation_alert->is_enabled_for( \%conditions ) ) { |
2900 |
if ( $circulation_alert->is_enabled_for( \%conditions ) ) { |
| 2900 |
SendCirculationAlert( |
2901 |
SendCirculationAlert( |
| 2901 |
{ |
2902 |
{ |
| 2902 |
type => 'RENEWAL', |
2903 |
type => 'RENEWAL', |
| 2903 |
item => $item, |
2904 |
item => $item_unblessed, |
| 2904 |
borrower => $patron->unblessed, |
2905 |
borrower => $patron->unblessed, |
| 2905 |
branch => $branch, |
2906 |
branch => $branch, |
| 2906 |
} |
2907 |
} |
|
Lines 2928-2937
sub AddRenewal {
Link Here
|
| 2928 |
type => 'renew', |
2929 |
type => 'renew', |
| 2929 |
amount => $charge, |
2930 |
amount => $charge, |
| 2930 |
itemnumber => $itemnumber, |
2931 |
itemnumber => $itemnumber, |
| 2931 |
itemtype => $item->{itype}, |
2932 |
itemtype => $item->effective_itemtype, |
| 2932 |
location => $item->{location}, |
2933 |
location => $item->location, |
| 2933 |
borrowernumber => $borrowernumber, |
2934 |
borrowernumber => $borrowernumber, |
| 2934 |
ccode => $item->{'ccode'} |
2935 |
ccode => $item->ccode, |
| 2935 |
} |
2936 |
} |
| 2936 |
); |
2937 |
); |
| 2937 |
|
2938 |
|
|
Lines 2949-2955
sub GetRenewCount {
Link Here
|
| 2949 |
my $renewsleft = 0; |
2950 |
my $renewsleft = 0; |
| 2950 |
|
2951 |
|
| 2951 |
my $patron = Koha::Patrons->find( $bornum ); |
2952 |
my $patron = Koha::Patrons->find( $bornum ); |
| 2952 |
my $item = GetItem($itemno); |
2953 |
my $item = Koha::Items->find($itemno); |
| 2953 |
|
2954 |
|
| 2954 |
return (0, 0, 0) unless $patron or $item; # Wrong call, no renewal allowed |
2955 |
return (0, 0, 0) unless $patron or $item; # Wrong call, no renewal allowed |
| 2955 |
|
2956 |
|
|
Lines 2966-2976
sub GetRenewCount {
Link Here
|
| 2966 |
my $data = $sth->fetchrow_hashref; |
2967 |
my $data = $sth->fetchrow_hashref; |
| 2967 |
$renewcount = $data->{'renewals'} if $data->{'renewals'}; |
2968 |
$renewcount = $data->{'renewals'} if $data->{'renewals'}; |
| 2968 |
# $item and $borrower should be calculated |
2969 |
# $item and $borrower should be calculated |
| 2969 |
my $branchcode = _GetCircControlBranch($item, $patron->unblessed); |
2970 |
my $branchcode = _GetCircControlBranch($item->unblessed, $patron->unblessed); |
| 2970 |
|
2971 |
|
| 2971 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
2972 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
| 2972 |
{ categorycode => $patron->categorycode, |
2973 |
{ categorycode => $patron->categorycode, |
| 2973 |
itemtype => $item->{itype}, |
2974 |
itemtype => $item->effective_itemtype, |
| 2974 |
branchcode => $branchcode |
2975 |
branchcode => $branchcode |
| 2975 |
} |
2976 |
} |
| 2976 |
); |
2977 |
); |
|
Lines 3005-3021
sub GetSoonestRenewDate {
Link Here
|
| 3005 |
|
3006 |
|
| 3006 |
my $dbh = C4::Context->dbh; |
3007 |
my $dbh = C4::Context->dbh; |
| 3007 |
|
3008 |
|
| 3008 |
my $item = GetItem($itemnumber) or return; |
3009 |
my $item = Koha::Items->find($itemnumber) or return; |
| 3009 |
my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; |
3010 |
my $itemissue = $item->checkout or return; |
| 3010 |
|
3011 |
|
| 3011 |
$borrowernumber ||= $itemissue->borrowernumber; |
3012 |
$borrowernumber ||= $itemissue->borrowernumber; |
| 3012 |
my $patron = Koha::Patrons->find( $borrowernumber ) |
3013 |
my $patron = Koha::Patrons->find( $borrowernumber ) |
| 3013 |
or return; |
3014 |
or return; |
| 3014 |
|
3015 |
|
| 3015 |
my $branchcode = _GetCircControlBranch( $item, $patron->unblessed ); |
3016 |
my $branchcode = _GetCircControlBranch( $item->unblessed, $patron->unblessed ); |
| 3016 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
3017 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
| 3017 |
{ categorycode => $patron->categorycode, |
3018 |
{ categorycode => $patron->categorycode, |
| 3018 |
itemtype => $item->{itype}, |
3019 |
itemtype => $item->effective_itemtype, |
| 3019 |
branchcode => $branchcode |
3020 |
branchcode => $branchcode |
| 3020 |
} |
3021 |
} |
| 3021 |
); |
3022 |
); |
|
Lines 3064-3080
sub GetLatestAutoRenewDate {
Link Here
|
| 3064 |
|
3065 |
|
| 3065 |
my $dbh = C4::Context->dbh; |
3066 |
my $dbh = C4::Context->dbh; |
| 3066 |
|
3067 |
|
| 3067 |
my $item = GetItem($itemnumber) or return; |
3068 |
my $item = Koha::Items->find($itemnumber) or return; |
| 3068 |
my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; |
3069 |
my $itemissue = $item->checkout or return; |
| 3069 |
|
3070 |
|
| 3070 |
$borrowernumber ||= $itemissue->borrowernumber; |
3071 |
$borrowernumber ||= $itemissue->borrowernumber; |
| 3071 |
my $patron = Koha::Patrons->find( $borrowernumber ) |
3072 |
my $patron = Koha::Patrons->find( $borrowernumber ) |
| 3072 |
or return; |
3073 |
or return; |
| 3073 |
|
3074 |
|
| 3074 |
my $branchcode = _GetCircControlBranch( $item, $patron->unblessed ); |
3075 |
my $branchcode = _GetCircControlBranch( $item->unblessed, $patron->unblessed ); |
| 3075 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
3076 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
| 3076 |
{ categorycode => $patron->categorycode, |
3077 |
{ categorycode => $patron->categorycode, |
| 3077 |
itemtype => $item->{itype}, |
3078 |
itemtype => $item->effective_itemtype, |
| 3078 |
branchcode => $branchcode |
3079 |
branchcode => $branchcode |
| 3079 |
} |
3080 |
} |
| 3080 |
); |
3081 |
); |
|
Lines 3651-3658
sub ReturnLostItem{
Link Here
|
| 3651 |
|
3652 |
|
| 3652 |
MarkIssueReturned( $borrowernumber, $itemnum ); |
3653 |
MarkIssueReturned( $borrowernumber, $itemnum ); |
| 3653 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
3654 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
| 3654 |
my $item = C4::Items::GetItem( $itemnum ); |
3655 |
my $item = Koha::Items->find($itemnum); |
| 3655 |
my $old_note = ($item->{'paidfor'} && ($item->{'paidfor'} ne q{})) ? $item->{'paidfor'}.' / ' : q{}; |
3656 |
my $old_note = ($item->paidfor && ($item->paidfor ne q{})) ? $item->paidfor.' / ' : q{}; |
| 3656 |
my @datearr = localtime(time); |
3657 |
my @datearr = localtime(time); |
| 3657 |
my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3]; |
3658 |
my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3]; |
| 3658 |
my $bor = $patron->firstname . ' ' . $patron->surname . ' ' . $patron->cardnumber; |
3659 |
my $bor = $patron->firstname . ' ' . $patron->surname . ' ' . $patron->cardnumber; |
|
Lines 3839-3846
sub ProcessOfflinePayment {
Link Here
|
| 3839 |
sub TransferSlip { |
3840 |
sub TransferSlip { |
| 3840 |
my ($branch, $itemnumber, $barcode, $to_branch) = @_; |
3841 |
my ($branch, $itemnumber, $barcode, $to_branch) = @_; |
| 3841 |
|
3842 |
|
| 3842 |
my $item = GetItem( $itemnumber, $barcode ) |
3843 |
my $item = |
| 3843 |
or return; |
3844 |
$itemnumber |
|
|
3845 |
? Koha::Items->find($itemnumber) |
| 3846 |
: Koha::Items->find( { barcode => $barcode } ); |
| 3847 |
|
| 3848 |
$item or return; |
| 3844 |
|
3849 |
|
| 3845 |
return C4::Letters::GetPreparedLetter ( |
3850 |
return C4::Letters::GetPreparedLetter ( |
| 3846 |
module => 'circulation', |
3851 |
module => 'circulation', |
|
Lines 3848-3855
sub TransferSlip {
Link Here
|
| 3848 |
branchcode => $branch, |
3853 |
branchcode => $branch, |
| 3849 |
tables => { |
3854 |
tables => { |
| 3850 |
'branches' => $to_branch, |
3855 |
'branches' => $to_branch, |
| 3851 |
'biblio' => $item->{biblionumber}, |
3856 |
'biblio' => $item->biblionumber, |
| 3852 |
'items' => $item, |
3857 |
'items' => $item->unblessed, |
| 3853 |
}, |
3858 |
}, |
| 3854 |
); |
3859 |
); |
| 3855 |
} |
3860 |
} |