Lines 308-314
sub transferbook {
Link Here
|
308 |
my $messages; |
308 |
my $messages; |
309 |
my $dotransfer = 1; |
309 |
my $dotransfer = 1; |
310 |
my $itemnumber = GetItemnumberFromBarcode( $barcode ); |
310 |
my $itemnumber = GetItemnumberFromBarcode( $barcode ); |
311 |
my $issue = GetItemIssue($itemnumber); |
311 |
my $issue = Koha::Issues->find({ itemnumber => $itemnumber }); |
312 |
my $biblio = GetBiblioFromItemNumber($itemnumber); |
312 |
my $biblio = GetBiblioFromItemNumber($itemnumber); |
313 |
|
313 |
|
314 |
# bad barcode.. |
314 |
# bad barcode.. |
Lines 350-358
sub transferbook {
Link Here
|
350 |
} |
350 |
} |
351 |
|
351 |
|
352 |
# check if it is still issued to someone, return it... |
352 |
# check if it is still issued to someone, return it... |
353 |
if ($issue->{borrowernumber}) { |
353 |
if ( $issue ) { |
354 |
AddReturn( $barcode, $fbr ); |
354 |
AddReturn( $barcode, $fbr ); |
355 |
$messages->{'WasReturned'} = $issue->{borrowernumber}; |
355 |
$messages->{'WasReturned'} = $issue->borrowernumber; |
356 |
} |
356 |
} |
357 |
|
357 |
|
358 |
# find reserves..... |
358 |
# find reserves..... |
Lines 671-677
sub CanBookBeIssued {
Link Here
|
671 |
my $override_high_holds = $params->{override_high_holds} || 0; |
671 |
my $override_high_holds = $params->{override_high_holds} || 0; |
672 |
|
672 |
|
673 |
my $item = GetItem(GetItemnumberFromBarcode( $barcode )); |
673 |
my $item = GetItem(GetItemnumberFromBarcode( $barcode )); |
674 |
my $issue = GetItemIssue($item->{itemnumber}); |
674 |
my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); |
675 |
my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); |
675 |
my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); |
676 |
$item->{'itemtype'}=$item->{'itype'}; |
676 |
$item->{'itemtype'}=$item->{'itype'}; |
677 |
my $dbh = C4::Context->dbh; |
677 |
my $dbh = C4::Context->dbh; |
Lines 829-837
sub CanBookBeIssued {
Link Here
|
829 |
# |
829 |
# |
830 |
my $switch_onsite_checkout = |
830 |
my $switch_onsite_checkout = |
831 |
C4::Context->preference('SwitchOnSiteCheckouts') |
831 |
C4::Context->preference('SwitchOnSiteCheckouts') |
832 |
and $issue->{onsite_checkout} |
|
|
833 |
and $issue |
832 |
and $issue |
834 |
and $issue->{borrowernumber} == $borrower->{'borrowernumber'} ? 1 : 0; |
833 |
and $issue->onsite_checkout |
|
|
834 |
and $issue->borrowernumber == $borrower->{'borrowernumber'} ? 1 : 0; |
835 |
my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } ); |
835 |
my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } ); |
836 |
# if TooMany max_allowed returns 0 the user doesn't have permission to check out this book |
836 |
# if TooMany max_allowed returns 0 the user doesn't have permission to check out this book |
837 |
if ( $toomany ) { |
837 |
if ( $toomany ) { |
Lines 939-951
sub CanBookBeIssued {
Link Here
|
939 |
# |
939 |
# |
940 |
# CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER |
940 |
# CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER |
941 |
# |
941 |
# |
942 |
if ( $issue->{borrowernumber} && $issue->{borrowernumber} eq $borrower->{'borrowernumber'} ){ |
942 |
if ( $issue && $issue->borrowernumber eq $borrower->{'borrowernumber'} ){ |
943 |
|
943 |
|
944 |
# Already issued to current borrower. |
944 |
# Already issued to current borrower. |
945 |
# If it is an on-site checkout if it can be switched to a normal checkout |
945 |
# If it is an on-site checkout if it can be switched to a normal checkout |
946 |
# or ask whether the loan should be renewed |
946 |
# or ask whether the loan should be renewed |
947 |
|
947 |
|
948 |
if ( $issue->{onsite_checkout} |
948 |
if ( $issue->onsite_checkout |
949 |
and C4::Context->preference('SwitchOnSiteCheckouts') ) { |
949 |
and C4::Context->preference('SwitchOnSiteCheckouts') ) { |
950 |
$messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1; |
950 |
$messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1; |
951 |
} else { |
951 |
} else { |
Lines 966-975
sub CanBookBeIssued {
Link Here
|
966 |
} |
966 |
} |
967 |
} |
967 |
} |
968 |
} |
968 |
} |
969 |
elsif ($issue->{borrowernumber}) { |
969 |
elsif ( $issue ) { |
970 |
|
970 |
|
971 |
# issued to someone else |
971 |
# issued to someone else |
972 |
my $currborinfo = C4::Members::GetMember( borrowernumber => $issue->{borrowernumber} ); |
972 |
my $currborinfo = C4::Members::GetMember( borrowernumber => $issue->borrowernumber ); |
973 |
|
973 |
|
974 |
|
974 |
|
975 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); |
975 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); |
Lines 1299-1311
sub AddIssue {
Link Here
|
1299 |
my $branch = _GetCircControlBranch( $item, $borrower ); |
1299 |
my $branch = _GetCircControlBranch( $item, $borrower ); |
1300 |
|
1300 |
|
1301 |
# get actual issuing if there is one |
1301 |
# get actual issuing if there is one |
1302 |
my $actualissue = GetItemIssue( $item->{itemnumber} ); |
1302 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); |
1303 |
|
1303 |
|
1304 |
# get biblioinformation for this item |
1304 |
# get biblioinformation for this item |
1305 |
my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} ); |
1305 |
my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} ); |
1306 |
|
1306 |
|
1307 |
# check if we just renew the issue. |
1307 |
# check if we just renew the issue. |
1308 |
if ( $actualissue->{borrowernumber} eq $borrower->{'borrowernumber'} |
1308 |
if ( $actualissue and $actualissue->borrowernumber eq $borrower->{'borrowernumber'} |
1309 |
and not $switch_onsite_checkout ) { |
1309 |
and not $switch_onsite_checkout ) { |
1310 |
$datedue = AddRenewal( |
1310 |
$datedue = AddRenewal( |
1311 |
$borrower->{'borrowernumber'}, |
1311 |
$borrower->{'borrowernumber'}, |
Lines 1317-1324
sub AddIssue {
Link Here
|
1317 |
} |
1317 |
} |
1318 |
else { |
1318 |
else { |
1319 |
# it's NOT a renewal |
1319 |
# it's NOT a renewal |
1320 |
if ( $actualissue->{borrowernumber} |
1320 |
if ( $actualissue and not $switch_onsite_checkout ) { |
1321 |
and not $switch_onsite_checkout ) { |
|
|
1322 |
# This book is currently on loan, but not to the person |
1321 |
# This book is currently on loan, but not to the person |
1323 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1322 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1324 |
my ( $allowed, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); |
1323 |
my ( $allowed, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); |
Lines 2984-2992
sub GetSoonestRenewDate {
Link Here
|
2984 |
my $dbh = C4::Context->dbh; |
2983 |
my $dbh = C4::Context->dbh; |
2985 |
|
2984 |
|
2986 |
my $item = GetItem($itemnumber) or return; |
2985 |
my $item = GetItem($itemnumber) or return; |
2987 |
my $itemissue = GetItemIssue($itemnumber) or return; |
2986 |
my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; |
2988 |
|
2987 |
|
2989 |
$borrowernumber ||= $itemissue->{borrowernumber}; |
2988 |
$borrowernumber ||= $itemissue->borrowernumber; |
2990 |
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) |
2989 |
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) |
2991 |
or return; |
2990 |
or return; |
2992 |
|
2991 |
|
Lines 3005-3012
sub GetSoonestRenewDate {
Link Here
|
3005 |
and $issuing_rule->norenewalbefore ne "" ) |
3004 |
and $issuing_rule->norenewalbefore ne "" ) |
3006 |
{ |
3005 |
{ |
3007 |
my $soonestrenewal = |
3006 |
my $soonestrenewal = |
3008 |
$itemissue->{date_due}->clone() |
3007 |
dt_from_string( $itemissue->date_due )->subtract( |
3009 |
->subtract( |
|
|
3010 |
$issuing_rule->lengthunit => $issuing_rule->norenewalbefore ); |
3008 |
$issuing_rule->lengthunit => $issuing_rule->norenewalbefore ); |
3011 |
|
3009 |
|
3012 |
if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date' |
3010 |
if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date' |
Lines 3044-3052
sub GetLatestAutoRenewDate {
Link Here
|
3044 |
my $dbh = C4::Context->dbh; |
3042 |
my $dbh = C4::Context->dbh; |
3045 |
|
3043 |
|
3046 |
my $item = GetItem($itemnumber) or return; |
3044 |
my $item = GetItem($itemnumber) or return; |
3047 |
my $itemissue = GetItemIssue($itemnumber) or return; |
3045 |
my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; |
3048 |
|
3046 |
|
3049 |
$borrowernumber ||= $itemissue->{borrowernumber}; |
3047 |
$borrowernumber ||= $itemissue->borrowernumber; |
3050 |
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) |
3048 |
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) |
3051 |
or return; |
3049 |
or return; |
3052 |
|
3050 |
|
Lines 3062-3068
sub GetLatestAutoRenewDate {
Link Here
|
3062 |
return if not $issuing_rule->no_auto_renewal_after |
3060 |
return if not $issuing_rule->no_auto_renewal_after |
3063 |
or $issuing_rule->no_auto_renewal_after eq ''; |
3061 |
or $issuing_rule->no_auto_renewal_after eq ''; |
3064 |
|
3062 |
|
3065 |
my $maximum_renewal_date = dt_from_string($itemissue->{issuedate}); |
3063 |
my $maximum_renewal_date = dt_from_string($itemissue->issuedate); |
3066 |
$maximum_renewal_date->add( |
3064 |
$maximum_renewal_date->add( |
3067 |
$issuing_rule->lengthunit => $issuing_rule->no_auto_renewal_after |
3065 |
$issuing_rule->lengthunit => $issuing_rule->no_auto_renewal_after |
3068 |
); |
3066 |
); |