Lines 307-313
sub transferbook {
Link Here
|
307 |
my $messages; |
307 |
my $messages; |
308 |
my $dotransfer = 1; |
308 |
my $dotransfer = 1; |
309 |
my $itemnumber = GetItemnumberFromBarcode( $barcode ); |
309 |
my $itemnumber = GetItemnumberFromBarcode( $barcode ); |
310 |
my $issue = GetItemIssue($itemnumber); |
310 |
my $issue = Koha::Issues->find({ itemnumber => $itemnumber }); |
311 |
my $biblio = GetBiblioFromItemNumber($itemnumber); |
311 |
my $biblio = GetBiblioFromItemNumber($itemnumber); |
312 |
|
312 |
|
313 |
# bad barcode.. |
313 |
# bad barcode.. |
Lines 349-357
sub transferbook {
Link Here
|
349 |
} |
349 |
} |
350 |
|
350 |
|
351 |
# check if it is still issued to someone, return it... |
351 |
# check if it is still issued to someone, return it... |
352 |
if ($issue->{borrowernumber}) { |
352 |
if ( $issue ) { |
353 |
AddReturn( $barcode, $fbr ); |
353 |
AddReturn( $barcode, $fbr ); |
354 |
$messages->{'WasReturned'} = $issue->{borrowernumber}; |
354 |
$messages->{'WasReturned'} = $issue->borrowernumber; |
355 |
} |
355 |
} |
356 |
|
356 |
|
357 |
# find reserves..... |
357 |
# find reserves..... |
Lines 674-680
sub CanBookBeIssued {
Link Here
|
674 |
my $override_high_holds = $params->{override_high_holds} || 0; |
674 |
my $override_high_holds = $params->{override_high_holds} || 0; |
675 |
|
675 |
|
676 |
my $item = GetItem(GetItemnumberFromBarcode( $barcode )); |
676 |
my $item = GetItem(GetItemnumberFromBarcode( $barcode )); |
677 |
my $issue = GetItemIssue($item->{itemnumber}); |
677 |
my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); |
678 |
my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); |
678 |
my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); |
679 |
$item->{'itemtype'}=$item->{'itype'}; |
679 |
$item->{'itemtype'}=$item->{'itype'}; |
680 |
my $dbh = C4::Context->dbh; |
680 |
my $dbh = C4::Context->dbh; |
Lines 832-840
sub CanBookBeIssued {
Link Here
|
832 |
# |
832 |
# |
833 |
my $switch_onsite_checkout = |
833 |
my $switch_onsite_checkout = |
834 |
C4::Context->preference('SwitchOnSiteCheckouts') |
834 |
C4::Context->preference('SwitchOnSiteCheckouts') |
835 |
and $issue->{onsite_checkout} |
|
|
836 |
and $issue |
835 |
and $issue |
837 |
and $issue->{borrowernumber} == $borrower->{'borrowernumber'} ? 1 : 0; |
836 |
and $issue->onsite_checkout |
|
|
837 |
and $issue->borrowernumber == $borrower->{'borrowernumber'} ? 1 : 0; |
838 |
my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } ); |
838 |
my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } ); |
839 |
# if TooMany max_allowed returns 0 the user doesn't have permission to check out this book |
839 |
# if TooMany max_allowed returns 0 the user doesn't have permission to check out this book |
840 |
if ( $toomany ) { |
840 |
if ( $toomany ) { |
Lines 941-953
sub CanBookBeIssued {
Link Here
|
941 |
# |
941 |
# |
942 |
# CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER |
942 |
# CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER |
943 |
# |
943 |
# |
944 |
if ( $issue->{borrowernumber} && $issue->{borrowernumber} eq $borrower->{'borrowernumber'} ){ |
944 |
if ( $issue && $issue->borrowernumber eq $borrower->{'borrowernumber'} ){ |
945 |
|
945 |
|
946 |
# Already issued to current borrower. |
946 |
# Already issued to current borrower. |
947 |
# If it is an on-site checkout if it can be switched to a normal checkout |
947 |
# If it is an on-site checkout if it can be switched to a normal checkout |
948 |
# or ask whether the loan should be renewed |
948 |
# or ask whether the loan should be renewed |
949 |
|
949 |
|
950 |
if ( $issue->{onsite_checkout} |
950 |
if ( $issue->onsite_checkout |
951 |
and C4::Context->preference('SwitchOnSiteCheckouts') ) { |
951 |
and C4::Context->preference('SwitchOnSiteCheckouts') ) { |
952 |
$messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1; |
952 |
$messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1; |
953 |
} else { |
953 |
} else { |
Lines 968-977
sub CanBookBeIssued {
Link Here
|
968 |
} |
968 |
} |
969 |
} |
969 |
} |
970 |
} |
970 |
} |
971 |
elsif ($issue->{borrowernumber}) { |
971 |
elsif ( $issue ) { |
972 |
|
972 |
|
973 |
# issued to someone else |
973 |
# issued to someone else |
974 |
my $currborinfo = C4::Members::GetMember( borrowernumber => $issue->{borrowernumber} ); |
974 |
my $currborinfo = C4::Members::GetMember( borrowernumber => $issue->borrowernumber ); |
975 |
|
975 |
|
976 |
|
976 |
|
977 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); |
977 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); |
Lines 1304-1316
sub AddIssue {
Link Here
|
1304 |
my $branch = _GetCircControlBranch( $item, $borrower ); |
1304 |
my $branch = _GetCircControlBranch( $item, $borrower ); |
1305 |
|
1305 |
|
1306 |
# get actual issuing if there is one |
1306 |
# get actual issuing if there is one |
1307 |
my $actualissue = GetItemIssue( $item->{itemnumber} ); |
1307 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); |
1308 |
|
1308 |
|
1309 |
# get biblioinformation for this item |
1309 |
# get biblioinformation for this item |
1310 |
my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} ); |
1310 |
my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} ); |
1311 |
|
1311 |
|
1312 |
# check if we just renew the issue. |
1312 |
# check if we just renew the issue. |
1313 |
if ( $actualissue->{borrowernumber} eq $borrower->{'borrowernumber'} |
1313 |
if ( $actualissue and $actualissue->borrowernumber eq $borrower->{'borrowernumber'} |
1314 |
and not $switch_onsite_checkout ) { |
1314 |
and not $switch_onsite_checkout ) { |
1315 |
$datedue = AddRenewal( |
1315 |
$datedue = AddRenewal( |
1316 |
$borrower->{'borrowernumber'}, |
1316 |
$borrower->{'borrowernumber'}, |
Lines 1322-1329
sub AddIssue {
Link Here
|
1322 |
} |
1322 |
} |
1323 |
else { |
1323 |
else { |
1324 |
# it's NOT a renewal |
1324 |
# it's NOT a renewal |
1325 |
if ( $actualissue->{borrowernumber} |
1325 |
if ( $actualissue and not $switch_onsite_checkout ) { |
1326 |
and not $switch_onsite_checkout ) { |
|
|
1327 |
# This book is currently on loan, but not to the person |
1326 |
# This book is currently on loan, but not to the person |
1328 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1327 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1329 |
my ( $allowed, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); |
1328 |
my ( $allowed, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); |
Lines 3022-3030
sub GetSoonestRenewDate {
Link Here
|
3022 |
my $dbh = C4::Context->dbh; |
3021 |
my $dbh = C4::Context->dbh; |
3023 |
|
3022 |
|
3024 |
my $item = GetItem($itemnumber) or return; |
3023 |
my $item = GetItem($itemnumber) or return; |
3025 |
my $itemissue = GetItemIssue($itemnumber) or return; |
3024 |
my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; |
3026 |
|
3025 |
|
3027 |
$borrowernumber ||= $itemissue->{borrowernumber}; |
3026 |
$borrowernumber ||= $itemissue->borrowernumber; |
3028 |
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) |
3027 |
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) |
3029 |
or return; |
3028 |
or return; |
3030 |
|
3029 |
|
Lines 3043-3050
sub GetSoonestRenewDate {
Link Here
|
3043 |
and $issuing_rule->norenewalbefore ne "" ) |
3042 |
and $issuing_rule->norenewalbefore ne "" ) |
3044 |
{ |
3043 |
{ |
3045 |
my $soonestrenewal = |
3044 |
my $soonestrenewal = |
3046 |
$itemissue->{date_due}->clone() |
3045 |
dt_from_string( $itemissue->date_due )->subtract( |
3047 |
->subtract( |
|
|
3048 |
$issuing_rule->lengthunit => $issuing_rule->norenewalbefore ); |
3046 |
$issuing_rule->lengthunit => $issuing_rule->norenewalbefore ); |
3049 |
|
3047 |
|
3050 |
if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date' |
3048 |
if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date' |
Lines 3082-3090
sub GetLatestAutoRenewDate {
Link Here
|
3082 |
my $dbh = C4::Context->dbh; |
3080 |
my $dbh = C4::Context->dbh; |
3083 |
|
3081 |
|
3084 |
my $item = GetItem($itemnumber) or return; |
3082 |
my $item = GetItem($itemnumber) or return; |
3085 |
my $itemissue = GetItemIssue($itemnumber) or return; |
3083 |
my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; |
3086 |
|
3084 |
|
3087 |
$borrowernumber ||= $itemissue->{borrowernumber}; |
3085 |
$borrowernumber ||= $itemissue->borrowernumber; |
3088 |
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) |
3086 |
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) |
3089 |
or return; |
3087 |
or return; |
3090 |
|
3088 |
|
Lines 3100-3106
sub GetLatestAutoRenewDate {
Link Here
|
3100 |
return if not $issuing_rule->no_auto_renewal_after |
3098 |
return if not $issuing_rule->no_auto_renewal_after |
3101 |
or $issuing_rule->no_auto_renewal_after eq ''; |
3099 |
or $issuing_rule->no_auto_renewal_after eq ''; |
3102 |
|
3100 |
|
3103 |
my $maximum_renewal_date = dt_from_string($itemissue->{issuedate}); |
3101 |
my $maximum_renewal_date = dt_from_string($itemissue->issuedate); |
3104 |
$maximum_renewal_date->add( |
3102 |
$maximum_renewal_date->add( |
3105 |
$issuing_rule->lengthunit => $issuing_rule->no_auto_renewal_after |
3103 |
$issuing_rule->lengthunit => $issuing_rule->no_auto_renewal_after |
3106 |
); |
3104 |
); |